From nobody Thu Nov 6 06:39:51 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 1498193571334414.3559163301304; Thu, 22 Jun 2017 21:52:51 -0700 (PDT) Received: from localhost ([::1]:33582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOGaP-0002Sy-Sp for importer@patchew.org; Fri, 23 Jun 2017 00:52:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOGVA-0005yE-0G for qemu-devel@nongnu.org; Fri, 23 Jun 2017 00:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOGV8-0001Hn-S0 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 00:47:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOGV8-0001HN-JI for qemu-devel@nongnu.org; Fri, 23 Jun 2017 00:47:22 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C18D3DEE4 for ; Fri, 23 Jun 2017 04:47:21 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8930D70528; Fri, 23 Jun 2017 04:47:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C18D3DEE4 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 8C18D3DEE4 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 12:46:41 +0800 Message-Id: <1498193206-18007-6-git-send-email-peterx@redhat.com> In-Reply-To: <1498193206-18007-1-git-send-email-peterx@redhat.com> References: <1498193206-18007-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 23 Jun 2017 04:47: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 v5 05/10] 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 , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster 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, and AccelClass.global_props for Xen. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 11 ++++++++++- include/hw/compat.h | 4 ++++ include/migration/global_state.h | 1 - migration/global_state.c | 9 ++------- migration/migration.c | 7 +++++++ migration/migration.h | 6 ++++++ 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 46a2bc4..3b51297 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -318,7 +318,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 e877d45..edbdbfd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3580,7 +3580,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 d3fa705..9163a0a 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -139,19 +139,28 @@ static int xen_init(MachineState *ms) } qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); =20 - global_state_set_optional(); savevm_skip_configuration(); savevm_skip_section_footers(); =20 return 0; } =20 +GlobalProperty xen_compat_props[] =3D { + { + .driver =3D "migration", + .property =3D "store-global-state", + .value =3D "off", + }, + { .driver =3D NULL, .property =3D NULL, .value =3D NULL }, +}; + static void xen_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); ac->name =3D "Xen"; ac->init_machine =3D xen_init; ac->allowed =3D &xen_allowed; + ac->global_props =3D xen_compat_props; } =20 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") diff --git a/include/hw/compat.h b/include/hw/compat.h index 26cd585..a506a74 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -181,6 +181,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/global_state.h b/include/migration/global_st= ate.h index 90faea7..d307de8 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -16,7 +16,6 @@ #include "sysemu/sysemu.h" =20 void register_global_state(void); -void global_state_set_optional(void); int global_state_store(void); void global_state_store_running(void); bool global_state_received(void); diff --git a/migration/global_state.c b/migration/global_state.c index f792cf5..dcbbcb2 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -15,12 +15,12 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/util.h" +#include "migration.h" #include "migration/global_state.h" #include "migration/vmstate.h" #include "trace.h" =20 typedef struct { - bool optional; uint32_t size; uint8_t runstate[100]; RunState state; @@ -57,11 +57,6 @@ 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; @@ -69,7 +64,7 @@ static bool global_state_needed(void *opaque) =20 /* If it is not optional, it is mandatory */ =20 - if (s->optional =3D=3D false) { + if (migrate_get_current()->store_global_state) { return true; } =20 diff --git a/migration/migration.c b/migration/migration.c index 2c25927..221b22c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1976,11 +1976,18 @@ 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); =20 dc->user_creatable =3D false; + dc->props =3D migration_properties; } =20 static void migration_instance_init(Object *obj) diff --git a/migration/migration.h b/migration/migration.h index 3fca364..4b898e9 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -133,6 +133,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); --=20 2.7.4