From nobody Wed May 8 00:37:06 2024 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 1495035593448469.1295089362295; Wed, 17 May 2017 08:39:53 -0700 (PDT) Received: from localhost ([::1]:49539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB13H-0001bk-Ua for importer@patchew.org; Wed, 17 May 2017 11:39:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB11r-0000l1-A9 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11o-0004q7-94 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11o-0004pu-34 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11FBE8535D for ; Wed, 17 May 2017 15:38:19 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EEC817A7B; Wed, 17 May 2017 15:38:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11FBE8535D Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 11FBE8535D From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:08 +0200 Message-Id: <20170517153812.21993-2-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 May 2017 15:38:19 +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 1/5] hmp: Use visitor api for hmp_migrate_set_parameter() 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" We only use it for int64 at this point, I am not able to find a way to parse an int with MiB units. Signed-off-by: Juan Quintela Reviewed-by: Markus Armbruster --- hmp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index b9dd933..acbbc5c 100644 --- a/hmp.c +++ b/hmp.c @@ -29,6 +29,7 @@ #include "monitor/qdev.h" #include "qapi/opts-visitor.h" #include "qapi/qmp/qerror.h" +#include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qapi/util.h" #include "qapi-visit.h" @@ -1523,8 +1524,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) { const char *param =3D qdict_get_str(qdict, "parameter"); const char *valuestr =3D qdict_get_str(qdict, "value"); + Visitor *v =3D string_input_visitor_new(valuestr); uint64_t valuebw =3D 0; - long valueint =3D 0; + int64_t valueint =3D 0; Error *err =3D NULL; bool use_int_value =3D false; int i, ret; @@ -1582,9 +1584,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) } =20 if (use_int_value) { - if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) { - error_setg(&err, "Unable to parse '%s' as an int", - valuestr); + visit_type_int(v, param, &valueint, &err); + if (err) { goto cleanup; } /* Set all integers; only one has_FOO will be set, and @@ -1608,6 +1609,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) } =20 cleanup: + visit_free(v); if (err) { error_report_err(err); } --=20 2.9.3 From nobody Wed May 8 00:37:06 2024 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 1495035734676966.0026270709899; Wed, 17 May 2017 08:42:14 -0700 (PDT) Received: from localhost ([::1]:49555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB15X-0003Y0-Qa for importer@patchew.org; Wed, 17 May 2017 11:42:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB11s-0000l6-9X for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11q-0004qg-Gz for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11q-0004qb-74 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E13E46297 for ; Wed, 17 May 2017 15:38:21 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6319317A7B; Wed, 17 May 2017 15:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2E13E46297 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2E13E46297 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:09 +0200 Message-Id: <20170517153812.21993-3-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 May 2017 15:38:21 +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 Signed-off-by: Juan Quintela --- hmp.c | 13 ++++++++ include/migration/block.h | 2 ++ include/migration/migration.h | 6 ++++ migration/migration.c | 73 +++++++++++++++++++++++++++++++++++++++= ++++ qapi-schema.json | 28 +++++++++++++++-- 5 files changed, 119 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..f2bb448 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,26 @@ void qmp_migrate(const char *uri, bool has_blk, bool= blk, return; } =20 + if (((has_blk && blk) || (has_inc && inc)) + && (migrate_use_block() || migrate_use_block_incremental())) { + error_setg(errp, "Command options are incompatible with current " + "migration capabilities"); + return; + } + + if ((has_blk && blk) || (has_inc & inc)) { + 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 +1459,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..621126a 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 are +# mirror jobs to a builtin NBD server on the destination, which +# are more flexible. +# (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 From nobody Wed May 8 00:37:06 2024 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 1495035594309604.0747677498949; Wed, 17 May 2017 08:39:54 -0700 (PDT) Received: from localhost ([::1]:49540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB13J-0001cv-0N for importer@patchew.org; Wed, 17 May 2017 11:39:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB11t-0000lO-Jg for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11s-0004rH-JU for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11s-0004r0-AT for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46F1961B80 for ; Wed, 17 May 2017 15:38:23 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FB2417A7B; Wed, 17 May 2017 15:38:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 46F1961B80 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 46F1961B80 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:10 +0200 Message-Id: <20170517153812.21993-4-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 17 May 2017 15:38:23 +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 3/5] migration: Remove use of old MigrationParams 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" We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty. For savevm, one can't do a: savevm -b/-i foo but now one can do: migrate_set_capability block on savevm foo And we can't use block migration. We could disable block capability unconditionally, but it would not be much better. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake --- - Maintain shared/enabled dependency (Xu suggestion) - Now we maintain the dependency on the setter functions - improve error messages Signed-off-by: Juan Quintela --- include/migration/migration.h | 3 +-- migration/block.c | 17 ++--------------- migration/colo.c | 4 ++-- migration/migration.c | 3 --- migration/savevm.c | 8 ++++++-- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 024a048..4dedc66 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -39,8 +39,7 @@ #define QEMU_VM_SECTION_FOOTER 0x7e =20 struct MigrationParams { - bool blk; - bool shared; + bool unused; /* C doesn't allow empty structs */ }; =20 /* Messages sent on the return path from destination to source */ diff --git a/migration/block.c b/migration/block.c index 060087f..5d22926 100644 --- a/migration/block.c +++ b/migration/block.c @@ -94,9 +94,6 @@ typedef struct BlkMigBlock { } BlkMigBlock; =20 typedef struct BlkMigState { - /* Written during setup phase. Can be read without a lock. */ - int blk_enable; - int shared_base; QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list; int64_t total_sector_sum; bool zero_blocks; @@ -425,7 +422,7 @@ static int init_blk_migration(QEMUFile *f) bmds->bulk_completed =3D 0; bmds->total_sectors =3D sectors; bmds->completed_sectors =3D 0; - bmds->shared_base =3D block_mig_state.shared_base; + bmds->shared_base =3D migrate_use_block_incremental(); =20 assert(i < num_bs); bmds_bs[i].bmds =3D bmds; @@ -994,22 +991,12 @@ static int block_load(QEMUFile *f, void *opaque, int = version_id) return 0; } =20 -static void block_set_params(const MigrationParams *params, void *opaque) -{ - block_mig_state.blk_enable =3D params->blk; - block_mig_state.shared_base =3D params->shared; - - /* shared base means that blk_enable =3D 1 */ - block_mig_state.blk_enable |=3D params->shared; -} - static bool block_is_active(void *opaque) { - return block_mig_state.blk_enable =3D=3D 1; + return migrate_use_block(); } =20 static SaveVMHandlers savevm_block_handlers =3D { - .set_params =3D block_set_params, .save_live_setup =3D block_save_setup, .save_live_iterate =3D block_save_iterate, .save_live_complete_precopy =3D block_save_complete, diff --git a/migration/colo.c b/migration/colo.c index 963c802..8c86892 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -14,6 +14,7 @@ #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "migration/colo.h" +#include "migration/block.h" #include "io/channel-buffer.h" #include "trace.h" #include "qemu/error-report.h" @@ -345,8 +346,7 @@ static int colo_do_checkpoint_transaction(MigrationStat= e *s, } =20 /* Disable block migration */ - s->params.blk =3D 0; - s->params.shared =3D 0; + migrate_set_block_enabled(false, &local_err); qemu_savevm_state_header(fb); qemu_savevm_state_begin(fb, &s->params); qemu_mutex_lock_iothread(); diff --git a/migration/migration.c b/migration/migration.c index f2bb448..f4cbfe6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1224,9 +1224,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, MigrationParams params; const char *p; =20 - params.blk =3D has_blk && blk; - params.shared =3D has_inc && inc; - if (migration_is_setup_or_active(s->state) || s->state =3D=3D MIGRATION_STATUS_CANCELLING || s->state =3D=3D MIGRATION_STATUS_COLO) { diff --git a/migration/savevm.c b/migration/savevm.c index f5e8194..2f1f4eb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1233,8 +1233,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **err= p) { int ret; MigrationParams params =3D { - .blk =3D 0, - .shared =3D 0 }; MigrationState *ms =3D migrate_init(¶ms); MigrationStatus status; @@ -1245,6 +1243,12 @@ static int qemu_savevm_state(QEMUFile *f, Error **er= rp) goto done; } =20 + if (migrate_use_block()) { + error_setg(errp, "Block migration and snapshots are incompatible"); + ret =3D -EINVAL; + goto done; + } + qemu_mutex_unlock_iothread(); qemu_savevm_state_header(f); qemu_savevm_state_begin(f, ¶ms); --=20 2.9.3 From nobody Wed May 8 00:37:06 2024 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 1495035735413345.4675017008216; Wed, 17 May 2017 08:42:15 -0700 (PDT) Received: from localhost ([::1]:49556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB15Z-0003YD-0l for importer@patchew.org; Wed, 17 May 2017 11:42:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB11w-0000nb-8X for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11v-0004rx-0m for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11u-0004rh-O8 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA53FC057FAF for ; Wed, 17 May 2017 15:38:25 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9808D17A7B; Wed, 17 May 2017 15:38:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AA53FC057FAF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AA53FC057FAF From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:11 +0200 Message-Id: <20170517153812.21993-5-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 May 2017 15:38:25 +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 4/5] migration: Remove old MigrationParams 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" Not used anymore after moving block migration to use capabilities. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: zhanghailiang Reviewed-by: Peter Xu --- include/migration/migration.h | 10 ++-------- include/migration/vmstate.h | 1 - include/qemu/typedefs.h | 1 - include/sysemu/sysemu.h | 3 +-- migration/colo.c | 2 +- migration/migration.c | 8 +++----- migration/savevm.c | 16 +++------------- 7 files changed, 10 insertions(+), 31 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 4dedc66..b80a6ed 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -38,10 +38,6 @@ #define QEMU_VM_COMMAND 0x08 #define QEMU_VM_SECTION_FOOTER 0x7e =20 -struct MigrationParams { - bool unused; /* C doesn't allow empty structs */ -}; - /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { MIG_RP_MSG_INVALID =3D 0, /* Must be 0 */ @@ -109,12 +105,10 @@ struct MigrationState QEMUBH *cleanup_bh; QEMUFile *to_dst_file; =20 - /* New style params from 'migrate-set-parameters' */ + /* params from 'migrate-set-parameters' */ MigrationParameters parameters; =20 int state; - /* Old style params from 'migrate' command */ - MigrationParams params; =20 /* State related to return path */ struct { @@ -207,7 +201,7 @@ void migrate_fd_connect(MigrationState *s); =20 void add_migration_state_change_notifier(Notifier *notify); void remove_migration_state_change_notifier(Notifier *notify); -MigrationState *migrate_init(const MigrationParams *params); +MigrationState *migrate_init(void); bool migration_is_blocked(Error **errp); bool migration_in_setup(MigrationState *); bool migration_is_idle(void); diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 8489659..dacb052 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -37,7 +37,6 @@ typedef int LoadStateHandler(QEMUFile *f, void *opaque, i= nt version_id); =20 typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ - void (*set_params)(const MigrationParams *params, void * opaque); SaveStateHandler *save_state; =20 void (*cleanup)(void *opaque); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 7d85057..33a6aa1 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -49,7 +49,6 @@ typedef struct MemoryRegion MemoryRegion; typedef struct MemoryRegionCache MemoryRegionCache; typedef struct MemoryRegionSection MemoryRegionSection; typedef struct MigrationIncomingState MigrationIncomingState; -typedef struct MigrationParams MigrationParams; typedef struct MigrationState MigrationState; typedef struct Monitor Monitor; typedef struct MonitorDef MonitorDef; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 83c1ceb..765358e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -102,8 +102,7 @@ enum qemu_vm_cmd { #define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24) =20 bool qemu_savevm_state_blocked(Error **errp); -void qemu_savevm_state_begin(QEMUFile *f, - const MigrationParams *params); +void qemu_savevm_state_begin(QEMUFile *f); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); void qemu_savevm_state_cleanup(void); diff --git a/migration/colo.c b/migration/colo.c index 8c86892..dd38fed 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -348,7 +348,7 @@ static int colo_do_checkpoint_transaction(MigrationStat= e *s, /* Disable block migration */ migrate_set_block_enabled(false, &local_err); qemu_savevm_state_header(fb); - qemu_savevm_state_begin(fb, &s->params); + qemu_savevm_state_begin(fb); qemu_mutex_lock_iothread(); qemu_savevm_state_complete_precopy(fb, false); qemu_mutex_unlock_iothread(); diff --git a/migration/migration.c b/migration/migration.c index f4cbfe6..168b648 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1118,7 +1118,7 @@ bool migration_is_idle(void) return false; } =20 -MigrationState *migrate_init(const MigrationParams *params) +MigrationState *migrate_init(void) { MigrationState *s =3D migrate_get_current(); =20 @@ -1132,7 +1132,6 @@ MigrationState *migrate_init(const MigrationParams *p= arams) s->cleanup_bh =3D 0; s->to_dst_file =3D NULL; s->state =3D MIGRATION_STATUS_NONE; - s->params =3D *params; s->rp_state.from_dst_file =3D NULL; s->rp_state.error =3D false; s->mbps =3D 0.0; @@ -1221,7 +1220,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, { Error *local_err =3D NULL; MigrationState *s =3D migrate_get_current(); - MigrationParams params; const char *p; =20 if (migration_is_setup_or_active(s->state) || @@ -1259,7 +1257,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, migrate_set_block_incremental(s, true); } =20 - s =3D migrate_init(¶ms); + s =3D migrate_init(); =20 if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); @@ -1983,7 +1981,7 @@ static void *migration_thread(void *opaque) qemu_savevm_send_postcopy_advise(s->to_dst_file); } =20 - qemu_savevm_state_begin(s->to_dst_file, &s->params); + qemu_savevm_state_begin(s->to_dst_file); =20 s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, diff --git a/migration/savevm.c b/migration/savevm.c index 2f1f4eb..a728414 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -966,21 +966,13 @@ void qemu_savevm_state_header(QEMUFile *f) =20 } =20 -void qemu_savevm_state_begin(QEMUFile *f, - const MigrationParams *params) +void qemu_savevm_state_begin(QEMUFile *f) { SaveStateEntry *se; int ret; =20 trace_savevm_state_begin(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->set_params) { - continue; - } - se->ops->set_params(params, se->opaque); - } - - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || !se->ops->save_live_setup) { continue; } @@ -1232,9 +1224,7 @@ void qemu_savevm_state_cleanup(void) static int qemu_savevm_state(QEMUFile *f, Error **errp) { int ret; - MigrationParams params =3D { - }; - MigrationState *ms =3D migrate_init(¶ms); + MigrationState *ms =3D migrate_init(); MigrationStatus status; ms->to_dst_file =3D f; =20 @@ -1251,7 +1241,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **err= p) =20 qemu_mutex_unlock_iothread(); qemu_savevm_state_header(f); - qemu_savevm_state_begin(f, ¶ms); + qemu_savevm_state_begin(f); qemu_mutex_lock_iothread(); =20 while (qemu_file_get_error(f) =3D=3D 0) { --=20 2.9.3 From nobody Wed May 8 00:37:06 2024 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 1495035733677322.4027112911059; Wed, 17 May 2017 08:42:13 -0700 (PDT) Received: from localhost ([::1]:49554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB15Y-0003Xv-2o for importer@patchew.org; Wed, 17 May 2017 11:42:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB122-0000tE-Na for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11x-0004vU-Mq for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11x-0004un-DU for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C282C057FA4 for ; Wed, 17 May 2017 15:38:28 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03E1917A7B; Wed, 17 May 2017 15:38:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5C282C057FA4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5C282C057FA4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:12 +0200 Message-Id: <20170517153812.21993-6-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 May 2017 15:38:28 +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 5/5] block migration: Allow compile time disable 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" From: "Dr. David Alan Gilbert" Many users now prefer to use drive_mirror over NBD as an alternative to the older migrate -b option; drive_mirror is more complex to setup but gives you more options (e.g. only migrating some of the disks if some of them are shared). Allow the large chunk of block migration code to be compiled out for those who don't use it. Based on a downstream-patch we've had for a while by Jeff Cody. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- configure | 11 +++++++++++ include/migration/block.h | 24 +++++++++++++++++++++++- migration/Makefile.objs | 2 +- migration/migration.c | 13 +++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 57b5ae6..ace1a52 100755 --- a/configure +++ b/configure @@ -316,6 +316,7 @@ vte=3D"" virglrenderer=3D"" tpm=3D"yes" libssh2=3D"" +live_block_migration=3D"yes" numa=3D"" tcmalloc=3D"no" jemalloc=3D"no" @@ -1169,6 +1170,10 @@ for opt do ;; --enable-libssh2) libssh2=3D"yes" ;; + --disable-live-block-migration) live_block_migration=3D"no" + ;; + --enable-live-block-migration) live_block_migration=3D"yes" + ;; --disable-numa) numa=3D"no" ;; --enable-numa) numa=3D"yes" @@ -1401,6 +1406,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: libnfs nfs support smartcard smartcard support (libcacard) libusb libusb (for usb passthrough) + live-block-migration Block migration in the main migration stream usb-redir usb network redirection support lzo support of lzo compression library snappy support of snappy compression library @@ -5216,6 +5222,7 @@ echo "TPM support $tpm" echo "libssh2 support $libssh2" echo "TPM passthrough $tpm_passthrough" echo "QOM debugging $qom_cast_debug" +echo "Live block migration $live_block_migration" echo "lzo support $lzo" echo "snappy support $snappy" echo "bzip2 support $bzip2" @@ -5782,6 +5789,10 @@ if test "$libssh2" =3D "yes" ; then echo "LIBSSH2_LIBS=3D$libssh2_libs" >> $config_host_mak fi =20 +if test "$live_block_migration" =3D "yes" ; then + echo "CONFIG_LIVE_BLOCK_MIGRATION=3Dy" >> $config_host_mak +fi + # USB host support if test "$libusb" =3D "yes"; then echo "HOST_USB=3Dlibusb legacy" >> $config_host_mak diff --git a/include/migration/block.h b/include/migration/block.h index 5225af9..28cff53 100644 --- a/include/migration/block.h +++ b/include/migration/block.h @@ -14,12 +14,34 @@ #ifndef MIGRATION_BLOCK_H #define MIGRATION_BLOCK_H =20 +#ifdef CONFIG_LIVE_BLOCK_MIGRATION void blk_mig_init(void); int blk_mig_active(void); uint64_t blk_mig_bytes_transferred(void); uint64_t blk_mig_bytes_remaining(void); uint64_t blk_mig_bytes_total(void); =20 +#else +static inline void blk_mig_init(void) { } +static inline int blk_mig_active(void) +{ + return false; +} +static inline uint64_t blk_mig_bytes_transferred(void) +{ + return 0; +} + +static inline uint64_t blk_mig_bytes_remaining(void) +{ + return 0; +} + +static inline uint64_t blk_mig_bytes_total(void) +{ + return 0; +} +#endif /* CONFIG_LIVE_BLOCK_MIGRATION */ + void migrate_set_block_enabled(bool value, Error **errp); - #endif /* MIGRATION_BLOCK_H */ diff --git a/migration/Makefile.objs b/migration/Makefile.objs index c1920b6..00a3f4a 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -9,5 +9,5 @@ common-obj-y +=3D qjson.o =20 common-obj-$(CONFIG_RDMA) +=3D rdma.o =20 -common-obj-y +=3D block.o +common-obj-$(CONFIG_LIVE_BLOCK_MIGRATION) +=3D block.o =20 diff --git a/migration/migration.c b/migration/migration.c index 168b648..d5ebcd2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -547,6 +547,11 @@ MigrationCapabilityStatusList *qmp_query_migrate_capab= ilities(Error **errp) =20 caps =3D NULL; /* silence compiler warning */ for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { +#ifndef CONFIG_LIVE_BLOCK_MIGRATION + if (i =3D=3D MIGRATION_CAPABILITY_BLOCK) { + continue; + } +#endif if (i =3D=3D MIGRATION_CAPABILITY_X_COLO && !colo_supported()) { continue; } @@ -763,6 +768,14 @@ void qmp_migrate_set_capabilities(MigrationCapabilityS= tatusList *params, } =20 for (cap =3D params; cap; cap =3D cap->next) { +#ifndef CONFIG_LIVE_BLOCK_MIGRATION + if (cap->value->capability =3D=3D MIGRATION_CAPABILITY_BLOCK) { + error_setg(errp, "QEMU compiled without old-style (blk/-b, inc= /-i) " + "block migration"); + error_append_hint(errp, "Use drive_mirror+NBD instead.\n"); + continue; + } +#endif if (cap->value->capability =3D=3D MIGRATION_CAPABILITY_X_COLO) { if (!colo_supported()) { error_setg(errp, "COLO is not currently supported, please" --=20 2.9.3