[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 1/1] virtio-serial-bus: Unset guest_connecte
From: |
Alon Levy |
Subject: |
Re: [Qemu-devel] [RFC PATCH 1/1] virtio-serial-bus: Unset guest_connected at reset and driver reset |
Date: |
Wed, 25 Apr 2012 12:27:47 +0300 |
User-agent: |
Mutt/1.5.21 (2011-07-01) |
On Tue, Apr 24, 2012 at 07:39:27PM +0530, Amit Shah wrote:
> When a guest driver resets the virtio status to not ready, or when qemu
> is reset, reset the guest_connected bit and let ports know if they have
> the guest_close() callback registered.
>
Reviewed-by: Alon Levy <address@hidden>
Looks like extra work for multiport aware drivers, or put another way it
would fix the guest_connected to be false if they forgot to use
VIRTIO_CONSOLE_PORT_OPEN.
> Signed-off-by: Amit Shah <address@hidden>
> ---
> hw/virtio-serial-bus.c | 28 ++++++++++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 796224b..ffbdfc2 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -528,6 +528,22 @@ static void set_config(VirtIODevice *vdev, const uint8_t
> *config_data)
> memcpy(&config, config_data, sizeof(config));
> }
>
> +static void guest_reset(VirtIOSerial *vser)
> +{
> + VirtIOSerialPort *port;
> + VirtIOSerialPortClass *vsc;
> +
> + QTAILQ_FOREACH(port, &vser->ports, next) {
> + vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
> + if (port->guest_connected) {
> + port->guest_connected = false;
> +
> + if (vsc->guest_close)
> + vsc->guest_close(port);
> + }
> + }
> +}
> +
> static void set_status(VirtIODevice *vdev, uint8_t status)
> {
> VirtIOSerial *vser;
> @@ -546,6 +562,17 @@ static void set_status(VirtIODevice *vdev, uint8_t
> status)
> */
> port->guest_connected = true;
> }
> + if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
> + guest_reset(vser);
> + }
> +}
> +
> +static void vser_reset(VirtIODevice *vdev)
> +{
> + VirtIOSerial *vser;
> +
> + vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
> + guest_reset(vser);
> }
>
> static void virtio_serial_save(QEMUFile *f, void *opaque)
> @@ -918,6 +945,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev,
> virtio_serial_conf *conf)
> vser->vdev.get_config = get_config;
> vser->vdev.set_config = set_config;
> vser->vdev.set_status = set_status;
> + vser->vdev.reset = vser_reset;
>
> vser->qdev = dev;
>
> --
> 1.7.7.6
>
>