On 12/23/2009 01:52 PM, Amit Shah wrote:
Via control channel messages, the guest can tell us whether a port got
opened or closed. Similarly, we can also indicate to the guest of host
port open/close events.
Signed-off-by: Amit Shah<amit.s...@redhat.com>
---
hw/virtio-serial-bus.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
hw/virtio-serial.c | 6 ++++
hw/virtio-serial.h | 6 ++++
3 files changed, 85 insertions(+), 0 deletions(-)
@@ -347,6 +378,8 @@ static void set_config(VirtIODevice *vdev, const uint8_t
*config_data)
static void virtio_serial_save(QEMUFile *f, void *opaque)
{
VirtIOSerial *s = opaque;
+ VirtIOSerialPort *port;
+ uint32_t nr_active_ports;
/* The virtio device */
virtio_save(&s->vdev, f);
@@ -357,11 +390,35 @@ static void virtio_serial_save(QEMUFile *f, void *opaque)
/* Items in struct VirtIOSerial */
qemu_put_be32s(f,&s->guest_features);
+
+ /* Do this because we might have hot-unplugged some ports */
+ nr_active_ports = 0;
+ QTAILQ_FOREACH(port,&s->ports, next)
+ nr_active_ports++;
+
+ qemu_put_be32s(f,&nr_active_ports);
+
+ /*
+ * Items in struct VirtIOSerialPort.
+ */
+ QTAILQ_FOREACH(port,&s->ports, next) {
+ /*
+ * We put the port number because we may not have an active
+ * port at id 0 that's reserved for a console port, or in case
+ * of ports that might have gotten unplugged
+ */
+ qemu_put_be32s(f,&port->id);
+ qemu_put_byte(f, port->guest_connected);
+
+ }
}
I imagine this sort of thing is going to give Juan quite a head-ache
when it comes time to VMState conversion.
Are there not separate qdev devices for each port? Can't the state be
stored in that?
Regards,
Anthony Liguori