qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/8] virtio-serial-bus: Maintain guest and host


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 3/8] virtio-serial-bus: Maintain guest and host port open/close state
Date: Wed, 23 Dec 2009 17:14:28 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Thunderbird/3.0

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<address@hidden>
---
  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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]