From 2e31e210a8590461d428855426a04dfa49717b51 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:11 +0200 Subject: spice: add module helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new spice-module.c + qemu-spice-module.h files. The code needed to support modular spice will be there. For starters this will be only the using_spice variable, more will follow ... Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-2-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 23 +++++++++++++++++++++++ include/ui/qemu-spice.h | 4 +--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 include/ui/qemu-spice-module.h (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h new file mode 100644 index 0000000..1af0e65 --- /dev/null +++ b/include/ui/qemu-spice-module.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef QEMU_SPICE_MODULE_H +#define QEMU_SPICE_MODULE_H + +extern int using_spice; + +#endif diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 0e8ec3f..ab52378 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -19,14 +19,13 @@ #define QEMU_SPICE_H #include "qapi/error.h" +#include "ui/qemu-spice-module.h" #ifdef CONFIG_SPICE #include #include "qemu/config-file.h" -extern int using_spice; - void qemu_spice_init(void); void qemu_spice_input_init(void); void qemu_spice_display_init(void); @@ -50,7 +49,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, #include "qemu/error-report.h" -#define using_spice 0 #define spice_displays 0 static inline int qemu_spice_set_passwd(const char *passwd, bool fail_if_connected, -- cgit v1.1 From 7477477ca7bbf42588575039edcac852fbdb1d75 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:12 +0200 Subject: spice: add QemuSpiceOps, move migrate_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-3-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 5 +++++ include/ui/qemu-spice.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index 1af0e65..7a9963d 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -18,6 +18,11 @@ #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 diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index ab52378..3157016 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -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) -- cgit v1.1 From 63be30e6d53e78bbe5e21cbf930014ef4844fb31 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:13 +0200 Subject: spice: move qemu_spice_init() to QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-4-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 1 + include/ui/qemu-spice.h | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index 7a9963d..b182bc4 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -19,6 +19,7 @@ #define QEMU_SPICE_MODULE_H struct QemuSpiceOps { + void (*init)(void); int (*migrate_info)(const char *h, int p, int t, const char *s); }; diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 3157016..e6df0a8 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -26,7 +26,6 @@ #include #include "qemu/config-file.h" -void qemu_spice_init(void); void qemu_spice_input_init(void); void qemu_spice_display_init(void); int qemu_spice_display_add_client(int csock, int skipauth, int tls); @@ -74,10 +73,6 @@ static inline void qemu_spice_display_init(void) abort(); } -static inline void qemu_spice_init(void) -{ -} - #endif /* CONFIG_SPICE */ static inline bool qemu_using_spice(Error **errp) -- cgit v1.1 From b192cd1e4f9321b74e1d8b13b94a239a4750abfb Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:14 +0200 Subject: spice: move display_init() to QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-5-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 1 + include/ui/qemu-spice.h | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index b182bc4..dbe0903 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -20,6 +20,7 @@ struct QemuSpiceOps { void (*init)(void); + void (*display_init)(void); int (*migrate_info)(const char *h, int p, int t, const char *s); }; diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index e6df0a8..a3fd1ea 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -66,13 +66,6 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth, return -1; } -static inline void qemu_spice_display_init(void) -{ - /* This must never be called if CONFIG_SPICE is disabled */ - error_report("spice support is disabled"); - abort(); -} - #endif /* CONFIG_SPICE */ static inline bool qemu_using_spice(Error **errp) -- cgit v1.1 From 05b53636d01c1c9b650465def20b683ea1382f63 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:15 +0200 Subject: spice: move add_interface() to QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-6-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 7 +++++++ include/ui/qemu-spice.h | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index dbe0903..f93acde 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -18,10 +18,17 @@ #ifndef QEMU_SPICE_MODULE_H #define QEMU_SPICE_MODULE_H +#ifdef CONFIG_SPICE +#include +#endif + struct QemuSpiceOps { void (*init)(void); void (*display_init)(void); int (*migrate_info)(const char *h, int p, int t, const char *s); +#ifdef CONFIG_SPICE + int (*add_interface)(SpiceBaseInstance *sin); +#endif }; extern int using_spice; diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index a3fd1ea..6018577 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -29,7 +29,6 @@ void qemu_spice_input_init(void); void qemu_spice_display_init(void); int qemu_spice_display_add_client(int csock, int skipauth, int tls); -int qemu_spice_add_interface(SpiceBaseInstance *sin); bool qemu_spice_have_display_interface(QemuConsole *con); int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con); int qemu_spice_set_passwd(const char *passwd, -- cgit v1.1 From 08ad262643bb925e7f0437630f81b6d1f3acd936 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:16 +0200 Subject: spice: move auth functions to QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move qemu_spice_set_passwd() and qemu_spice_set_pw_expire() functions to QemuSpiceOps. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-7-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 3 +++ include/ui/qemu-spice.h | 14 -------------- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index f93acde..1ea3a99 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -26,6 +26,9 @@ struct QemuSpiceOps { void (*init)(void); void (*display_init)(void); int (*migrate_info)(const char *h, int p, int t, const char *s); + int (*set_passwd)(const char *passwd, + bool fail_if_connected, bool disconnect_if_connected); + int (*set_pw_expire)(time_t expires); #ifdef CONFIG_SPICE int (*add_interface)(SpiceBaseInstance *sin); #endif diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 6018577..921b7a3 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -31,9 +31,6 @@ void qemu_spice_display_init(void); int qemu_spice_display_add_client(int csock, int skipauth, int tls); bool qemu_spice_have_display_interface(QemuConsole *con); int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con); -int qemu_spice_set_passwd(const char *passwd, - bool fail_if_connected, bool disconnect_if_connected); -int qemu_spice_set_pw_expire(time_t expires); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, const char *subject); @@ -48,17 +45,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, #include "qemu/error-report.h" #define spice_displays 0 -static inline int qemu_spice_set_passwd(const char *passwd, - bool fail_if_connected, - bool disconnect_if_connected) -{ - return -1; -} -static inline int qemu_spice_set_pw_expire(time_t expires) -{ - return -1; -} - static inline int qemu_spice_display_add_client(int csock, int skipauth, int tls) { -- cgit v1.1 From 864a024c69da2bcf77ecfd0d8bd77f628ded5ba0 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:17 +0200 Subject: spice: move display_add_client() to QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-8-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 1 + include/ui/qemu-spice.h | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index 1ea3a99..7422f64 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -29,6 +29,7 @@ struct QemuSpiceOps { int (*set_passwd)(const char *passwd, bool fail_if_connected, bool disconnect_if_connected); int (*set_pw_expire)(time_t expires); + int (*display_add_client)(int csock, int skipauth, int tls); #ifdef CONFIG_SPICE int (*add_interface)(SpiceBaseInstance *sin); #endif diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 921b7a3..2beb792 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -28,7 +28,6 @@ void qemu_spice_input_init(void); void qemu_spice_display_init(void); -int qemu_spice_display_add_client(int csock, int skipauth, int tls); bool qemu_spice_have_display_interface(QemuConsole *con); int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, @@ -45,11 +44,6 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, #include "qemu/error-report.h" #define spice_displays 0 -static inline int qemu_spice_display_add_client(int csock, int skipauth, - int tls) -{ - return -1; -} #endif /* CONFIG_SPICE */ -- cgit v1.1 From db5732c9cfcbf109ff97ee392c285a4675ffe398 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 19 Oct 2020 09:52:18 +0200 Subject: spice: wire up monitor in QemuSpiceOps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename qmp_query_spice() to qmp_query_spice_real(), add to QemuSpiceOps. Add new qmp_query_spice() function which calls the real function via QemuSpiceOps if available, otherwise return SpiceInfo.enabled = false. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20201019075224.14803-9-kraxel@redhat.com --- include/ui/qemu-spice-module.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index 7422f64..1f22d55 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -22,6 +22,8 @@ #include #endif +typedef struct SpiceInfo SpiceInfo; + struct QemuSpiceOps { void (*init)(void); void (*display_init)(void); @@ -32,6 +34,7 @@ struct QemuSpiceOps { int (*display_add_client)(int csock, int skipauth, int tls); #ifdef CONFIG_SPICE int (*add_interface)(SpiceBaseInstance *sin); + SpiceInfo* (*qmp_query)(Error **errp); #endif }; -- cgit v1.1