From nobody Mon Apr 29 07:59:21 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 1498649598221316.3639312866177; Wed, 28 Jun 2017 04:33:18 -0700 (PDT) Received: from localhost ([::1]:60619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBDe-00044o-0K for importer@patchew.org; Wed, 28 Jun 2017 07:33:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBo-0002sg-U1 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBh-0004Q8-NT for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBh-0004O3-Cx for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EA348553E for ; Wed, 28 Jun 2017 11:31:12 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07BD95C3FB; Wed, 28 Jun 2017 11:31:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5EA348553E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5EA348553E From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:53 +0200 Message-Id: <20170628113106.5248-2-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 28 Jun 2017 11:31:12 +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] [PULL 01/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu We have HW_COMPAT_*, however that's only bound 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. Meanwhile, move it to qdev-properties.c where seems more proper (since it'll be used not only in machine codes). Signed-off-by: Peter Xu Message-Id: <1498536619-14548-2-git-send-email-peterx@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Juan Quintela --- hw/core/machine.c | 13 ------------- hw/core/qdev-properties.c | 14 ++++++++++++++ include/hw/qdev-properties.h | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 2e7e977..ecb5552 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -770,19 +770,6 @@ 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) -{ - GlobalProperty *p =3D g_new0(GlobalProperty, 1); - /* Machine compat_props must never cause errors: */ - p->errp =3D &error_abort; - p->driver =3D driver; - p->property =3D property; - p->value =3D value; - qdev_prop_register_global(p); -} - static void machine_register_compat_for_subclass(ObjectClass *oc, void *op= aque) { GlobalProperty *p =3D opaque; diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 68cd653..adf62ad 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1084,6 +1084,20 @@ void qdev_prop_register_global(GlobalProperty *prop) global_props =3D g_list_append(global_props, prop); } =20 +void register_compat_prop(const char *driver, + const char *property, + const char *value) +{ + GlobalProperty *p =3D g_new0(GlobalProperty, 1); + + /* Any compat_props must never cause error */ + p->errp =3D &error_abort; + p->driver =3D driver; + p->property =3D property; + p->value =3D value; + qdev_prop_register_global(p); +} + void qdev_prop_register_global_list(GlobalProperty *props) { int i; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 39bf4b2..50ade83 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -210,6 +210,29 @@ void error_set_from_qdev_prop_error(Error **errp, int = ret, DeviceState *dev, Property *prop, const char *value); =20 /** + * register_compat_prop: + * + * Register internal (not user-provided) global property, changing the + * default value of a given property in a device type. This can be used + * for enabling machine-type compatibility or for enabling + * accelerator-specific defaults in devices. + * + * The property values set using this function must be always valid and + * never report setter errors, as the property will have + * GlobalProperty::errp set to &error_abort. + * + * User-provided global properties should override internal global + * properties, so callers of this function should ensure that it is + * called before user-provided global properties are registered. + * + * @driver: Device type to be affected + * @property: Property whose default value is going to be changed + * @value: New default value for the property + */ +void register_compat_prop(const char *driver, const char *property, + const char *value); + +/** * qdev_property_add_static: * @dev: Device to add the property to. * @prop: The qdev property definition. --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649754849979.4057408839919; Wed, 28 Jun 2017 04:35:54 -0700 (PDT) Received: from localhost ([::1]:60641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBGC-0006pO-NO for importer@patchew.org; Wed, 28 Jun 2017 07:35:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBp-0002t2-Bf for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBj-0004Sg-AK for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53942) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBj-0004Rk-0Q for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1872D142868 for ; Wed, 28 Jun 2017 11:31:14 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFFE25C3FB; Wed, 28 Jun 2017 11:31:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1872D142868 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 1872D142868 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:54 +0200 Message-Id: <20170628113106.5248-3-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 28 Jun 2017 11:31:14 +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] [PULL 02/14] accel: introduce AccelClass.global_props 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 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: Peter Xu Introduce this new field for the accelerator classes so that each specific accelerator in the future can register its own global properties to be used further by the system. It works just like how the old machine compatible properties do, but only tailored for accelerators. Introduce register_compat_props_array() for it. Export it so that it may be used in other codes as well in the future. Suggested-by: Eduardo Habkost Signed-off-by: Peter Xu Message-Id: <1498536619-14548-3-git-send-email-peterx@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Juan Quintela --- accel/accel.c | 6 ++++++ hw/core/qdev-properties.c | 7 +++++++ include/hw/qdev-properties.h | 6 ++++++ include/sysemu/accel.h | 11 +++++++++++ vl.c | 1 + 5 files changed, 31 insertions(+) diff --git a/accel/accel.c b/accel/accel.c index 7c079a5..fa85844 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -120,6 +120,12 @@ void configure_accelerator(MachineState *ms) } } =20 +void accel_register_compat_props(AccelState *accel) +{ + AccelClass *class =3D ACCEL_GET_CLASS(accel); + register_compat_props_array(class->global_props); +} + static void register_accel_types(void) { type_register_static(&accel_type); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index adf62ad..f11d578 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1098,6 +1098,13 @@ void register_compat_prop(const char *driver, qdev_prop_register_global(p); } =20 +void register_compat_props_array(GlobalProperty *prop) +{ + for (; prop && prop->driver; prop++) { + register_compat_prop(prop->driver, prop->property, prop->value); + } +} + void qdev_prop_register_global_list(GlobalProperty *props) { int i; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 50ade83..0604c33 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -231,6 +231,12 @@ void error_set_from_qdev_prop_error(Error **errp, int = ret, DeviceState *dev, */ void register_compat_prop(const char *driver, const char *property, const char *value); +/* + * register_compat_props_array(): using register_compat_prop(), which + * only registers internal global properties (which has lower priority + * than user-provided global properties) + */ +void register_compat_props_array(GlobalProperty *prop); =20 /** * qdev_property_add_static: diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 15944c1..ecc5c84 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -24,6 +24,7 @@ #define HW_ACCEL_H =20 #include "qom/object.h" +#include "hw/qdev-properties.h" =20 typedef struct AccelState { /*< private >*/ @@ -40,6 +41,14 @@ typedef struct AccelClass { int (*available)(void); int (*init_machine)(MachineState *ms); bool *allowed; + /* + * Array of global properties that would be applied when specific + * accelerator is chosen. It works like MachineClass.compat_props + * but it's for accelerators not machines. Accelerator-provided + * global properties may be overridden by machine-type + * compat_props or user-provided global properties. + */ + GlobalProperty *global_props; } AccelClass; =20 #define TYPE_ACCEL "accel" @@ -57,5 +66,7 @@ typedef struct AccelClass { extern int tcg_tb_size; =20 void configure_accelerator(MachineState *ms); +/* Register accelerator specific global properties */ +void accel_register_compat_props(AccelState *accel); =20 #endif diff --git a/vl.c b/vl.c index 59fea15..4452d7a 100644 --- a/vl.c +++ b/vl.c @@ -4571,6 +4571,7 @@ int main(int argc, char **argv, char **envp) exit (i =3D=3D 1 ? 1 : 0); } =20 + accel_register_compat_props(current_machine->accelerator); machine_register_compat_props(current_machine); =20 qemu_opts_foreach(qemu_find_opts("global"), --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649595362716.273280718868; Wed, 28 Jun 2017 04:33:15 -0700 (PDT) Received: from localhost ([::1]:60617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBDd-00043m-Ht for importer@patchew.org; Wed, 28 Jun 2017 07:33:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBp-0002sx-9a for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBk-0004VC-Ti for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58642) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBk-0004U6-OT for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C19594E4D2 for ; Wed, 28 Jun 2017 11:31:15 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A4BA5C3FB; Wed, 28 Jun 2017 11:31:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C19594E4D2 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C19594E4D2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:55 +0200 Message-Id: <20170628113106.5248-4-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 11:31: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] [PULL 03/14] vl: clean up global property registration 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 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: Peter Xu It's not that clear on how the global properties are registered to global_props (and also its priority relationship). Let's provide a single function to be called in main() for that, with comment to explain it a bit. Signed-off-by: Peter Xu Message-Id: <1498536619-14548-4-git-send-email-peterx@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Juan Quintela --- vl.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 4452d7a..c0cdb17 100644 --- a/vl.c +++ b/vl.c @@ -2969,6 +2969,25 @@ static int qemu_read_default_config_file(void) return 0; } =20 +static void user_register_global_props(void) +{ + qemu_opts_foreach(qemu_find_opts("global"), + global_init_func, NULL, NULL); +} + +/* + * Note: we should see that these properties are actually having a + * priority: accel < machine < user. This means e.g. when user + * specifies something in "-global", it'll always be used with highest + * priority than either machine/accelerator compat properties. + */ +static void register_global_properties(MachineState *ms) +{ + accel_register_compat_props(ms->accelerator); + machine_register_compat_props(ms); + user_register_global_props(); +} + int main(int argc, char **argv, char **envp) { int i; @@ -4571,11 +4590,11 @@ int main(int argc, char **argv, char **envp) exit (i =3D=3D 1 ? 1 : 0); } =20 - accel_register_compat_props(current_machine->accelerator); - machine_register_compat_props(current_machine); - - qemu_opts_foreach(qemu_find_opts("global"), - global_init_func, NULL, NULL); + /* + * Register all the global properties, including accel properties, + * machine properties, and user-specified ones. + */ + register_global_properties(current_machine); =20 /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649754341532.6865723460542; Wed, 28 Jun 2017 04:35:54 -0700 (PDT) Received: from localhost ([::1]:60643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBGD-0006qa-06 for importer@patchew.org; Wed, 28 Jun 2017 07:35:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBt-0002vq-NB for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBp-0004bn-UH for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBp-0004a0-GG for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77689C057EC9 for ; Wed, 28 Jun 2017 11:31:20 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F4AD5C3FB; Wed, 28 Jun 2017 11:31:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77689C057EC9 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 77689C057EC9 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:56 +0200 Message-Id: <20170628113106.5248-5-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 28 Jun 2017 11:31:20 +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] [PULL 04/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu 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. Now we init the MigrationState struct statically in main() to make sure it's initialized after global properties are applied, since we'll use them during creation of the object. No functional change at all. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-5-git-send-email-peterx@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Juan Quintela --- include/migration/misc.h | 1 + migration/migration.c | 78 ++++++++++++++++++++++++++++++++++----------= ---- migration/migration.h | 19 ++++++++++++ vl.c | 6 ++++ 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 65c7070..2d36cf5 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -45,6 +45,7 @@ void savevm_skip_section_footers(void); void savevm_skip_configuration(void); =20 /* migration/migration.c */ +void migration_object_init(void); void qemu_start_incoming_migration(const char *uri, Error **errp); bool migration_is_idle(void); void add_migration_state_change_notifier(Notifier *notify); diff --git a/migration/migration.c b/migration/migration.c index f588329..2c25927 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -98,32 +98,21 @@ enum mig_rp_message_type { migrations at once. For now we don't need to add dynamic creation of migration */ =20 +static MigrationState *current_migration; + +void migration_object_init(void) +{ + /* This can only be called once. */ + assert(!current_migration); + current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); +} + /* 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, - }, - }; - - if (!once) { - current_migration.parameters.tls_creds =3D g_strdup(""); - current_migration.parameters.tls_hostname =3D g_strdup(""); - once =3D true; - } - return ¤t_migration; + /* This can only be called after the object created. */ + assert(current_migration); + return current_migration; } =20 MigrationIncomingState *migration_incoming_get_current(void) @@ -1987,3 +1976,46 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +static void migration_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->user_creatable =3D false; +} + +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_init =3D migration_class_init, + .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); diff --git a/migration/migration.h b/migration/migration.h index d9a268a..3fca364 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -19,6 +19,7 @@ #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" +#include "hw/qdev.h" =20 /* State for the incoming migration */ struct MigrationIncomingState { @@ -62,8 +63,26 @@ struct MigrationIncomingState { MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); =20 +#define TYPE_MIGRATION "migration" + +#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/vl.c b/vl.c index c0cdb17..f0a0515 100644 --- a/vl.c +++ b/vl.c @@ -4596,6 +4596,12 @@ int main(int argc, char **argv, char **envp) */ register_global_properties(current_machine); =20 + /* + * Migration object can only be created after global properties + * are applied correctly. + */ + migration_object_init(); + /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query clock values from the log. */ --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649756151493.2425909379858; Wed, 28 Jun 2017 04:35:56 -0700 (PDT) Received: from localhost ([::1]:60642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBGD-0006qF-S0 for importer@patchew.org; Wed, 28 Jun 2017 07:35:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBv-0002y3-LJ for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBr-0004gN-Tr for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBr-0004dM-F2 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5679F4E4F3 for ; Wed, 28 Jun 2017 11:31:22 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id C85865C3FB; Wed, 28 Jun 2017 11:31:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5679F4E4F3 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5679F4E4F3 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:57 +0200 Message-Id: <20170628113106.5248-6-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 11:31:22 +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] [PULL 05/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu 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 Message-Id: <1498536619-14548-6-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- 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 ede5167..f07d40a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3581,7 +3581,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..459e6ab 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 +static GlobalProperty xen_compat_props[] =3D { + { + .driver =3D "migration", + .property =3D "store-global-state", + .value =3D "off", + }, + { /* end of list */ }, +}; + 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.9.4 From nobody Mon Apr 29 07:59:21 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 1498650005829809.0335826307308; Wed, 28 Jun 2017 04:40:05 -0700 (PDT) Received: from localhost ([::1]:60666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBKG-0002E3-H6 for importer@patchew.org; Wed, 28 Jun 2017 07:40:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBx-0002zc-97 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBt-0004j1-V2 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBt-0004iF-KZ for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B43F4E048 for ; Wed, 28 Jun 2017 11:31:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C6B05C3FB; Wed, 28 Jun 2017 11:31:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B43F4E048 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B43F4E048 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:58 +0200 Message-Id: <20170628113106.5248-7-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 11:31: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] [PULL 06/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu 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. Hmm, now vl.c has no way to access migrate_get_current(). Export a function for it to setup only_migratable. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-7-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- include/migration/misc.h | 2 ++ include/sysemu/sysemu.h | 1 - migration/migration.c | 8 +++++++- migration/migration.h | 3 +++ migration/savevm.c | 2 +- vl.c | 9 +++++++-- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 2d36cf5..6ac3307 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -55,4 +55,6 @@ bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); +void migration_only_migratable_set(void); + #endif 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 221b22c..67f9e68 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -115,6 +115,11 @@ MigrationState *migrate_get_current(void) return current_migration; } =20 +void migration_only_migratable_set(void) +{ + migrate_get_current()->only_migratable =3D true; +} + MigrationIncomingState *migration_incoming_get_current(void) { static bool once; @@ -986,7 +991,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: "); @@ -1979,6 +1984,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/migration.h b/migration/migration.h index 4b898e9..34377dd 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -139,6 +139,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/migration/savevm.c b/migration/savevm.c index c7a49c9..1499cd3 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2336,7 +2336,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 f0a0515..36ff3f4 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 @@ -3953,7 +3952,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" + */ + migration_only_migratable_set(); break; case QEMU_OPTION_nodefaults: has_defaults =3D 0; --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649607943456.45895607462626; Wed, 28 Jun 2017 04:33:27 -0700 (PDT) Received: from localhost ([::1]:60620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBDo-0004Cj-JH for importer@patchew.org; Wed, 28 Jun 2017 07:33:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBBy-00030k-J8 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBx-0004ln-BJ for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBx-0004lV-2h for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25C94C04B333 for ; Wed, 28 Jun 2017 11:31:28 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC9FC5C3FB; Wed, 28 Jun 2017 11:31:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 25C94C04B333 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 25C94C04B333 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:30:59 +0200 Message-Id: <20170628113106.5248-8-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 28 Jun 2017 11:31: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] [PULL 07/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu It was in SaveState but now moved to MigrationState altogether, reverted its meaning, then renamed to "send_configuration". Again, using HW_COMPAT_2_3 for old PC/SPAPR machines, and accel_register_prop() for xen_init(). Removing savevm_skip_configuration(). Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-8-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 6 +++++- include/hw/compat.h | 4 ++++ include/migration/misc.h | 1 - migration/migration.c | 2 ++ migration/migration.h | 3 +++ migration/savevm.c | 15 ++++----------- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 3b51297..488fc0a 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; } - 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 f07d40a..8429187 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3581,7 +3581,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 459e6ab..1f3688d 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -139,7 +139,6 @@ static int xen_init(MachineState *ms) } qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); =20 - savevm_skip_configuration(); savevm_skip_section_footers(); =20 return 0; @@ -151,6 +150,11 @@ static GlobalProperty xen_compat_props[] =3D { .property =3D "store-global-state", .value =3D "off", }, + { + .driver =3D "migration", + .property =3D "send-configuration", + .value =3D "off", + }, { /* end of list */ }, }; =20 diff --git a/include/hw/compat.h b/include/hw/compat.h index a506a74..1a3fd94 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -183,6 +183,10 @@ .value =3D "off",\ },{\ .driver =3D "migration",\ + .property =3D "send-configuration",\ + .value =3D "off",\ + },{\ + .driver =3D "migration",\ .property =3D "store-global-state",\ .value =3D "off",\ }, diff --git a/include/migration/misc.h b/include/migration/misc.h index 6ac3307..f30db4d 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -42,7 +42,6 @@ int64_t self_announce_delay(int round) =20 void dump_vmstate_json_to_file(FILE *out_fp); void savevm_skip_section_footers(void); -void savevm_skip_configuration(void); =20 /* migration/migration.c */ void migration_object_init(void); diff --git a/migration/migration.c b/migration/migration.c index 67f9e68..414e14d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1985,6 +1985,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("send-configuration", MigrationState, + send_configuration, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/migration/migration.h b/migration/migration.h index 34377dd..4d4ea0d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -142,6 +142,9 @@ struct MigrationState =20 /* Whether the VM is only allowing for migratable devices */ bool only_migratable; + + /* Whether we send QEMU_VM_CONFIGURATION during migration */ + bool send_configuration; }; =20 void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/savevm.c b/migration/savevm.c index 1499cd3..0a8c61f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -287,7 +287,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; @@ -296,15 +295,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; @@ -970,11 +962,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()->send_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) @@ -1995,7 +1987,8 @@ int qemu_loadvm_state(QEMUFile *f) return -ENOTSUP; } =20 - if (!savevm_state.skip_configuration || enforce_config_section()) { + if (migrate_get_current()->send_configuration || + enforce_config_section()) { if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { error_report("Configuration section missing"); return -EINVAL; --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649882431441.1444461249348; Wed, 28 Jun 2017 04:38:02 -0700 (PDT) Received: from localhost ([::1]:60654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBIH-0008Sj-64 for importer@patchew.org; Wed, 28 Jun 2017 07:38:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBC0-00032W-7N for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBBz-0004mk-1e for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42870) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBBy-0004mB-Ph for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD3943DBE4 for ; Wed, 28 Jun 2017 11:31:29 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 766035C3FB; Wed, 28 Jun 2017 11:31:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD3943DBE4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CD3943DBE4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:00 +0200 Message-Id: <20170628113106.5248-9-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 28 Jun 2017 11:31:29 +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] [PULL 08/14] 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@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: Peter Xu Move it into MigrationState, revert its meaning and renaming it to send_section_footer, with a property bound to it. Same trick is played like previous patches. Removing savevm_skip_section_footers(). Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-9-git-send-email-peterx@redhat.com> Signed-off-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/misc.h | 1 - migration/migration.c | 2 ++ migration/migration.h | 2 ++ migration/savevm.c | 11 ++--------- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 488fc0a..22dbef6 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -314,7 +314,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 8429187..ea44358 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3580,7 +3580,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 1f3688d..632a938 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -138,9 +138,6 @@ static int xen_init(MachineState *ms) return -1; } qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); - - savevm_skip_section_footers(); - return 0; } =20 @@ -155,6 +152,11 @@ static GlobalProperty xen_compat_props[] =3D { .property =3D "send-configuration", .value =3D "off", }, + { + .driver =3D "migration", + .property =3D "send-section-footer", + .value =3D "off", + }, { /* end of list */ }, }; =20 diff --git a/include/hw/compat.h b/include/hw/compat.h index 1a3fd94..08f3600 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -187,6 +187,10 @@ .value =3D "off",\ },{\ .driver =3D "migration",\ + .property =3D "send-section-footer",\ + .value =3D "off",\ + },{\ + .driver =3D "migration",\ .property =3D "store-global-state",\ .value =3D "off",\ }, diff --git a/include/migration/misc.h b/include/migration/misc.h index f30db4d..854c28d 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -41,7 +41,6 @@ int64_t self_announce_delay(int round) /* migration/savevm.c */ =20 void dump_vmstate_json_to_file(FILE *out_fp); -void savevm_skip_section_footers(void); =20 /* migration/migration.c */ void migration_object_init(void); diff --git a/migration/migration.c b/migration/migration.c index 414e14d..96c6412 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1987,6 +1987,8 @@ static Property migration_properties[] =3D { DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, f= alse), DEFINE_PROP_BOOL("send-configuration", MigrationState, send_configuration, true), + DEFINE_PROP_BOOL("send-section-footer", MigrationState, + send_section_footer, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/migration/migration.h b/migration/migration.h index 4d4ea0d..994b017 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -145,6 +145,8 @@ struct MigrationState =20 /* Whether we send QEMU_VM_CONFIGURATION during migration */ bool send_configuration; + /* Whether we send section footer during migration */ + bool send_section_footer; }; =20 void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/savevm.c b/migration/savevm.c index 0a8c61f..7b39fb9 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -62,8 +62,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 */ @@ -761,11 +759,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) */ @@ -793,7 +786,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()->send_section_footer) { qemu_put_byte(f, QEMU_VM_SECTION_FOOTER); qemu_put_be32(f, se->section_id); } @@ -1802,7 +1795,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()->send_section_footer) { /* No footer to check */ return true; } --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649881398944.2492687188548; Wed, 28 Jun 2017 04:38:01 -0700 (PDT) Received: from localhost ([::1]:60653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBIF-0008Rk-75 for importer@patchew.org; Wed, 28 Jun 2017 07:37:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBC1-00033n-K5 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBC0-0004nE-ML for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBC0-0004n0-ES for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82D6E7F6BA for ; Wed, 28 Jun 2017 11:31:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A8135C3FB; Wed, 28 Jun 2017 11:31:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 82D6E7F6BA 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 82D6E7F6BA From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:01 +0200 Message-Id: <20170628113106.5248-10-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Jun 2017 11:31:31 +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] [PULL 09/14] migration: merge enforce_config_section somewhat 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 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: Peter Xu These two parameters: - MachineState::enforce_config_section - MigrationState::send_configuration are playing similar role here. This patch merges the first one into second, then we'll have a single place to reference whether we need to send the configuration section. I didn't remove the MachineState.enforce_config_section field since when applying that machine property (in machine_set_property()) we haven't yet initialized global properties and migration object. Then, it's still not easy to pass that boolean to MigrationState at such an early time. A natural benefit for current patch is that now we kept the meaning of "enforce-config-section" since it'll still have the highest priority (that's what "enforce" mean I guess). Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-10-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 12 ++++++++++++ migration/savevm.c | 12 ++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 96c6412..e7e6cf3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -42,6 +42,7 @@ #include "exec/target_page.h" #include "io/channel-buffer.h" #include "migration/colo.h" +#include "hw/boards.h" =20 #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttli= ng */ =20 @@ -102,9 +103,20 @@ static MigrationState *current_migration; =20 void migration_object_init(void) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + /* This can only be called once. */ assert(!current_migration); current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); + + /* + * We cannot really do this in migration_instance_init() since at + * that time global properties are not yet applied, then this + * value will be definitely replaced by something else. + */ + if (ms->enforce_config_section) { + current_migration->send_configuration =3D true; + } } =20 /* For outgoing */ diff --git a/migration/savevm.c b/migration/savevm.c index 7b39fb9..be3f885 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -943,20 +943,13 @@ bool qemu_savevm_state_blocked(Error **errp) return false; } =20 -static bool enforce_config_section(void) -{ - MachineState *machine =3D MACHINE(qdev_get_machine()); - return machine->enforce_config_section; -} - void qemu_savevm_state_header(QEMUFile *f) { trace_savevm_state_header(); qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); =20 - if (migrate_get_current()->send_configuration || - enforce_config_section()) { + if (migrate_get_current()->send_configuration) { qemu_put_byte(f, QEMU_VM_CONFIGURATION); vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0); } @@ -1980,8 +1973,7 @@ int qemu_loadvm_state(QEMUFile *f) return -ENOTSUP; } =20 - if (migrate_get_current()->send_configuration || - enforce_config_section()) { + if (migrate_get_current()->send_configuration) { if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { error_report("Configuration section missing"); return -EINVAL; --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498650110978575.1064594886017; Wed, 28 Jun 2017 04:41:50 -0700 (PDT) Received: from localhost ([::1]:60683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBLx-0003gM-SR for importer@patchew.org; Wed, 28 Jun 2017 07:41:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBC6-00039h-Qt for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBC3-0004oc-Jl for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBC3-0004o5-B0 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50A5785A05 for ; Wed, 28 Jun 2017 11:31:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id D105D5C3FB; Wed, 28 Jun 2017 11:31:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 50A5785A05 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 50A5785A05 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:02 +0200 Message-Id: <20170628113106.5248-11-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Jun 2017 11:31:34 +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] [PULL 10/14] migration: hmp: dump globals 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 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: Peter Xu Now we have some globals that can be configured for migration. Dump them in HMP info migration for better debugging. (we can also use this to monitor whether COMPAT fields are applied correctly on compatible machines) Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1498536619-14548-11-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- hmp.c | 3 +++ include/migration/misc.h | 1 + migration/migration.c | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/hmp.c b/hmp.c index 8c72c58..4c41cac 100644 --- a/hmp.c +++ b/hmp.c @@ -43,6 +43,7 @@ #include "exec/ramlist.h" #include "hw/intc/intc.h" #include "migration/snapshot.h" +#include "migration/misc.h" =20 #ifdef CONFIG_SPICE #include @@ -164,6 +165,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info =3D qmp_query_migrate(NULL); caps =3D qmp_query_migrate_capabilities(NULL); =20 + migration_global_dump(mon); + /* do not display parameters during setup */ if (info->has_status && caps) { monitor_printf(mon, "capabilities: "); diff --git a/include/migration/misc.h b/include/migration/misc.h index 854c28d..2255121 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -54,5 +54,6 @@ bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); void migration_only_migratable_set(void); +void migration_global_dump(Monitor *mon); =20 #endif diff --git a/migration/migration.c b/migration/migration.c index e7e6cf3..b1b0825 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -43,6 +43,7 @@ #include "io/channel-buffer.h" #include "migration/colo.h" #include "hw/boards.h" +#include "monitor/monitor.h" =20 #define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttli= ng */ =20 @@ -1993,6 +1994,16 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +void migration_global_dump(Monitor *mon) +{ + MigrationState *ms =3D migrate_get_current(); + + monitor_printf(mon, "globals: store-global-state=3D%d, only_migratable= =3D%d, " + "send-configuration=3D%d, send-section-footer=3D%d\n", + ms->store_global_state, ms->only_migratable, + ms->send_configuration, ms->send_section_footer); +} + static Property migration_properties[] =3D { DEFINE_PROP_BOOL("store-global-state", MigrationState, store_global_state, true), --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498650006408695.5304403121819; Wed, 28 Jun 2017 04:40:06 -0700 (PDT) Received: from localhost ([::1]:60667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBKH-0002F4-8d for importer@patchew.org; Wed, 28 Jun 2017 07:40:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBC6-00039i-RR for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBC5-0004pg-QW for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBC5-0004pH-KA for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A57C67DCF0 for ; Wed, 28 Jun 2017 11:31:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80A447ABEC; Wed, 28 Jun 2017 11:31:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A57C67DCF0 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A57C67DCF0 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:03 +0200 Message-Id: <20170628113106.5248-12-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 28 Jun 2017 11:31:36 +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] [PULL 11/14] migration: add comment for TYPE_MIGRATE 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 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: Peter Xu It'll be strange that the migration object inherits TYPE_DEVICE. Add some explanations to it. Signed-off-by: Peter Xu Message-Id: <1498634144-26508-1-git-send-email-peterx@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index b1b0825..2398a9d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2046,6 +2046,14 @@ static void migration_instance_init(Object *obj) =20 static const TypeInfo migration_type =3D { .name =3D TYPE_MIGRATION, + /* + * NOTE: "migration" itself is not really a device. We used + * TYPE_DEVICE here only to leverage some existing QDev features + * like "-global" properties, and HW_COMPAT_* fields (which are + * finally applied as global properties as well). If one day the + * global property feature can be migrated from QDev to QObject in + * general, then we can switch to QObject as well. + */ .parent =3D TYPE_DEVICE, .class_init =3D migration_class_init, .class_size =3D sizeof(MigrationClass), --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498650287423867.803683430888; Wed, 28 Jun 2017 04:44:47 -0700 (PDT) Received: from localhost ([::1]:60704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBOo-0006F6-9D for importer@patchew.org; Wed, 28 Jun 2017 07:44:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBCD-0003Fd-OF for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBC8-0004qz-0l for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBC7-0004qd-O1 for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5FB14ACCA; Wed, 28 Jun 2017 11:31:38 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 032637ABEC; Wed, 28 Jun 2017 11:31:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5FB14ACCA 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5FB14ACCA From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:04 +0200 Message-Id: <20170628113106.5248-13-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 11:31:38 +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] [PULL 12/14] vmstate: error hint for failed equal checks 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, Halil Pasic , dgilbert@redhat.com, peterx@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: Halil Pasic In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required. Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the _EQUAL macros called _err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them. Signed-off-by: Halil Pasic Message-Id: <20170623144823.42936-1-pasic@linux.vnet.ibm.com> Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hw/block/fdc.c | 2 +- hw/display/qxl.c | 4 ++-- hw/display/vga.c | 2 +- hw/display/virtio-gpu.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/ide/ahci.c | 2 +- hw/input/vmmouse.c | 2 +- hw/intc/openpic.c | 2 +- hw/intc/xics.c | 2 +- hw/misc/max111x.c | 2 +- hw/nvram/eeprom93xx.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_pci.c | 4 ++-- hw/ppc/spapr_vio.c | 4 ++-- hw/usb/hcd-uhci.c | 2 +- include/migration/vmstate.h | 51 +++++++++++++++++++++++++++++++----------= ---- migration/vmstate-types.c | 15 +++++++++++++ target/ppc/machine.c | 8 +++---- 20 files changed, 74 insertions(+), 40 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 28f6b6e..4011290 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1217,7 +1217,7 @@ static const VMStateDescription vmstate_fdc =3D { VMSTATE_UINT8(config, FDCtrl), VMSTATE_UINT8(lock, FDCtrl), VMSTATE_UINT8(pwrd, FDCtrl), - VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl), + VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl, NULL), VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1, vmstate_fdrive, FDrive), VMSTATE_END_OF_LIST() diff --git a/hw/display/qxl.c b/hw/display/qxl.c index ad09bb9..3c1688e 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2373,12 +2373,12 @@ static VMStateDescription qxl_vmstate =3D { VMSTATE_UINT32(last_release_offset, PCIQXLDevice), VMSTATE_UINT32(mode, PCIQXLDevice), VMSTATE_UINT32(ssd.unique, PCIQXLDevice), - VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice), + VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice, NULL), VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, 0, qxl_memslot, struct guest_slots), VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0, qxl_surface, QXLSurfaceCreate), - VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice), + VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice, NULL), VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice, ssd.num_surfaces, 0, vmstate_info_uint64, uint64_t), diff --git a/hw/display/vga.c b/hw/display/vga.c index dcc95f8..80508b8 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2099,7 +2099,7 @@ const VMStateDescription vmstate_vga_common =3D { VMSTATE_BUFFER(palette, VGACommonState), =20 VMSTATE_INT32(bank_offset, VGACommonState), - VMSTATE_UINT8_EQUAL(is_vbe_vmstate, VGACommonState), + VMSTATE_UINT8_EQUAL(is_vbe_vmstate, VGACommonState, NULL), VMSTATE_UINT16(vbe_index, VGACommonState), VMSTATE_UINT16_ARRAY(vbe_regs, VGACommonState, VBE_DISPI_INDEX_NB), VMSTATE_UINT32(vbe_start_addr, VGACommonState), diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 58dc0b2..0506d2c 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -962,7 +962,7 @@ static const VMStateDescription vmstate_virtio_gpu_scan= outs =3D { .version_id =3D 1, .fields =3D (VMStateField[]) { VMSTATE_INT32(enable, struct VirtIOGPU), - VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU), + VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU, NULL), VMSTATE_STRUCT_VARRAY_UINT32(scanout, struct VirtIOGPU, conf.max_outputs, 1, vmstate_virtio_gpu_scanout, diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index ec5f27d..c989cef 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1192,7 +1192,7 @@ static const VMStateDescription vmstate_vmware_vga_in= ternal =3D { .minimum_version_id =3D 0, .post_load =3D vmsvga_post_load, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s), + VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s, NULL), VMSTATE_INT32(enable, struct vmsvga_state_s), VMSTATE_INT32(config, struct vmsvga_state_s), VMSTATE_INT32(cursor.id, struct vmsvga_state_s), diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f60826d..874d3fe 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1669,7 +1669,7 @@ const VMStateDescription vmstate_ahci =3D { VMSTATE_UINT32(control_regs.impl, AHCIState), VMSTATE_UINT32(control_regs.version, AHCIState), VMSTATE_UINT32(idp_index, AHCIState), - VMSTATE_INT32_EQUAL(ports, AHCIState), + VMSTATE_INT32_EQUAL(ports, AHCIState, NULL), VMSTATE_END_OF_LIST() }, }; diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c index 4747da9..b6d2208 100644 --- a/hw/input/vmmouse.c +++ b/hw/input/vmmouse.c @@ -243,7 +243,7 @@ static const VMStateDescription vmstate_vmmouse =3D { .minimum_version_id =3D 0, .post_load =3D vmmouse_post_load, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(queue_size, VMMouseState), + VMSTATE_INT32_EQUAL(queue_size, VMMouseState, NULL), VMSTATE_UINT32_ARRAY(queue, VMMouseState, VMMOUSE_QUEUE_SIZE), VMSTATE_UINT16(nb_queue, VMMouseState), VMSTATE_UINT16(status, VMMouseState), diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index f966d06..5595bb2 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -1499,7 +1499,7 @@ static const VMStateDescription vmstate_openpic =3D { VMSTATE_UINT32(max_irq, OpenPICState), VMSTATE_STRUCT_VARRAY_UINT32(src, OpenPICState, max_irq, 0, vmstate_openpic_irqsource, IRQSource), - VMSTATE_UINT32_EQUAL(nb_cpus, OpenPICState), + VMSTATE_UINT32_EQUAL(nb_cpus, OpenPICState, NULL), VMSTATE_STRUCT_VARRAY_UINT32(dst, OpenPICState, nb_cpus, 0, vmstate_openpic_irqdest, IRQDest), VMSTATE_STRUCT_ARRAY(timers, OpenPICState, OPENPIC_MAX_TMR, 0, diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 7ccfb53..d4194d6 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -574,7 +574,7 @@ static const VMStateDescription vmstate_ics_simple =3D { .post_load =3D ics_simple_dispatch_post_load, .fields =3D (VMStateField[]) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(nr_irqs, ICSState), + VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL), =20 VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, vmstate_ics_simple_irq, diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c index 2a277bd..6dbdc03 100644 --- a/hw/misc/max111x.c +++ b/hw/misc/max111x.c @@ -116,7 +116,7 @@ static const VMStateDescription vmstate_max111x =3D { VMSTATE_UINT8(tb1, MAX111xState), VMSTATE_UINT8(rb2, MAX111xState), VMSTATE_UINT8(rb3, MAX111xState), - VMSTATE_INT32_EQUAL(inputs, MAX111xState), + VMSTATE_INT32_EQUAL(inputs, MAX111xState, NULL), VMSTATE_INT32(com, MAX111xState), VMSTATE_ARRAY_INT32_UNSAFE(input, MAX111xState, inputs, vmstate_info_uint8, uint8_t), diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c index 848692a..2fd0e3c 100644 --- a/hw/nvram/eeprom93xx.c +++ b/hw/nvram/eeprom93xx.c @@ -143,7 +143,7 @@ static const VMStateDescription vmstate_eeprom =3D { VMSTATE_UINT8(addrbits, eeprom_t), VMSTATE_UINT16_HACK_TEST(size, eeprom_t, is_old_eeprom_version), VMSTATE_UNUSED_TEST(is_old_eeprom_version, 1), - VMSTATE_UINT16_EQUAL_V(size, eeprom_t, EEPROM_VERSION), + VMSTATE_UINT16_EQUAL_V(size, eeprom_t, EEPROM_VERSION, NULL), VMSTATE_UINT16(data, eeprom_t), VMSTATE_VARRAY_UINT16_UNSAFE(contents, eeprom_t, size, 0, vmstate_info_uint16, uint16_t), diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 98ccc27..b7fee4b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -74,7 +74,7 @@ static const VMStateDescription vmstate_pcibus =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(nirq, PCIBus), + VMSTATE_INT32_EQUAL(nirq, PCIBus, NULL), VMSTATE_VARRAY_INT32(irq_count, PCIBus, nirq, 0, vmstate_info_int32, int32_t), diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 828052b..9720074 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -813,7 +813,7 @@ const VMStateDescription vmstate_pcie_aer_log =3D { .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { VMSTATE_UINT16(log_num, PCIEAERLog), - VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog), + VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog, NULL), VMSTATE_VALIDATE("log_num <=3D log_max", pcie_aer_state_log_num_va= lid), VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num, vmstate_pcie_aer_err, PCIEAERErr), diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 0341bc0..8656a54 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -231,7 +231,7 @@ static const VMStateDescription vmstate_spapr_tce_table= =3D { .post_load =3D spapr_tce_table_post_load, .fields =3D (VMStateField []) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(liobn, sPAPRTCETable), + VMSTATE_UINT32_EQUAL(liobn, sPAPRTCETable, NULL), =20 /* IOMMU state */ VMSTATE_UINT32(mig_nb_table, sPAPRTCETable), diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 0b447f2..3b37dcd 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1848,7 +1848,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi= =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi), + VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi, NULL), =20 VMSTATE_END_OF_LIST() }, @@ -1936,7 +1936,7 @@ static const VMStateDescription vmstate_spapr_pci =3D= { .pre_save =3D spapr_pci_pre_save, .post_load =3D spapr_pci_post_load, .fields =3D (VMStateField[]) { - VMSTATE_UINT64_EQUAL(buid, sPAPRPHBState), + VMSTATE_UINT64_EQUAL(buid, sPAPRPHBState, NULL), VMSTATE_UINT32_TEST(mig_liobn, sPAPRPHBState, pre_2_8_migration), VMSTATE_UINT64_TEST(mig_mem_win_addr, sPAPRPHBState, pre_2_8_migra= tion), VMSTATE_UINT64_TEST(mig_mem_win_size, sPAPRPHBState, pre_2_8_migra= tion), diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index a0ee4fd..ea3bc8b 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -557,8 +557,8 @@ const VMStateDescription vmstate_spapr_vio =3D { .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { /* Sanity check */ - VMSTATE_UINT32_EQUAL(reg, VIOsPAPRDevice), - VMSTATE_UINT32_EQUAL(irq, VIOsPAPRDevice), + VMSTATE_UINT32_EQUAL(reg, VIOsPAPRDevice, NULL), + VMSTATE_UINT32_EQUAL(irq, VIOsPAPRDevice, NULL), =20 /* General VIO device state */ VMSTATE_UINT64(signal_state, VIOsPAPRDevice), diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index ca72a80..e3562a4 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -415,7 +415,7 @@ static const VMStateDescription vmstate_uhci =3D { .post_load =3D uhci_post_load, .fields =3D (VMStateField[]) { VMSTATE_PCI_DEVICE(dev, UHCIState), - VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState), + VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState, NULL), VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS, 1, vmstate_uhci_port, UHCIPort), VMSTATE_UINT16(cmd, UHCIState), diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index e85fbd8..85e43da 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -155,6 +155,7 @@ typedef enum { =20 struct VMStateField { const char *name; + const char *err_hint; size_t offset; size_t size; size_t start; @@ -256,6 +257,18 @@ extern const VMStateInfo vmstate_info_qtailq; .offset =3D vmstate_offset_value(_state, _field, _type), \ } =20 +#define VMSTATE_SINGLE_FULL(_field, _state, _test, _version, _info, \ + _type, _err_hint) { \ + .name =3D (stringify(_field)), \ + .err_hint =3D (_err_hint), \ + .version_id =3D (_version), \ + .field_exists =3D (_test), \ + .size =3D sizeof(_type), \ + .info =3D &(_info), \ + .flags =3D VMS_SINGLE, \ + .offset =3D vmstate_offset_value(_state, _field, _type), \ +} + /* Validate state using a boolean predicate. */ #define VMSTATE_VALIDATE(_name, _test) { \ .name =3D (_name), \ @@ -762,29 +775,35 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_UINT64(_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) =20 -#define VMSTATE_UINT8_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) +#define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_uint8_equal, uint8_t, _err_hint) =20 -#define VMSTATE_UINT16_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) +#define VMSTATE_UINT16_EQUAL(_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_uint16_equal, uint16_t, _err_hint) =20 -#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) +#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint16_equal, uint16_t, _err_hint) =20 -#define VMSTATE_INT32_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) +#define VMSTATE_INT32_EQUAL(_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_int32_equal, int32_t, _err_hint) =20 -#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t) +#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint32_equal, uint32_t, _err_hint) =20 -#define VMSTATE_UINT32_EQUAL(_f, _s) \ - VMSTATE_UINT32_EQUAL_V(_f, _s, 0) +#define VMSTATE_UINT32_EQUAL(_f, _s, _err_hint) \ + VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint) =20 -#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t) +#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint64_equal, uint64_t, _err_hint) =20 -#define VMSTATE_UINT64_EQUAL(_f, _s) \ - VMSTATE_UINT64_EQUAL_V(_f, _s, 0) +#define VMSTATE_UINT64_EQUAL(_f, _s, _err_hint) \ + VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint) =20 #define VMSTATE_INT32_POSITIVE_LE(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 02f05a3..c056c98 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -126,6 +126,9 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_= t size, return 0; } error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); + if (field->err_hint) { + error_printf("%s\n", field->err_hint); + } return -EINVAL; } =20 @@ -267,6 +270,9 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%" PRIx32 " !=3D %" PRIx32, *v, v2); + if (field->err_hint) { + error_printf("%s\n", field->err_hint); + } return -EINVAL; } =20 @@ -341,6 +347,9 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%" PRIx64 " !=3D %" PRIx64, *v, v2); + if (field->err_hint) { + error_printf("%s\n", field->err_hint); + } return -EINVAL; } =20 @@ -364,6 +373,9 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_= t size, return 0; } error_report("%x !=3D %x", *v, v2); + if (field->err_hint) { + error_printf("%s\n", field->err_hint); + } return -EINVAL; } =20 @@ -387,6 +399,9 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size= _t size, return 0; } error_report("%x !=3D %x", *v, v2); + if (field->err_hint) { + error_printf("%s\n", field->err_hint); + } return -EINVAL; } =20 diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 6cb3a48..445f489 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -419,7 +419,7 @@ static const VMStateDescription vmstate_slb =3D { .needed =3D slb_needed, .post_load =3D slb_post_load, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(env.slb_nr, PowerPCCPU), + VMSTATE_INT32_EQUAL(env.slb_nr, PowerPCCPU, NULL), VMSTATE_SLB_ARRAY(env.slb, PowerPCCPU, MAX_SLB_ENTRIES), VMSTATE_END_OF_LIST() } @@ -452,7 +452,7 @@ static const VMStateDescription vmstate_tlb6xx =3D { .minimum_version_id =3D 1, .needed =3D tlb6xx_needed, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU, env.nb_tlb, vmstate_tlb6xx_entry, @@ -510,7 +510,7 @@ static const VMStateDescription vmstate_tlbemb =3D { .minimum_version_id =3D 1, .needed =3D tlbemb_needed, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU, env.nb_tlb, vmstate_tlbemb_entry, @@ -551,7 +551,7 @@ static const VMStateDescription vmstate_tlbmas =3D { .minimum_version_id =3D 1, .needed =3D tlbmas_needed, .fields =3D (VMStateField[]) { - VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU), + VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU, env.nb_tlb, vmstate_tlbmas_entry, --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498650207312253.00397968447112; Wed, 28 Jun 2017 04:43:27 -0700 (PDT) Received: from localhost ([::1]:60687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBNW-0004iK-6l for importer@patchew.org; Wed, 28 Jun 2017 07:43:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBCC-0003Er-4G for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBCB-0004tK-4g for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61167) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBCA-0004sq-SR for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E51F280F6C for ; Wed, 28 Jun 2017 11:31:40 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2340D5C3FB; Wed, 28 Jun 2017 11:31:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E51F280F6C 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=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E51F280F6C From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:05 +0200 Message-Id: <20170628113106.5248-14-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 28 Jun 2017 11:31:42 +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] [PULL 13/14] migration: add "return-path" 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 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: Peter Xu When this capability is enabled, QEMU will use the return path even for precopy migration. This is helpful at least in one case when destination failed to load the image while source quited without confirmation. With return path, source will wait for the last response from destination, and if destination fails, it'll fail the migration on source, then the guest can be run again on the source (rather than assuming to be good, then the guest will be lost after source quits). It needs to be enabled explicitly on source, otherwise disabled. Signed-off-by: Peter Xu Message-Id: <1498472935-14461-1-git-send-email-peterx@redhat.com> Reviewed-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- migration/migration.c | 16 +++++++++++++--- migration/migration.h | 1 + qapi-schema.json | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2398a9d..51ccd1a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1311,6 +1311,15 @@ bool migrate_use_block(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK]; } =20 +bool migrate_use_return_path(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_RETURN_PATH]; +} + bool migrate_use_block_incremental(void) { MigrationState *s; @@ -1975,10 +1984,11 @@ void migrate_fd_connect(MigrationState *s) notifier_list_notify(&migration_state_notifiers, s); =20 /* - * Open the return path; currently for postcopy but other things might - * also want it. + * Open the return path. For postcopy, it is used exclusively. For + * precopy, only if user specified "return-path" capability would + * QEMU uses the return path. */ - if (migrate_postcopy_ram()) { + if (migrate_postcopy_ram() || migrate_use_return_path()) { if (open_return_path_on_source(s)) { error_report("Unable to open return-path for postcopy"); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, diff --git a/migration/migration.h b/migration/migration.h index 994b017..148c9fa 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -177,6 +177,7 @@ bool migrate_colo_enabled(void); =20 bool migrate_use_block(void); bool migrate_use_block_incremental(void); +bool migrate_use_return_path(void); =20 bool migrate_use_compression(void); int migrate_compress_level(void); diff --git a/qapi-schema.json b/qapi-schema.json index 4b50b65..9e34cf7 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -900,12 +900,15 @@ # offers more flexibility. # (Since 2.10) # +# @return-path: If enabled, migration will use the return path even +# for precopy. (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', - 'block' ] } + 'block', 'return-path' ] } =20 ## # @MigrationCapabilityStatus: --=20 2.9.4 From nobody Mon Apr 29 07:59:21 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 1498649878817440.0426106488982; Wed, 28 Jun 2017 04:37:58 -0700 (PDT) Received: from localhost ([::1]:60652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBID-0008QV-MQ for importer@patchew.org; Wed, 28 Jun 2017 07:37:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQBCF-0003Fe-7j for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQBCC-0004u1-2b for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQBCB-0004tO-QU for qemu-devel@nongnu.org; Wed, 28 Jun 2017 07:31:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DABECC04B927; Wed, 28 Jun 2017 11:31:42 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D0847ABEC; Wed, 28 Jun 2017 11:31:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DABECC04B927 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DABECC04B927 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:31:06 +0200 Message-Id: <20170628113106.5248-15-quintela@redhat.com> In-Reply-To: <20170628113106.5248-1-quintela@redhat.com> References: <20170628113106.5248-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 28 Jun 2017 11:31:43 +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] [PULL 14/14] exec: fix access to ram_list.dirty_memory when sync dirty bitmap 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, Haozhong Zhang , dgilbert@redhat.com, peterx@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: Haozhong Zhang In cpu_physical_memory_sync_dirty_bitmap(rb, start, ...), the 2nd argument 'start' is relative to the start of the ramblock 'rb'. When it's used to access the dirty memory bitmap of ram_list (i.e. ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION]->blocks[]), an offset to the start of all RAM (i.e. rb->offset) should be added to it, which has however been missed since c/s 6b6712efcc. For a ramblock of host memory backend whose offset is not zero, cpu_physical_memory_sync_dirty_bitmap() synchronizes the incorrect part of the dirty memory bitmap of ram_list to the per ramblock dirty bitmap. As a result, a guest with host memory backend may crash after migration. Fix it by adding the offset of ramblock when accessing the dirty memory bitmap of ram_list in cpu_physical_memory_sync_dirty_bitmap(). Reported-by: Stefan Hajnoczi Signed-off-by: Haozhong Zhang Message-Id: <20170628083704.24997-1-haozhong.zhang@intel.com> Reviewed-by: Juan Quintela Tested-by: Juan Quintela Tested-by: Stefan Hajnoczi Signed-off-by: Juan Quintela --- include/exec/ram_addr.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 73d1bea..c04f4f6 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -386,8 +386,9 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock= *rb, int k; int nr =3D BITS_TO_LONGS(length >> TARGET_PAGE_BITS); unsigned long * const *src; - unsigned long idx =3D (page * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_= SIZE; - unsigned long offset =3D BIT_WORD((page * BITS_PER_LONG) % + unsigned long word =3D BIT_WORD((start + rb->offset) >> TARGET_PAG= E_BITS); + unsigned long idx =3D (word * BITS_PER_LONG) / DIRTY_MEMORY_BLOCK_= SIZE; + unsigned long offset =3D BIT_WORD((word * BITS_PER_LONG) % DIRTY_MEMORY_BLOCK_SIZE); =20 rcu_read_lock(); @@ -414,9 +415,11 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBloc= k *rb, =20 rcu_read_unlock(); } else { + ram_addr_t offset =3D rb->offset; + for (addr =3D 0; addr < length; addr +=3D TARGET_PAGE_SIZE) { if (cpu_physical_memory_test_and_clear_dirty( - start + addr, + start + addr + offset, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION)) { *real_dirty_pages +=3D 1; --=20 2.9.4