[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features after g
From: |
Alon Levy |
Subject: |
[Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features after guest sets them |
Date: |
Mon, 23 Apr 2012 14:26:24 +0300 |
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;
--
1.7.10
- [Qemu-devel] [PATCH 1/2] virtio: set guest_features before calling set_features callback, not after, Alon Levy, 2012/04/23
- [Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features after guest sets them,
Alon Levy <=
- Re: [Qemu-devel] [PATCH 1/2] virtio: set guest_features before calling set_features callback, not after, Amit Shah, 2012/04/23
- Re: [Qemu-devel] [PATCH 1/2] virtio: set guest_features before calling set_features callback, not after, Michael S. Tsirkin, 2012/04/23