Patchwork [6/6] spice-qemu-char: register spicevmc ports during qemu_spice_init()

login
register
mail settings
Submitter Marc-André Lureau
Date Nov. 30, 2012, 1:25 p.m.
Message ID <1354281947-20227-7-git-send-email-marcandre.lureau@redhat.com>
Download mbox | patch
Permalink /patch/202958/
State New
Headers show

Comments

Marc-André Lureau - Nov. 30, 2012, 1:25 p.m.
Do the delayed registration of spicevmc ports after Spice server is
initialized.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 spice-qemu-char.c | 13 +++++++++++++
 ui/qemu-spice.h   |  1 +
 ui/spice-core.c   |  2 ++
 3 files changed, 16 insertions(+)

Patch

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 13de037..8577664 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -275,6 +275,7 @@  CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
 
     return chr;
 }
+
 static int port_can_read(void *opaque)
 {
     CharDriverState *chr = opaque;
@@ -388,3 +389,15 @@  CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts)
 
     return chr;
 }
+
+void qemu_spice_register_ports(void)
+{
+    SpiceCharDriver *s;
+
+    QLIST_FOREACH(s, &spice_chars, next) {
+        if (s->sin.portname == NULL) {
+            continue;
+        }
+        vmc_register_interface(s);
+    }
+}
diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h
index ab1943a..5d60e99 100644
--- a/ui/qemu-spice.h
+++ b/ui/qemu-spice.h
@@ -47,6 +47,7 @@  void do_info_spice(Monitor *mon, QObject **ret_data);
 
 CharDriverState *qemu_chr_open_spice(QemuOpts *opts);
 CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts);
+void qemu_spice_register_ports(void);
 
 #else  /* CONFIG_SPICE */
 #include "monitor.h"
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 261c6f2..979c689 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -714,6 +714,8 @@  void qemu_spice_init(void)
     g_free(x509_key_file);
     g_free(x509_cert_file);
     g_free(x509_cacert_file);
+
+    qemu_spice_register_ports();
 }
 
 int qemu_spice_add_interface(SpiceBaseInstance *sin)