From patchwork Fri Oct 14 15:28:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 9376973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF4AD6022E for ; Fri, 14 Oct 2016 15:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE7E92A69D for ; Fri, 14 Oct 2016 15:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A208D2A774; Fri, 14 Oct 2016 15:38:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A69C22A69D for ; Fri, 14 Oct 2016 15:38:15 +0000 (UTC) Received: from localhost ([::1]:47955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv4Yo-0006AU-Ez for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Oct 2016 11:38:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv4Pg-0007Jr-Cp for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bv4Pd-0008Hu-EV for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:28:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv4Pd-0008Hn-4V for qemu-devel@nongnu.org; Fri, 14 Oct 2016 11:28:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C16666CB5 for ; Fri, 14 Oct 2016 15:28:44 +0000 (UTC) Received: from emacs.mitica (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9EFSV1A025555; Fri, 14 Oct 2016 11:28:43 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 14 Oct 2016 17:28:15 +0200 Message-Id: <1476458903-7888-8-git-send-email-quintela@redhat.com> In-Reply-To: <1476458903-7888-1-git-send-email-quintela@redhat.com> References: <1476458903-7888-1-git-send-email-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Oct 2016 15:28:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/15] migrate: Share common MigrationParameters struct X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake It is rather verbose, and slightly error-prone, to repeat the same set of parameters for input (migrate-set-parameters) as for output (query-migrate-parameters), where the only difference is whether the members are optional. We can just document that the optional members will always be present on output, and then share a common struct between both commands. The next patch can then reduce the amount of code needed on input. Also, we made a mistake in qemu 2.7 of returning an empty string during 'query-migrate-parameters' when there is no TLS, rather than omitting TLS details entirely. Technically, this change risks breaking any 2.7 client that is hard-coded to expect the parameter's existence; on the other hand, clients that are portable to 2.6 already must be prepared for those members to not be present. And this gets rid of yet one more place where the QMP output visitor is silently converting a NULL string into "" (which is a hack I ultimately want to kill off). Signed-off-by: Eric Blake Reviewed-by: Marc-André Lureau Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hmp.c | 9 +++- migration/migration.c | 7 +++ qapi-schema.json | 117 +++++++++++++++++++------------------------------- 3 files changed, 57 insertions(+), 76 deletions(-) diff --git a/hmp.c b/hmp.c index 9509596..c405d3e 100644 --- a/hmp.c +++ b/hmp.c @@ -284,27 +284,32 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) if (params) { monitor_printf(mon, "parameters:"); + assert(params->has_compress_level); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL], params->compress_level); + assert(params->has_compress_threads); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS], params->compress_threads); + assert(params->has_decompress_threads); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS], params->decompress_threads); + assert(params->has_cpu_throttle_initial); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL], params->cpu_throttle_initial); + assert(params->has_cpu_throttle_increment); monitor_printf(mon, " %s: %" PRId64, MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT], params->cpu_throttle_increment); monitor_printf(mon, " %s: '%s'", MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_CREDS], - params->tls_creds ? : ""); + params->has_tls_creds ? params->tls_creds : ""); monitor_printf(mon, " %s: '%s'", MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME], - params->tls_hostname ? : ""); + params->has_tls_hostname ? params->tls_hostname : ""); monitor_printf(mon, "\n"); } diff --git a/migration/migration.c b/migration/migration.c index 955d5ee..1a8f26b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -559,12 +559,19 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) MigrationState *s = migrate_get_current(); params = g_malloc0(sizeof(*params)); + params->has_compress_level = true; params->compress_level = s->parameters.compress_level; + params->has_compress_threads = true; params->compress_threads = s->parameters.compress_threads; + params->has_decompress_threads = true; params->decompress_threads = s->parameters.decompress_threads; + params->has_cpu_throttle_initial = true; params->cpu_throttle_initial = s->parameters.cpu_throttle_initial; + params->has_cpu_throttle_increment = true; params->cpu_throttle_increment = s->parameters.cpu_throttle_increment; + params->has_tls_creds = !!s->parameters.tls_creds; params->tls_creds = g_strdup(s->parameters.tls_creds); + params->has_tls_hostname = !!s->parameters.tls_hostname; params->tls_hostname = g_strdup(s->parameters.tls_hostname); return params; diff --git a/qapi-schema.json b/qapi-schema.json index 9e47b47..e16e889 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -668,40 +668,53 @@ # # @migrate-set-parameters # -# Set the following migration parameters -# -# @compress-level: compression level -# -# @compress-threads: compression thread count -# -# @decompress-threads: decompression thread count -# -# @cpu-throttle-initial: Initial percentage of time guest cpus are throttled -# when migration auto-converge is activated. The -# default value is 20. (Since 2.7) -# -# @cpu-throttle-increment: throttle percentage increase each time -# auto-converge detects that migration is not making -# progress. The default value is 10. (Since 2.7) -# -# @tls-creds: ID of the 'tls-creds' object that provides credentials for -# establishing a TLS connection over the migration data channel. -# On the outgoing side of the migration, the credentials must -# be for a 'client' endpoint, while for the incoming side the -# credentials must be for a 'server' endpoint. Setting this -# will enable TLS for all migrations. The default is unset, -# resulting in unsecured migration at the QEMU level. (Since 2.7) -# -# @tls-hostname: hostname of the target host for the migration. This is -# required when using x509 based TLS credentials and the -# migration URI does not already include a hostname. For -# example if using fd: or exec: based migration, the -# hostname must be provided so that the server's x509 -# certificate identity can be validated. (Since 2.7) +# Set various migration parameters. See MigrationParameters for details. # # Since: 2.4 ## { 'command': 'migrate-set-parameters', + 'data': 'MigrationParameters' } + +# +# @MigrationParameters +# +# Optional members can be omitted on input ('migrate-set-parameters') +# but most members will always be present on output +# ('query-migrate-parameters'), with the exception of tls-creds and +# tls-hostname. +# +# @compress-level: #optional compression level +# +# @compress-threads: #optional compression thread count +# +# @decompress-threads: #optional decompression thread count +# +# @cpu-throttle-initial: #optional Initial percentage of time guest cpus are +# throttledwhen migration auto-converge is activated. +# The default value is 20. (Since 2.7) +# +# @cpu-throttle-increment: #optional throttle percentage increase each time +# auto-converge detects that migration is not making +# progress. The default value is 10. (Since 2.7) +# +# @tls-creds: #optional ID of the 'tls-creds' object that provides credentials +# for establishing a TLS connection over the migration data +# channel. On the outgoing side of the migration, the credentials +# must be for a 'client' endpoint, while for the incoming side the +# credentials must be for a 'server' endpoint. Setting this +# will enable TLS for all migrations. The default is unset, +# resulting in unsecured migration at the QEMU level. (Since 2.7) +# +# @tls-hostname: #optional hostname of the target host for the migration. This +# is required when using x509 based TLS credentials and the +# migration URI does not already include a hostname. For +# example if using fd: or exec: based migration, the +# hostname must be provided so that the server's x509 +# certificate identity can be validated. (Since 2.7) +# +# Since: 2.4 +## +{ 'struct': 'MigrationParameters', 'data': { '*compress-level': 'int', '*compress-threads': 'int', '*decompress-threads': 'int', @@ -709,50 +722,6 @@ '*cpu-throttle-increment': 'int', '*tls-creds': 'str', '*tls-hostname': 'str'} } - -# -# @MigrationParameters -# -# @compress-level: compression level -# -# @compress-threads: compression thread count -# -# @decompress-threads: decompression thread count -# -# @cpu-throttle-initial: Initial percentage of time guest cpus are throttled -# when migration auto-converge is activated. The -# default value is 20. (Since 2.7) -# -# @cpu-throttle-increment: throttle percentage increase each time -# auto-converge detects that migration is not making -# progress. The default value is 10. (Since 2.7) -# -# @tls-creds: ID of the 'tls-creds' object that provides credentials for -# establishing a TLS connection over the migration data channel. -# On the outgoing side of the migration, the credentials must -# be for a 'client' endpoint, while for the incoming side the -# credentials must be for a 'server' endpoint. Setting this -# will enable TLS for all migrations. The default is unset, -# resulting in unsecured migration at the QEMU level. (Since 2.7) -# -# @tls-hostname: hostname of the target host for the migration. This is -# required when using x509 based TLS credentials and the -# migration URI does not already include a hostname. For -# example if using fd: or exec: based migration, the -# hostname must be provided so that the server's x509 -# certificate identity can be validated. (Since 2.7) -# -# Since: 2.4 -## -{ 'struct': 'MigrationParameters', - 'data': { 'compress-level': 'int', - 'compress-threads': 'int', - 'decompress-threads': 'int', - 'cpu-throttle-initial': 'int', - 'cpu-throttle-increment': 'int', - 'tls-creds': 'str', - 'tls-hostname': 'str'} } - ## # @query-migrate-parameters #