From patchwork Fri Aug 19 17:08:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 110708 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 92A59B6F7B for ; Sat, 20 Aug 2011 03:11:15 +1000 (EST) Received: from localhost ([::1]:50091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QuSb9-0004wc-9V for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2011 13:11:11 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QuSaa-0003ht-PA for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QuSaZ-0001Bh-Cm for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QuSaZ-0001BX-2S for qemu-devel@nongnu.org; Fri, 19 Aug 2011 13:10:35 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7JHAYmY026080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Aug 2011 13:10:34 -0400 Received: from bow.redhat.com (vpn-9-99.rdu.redhat.com [10.11.9.99]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7JHAPpe023778; Fri, 19 Aug 2011 13:10:33 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Fri, 19 Aug 2011 10:08:48 -0700 Message-Id: <1313773728-6104-4-git-send-email-alevy@redhat.com> In-Reply-To: <1313773728-6104-1-git-send-email-alevy@redhat.com> References: <1313773728-6104-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kraxel@redhat.com Subject: [Qemu-devel] [PATCH 3/3] monitor: add client_migrate_switch command (RHBZ 725009) 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 Complementary to the auto_switch parameter of client_migrate_info, if that is set to false the new command client_migrate_switch can be used to complete the switch to the new client. This allows the vm manager (i.e. libvirt) to first ensure the ticketing information in the target vm is valid before issuing the switch. Signed-off-by: Alon Levy --- hmp-commands.hx | 15 +++++++++++++++ monitor.c | 23 +++++++++++++++++++++++ qmp-commands.hx | 27 +++++++++++++++++++++++++++ ui/qemu-spice.h | 5 +++++ ui/spice-core.c | 4 ++++ 5 files changed, 74 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index fc2bf99..7979529 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -839,6 +839,21 @@ new parameters (if specified) once the vm migration finished successfully. ETEXI { + .name = "client_migrate_switch", + .args_type = "protocol:s", + .params = "protocol", + .help = "tell client to disconnect and reconnect to client_migrate_info set destination", + .user_print = monitor_user_noop, + .mhandler.cmd_new = client_migrate_switch, + }, + +STEXI +@item client_migrate_switch @var{protocol} +@findex client_migrate_switch +Tell the spice/vnc client to switch to the target set previously with client_migrate_info. Only has an effect if the last client_migrate_info used auto_switch=false. +ETEXI + + { .name = "snapshot_blkdev", .args_type = "device:B,snapshot-file:s?,format:s?", .params = "device [new-image-file] [format]", diff --git a/monitor.c b/monitor.c index 1daa283..ae6f4ad 100644 --- a/monitor.c +++ b/monitor.c @@ -1248,6 +1248,29 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, QObject **ret_d return -1; } +static int client_migrate_switch(Monitor *mon, const QDict *qdict, + QObject **ret_data) +{ + const char *protocol = qdict_get_str(qdict, "protocol"); + int ret; + + if (strcmp(protocol, "spice") == 0) { + if (!using_spice) { + qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); + return -1; + } + ret = qemu_spice_migrate_switch(); + 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 13b2bc6..9e0fecf 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -609,6 +609,33 @@ Example: EQMP { + .name = "client_migrate_switch", + .args_type = "protocol:s", + .params = "protocol", + .help = "tell client to disconnect and reconnect to client_migrate_info set destination", + .user_print = monitor_user_noop, + .mhandler.cmd_new = client_migrate_switch, + }, + +SQMP +client_migrate_switch +--------------------- + +Tell the spice/vnc client to switch to the target set previously with client_migrate_info. Only has an effect if the last client_migrate_info used auto_switch=false. + +Arguments: + +- "protocol": protocol: "spice" or "vnc" (json-string) + +Example: + +-> { "execute": "client_migrate_switch", + "arguments": { "protocol": "spice" } } +<- { "return": {} } + +EQMP + + { .name = "netdev_add", .args_type = "netdev:O", .params = "[user|tap|socket],id=str[,prop=value][,...]", diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h index e54f16e..113bd2f 100644 --- a/ui/qemu-spice.h +++ b/ui/qemu-spice.h @@ -38,6 +38,7 @@ int qemu_spice_set_passwd(const char *passwd, 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, int auto_switch); +int qemu_spice_migrate_switch(void); void do_info_spice_print(Monitor *mon, const QObject *data); void do_info_spice(Monitor *mon, QObject **ret_data); @@ -60,6 +61,10 @@ static inline int qemu_spice_set_pw_expire(time_t expires) static inline int qemu_spice_migrate_info(const char *h, int p, int t, const char *s) { return -1; } +static inline int qemu_spice_migrate_switch(void) +{ return -1; } + + #endif /* CONFIG_SPICE */ #endif /* QEMU_SPICE_H */ diff --git a/ui/spice-core.c b/ui/spice-core.c index 3a1d851..83362c2 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -451,6 +451,10 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, port, tls_port, subject); } +int qemu_spice_migrate_switch(void) +{ + return spice_server_migrate_switch(spice_server); +} static int add_channel(const char *name, const char *value, void *opaque) {