From nobody Wed Nov 5 14:23:02 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 1496980259338157.39443831254027; Thu, 8 Jun 2017 20:50:59 -0700 (PDT) Received: from localhost ([::1]:52484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAwr-0003Nu-Oh for importer@patchew.org; Thu, 08 Jun 2017 23:50:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvF-0002TU-M2 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvE-0007TU-RU for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvE-0007T7-L8 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E7D983F44 for ; Fri, 9 Jun 2017 03:49:15 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 085F41759C; Fri, 9 Jun 2017 03:49:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E7D983F44 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9E7D983F44 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:48:57 +0800 Message-Id: <1496980142-8986-2-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 09 Jun 2017 03:49:15 +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 v2 1/6] machine: export register_compat_prop() 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: Laurent Vivier , Eduardo Habkost , Juan Quintela , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Marcel Apfelbaum 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 HW_COMPAT_*, however that's only binded to machines, not other things (like accelerators). Behind it, it was register_compat_prop() that played the trick. Let's export the function for further use outside HW_COMPAT_* magic. CC: Eduardo Habkost CC: Markus Armbruster CC: Marcel Apfelbaum Signed-off-by: Peter Xu --- hw/core/machine.c | 6 +++--- include/hw/boards.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 3adebf1..320486d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -753,9 +753,9 @@ static void machine_class_finalize(ObjectClass *klass, = void *data) g_free(mc->name); } =20 -static void register_compat_prop(const char *driver, - const char *property, - const char *value) +void register_compat_prop(const char *driver, + const char *property, + const char *value) { GlobalProperty *p =3D g_new0(GlobalProperty, 1); /* Machine compat_props must never cause errors: */ diff --git a/include/hw/boards.h b/include/hw/boards.h index 76ce021..6e0f5c7 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -41,6 +41,9 @@ int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); +void register_compat_prop(const char *driver, + const char *property, + const char *value); void machine_register_compat_props(MachineState *machine); HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); void machine_set_cpu_numa_node(MachineState *machine, --=20 2.7.4 From nobody Wed Nov 5 14:23:02 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 1496980382979883.9416290530987; Thu, 8 Jun 2017 20:53:02 -0700 (PDT) Received: from localhost ([::1]:52489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAyr-0005Gu-8U for importer@patchew.org; Thu, 08 Jun 2017 23:53:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvI-0002VA-Nk for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvH-0007Vm-QJ for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvH-0007UY-HJ for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B0CB5AFC9 for ; Fri, 9 Jun 2017 03:49:18 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2748185EE3; Fri, 9 Jun 2017 03:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B0CB5AFC9 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6B0CB5AFC9 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:48:58 +0800 Message-Id: <1496980142-8986-3-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 09 Jun 2017 03:49:18 +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 v2 2/6] migration: let MigrationState be a qdev 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: Laurent Vivier , peterx@redhat.com, Markus Armbruster , "Dr . David Alan Gilbert" , Juan Quintela 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" Let the old man "MigrationState" join the object family. Direct benefit is that we can start to use all the property features derived from current QDev, like: HW_COMPAT_* bits, command line setup for migration parameters (so will never need to set them up each time using HMP/QMP, this is really, really attractive for test writters), etc. I see no reason to disallow this happen yet. So let's start from this one, to see whether it would be anything good. No functional change at all. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- include/migration/migration.h | 19 ++++++++++++++ migration/migration.c | 61 ++++++++++++++++++++++++++++-----------= ---- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 79b5484..bd0186c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -21,6 +21,7 @@ #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" +#include "hw/qdev.h" =20 #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 @@ -49,6 +50,8 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; =20 +#define TYPE_MIGRATION "migration" + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -91,8 +94,24 @@ struct MigrationIncomingState { MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); =20 +#define MIGRATION_CLASS(klass) \ + OBJECT_CLASS_CHECK(MigrationClass, (klass), TYPE_MIGRATION) +#define MIGRATION_OBJ(obj) \ + OBJECT_CHECK(MigrationState, (obj), TYPE_MIGRATION) +#define MIGRATION_GET_CLASS(obj) \ + OBJECT_GET_CLASS(MigrationClass, (obj), TYPE_MIGRATION) + +typedef struct MigrationClass { + /*< private >*/ + DeviceClass parent_class; +} MigrationClass; + struct MigrationState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ size_t bytes_xfer; size_t xfer_limit; QemuThread thread; diff --git a/migration/migration.c b/migration/migration.c index 48c94c9..98b77e2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -93,29 +93,13 @@ static bool deferred_incoming; /* For outgoing */ MigrationState *migrate_get_current(void) { - static bool once; - static MigrationState current_migration =3D { - .state =3D MIGRATION_STATUS_NONE, - .xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE, - .mbps =3D -1, - .parameters =3D { - .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, - .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, - .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUN= T, - .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, - .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_INCRE= MENT, - .max_bandwidth =3D MAX_THROTTLE, - .downtime_limit =3D DEFAULT_MIGRATE_SET_DOWNTIME, - .x_checkpoint_delay =3D DEFAULT_MIGRATE_X_CHECKPOINT_DELAY, - }, - }; + static MigrationState *current_migration; =20 - if (!once) { - current_migration.parameters.tls_creds =3D g_strdup(""); - current_migration.parameters.tls_hostname =3D g_strdup(""); - once =3D true; + if (!current_migration) { + current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); } - return ¤t_migration; + + return current_migration; } =20 MigrationIncomingState *migration_incoming_get_current(void) @@ -2123,3 +2107,38 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +static void migration_instance_init(Object *obj) +{ + MigrationState *ms =3D MIGRATION_OBJ(obj); + + ms->state =3D MIGRATION_STATUS_NONE; + ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; + ms->mbps =3D -1; + ms->parameters =3D (MigrationParameters) { + .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, + .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, + .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, + .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, + .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .max_bandwidth =3D MAX_THROTTLE, + .downtime_limit =3D DEFAULT_MIGRATE_SET_DOWNTIME, + .x_checkpoint_delay =3D DEFAULT_MIGRATE_X_CHECKPOINT_DELAY, + }; + ms->parameters.tls_creds =3D g_strdup(""); + ms->parameters.tls_hostname =3D g_strdup(""); +} + +static const TypeInfo migration_type =3D { + .name =3D TYPE_MIGRATION, + .parent =3D TYPE_DEVICE, + .class_size =3D sizeof(MigrationClass), + .instance_size =3D sizeof(MigrationState), + .instance_init =3D migration_instance_init, +}; + +static void register_migration_types(void) +{ + type_register_static(&migration_type); +} + +type_init(register_migration_types); --=20 2.7.4 From nobody Wed Nov 5 14:23:02 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 1496980385260858.7224088636896; Thu, 8 Jun 2017 20:53:05 -0700 (PDT) Received: from localhost ([::1]:52490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAyt-0005L6-TI for importer@patchew.org; Thu, 08 Jun 2017 23:53:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvN-0002Yz-Pf for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvK-0007Wo-N6 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvK-0007Wh-AC for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C1B781236 for ; Fri, 9 Jun 2017 03:49:21 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id E39EE1759C; Fri, 9 Jun 2017 03:49:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4C1B781236 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4C1B781236 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:48:59 +0800 Message-Id: <1496980142-8986-4-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 09 Jun 2017 03:49: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 v2 3/6] migration: move global_state.optional out 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: Laurent Vivier , peterx@redhat.com, Markus Armbruster , "Dr . David Alan Gilbert" , Juan Quintela 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" Put it into MigrationState then we can use the properties to specify whether to enable storing global state. Removing global_state_set_optional() since now we can use HW_COMPAT_2_3 for x86/power in general, and the register_compat_prop() for xen_init(). Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 8 +++++++- include/hw/compat.h | 4 ++++ include/migration/migration.h | 7 ++++++- migration/migration.c | 24 ++++++++++++++++-------- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2234bd0..c83cec5 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -317,7 +317,6 @@ static void pc_compat_2_3(MachineState *machine) if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; } - global_state_set_optional(); savevm_skip_configuration(); } =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ab3aab1..3e78bb9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3593,7 +3593,6 @@ static void spapr_machine_2_3_instance_options(Machin= eState *machine) { spapr_machine_2_4_instance_options(machine); savevm_skip_section_footers(); - global_state_set_optional(); savevm_skip_configuration(); } =20 diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index 0bed577..8240d50 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -138,7 +138,13 @@ static int xen_init(MachineState *ms) } qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); =20 - global_state_set_optional(); + /* + * TODO: make sure global MigrationState has not yet been created + * (otherwise the compat trick won't work). For now we are in + * configure_accelerator() so we are mostly good. Better to + * confirm that in the future. + */ + register_compat_prop("migration", "store-global-state", "off"); savevm_skip_configuration(); savevm_skip_section_footers(); =20 diff --git a/include/hw/compat.h b/include/hw/compat.h index 400c64b..5b5c8de 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -177,6 +177,10 @@ .driver =3D TYPE_PCI_DEVICE,\ .property =3D "x-pcie-lnksta-dllla",\ .value =3D "off",\ + },{\ + .driver =3D "migration",\ + .property =3D "store-global-state",\ + .value =3D "off",\ }, =20 #define HW_COMPAT_2_2 \ diff --git a/include/migration/migration.h b/include/migration/migration.h index bd0186c..d3ec719 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -162,6 +162,12 @@ struct MigrationState /* 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; + + /* + * Global switch on whether we need to store the global state + * during migration. + */ + bool store_global_state; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -240,7 +246,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, =20 void savevm_skip_section_footers(void); void register_global_state(void); -void global_state_set_optional(void); void savevm_skip_configuration(void); int global_state_store(void); void global_state_store_running(void); diff --git a/migration/migration.c b/migration/migration.c index 98b77e2..79d886c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -138,13 +138,13 @@ void migration_incoming_state_destroy(void) =20 =20 typedef struct { - bool optional; uint32_t size; uint8_t runstate[100]; RunState state; bool received; } GlobalState; =20 +/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state; =20 int global_state_store(void) @@ -175,19 +175,13 @@ static RunState global_state_get_runstate(void) return global_state.state; } =20 -void global_state_set_optional(void) -{ - global_state.optional =3D true; -} - static bool global_state_needed(void *opaque) { GlobalState *s =3D opaque; char *runstate =3D (char *)s->runstate; =20 /* If it is not optional, it is mandatory */ - - if (s->optional =3D=3D false) { + if (migrate_get_current()->store_global_state) { return true; } =20 @@ -2107,6 +2101,19 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +static Property migration_properties[] =3D { + DEFINE_PROP_BOOL("store-global-state", MigrationState, + store_global_state, true), + DEFINE_PROP_END_OF_LIST(), +}; + +static void migration_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D migration_properties; +} + static void migration_instance_init(Object *obj) { MigrationState *ms =3D MIGRATION_OBJ(obj); @@ -2131,6 +2138,7 @@ static void migration_instance_init(Object *obj) static const TypeInfo migration_type =3D { .name =3D TYPE_MIGRATION, .parent =3D TYPE_DEVICE, + .class_init =3D migration_class_init, .class_size =3D sizeof(MigrationClass), .instance_size =3D sizeof(MigrationState), .instance_init =3D migration_instance_init, --=20 2.7.4 From nobody Wed Nov 5 14:23:02 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 1496980267514990.5543624713172; Thu, 8 Jun 2017 20:51:07 -0700 (PDT) Received: from localhost ([::1]:52485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAwz-0003W3-QE for importer@patchew.org; Thu, 08 Jun 2017 23:51:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvO-0002ZS-C1 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvN-0007Ya-Bq for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvN-0007Xz-2y for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E7BA4E4D1 for ; Fri, 9 Jun 2017 03:49:24 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9ED185ECB; Fri, 9 Jun 2017 03:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0E7BA4E4D1 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0E7BA4E4D1 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:49:00 +0800 Message-Id: <1496980142-8986-5-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 09 Jun 2017 03:49:24 +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 v2 4/6] migration: move only_migratable to MigrationState 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: Laurent Vivier , peterx@redhat.com, Markus Armbruster , "Dr . David Alan Gilbert" , Juan Quintela 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" One less global variable, and it does only matter with migration. We keep the old "--only-migratable" option, but also now we support: -global migration.only-migratable=3Dtrue Currently still keep the old interface. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- include/migration/migration.h | 3 +++ include/sysemu/sysemu.h | 1 - migration/migration.c | 3 ++- migration/savevm.c | 2 +- vl.c | 9 +++++++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index d3ec719..27b07ed 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -168,6 +168,9 @@ struct MigrationState * during migration. */ bool store_global_state; + + /* Whether the VM is only allowing for migratable devices */ + bool only_migratable; }; =20 void migrate_set_state(int *state, int old_state, int new_state); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 9841a52..b213696 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -15,7 +15,6 @@ /* vl.c */ =20 extern const char *bios_name; -extern int only_migratable; extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; diff --git a/migration/migration.c b/migration/migration.c index 79d886c..dbec586 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1113,7 +1113,7 @@ static GSList *migration_blockers; =20 int migrate_add_blocker(Error *reason, Error **errp) { - if (only_migratable) { + if (migrate_get_current()->only_migratable) { error_propagate(errp, error_copy(reason)); error_prepend(errp, "disallowing migration blocker " "(--only_migratable) for: "); @@ -2104,6 +2104,7 @@ void migrate_fd_connect(MigrationState *s) static Property migration_properties[] =3D { DEFINE_PROP_BOOL("store-global-state", MigrationState, store_global_state, true), + DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, f= alse), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 9c320f5..f073027 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2321,7 +2321,7 @@ void vmstate_register_ram_global(MemoryRegion *mr) bool vmstate_check_only_migratable(const VMStateDescription *vmsd) { /* check needed if --only-migratable is specified */ - if (!only_migratable) { + if (!migrate_get_current()->only_migratable) { return true; } =20 diff --git a/vl.c b/vl.c index be4dcf2..e842eef 100644 --- a/vl.c +++ b/vl.c @@ -188,7 +188,6 @@ bool boot_strict; uint8_t *boot_splash_filedata; size_t boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; -int only_migratable; /* turn it off unless user states otherwise */ =20 int icount_align_option; =20 @@ -3937,7 +3936,13 @@ int main(int argc, char **argv, char **envp) incoming =3D optarg; break; case QEMU_OPTION_only_migratable: - only_migratable =3D 1; + /* + * TODO: we can remove this option one day, and we + * should all use: + * + * "-global migration.only-migratable=3Dtrue" + */ + migrate_get_current()->only_migratable =3D true; break; case QEMU_OPTION_nodefaults: has_defaults =3D 0; --=20 2.7.4 From nobody Wed Nov 5 14:23:02 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 1496980469073566.4402687627905; Thu, 8 Jun 2017 20:54:29 -0700 (PDT) Received: from localhost ([::1]:52493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJB0F-0006NQ-KT for importer@patchew.org; Thu, 08 Jun 2017 23:54:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvS-0002Zn-R2 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvR-0007ar-RS for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40086) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvR-0007Ze-Ib for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B80A3DE3D for ; Fri, 9 Jun 2017 03:49:28 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA1F1759C; Fri, 9 Jun 2017 03:49:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B80A3DE3D 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B80A3DE3D From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:49:01 +0800 Message-Id: <1496980142-8986-6-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 09 Jun 2017 03:49: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 v2 5/6] migration: move skip_configuration out 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: Laurent Vivier , peterx@redhat.com, Markus Armbruster , "Dr . David Alan Gilbert" , Juan Quintela 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" It was in SaveState but now moved to MigrationState altogether. Again, using HW_COMPAT_2_3 for old PC/SPAPR machines, and register_compat_prop() for xen_init(). Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 2 +- include/hw/compat.h | 4 ++++ include/migration/migration.h | 4 +++- migration/migration.c | 2 ++ migration/savevm.c | 15 ++++----------- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c83cec5..529018d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -317,7 +317,6 @@ static void pc_compat_2_3(MachineState *machine) if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; } - savevm_skip_configuration(); } =20 static void pc_compat_2_2(MachineState *machine) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3e78bb9..227b03b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3593,7 +3593,6 @@ static void spapr_machine_2_3_instance_options(Machin= eState *machine) { spapr_machine_2_4_instance_options(machine); savevm_skip_section_footers(); - savevm_skip_configuration(); } =20 static void spapr_machine_2_3_class_options(MachineClass *mc) diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index 8240d50..a80034f 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -145,7 +145,7 @@ static int xen_init(MachineState *ms) * confirm that in the future. */ register_compat_prop("migration", "store-global-state", "off"); - savevm_skip_configuration(); + register_compat_prop("migration", "skip-configuration", "on"); savevm_skip_section_footers(); =20 return 0; diff --git a/include/hw/compat.h b/include/hw/compat.h index 5b5c8de..4ed2ae7 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -179,6 +179,10 @@ .value =3D "off",\ },{\ .driver =3D "migration",\ + .property =3D "skip-configuration",\ + .value =3D "on",\ + },{\ + .driver =3D "migration",\ .property =3D "store-global-state",\ .value =3D "off",\ }, diff --git a/include/migration/migration.h b/include/migration/migration.h index 27b07ed..5f6861c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -171,6 +171,9 @@ struct MigrationState =20 /* Whether the VM is only allowing for migratable devices */ bool only_migratable; + + /* Whether we skip QEMU_VM_CONFIGURATION for migration */ + bool skip_configuration; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -249,7 +252,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, =20 void savevm_skip_section_footers(void); void register_global_state(void); -void savevm_skip_configuration(void); int global_state_store(void); void global_state_store_running(void); =20 diff --git a/migration/migration.c b/migration/migration.c index dbec586..a4ab83d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2105,6 +2105,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_BOOL("store-global-state", MigrationState, store_global_state, true), DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, f= alse), + DEFINE_PROP_BOOL("skip-configuration", MigrationState, + skip_configuration, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/migration/savevm.c b/migration/savevm.c index f073027..222af4c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -290,7 +290,6 @@ typedef struct SaveStateEntry { typedef struct SaveState { QTAILQ_HEAD(, SaveStateEntry) handlers; int global_section_id; - bool skip_configuration; uint32_t len; const char *name; uint32_t target_page_bits; @@ -299,15 +298,8 @@ typedef struct SaveState { static SaveState savevm_state =3D { .handlers =3D QTAILQ_HEAD_INITIALIZER(savevm_state.handlers), .global_section_id =3D 0, - .skip_configuration =3D false, }; =20 -void savevm_skip_configuration(void) -{ - savevm_state.skip_configuration =3D true; -} - - static void configuration_pre_save(void *opaque) { SaveState *state =3D opaque; @@ -989,11 +981,11 @@ void qemu_savevm_state_header(QEMUFile *f) qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); =20 - if (!savevm_state.skip_configuration || enforce_config_section()) { + if (!migrate_get_current()->skip_configuration || + enforce_config_section()) { qemu_put_byte(f, QEMU_VM_CONFIGURATION); vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0); } - } =20 void qemu_savevm_state_begin(QEMUFile *f) @@ -2003,7 +1995,8 @@ int qemu_loadvm_state(QEMUFile *f) return -ENOTSUP; } =20 - if (!savevm_state.skip_configuration || enforce_config_section()) { + if (!migrate_get_current()->skip_configuration || + enforce_config_section()) { if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { error_report("Configuration section missing"); return -EINVAL; --=20 2.7.4 From nobody Wed Nov 5 14:23:02 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 1496980394025787.9626336753488; Thu, 8 Jun 2017 20:53:14 -0700 (PDT) Received: from localhost ([::1]:52491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAz2-0005RD-Fd for importer@patchew.org; Thu, 08 Jun 2017 23:53:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJAvW-0002aM-Lb for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJAvV-0007eH-Lu for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJAvV-0007dV-Ci for qemu-devel@nongnu.org; Thu, 08 Jun 2017 23:49:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FE988553E for ; Fri, 9 Jun 2017 03:49:32 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 159E71759C; Fri, 9 Jun 2017 03:49:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5FE988553E 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5FE988553E From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 9 Jun 2017 11:49:02 +0800 Message-Id: <1496980142-8986-7-git-send-email-peterx@redhat.com> In-Reply-To: <1496980142-8986-1-git-send-email-peterx@redhat.com> References: <1496980142-8986-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 09 Jun 2017 03:49:32 +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 v2 6/6] migration: move skip_section_footers 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: Laurent Vivier , peterx@redhat.com, Markus Armbruster , "Dr . David Alan Gilbert" , Juan Quintela 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" Move it into MigrationState, with a property binded to it. Same trick is played like previous patches. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 2 +- include/hw/compat.h | 4 ++++ include/migration/migration.h | 3 ++- migration/migration.c | 2 ++ migration/savevm.c | 11 ++--------- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 529018d..1be23e2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -313,7 +313,6 @@ static void pc_init1(MachineState *machine, static void pc_compat_2_3(MachineState *machine) { PCMachineState *pcms =3D PC_MACHINE(machine); - savevm_skip_section_footers(); if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 227b03b..944f829 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3592,7 +3592,6 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false); static void spapr_machine_2_3_instance_options(MachineState *machine) { spapr_machine_2_4_instance_options(machine); - savevm_skip_section_footers(); } =20 static void spapr_machine_2_3_class_options(MachineClass *mc) diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index a80034f..e8f08bb 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -146,7 +146,7 @@ static int xen_init(MachineState *ms) */ register_compat_prop("migration", "store-global-state", "off"); register_compat_prop("migration", "skip-configuration", "on"); - savevm_skip_section_footers(); + register_compat_prop("migration", "skip-section-footer", "on"); =20 return 0; } diff --git a/include/hw/compat.h b/include/hw/compat.h index 4ed2ae7..ef5fbc7 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -183,6 +183,10 @@ .value =3D "on",\ },{\ .driver =3D "migration",\ + .property =3D "skip-section-footer",\ + .value =3D "on",\ + },{\ + .driver =3D "migration",\ .property =3D "store-global-state",\ .value =3D "off",\ }, diff --git a/include/migration/migration.h b/include/migration/migration.h index 5f6861c..dc35567 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -174,6 +174,8 @@ struct MigrationState =20 /* Whether we skip QEMU_VM_CONFIGURATION for migration */ bool skip_configuration; + /* Whether we skip section footer */ + bool skip_section_footer; }; =20 void migrate_set_state(int *state, int old_state, int new_state); @@ -250,7 +252,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, ram_addr_t offset, size_t size, uint64_t *bytes_sent); =20 -void savevm_skip_section_footers(void); void register_global_state(void); int global_state_store(void); void global_state_store_running(void); diff --git a/migration/migration.c b/migration/migration.c index a4ab83d..9f90f7b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2107,6 +2107,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, f= alse), DEFINE_PROP_BOOL("skip-configuration", MigrationState, skip_configuration, false), + DEFINE_PROP_BOOL("skip-section-footer", MigrationState, + skip_section_footer, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 222af4c..06d6986 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -65,8 +65,6 @@ =20 const unsigned int postcopy_ram_discard_version =3D 0; =20 -static bool skip_section_footers; - /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { MIG_CMD_INVALID =3D 0, /* Must be 0 */ @@ -780,11 +778,6 @@ static void vmstate_save(QEMUFile *f, SaveStateEntry *= se, QJSON *vmdesc) vmstate_save_state(f, se->vmsd, se->opaque, vmdesc); } =20 -void savevm_skip_section_footers(void) -{ - skip_section_footers =3D true; -} - /* * Write the header for device section (QEMU_VM_SECTION START/END/PART/FUL= L) */ @@ -812,7 +805,7 @@ static void save_section_header(QEMUFile *f, SaveStateE= ntry *se, */ static void save_section_footer(QEMUFile *f, SaveStateEntry *se) { - if (!skip_section_footers) { + if (!migrate_get_current()->skip_section_footer) { qemu_put_byte(f, QEMU_VM_SECTION_FOOTER); qemu_put_be32(f, se->section_id); } @@ -1810,7 +1803,7 @@ static bool check_section_footer(QEMUFile *f, SaveSta= teEntry *se) uint8_t read_mark; uint32_t read_section_id; =20 - if (skip_section_footers) { + if (migrate_get_current()->skip_section_footer) { /* No footer to check */ return true; } --=20 2.7.4