[Spice-devel] [PATCH 5/6] spice-qemu-char: keep a list of spice chardev

Marc-André Lureau marcandre.lureau at gmail.com
Fri Nov 30 05:25:46 PST 2012


Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 spice-qemu-char.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 629b500..13de037 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -25,8 +25,12 @@ typedef struct SpiceCharDriver {
     ssize_t               bufsize, datalen;
     uint32_t              debug;
     CharDriverState       *chardev;
+    QLIST_ENTRY(SpiceCharDriver) next;
 } SpiceCharDriver;
 
+static QLIST_HEAD(, SpiceCharDriver) spice_chars =
+    QLIST_HEAD_INITIALIZER(spice_chars);
+
 static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
 {
     SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin);
@@ -180,6 +184,7 @@ static void spice_chr_close(struct CharDriverState *chr)
 
     printf("%s\n", __func__);
     vmc_unregister_interface(s);
+    QLIST_REMOVE(s, next);
     g_free(s);
 }
 
@@ -230,6 +235,8 @@ static CharDriverState *chr_open(QemuOpts *opts, const char *subtype)
     chr->chr_guest_open = spice_chr_guest_open;
     chr->chr_guest_close = spice_chr_guest_close;
 
+    QLIST_INSERT_HEAD(&spice_chars, s, next);
+
     return chr;
 }
 
-- 
1.7.11.7



More information about the Spice-devel mailing list