Blame SOURCES/ga-virtio-serial-create-a-linked-list-of-all-active-dev.patch

d81766
From 6ecbd9a477c002a309ae3c1785a9449bde7234e3 Mon Sep 17 00:00:00 2001
d81766
From: Amit Shah <amit.shah@redhat.com>
d81766
Date: Tue, 19 Aug 2014 10:09:24 +0200
d81766
Subject: [PATCH 20/24] virtio-serial: create a linked list of all active devices
d81766
d81766
Message-id: <7f2c1dccc51dae825c74066ef090cd3083ee068f.1408441426.git.amit.shah@redhat.com>
d81766
Patchwork-id: 60624
d81766
O-Subject: [PATCH qemu-kvm-rhev RHEV7.1 1/2] virtio-serial: create a linked list of all active devices
d81766
Bugzilla: 1003432
d81766
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
d81766
RH-Acked-by: Amos Kong <akong@redhat.com>
d81766
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
d81766
d81766
To ensure two virtserialports don't get added to the system with the
d81766
same 'name' parameter, we need to access all the ports on all the
d81766
devices added, and compare the names.
d81766
d81766
We currently don't have a list of all VirtIOSerial devices added to the
d81766
system.  This commit adds a simple linked list in which devices are put
d81766
when they're initialized, and removed when they go away.
d81766
d81766
Signed-off-by: Amit Shah <amit.shah@redhat.com>
d81766
Reviewed-by: Markus Armbruster <armbru@redhat.com>
d81766
(cherry picked from commit a1857ad1acbddbefe7ce8adb24b0e40991c5c38f)
d81766
Signed-off-by: Amit Shah <amit.shah@redhat.com>
d81766
---
d81766
 hw/char/virtio-serial-bus.c       | 10 ++++++++++
d81766
 include/hw/virtio/virtio-serial.h |  2 ++
d81766
 2 files changed, 12 insertions(+)
d81766
d81766
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
d81766
---
d81766
 hw/char/virtio-serial-bus.c       |   10 ++++++++++
d81766
 include/hw/virtio/virtio-serial.h |    2 ++
d81766
 2 files changed, 12 insertions(+), 0 deletions(-)
d81766
d81766
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
d81766
index 23123b7..49a9867 100644
d81766
--- a/hw/char/virtio-serial-bus.c
d81766
+++ b/hw/char/virtio-serial-bus.c
d81766
@@ -26,6 +26,10 @@
d81766
 #include "hw/virtio/virtio-serial.h"
d81766
 #include "hw/virtio/virtio-access.h"
d81766
 
d81766
+struct VirtIOSerialDevices {
d81766
+    QLIST_HEAD(, VirtIOSerial) devices;
d81766
+} vserdevices;
d81766
+
d81766
 static VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)
d81766
 {
d81766
     VirtIOSerialPort *port;
d81766
@@ -983,6 +987,8 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
d81766
      */
d81766
     register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
d81766
                     virtio_serial_load, vser);
d81766
+
d81766
+    QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
d81766
 }
d81766
 
d81766
 static void virtio_serial_port_class_init(ObjectClass *klass, void *data)
d81766
@@ -1011,6 +1017,8 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
d81766
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
d81766
     VirtIOSerial *vser = VIRTIO_SERIAL(dev);
d81766
 
d81766
+    QLIST_REMOVE(vser, next);
d81766
+
d81766
     unregister_savevm(dev, "virtio-console", vser);
d81766
 
d81766
     g_free(vser->ivqs);
d81766
@@ -1035,6 +1043,8 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data)
d81766
     DeviceClass *dc = DEVICE_CLASS(klass);
d81766
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
d81766
 
d81766
+    QLIST_INIT(&vserdevices.devices);
d81766
+
d81766
     dc->props = virtio_serial_properties;
d81766
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
d81766
     vdc->realize = virtio_serial_device_realize;
d81766
diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h
d81766
index 4746312..a679e54 100644
d81766
--- a/include/hw/virtio/virtio-serial.h
d81766
+++ b/include/hw/virtio/virtio-serial.h
d81766
@@ -202,6 +202,8 @@ struct VirtIOSerial {
d81766
 
d81766
     QTAILQ_HEAD(, VirtIOSerialPort) ports;
d81766
 
d81766
+    QLIST_ENTRY(VirtIOSerial) next;
d81766
+
d81766
     /* bitmap for identifying active ports */
d81766
     uint32_t *ports_map;
d81766
 
d81766
-- 
d81766
1.7.1
d81766