]> git.proxmox.com Git - mirror_qemu.git/commitdiff
spice: add QemuSpiceOps, move migrate_info
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 19 Oct 2020 07:52:12 +0000 (09:52 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 21 Oct 2020 13:46:14 +0000 (15:46 +0200)
Add QemuSpiceOps struct.  This struct holds function pointers to the
spice functions.  It will be initialized with pointers to the stub
functions.  When spice gets initialized the function pointers will
be re-written to the real functions.

The spice stubs will move from qemu-spice.h to spice-module.c for that,
because they will be needed for both "CONFIG_SPICE=n" and "CONFIG_SPICE=y
but spice module not loaded" cases.

This patch adds the infrastructure and starts with moving
qemu_spice_migrate_info() to QemuSpiceOps.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20201019075224.14803-3-kraxel@redhat.com

include/ui/qemu-spice-module.h
include/ui/qemu-spice.h
monitor/misc.c
ui/spice-core.c
ui/spice-module.c

index 1af0e659a109de4132c723efae34d8bb0ca8c332..7a9963dd5810a3f0081ad21694015dab42f54172 100644 (file)
 #ifndef QEMU_SPICE_MODULE_H
 #define QEMU_SPICE_MODULE_H
 
+struct QemuSpiceOps {
+    int (*migrate_info)(const char *h, int p, int t, const char *s);
+};
+
 extern int using_spice;
+extern struct QemuSpiceOps qemu_spice;
 
 #endif
index ab523788b9a95912e513abd439e14ad787915e66..3157016c2bb42fb5fe62486eb041c83d0f97707f 100644 (file)
@@ -60,11 +60,6 @@ static inline int qemu_spice_set_pw_expire(time_t expires)
 {
     return -1;
 }
-static inline int qemu_spice_migrate_info(const char *h, int p, int t,
-                                          const char *s)
-{
-    return -1;
-}
 
 static inline int qemu_spice_display_add_client(int csock, int skipauth,
                                                 int tls)
index 4a859fb24a21fb090c8ac8414c3cba28c12c2ba7..32e6a8c13d07ad3860f3e3d98ca10c55d318dfad 100644 (file)
@@ -437,7 +437,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
             return;
         }
 
-        if (qemu_spice_migrate_info(hostname,
+        if (qemu_spice.migrate_info(hostname,
                                     has_port ? port : -1,
                                     has_tls_port ? tls_port : -1,
                                     cert_subject)) {
index a7fa5743585fc9735265f8f5c2f9a201742119ce..b03d743cf9b936e675be240fc8a4e6dd272ebe4d 100644 (file)
@@ -993,8 +993,13 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
     return spice_display_is_running;
 }
 
+static struct QemuSpiceOps real_spice_ops = {
+    .migrate_info = qemu_spice_migrate_info,
+};
+
 static void spice_register_config(void)
 {
+    qemu_spice = real_spice_ops;
     qemu_add_opts(&qemu_spice_opts);
 }
 opts_init(spice_register_config);
index f86b0ac517dca596c9744202f117658dd9d67128..f1939545a68414fae61712d538f9c3a7e854838f 100644 (file)
 #include "ui/qemu-spice-module.h"
 
 int using_spice;
+
+static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
+                                        const char *s)
+{
+    return -1;
+}
+
+struct QemuSpiceOps qemu_spice = {
+    .migrate_info = qemu_spice_migrate_info_stub,
+};