aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/meson.build28
-rw-r--r--ui/spice-core.c31
-rw-r--r--ui/spice-input.c6
-rw-r--r--ui/spice-module.c85
4 files changed, 134 insertions, 16 deletions
diff --git a/ui/meson.build b/ui/meson.build
index ab4de98b38..5d4906c023 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -12,9 +12,9 @@ softmmu_ss.add(files(
'keymaps.c',
'qemu-pixman.c',
))
+softmmu_ss.add([spice_headers, files('spice-module.c')])
softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('input-linux.c'))
-softmmu_ss.add(when: [spice, 'CONFIG_SPICE'], if_true: files('spice-core.c', 'spice-input.c', 'spice-display.c'))
softmmu_ss.add(when: cocoa, if_true: files('cocoa.m'))
vnc_ss = ss.source_set()
@@ -33,8 +33,6 @@ vnc_ss.add(zlib, png, jpeg)
vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
softmmu_ss.add_all(when: vnc, if_true: vnc_ss)
softmmu_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
-softmmu_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
-softmmu_ss.add(when: [opengl, 'CONFIG_OPENGL_DMABUF'], if_true: files('egl-headless.c'))
specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
ui_modules = {}
@@ -45,6 +43,20 @@ if curses.found()
ui_modules += {'curses' : curses_ss}
endif
+if config_host.has_key('CONFIG_OPENGL')
+ opengl_ss = ss.source_set()
+ opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
+ if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
+ ui_modules += {'opengl' : opengl_ss}
+endif
+
+if config_host.has_key('CONFIG_OPENGL_DMABUF')
+ egl_headless_ss = ss.source_set()
+ egl_headless_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL_DMABUF'],
+ if_true: files('egl-headless.c'))
+ ui_modules += {'egl-headless' : egl_headless_ss}
+endif
+
if config_host.has_key('CONFIG_GTK')
softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c'))
@@ -70,6 +82,16 @@ if sdl.found()
ui_modules += {'sdl' : sdl_ss}
endif
+if config_host.has_key('CONFIG_SPICE')
+ spice_core_ss = ss.source_set()
+ spice_core_ss.add(spice, pixman, files(
+ 'spice-core.c',
+ 'spice-input.c',
+ 'spice-display.c'
+ ))
+ ui_modules += {'spice-core' : spice_core_ss}
+endif
+
if config_host.has_key('CONFIG_SPICE') and config_host.has_key('CONFIG_GIO')
spice_ss = ss.source_set()
spice_ss.add(spice, gio, pixman, files('spice-app.c'))
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 47700b2200..eea52f5389 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -48,7 +48,6 @@ static time_t auth_expires = TIME_MAX;
static int spice_migration_completed;
static int spice_display_is_running;
static int spice_have_target_host;
-int using_spice = 0;
static QemuThread me;
@@ -503,7 +502,7 @@ static QemuOptsList qemu_spice_opts = {
},
};
-SpiceInfo *qmp_query_spice(Error **errp)
+static SpiceInfo *qmp_query_spice_real(Error **errp)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
int port, tls_port;
@@ -634,7 +633,7 @@ static void vm_change_state_handler(void *opaque, int running,
}
}
-void qemu_spice_init(void)
+static void qemu_spice_init(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
const char *password, *str, *x509_dir, *addr,
@@ -728,7 +727,7 @@ void qemu_spice_init(void)
tls_ciphers);
}
if (password) {
- qemu_spice_set_passwd(password, false, false);
+ qemu_spice.set_passwd(password, false, false);
}
if (qemu_opt_get_bool(opts, "sasl", 0)) {
if (spice_server_set_sasl(spice_server, 1) == -1) {
@@ -801,7 +800,7 @@ void qemu_spice_init(void)
migration_state.notify = migration_state_notifier;
add_migration_state_change_notifier(&migration_state);
spice_migrate.base.sif = &migrate_interface.base;
- qemu_spice_add_interface(&spice_migrate.base);
+ qemu_spice.add_interface(&spice_migrate.base);
qemu_spice_input_init();
@@ -830,7 +829,7 @@ void qemu_spice_init(void)
#endif
}
-int qemu_spice_add_interface(SpiceBaseInstance *sin)
+static int qemu_spice_add_interface(SpiceBaseInstance *sin)
{
if (!spice_server) {
if (QTAILQ_FIRST(&qemu_spice_opts.head) != NULL) {
@@ -942,8 +941,8 @@ static int qemu_spice_set_ticket(bool fail_if_conn, bool disconnect_if_conn)
fail_if_conn, disconnect_if_conn);
}
-int qemu_spice_set_passwd(const char *passwd,
- bool fail_if_conn, bool disconnect_if_conn)
+static int qemu_spice_set_passwd(const char *passwd,
+ bool fail_if_conn, bool disconnect_if_conn)
{
if (strcmp(auth, "spice") != 0) {
return -1;
@@ -954,13 +953,13 @@ int qemu_spice_set_passwd(const char *passwd,
return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
}
-int qemu_spice_set_pw_expire(time_t expires)
+static int qemu_spice_set_pw_expire(time_t expires)
{
auth_expires = expires;
return qemu_spice_set_ticket(false, false);
}
-int qemu_spice_display_add_client(int csock, int skipauth, int tls)
+static int qemu_spice_display_add_client(int csock, int skipauth, int tls)
{
if (tls) {
return spice_server_add_ssl_client(spice_server, csock, skipauth);
@@ -994,8 +993,20 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
return spice_display_is_running;
}
+static struct QemuSpiceOps real_spice_ops = {
+ .init = qemu_spice_init,
+ .display_init = qemu_spice_display_init,
+ .migrate_info = qemu_spice_migrate_info,
+ .set_passwd = qemu_spice_set_passwd,
+ .set_pw_expire = qemu_spice_set_pw_expire,
+ .display_add_client = qemu_spice_display_add_client,
+ .add_interface = qemu_spice_add_interface,
+ .qmp_query = qmp_query_spice_real,
+};
+
static void spice_register_config(void)
{
+ qemu_spice = real_spice_ops;
qemu_add_opts(&qemu_spice_opts);
}
opts_init(spice_register_config);
diff --git a/ui/spice-input.c b/ui/spice-input.c
index 21990fa996..bbd502564e 100644
--- a/ui/spice-input.c
+++ b/ui/spice-input.c
@@ -231,7 +231,7 @@ static void mouse_mode_notifier(Notifier *notifier, void *data)
}
if (is_absolute) {
- qemu_spice_add_interface(&pointer->tablet.base);
+ qemu_spice.add_interface(&pointer->tablet.base);
} else {
spice_server_remove_interface(&pointer->tablet.base);
}
@@ -245,13 +245,13 @@ void qemu_spice_input_init(void)
kbd = g_malloc0(sizeof(*kbd));
kbd->sin.base.sif = &kbd_interface.base;
- qemu_spice_add_interface(&kbd->sin.base);
+ qemu_spice.add_interface(&kbd->sin.base);
qemu_add_led_event_handler(kbd_leds, kbd);
pointer = g_malloc0(sizeof(*pointer));
pointer->mouse.base.sif = &mouse_interface.base;
pointer->tablet.base.sif = &tablet_interface.base;
- qemu_spice_add_interface(&pointer->mouse.base);
+ qemu_spice.add_interface(&pointer->mouse.base);
pointer->absolute = false;
pointer->mouse_mode.notify = mouse_mode_notifier;
diff --git a/ui/spice-module.c b/ui/spice-module.c
new file mode 100644
index 0000000000..3222335872
--- /dev/null
+++ b/ui/spice-module.c
@@ -0,0 +1,85 @@
+/*
+ * spice module support, also spice stubs.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "qapi/qapi-types-ui.h"
+#include "qapi/qapi-commands-ui.h"
+#include "ui/qemu-spice-module.h"
+
+int using_spice;
+
+static void qemu_spice_init_stub(void)
+{
+}
+
+static void qemu_spice_display_init_stub(void)
+{
+ /* This must never be called if CONFIG_SPICE is disabled */
+ error_report("spice support is disabled");
+ abort();
+}
+
+static int qemu_spice_migrate_info_stub(const char *h, int p, int t,
+ const char *s)
+{
+ return -1;
+}
+
+static int qemu_spice_set_passwd_stub(const char *passwd,
+ bool fail_if_connected,
+ bool disconnect_if_connected)
+{
+ return -1;
+}
+
+static int qemu_spice_set_pw_expire_stub(time_t expires)
+{
+ return -1;
+}
+
+static int qemu_spice_display_add_client_stub(int csock, int skipauth,
+ int tls)
+{
+ return -1;
+}
+
+struct QemuSpiceOps qemu_spice = {
+ .init = qemu_spice_init_stub,
+ .display_init = qemu_spice_display_init_stub,
+ .migrate_info = qemu_spice_migrate_info_stub,
+ .set_passwd = qemu_spice_set_passwd_stub,
+ .set_pw_expire = qemu_spice_set_pw_expire_stub,
+ .display_add_client = qemu_spice_display_add_client_stub,
+};
+
+#ifdef CONFIG_SPICE
+
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+ if (!qemu_spice.qmp_query) {
+ SpiceInfo *info = g_new0(SpiceInfo, 1);
+ info->enabled = false;
+ return info;
+ }
+ return qemu_spice.qmp_query(errp);
+}
+
+#endif