From nobody Wed Nov 5 21:57:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149510670753925.584777744280586; Thu, 18 May 2017 04:25:07 -0700 (PDT) Received: from localhost ([::1]:53070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBJYH-0001jO-Vx for importer@patchew.org; Thu, 18 May 2017 07:25:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBJSL-0005Ta-5K for qemu-devel@nongnu.org; Thu, 18 May 2017 07:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBJSA-0002HO-RP for qemu-devel@nongnu.org; Thu, 18 May 2017 07:18:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBJSA-0002G3-Hw for qemu-devel@nongnu.org; Thu, 18 May 2017 07:18:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 963607F7B1 for ; Thu, 18 May 2017 11:18:45 +0000 (UTC) Received: from secure.mitica (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id B79705DD70; Thu, 18 May 2017 11:18:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 963607F7B1 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 963607F7B1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 18 May 2017 13:18:34 +0200 Message-Id: <20170518111837.29212-3-quintela@redhat.com> In-Reply-To: <20170518111837.29212-1-quintela@redhat.com> References: <20170518111837.29212-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 18 May 2017 11:18:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/5] migration: Create block capability 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Create one capability for block migration and one parameter for incremental block migration. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake --- - address all Markus comments - use Markus and Eric text descriptions - change logic another time - improve text messages --- hmp.c | 13 ++++++++ include/migration/block.h | 2 ++ include/migration/migration.h | 6 ++++ migration/migration.c | 71 +++++++++++++++++++++++++++++++++++++++= ++++ qapi-schema.json | 28 +++++++++++++++-- 5 files changed, 117 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index acbbc5c..208154c 100644 --- a/hmp.c +++ b/hmp.c @@ -326,6 +326,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DEL= AY], params->x_checkpoint_delay); + assert(params->has_block_incremental); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_lookup[MIGRATION_PARAMETER_BLOCK_INCREMENTA= L], + params->block_incremental ? "on" : "off"); } =20 qapi_free_MigrationParameters(params); @@ -1527,6 +1531,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) Visitor *v =3D string_input_visitor_new(valuestr); uint64_t valuebw =3D 0; int64_t valueint =3D 0; + bool valuebool =3D false; Error *err =3D NULL; bool use_int_value =3D false; int i, ret; @@ -1581,6 +1586,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p.has_x_checkpoint_delay =3D true; use_int_value =3D true; break; + case MIGRATION_PARAMETER_BLOCK_INCREMENTAL: + p.has_block_incremental =3D true; + visit_type_bool(v, param, &valuebool, &err); + if (err) { + goto cleanup; + } + p.block_incremental =3D valuebool; + break; } =20 if (use_int_value) { diff --git a/include/migration/block.h b/include/migration/block.h index 41a1ac8..5225af9 100644 --- a/include/migration/block.h +++ b/include/migration/block.h @@ -20,4 +20,6 @@ uint64_t blk_mig_bytes_transferred(void); uint64_t blk_mig_bytes_remaining(void); uint64_t blk_mig_bytes_total(void); =20 +void migrate_set_block_enabled(bool value, Error **errp); + #endif /* MIGRATION_BLOCK_H */ diff --git a/include/migration/migration.h b/include/migration/migration.h index 49ec501..024a048 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -153,6 +153,9 @@ struct MigrationState =20 /* The last error that occurred */ Error *error; + /* Do we have to clean up -b/-i from old migrate parameters */ + /* This feature is deprecated and will be removed */ + bool must_remove_block_options; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -265,6 +268,9 @@ bool migrate_colo_enabled(void); =20 int64_t xbzrle_cache_resize(int64_t new_size); =20 +bool migrate_use_block(void); +bool migrate_use_block_incremental(void); + bool migrate_use_compression(void); int migrate_compress_level(void); int migrate_compress_threads(void); diff --git a/migration/migration.c b/migration/migration.c index 0304c01..c13c0a2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -592,6 +592,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->downtime_limit =3D s->parameters.downtime_limit; params->has_x_checkpoint_delay =3D true; params->x_checkpoint_delay =3D s->parameters.x_checkpoint_delay; + params->has_block_incremental =3D true; + params->block_incremental =3D s->parameters.block_incremental; =20 return params; } @@ -900,6 +902,9 @@ void qmp_migrate_set_parameters(MigrationParameters *pa= rams, Error **errp) colo_checkpoint_notify(s); } } + if (params->has_block_incremental) { + s->parameters.block_incremental =3D params->block_incremental; + } } =20 =20 @@ -935,6 +940,33 @@ void migrate_set_state(int *state, int old_state, int = new_state) } } =20 +void migrate_set_block_enabled(bool value, Error **errp) +{ + MigrationCapabilityStatusList *cap; + + cap =3D g_new0(MigrationCapabilityStatusList, 1); + cap->value =3D g_new0(MigrationCapabilityStatus, 1); + cap->value->capability =3D MIGRATION_CAPABILITY_BLOCK; + cap->value->state =3D value; + qmp_migrate_set_capabilities(cap, errp); + qapi_free_MigrationCapabilityStatusList(cap); +} + +static void migrate_set_block_incremental(MigrationState *s, bool value) +{ + s->parameters.block_incremental =3D value; +} + +static void block_cleanup_parameters(MigrationState *s) +{ + if (s->must_remove_block_options) { + /* setting to false can never fail */ + migrate_set_block_enabled(false, &error_abort); + migrate_set_block_incremental(s, false); + s->must_remove_block_options =3D false; + } +} + static void migrate_fd_cleanup(void *opaque) { MigrationState *s =3D opaque; @@ -967,6 +999,7 @@ static void migrate_fd_cleanup(void *opaque) } =20 notifier_list_notify(&migration_state_notifiers, s); + block_cleanup_parameters(s); } =20 void migrate_fd_error(MigrationState *s, const Error *error) @@ -979,6 +1012,7 @@ void migrate_fd_error(MigrationState *s, const Error *= error) s->error =3D error_copy(error); } notifier_list_notify(&migration_state_notifiers, s); + block_cleanup_parameters(s); } =20 static void migrate_fd_cancel(MigrationState *s) @@ -1020,6 +1054,7 @@ static void migrate_fd_cancel(MigrationState *s) s->block_inactive =3D false; } } + block_cleanup_parameters(s); } =20 void add_migration_state_change_notifier(Notifier *notify) @@ -1207,6 +1242,24 @@ void qmp_migrate(const char *uri, bool has_blk, bool= blk, return; } =20 + if ((has_blk && blk) || (has_inc && inc)) { + if (migrate_use_block() || migrate_use_block_incremental()) { + error_setg(errp, "Command options are incompatible with " + "current migration capabilities"); + return; + } + migrate_set_block_enabled(true, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + s->must_remove_block_options =3D true; + } + + if (has_inc && inc) { + migrate_set_block_incremental(s, true); + } + s =3D migrate_init(¶ms); =20 if (strstart(uri, "tcp:", &p)) { @@ -1404,6 +1457,24 @@ int64_t migrate_xbzrle_cache_size(void) return s->xbzrle_cache_size; } =20 +bool migrate_use_block(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK]; +} + +bool migrate_use_block_incremental(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.block_incremental; +} + /* migration thread support */ /* * Something bad happened to the RP stream, mark an error diff --git a/qapi-schema.json b/qapi-schema.json index 80603cf..e38c5f0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -894,11 +894,18 @@ # @release-ram: if enabled, qemu will free the migrated ram pages on the s= ource # during postcopy-ram migration. (since 2.9) # +# @block: If enabled, QEMU will also migrate the contents of all block +# devices. Default is disabled. A possible alternative uses +# mirror jobs to a builtin NBD server on the destination, which +# offers more flexibility. +# (Since 2.10) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', - 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] } + 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', + 'block' ] } =20 ## # @MigrationCapabilityStatus: @@ -1009,13 +1016,20 @@ # @x-checkpoint-delay: The delay time (in ms) between two COLO checkpoints= in # periodic mode. (Since 2.8) # +# @block-incremental: Affects how much storage is migrated when the +# block migration capability is enabled. When false, the entire +# storage backing chain is migrated into a flattened image at +# the destination; when true, only the active qcow2 layer is +# migrated and the destination must already have access to the +# same backing chain as was used on the source. (since 2.10) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay' ] } + 'downtime-limit', 'x-checkpoint-delay', 'block-incremental' ] } =20 ## # @migrate-set-parameters: @@ -1082,6 +1096,13 @@ # # @x-checkpoint-delay: the delay time between two COLO checkpoints. (Since= 2.8) # +# @block-incremental: Affects how much storage is migrated when the +# block migration capability is enabled. When false, the entire +# storage backing chain is migrated into a flattened image at +# the destination; when true, only the active qcow2 layer is +# migrated and the destination must already have access to the +# same backing chain as was used on the source. (since 2.10) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -1094,7 +1115,8 @@ '*tls-hostname': 'str', '*max-bandwidth': 'int', '*downtime-limit': 'int', - '*x-checkpoint-delay': 'int'} } + '*x-checkpoint-delay': 'int', + '*block-incremental': 'bool' } } =20 ## # @query-migrate-parameters: --=20 2.9.3