From 3125af295e92825834031e8cbb8ca55c718a6fcb Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 9 Jan 2023 20:03:14 +0100 Subject: ui: Factor out qmp_add_client() parts and move to ui/ui-qmp-cmds.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230109190321.1056914-11-armbru@redhat.com> --- ui/ui-qmp-cmds.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'ui/ui-qmp-cmds.c') diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c index c9f92ca..dbc4afc 100644 --- a/ui/ui-qmp-cmds.c +++ b/ui/ui-qmp-cmds.c @@ -14,10 +14,12 @@ */ #include "qemu/osdep.h" +#include "monitor/qmp-helpers.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" #include "qemu/cutils.h" #include "ui/console.h" +#include "ui/dbus-display.h" #include "ui/qemu-spice.h" void qmp_set_password(SetPasswordOptions *opts, Error **errp) @@ -103,6 +105,45 @@ void qmp_change_vnc_password(const char *password, Error **errp) } #endif +bool qmp_add_client_spice(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + if (!qemu_using_spice(errp)) { + return false; + } + skipauth = has_skipauth ? skipauth : false; + tls = has_tls ? tls : false; + if (qemu_spice.display_add_client(fd, skipauth, tls) < 0) { + error_setg(errp, "spice failed to add client"); + return false; + } + return true; +} + +#ifdef CONFIG_VNC +bool qmp_add_client_vnc(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + skipauth = has_skipauth ? skipauth : false; + vnc_display_add_client(NULL, fd, skipauth); + return true; +} +#endif + +#ifdef CONFIG_DBUS_DISPLAY +bool qmp_add_client_dbus_display(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + if (!qemu_using_dbus_display(errp)) { + return false; + } + if (!qemu_dbus_display.add_client(fd, errp)) { + return false; + } + return true; +} +#endif + void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) { switch (arg->type) { -- cgit v1.1