From patchwork Fri Oct 21 15:23:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 121004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8A6881007D3 for ; Sat, 22 Oct 2011 02:23:36 +1100 (EST) Received: from localhost ([::1]:48010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHGwW-0003Kd-4P for incoming@patchwork.ozlabs.org; Fri, 21 Oct 2011 11:23:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHGwK-0003HO-0I for qemu-devel@nongnu.org; Fri, 21 Oct 2011 11:23:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHGwH-0001pn-OD for qemu-devel@nongnu.org; Fri, 21 Oct 2011 11:23:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHGwH-0001p8-Dp for qemu-devel@nongnu.org; Fri, 21 Oct 2011 11:23:17 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9LFNEe6023795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Oct 2011 11:23:14 -0400 Received: from t500wlan.home.berrange.com.com (dhcp-1-188.lcy.redhat.com [10.32.224.188]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9LFNCeM016843; Fri, 21 Oct 2011 11:23:13 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Fri, 21 Oct 2011 16:23:12 +0100 Message-Id: <1319210592-18583-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: spice-devel@lists.freedesktop.org Subject: [Qemu-devel] [PATCH] Add SPICE support to add_client monitor command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Daniel P. Berrange" With the proposal of some new APIs[1] to libspice-server.so it is possible to add support for SPICE to the 'add_client' monitor command, bringing parity with VNC. Since SPICE can use TLS or plain connections, the command also gains a new 'tls' parameter to specify whether TLS should be attempted on the injected client sockets. NB1, since there is no SPICE release with these APIs, I have guessed the next SPICE version number in the #ifdef to be 0x000a00 (ie 0.10.0 in hex). NB2, obviously this should only be merged once the SPICE developers have accepted my proposed patches to libspice-server.so * qmp-commands.hx: Add 'tls' parameter & missing doc for 'skipauth' parameter * monitor.c: Wire up SPICE for 'add_client' command * ui/qemu-spice.h, ui/spice-core.c: Add qemu_spice_display_add_client API to wire up from monitor [1] http://lists.freedesktop.org/archives/spice-devel/2011-October/005834.html Signed-off-by: Daniel P. Berrange --- monitor.c | 9 +++++++-- qmp-commands.hx | 6 ++++-- ui/qemu-spice.h | 1 + ui/spice-core.c | 13 +++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 31b212a..cae3b12 100644 --- a/monitor.c +++ b/monitor.c @@ -1120,13 +1120,18 @@ static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_d CharDriverState *s; if (strcmp(protocol, "spice") == 0) { + int fd = monitor_get_fd(mon, fdname); + int skipauth = qdict_get_try_bool(qdict, "skipauth", 0); + int tls = qdict_get_try_bool(qdict, "tls", 0); if (!using_spice) { /* correct one? spice isn't a device ,,, */ qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); return -1; } - qerror_report(QERR_ADD_CLIENT_FAILED); - return -1; + if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) { + close(fd); + } + return 0; #ifdef CONFIG_VNC } else if (strcmp(protocol, "vnc") == 0) { int fd = monitor_get_fd(mon, fdname); diff --git a/qmp-commands.hx b/qmp-commands.hx index ea96191..de1ada3 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -911,8 +911,8 @@ EQMP { .name = "add_client", - .args_type = "protocol:s,fdname:s,skipauth:b?", - .params = "protocol fdname skipauth", + .args_type = "protocol:s,fdname:s,skipauth:b?,tls:b?", + .params = "protocol fdname skipauth tls", .help = "add a graphics client", .user_print = monitor_user_noop, .mhandler.cmd_new = add_graphics_client, @@ -928,6 +928,8 @@ Arguments: - "protocol": protocol name (json-string) - "fdname": file descriptor name (json-string) +- "skipauth": whether to skip authentication (json-bool) +- "tls": whether to perform TLS (json-bool) Example: diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h index f34be69..a0e213c 100644 --- a/ui/qemu-spice.h +++ b/ui/qemu-spice.h @@ -32,6 +32,7 @@ void qemu_spice_init(void); void qemu_spice_input_init(void); void qemu_spice_audio_init(void); void qemu_spice_display_init(DisplayState *ds); +int qemu_spice_display_add_client(int csock, int skipauth, int tls); int qemu_spice_add_interface(SpiceBaseInstance *sin); int qemu_spice_set_passwd(const char *passwd, bool fail_if_connected, bool disconnect_if_connected); diff --git a/ui/spice-core.c b/ui/spice-core.c index 3cbc721..854670e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -712,6 +712,19 @@ int qemu_spice_set_pw_expire(time_t expires) return qemu_spice_set_ticket(false, false); } +int qemu_spice_display_add_client(int csock, int skipauth, int tls) +{ +#if SPICE_SERVER_VERSION >= 0x000a00 + if (tls) { + return spice_server_add_ssl_client(spice_server, csock, skipauth); + } else { + return spice_server_add_client(spice_server, csock, skipauth); + } +#else + return -1; +#endif +} + static void spice_register_config(void) { qemu_add_opts(&qemu_spice_opts);