From: Amit Shah <amit.s...@redhat.com> 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 <amit.s...@redhat.com> --- 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; -- 1.7.10