From patchwork Mon Jan 10 16:37:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 78171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5E16CB713B for ; Tue, 11 Jan 2011 04:03:03 +1100 (EST) Received: from localhost ([127.0.0.1]:51685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcKmd-0005q8-Mm for incoming@patchwork.ozlabs.org; Mon, 10 Jan 2011 11:39:51 -0500 Received: from [140.186.70.92] (port=58332 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcKlG-000563-2K for qemu-devel@nongnu.org; Mon, 10 Jan 2011 11:38:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcKkE-0002hw-ND for qemu-devel@nongnu.org; Mon, 10 Jan 2011 11:37:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcKkE-0002hk-7q for qemu-devel@nongnu.org; Mon, 10 Jan 2011 11:37:22 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0AGbLeO024000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Jan 2011 11:37:21 -0500 Received: from rincewind.home.kraxel.org (vpn2-8-96.ams2.redhat.com [10.36.8.96]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0AGbI9m004946; Mon, 10 Jan 2011 11:37:19 -0500 Message-ID: <4D2B35BE.7000907@redhat.com> Date: Mon, 10 Jan 2011 17:37:18 +0100 From: Gerd Hoffmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Red Hat/3.1.7-3.el6_0 Thunderbird/3.1.7 MIME-Version: 1.0 To: "Daniel P. Berrange" Subject: Re: [Qemu-devel] [PATCH 2/6] spice: client migration. References: <1294666311-23457-1-git-send-email-kraxel@redhat.com> <1294666311-23457-3-git-send-email-kraxel@redhat.com> <20110110154934.GP2723@redhat.com> <20110110155712.GA17952@playa.tlv.redhat.com> <4D2B2F08.9060103@redhat.com> <20110110161817.GQ2723@redhat.com> In-Reply-To: <20110110161817.GQ2723@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, >> I like client_migrate_info and it fits both spice+vnc naming too. >> >> Given that vnc just needs hostname and port (which are present >> already) and the arguments not used by vnc are optional all we need >> to do is rename the command and add a "protocol" argument similar to >> "set_password", correct? > > Yeah, that sounds sufficient to me. Quick incremental patch attached. Became a bit larger than initially expected due to some code reorganization (move out of ui/spice-core.c) needed. comments? cheers, Gerd diff --git a/hmp-commands.hx b/hmp-commands.hx index e6d8f36..05b777b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -815,24 +815,21 @@ ETEXI }, STEXI -@item spice_migrate_info @var{hostname} @var{port} @var{tls-port} @var{cert-subject} -@findex spice_migrate_info -Set the spice connection info for the migration target. The spice -server will ask the spice client to automatically reconnect using the -new parameters (if specified) once the vm migration finished -successfully. +@item client_migrate_info @var{protocol} @var{hostname} @var{port} @var{tls-port} @var{cert-subject} +@findex client_migrate_info +Set the spice/vnc connection info for the migration target. The spice/vnc +server will ask the spice/vnc client to automatically reconnect using the +new parameters (if specified) once the vm migration finished successfully. ETEXI -#if defined(CONFIG_SPICE) { - .name = "spice_migrate_info", - .args_type = "hostname:s,port:i?,tls-port:i?,cert-subject:s?", - .params = "hostname port tls-port cert-subject", - .help = "send migration info to spice client", + .name = "client_migrate_info", + .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", + .params = "protocol hostname port tls-port cert-subject", + .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, - .mhandler.cmd_new = mon_spice_migrate, + .mhandler.cmd_new = client_migrate_info, }, -#endif STEXI @item snapshot_blkdev diff --git a/monitor.c b/monitor.c index 038d532..6f5ee14 100644 --- a/monitor.c +++ b/monitor.c @@ -1173,6 +1173,33 @@ static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data) return -1; } +static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ + const char *protocol = qdict_get_str(qdict, "protocol"); + const char *hostname = qdict_get_str(qdict, "hostname"); + const char *subject = qdict_get_try_str(qdict, "cert-subject"); + int port = qdict_get_try_int(qdict, "port", -1); + int tls_port = qdict_get_try_int(qdict, "tls-port", -1); + int ret; + + if (strcmp(protocol, "spice") == 0) { + if (!using_spice) { + qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); + return -1; + } + + ret = qemu_spice_migrate_info(hostname, port, tls_port, subject); + if (ret != 0) { + qerror_report(QERR_UNDEFINED_ERROR); + return -1; + } + return 0; + } + + qerror_report(QERR_INVALID_PARAMETER, "protocol"); + return -1; +} + static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data) { vga_hw_screen_dump(qdict_get_str(qdict, "filename")); diff --git a/qmp-commands.hx b/qmp-commands.hx index 24ada04..2ed8f44 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -503,39 +503,39 @@ EQMP }, SQMP -spice_migrate_info +client_migrate_info ------------------ -Set the spice connection info for the migration target. The spice -server will ask the spice client to automatically reconnect using the -new parameters (if specified) once the vm migration finished -successfully. +Set the spice/vnc connection info for the migration target. The spice/vnc +server will ask the spice/vnc client to automatically reconnect using the +new parameters (if specified) once the vm migration finished successfully. Arguments: +- "protocol": protocol: "spice" or "vnc" (json-string) - "hostname": migration target hostname (json-string) -- "port": spice tcp port for plaintext channels (json-int, optional) +- "port": spice/vnc tcp port for plaintext channels (json-int, optional) - "tls-port": spice tcp port for tls-secured channels (json-int, optional) - "cert-subject": server certificate subject (json-string, optional) Example: --> { "execute": "spice_migrate_info", - "arguments": { "hostname": "virt42.lab.kraxel.org", "port": 1234 } } +-> { "execute": "client_migrate_info", + "arguments": { "protocol": "spice", + "hostname": "virt42.lab.kraxel.org", + "port": 1234 } } <- { "return": {} } EQMP -#if defined(CONFIG_SPICE) { - .name = "spice_migrate_info", - .args_type = "hostname:s,port:i?,tls-port:i?,cert-subject:s?", - .params = "hostname port tls-port cert-subject", - .help = "send migration info to spice client", + .name = "client_migrate_info", + .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", + .params = "protocol hostname port tls-port cert-subject", + .help = "send migration info to spice/vnc client", .user_print = monitor_user_noop, - .mhandler.cmd_new = mon_spice_migrate, + .mhandler.cmd_new = client_migrate_info, }, -#endif SQMP migrate_set_speed diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h index f234c4d..78df3b4 100644 --- a/ui/qemu-spice.h +++ b/ui/qemu-spice.h @@ -36,10 +36,11 @@ int qemu_spice_add_interface(SpiceBaseInstance *sin); 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); void do_info_spice_print(Monitor *mon, const QObject *data); void do_info_spice(Monitor *mon, QObject **ret_data); -int mon_spice_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data); CharDriverState *qemu_chr_open_spice(QemuOpts *opts); @@ -48,6 +49,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts); #define using_spice 0 #define qemu_spice_set_passwd(_p, _f1, _f2) (-1) #define qemu_spice_set_pw_expire(_e) (-1) +#define qemu_spice_migrate_info(_h, _p, _t, _s) (-1) #endif /* CONFIG_SPICE */ diff --git a/ui/spice-core.c b/ui/spice-core.c index 95116cc..1aa1a5e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -431,26 +431,11 @@ static void migration_state_notifier(Notifier *notifier) } } -int mon_spice_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) +int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, + const char *subject) { - const char *hostname = qdict_get_str(qdict, "hostname"); - const char *subject = qdict_get_try_str(qdict, "cert-subject"); - int port = qdict_get_try_int(qdict, "port", -1); - int tls_port = qdict_get_try_int(qdict, "tls-port", -1); - int ret; - - if (!spice_server) { - qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); - return -1; - } - - ret = spice_server_migrate_info(spice_server, hostname, - port, tls_port, subject); - if (ret != 0) { - qerror_report(QERR_UNDEFINED_ERROR); - return -1; - } - return 0; + return spice_server_migrate_info(spice_server, hostname, + port, tls_port, subject); } static int add_channel(const char *name, const char *value, void *opaque)