[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features aft
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features after guest sets them |
Date: |
Mon, 23 Apr 2012 15:40:20 +0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Apr 23, 2012 at 02:26:24PM +0300, Alon Levy wrote:
> From: Amit Shah <address@hidden>
>
> Currently we query the virtio features w/o even waiting
> for the guest to boot up and ack features.
>
> Do the querying after set_features has succeeded.
>
> The check to enable guest_connected for the host to be able to write to
> the guest was flawed in this way, causing all ports to be initialised
> with the 'guest_connected' status to on.
>
> Signed-off-by: Amit Shah <address@hidden>
> ---
> hw/virtio-serial-bus.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index e22940e..90b3674 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -512,6 +512,23 @@ static uint32_t get_features(VirtIODevice *vdev,
> uint32_t features)
> return features;
> }
>
> +static void set_features(VirtIODevice *vdev, uint32_t features)
> +{
> + VirtIOSerial *vser;
> + VirtIOSerialPort *port;
> +
> + vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
> + port = find_port_by_id(vser, 0);
> +
> + if (port && !use_multiport(vser)) {
> + /*
> + * Allow writes to guest in this case; we have no way of
> + * knowing if a guest port is connected.
> + */
> + port->guest_connected = true;
> + }
> +}
> +
> /* Guest requested config info */
> static void get_config(VirtIODevice *vdev, uint8_t *config_data)
> {
> @@ -798,14 +815,6 @@ static int virtser_port_qdev_init(DeviceState *qdev)
> return ret;
> }
>
> - if (!use_multiport(port->vser)) {
> - /*
> - * Allow writes to guest in this case; we have no way of
> - * knowing if a guest port is connected.
> - */
> - port->guest_connected = true;
> - }
> -
> port->elem.out_num = 0;
>
> QTAILQ_INSERT_TAIL(&port->vser->ports, port, next);
> @@ -903,6 +912,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev,
> virtio_serial_conf *conf)
> mark_port_added(vser, 0);
>
> vser->vdev.get_features = get_features;
> + vser->vdev.set_features = set_features;
> vser->vdev.get_config = get_config;
> vser->vdev.set_config = set_config;
Problem is I think legacy guests don't call set_features.
A cleaner way is to check on set_status calls. Guest is not connected
until driver_ok is set anyway.
So you would do
if (!use_multiport(guest)) {
port->guest_connected = status & VIRTIO_CONFIG_S_DRIVER_OK;
}
You won't need patch 1/2 in this case either.
> --
> 1.7.10
>