From nobody Wed May 1 23:29:35 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 1498031663565387.45329482866566; Wed, 21 Jun 2017 00:54:23 -0700 (PDT) Received: from localhost ([::1]:52258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaSz-0003Rp-S7 for importer@patchew.org; Wed, 21 Jun 2017 03:54:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRE-0002E0-8D for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaR8-000370-7z for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaR7-00036o-Vf for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED1A98047E for ; Wed, 21 Jun 2017 07:52:24 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 933CD61F4C; Wed, 21 Jun 2017 07:52:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED1A98047E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED1A98047E From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:51:59 +0800 Message-Id: <1498031528-1990-2-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 21 Jun 2017 07:52:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 01/10] machine: export register_compat_prop() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- hw/core/machine.c | 13 ------------- hw/core/qdev-properties.c | 13 +++++++++++++ include/hw/qdev-properties.h | 3 +++ 3 files changed, 16 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 9f1a497..6ff1ac3 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1047,6 +1047,19 @@ 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); + /* 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); +} + 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 d206fc9..1722ca4 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -201,6 +201,9 @@ void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *de= v, Property *prop, const char *value); =20 +void register_compat_prop(const char *driver, const char *property, + const char *value); + /** * qdev_property_add_static: * @dev: Device to add the property to. --=20 2.7.4 From nobody Wed May 1 23:29:35 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 1498031662404358.7636082484207; Wed, 21 Jun 2017 00:54:22 -0700 (PDT) Received: from localhost ([::1]:52257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaSy-0003Qv-L7 for importer@patchew.org; Wed, 21 Jun 2017 03:54:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRC-0002Cp-MR for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRB-00037S-Q7 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRB-00037K-Hz for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78B8481127 for ; Wed, 21 Jun 2017 07:52:28 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F48F82475; Wed, 21 Jun 2017 07:52:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78B8481127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 78B8481127 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:00 +0800 Message-Id: <1498031528-1990-3-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 21 Jun 2017 07:52:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 02/10] 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: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Use the newly exported register_compat_prop() to pass the accelerator global properties to the global_props list. Suggested-by: Eduardo Habkost Signed-off-by: Peter Xu --- accel/accel.c | 10 ++++++++++ include/sysemu/accel.h | 10 ++++++++++ vl.c | 1 + 3 files changed, 21 insertions(+) diff --git a/accel/accel.c b/accel/accel.c index 7c079a5..212581c 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -120,6 +120,16 @@ void configure_accelerator(MachineState *ms) } } =20 +void accel_register_compat_props(AccelState *accel) +{ + AccelClass *class =3D ACCEL_GET_CLASS(accel); + GlobalProperty *prop; + + for (prop =3D class->global_props; prop && prop->driver; prop++) { + register_compat_prop(prop->driver, prop->property, prop->value); + } +} + static void register_accel_types(void) { type_register_static(&accel_type); diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 15944c1..8a01e51 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,13 @@ typedef struct AccelClass { int (*available)(void); int (*init_machine)(MachineState *ms); bool *allowed; + /* + * Array of gobal properties that would be applied when specific + * accelerator is chosen. It works just like + * MachineClass.compat_props but it's for accelerators not + * machines. + */ + GlobalProperty *global_props; } AccelClass; =20 #define TYPE_ACCEL "accel" @@ -57,5 +65,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.7.4 From nobody Wed May 1 23:29:35 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 1498031669016397.5708944167236; Wed, 21 Jun 2017 00:54:29 -0700 (PDT) Received: from localhost ([::1]:52259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaT5-0003XP-P2 for importer@patchew.org; Wed, 21 Jun 2017 03:54:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRH-0002Fw-MD for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRG-00038b-P1 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46115) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRG-00038M-JI for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D85B6655 for ; Wed, 21 Jun 2017 07:52:33 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id F26A986337; Wed, 21 Jun 2017 07:52:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D85B6655 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8D85B6655 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:01 +0800 Message-Id: <1498031528-1990-4-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 21 Jun 2017 07:52:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 03/10] vl: clean up global property registerations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- vl.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 4452d7a..cdd2ec8 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_compat_props(void) +{ + qemu_opts_foreach(qemu_find_opts("global"), + global_init_func, NULL, NULL); +} + +/* + * Note: we should see that these compat 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. + */ +static void register_global_properties(MachineState *ms) +{ + accel_register_compat_props(ms->accelerator); + machine_register_compat_props(ms); + user_register_compat_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.7.4 From nobody Wed May 1 23:29:35 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 1498031789671752.5838042465649; Wed, 21 Jun 2017 00:56:29 -0700 (PDT) Received: from localhost ([::1]:52270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaV2-0005FO-88 for importer@patchew.org; Wed, 21 Jun 2017 03:56:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRV-0002U9-1m for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRR-0003BF-4G for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38502) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRQ-0003Az-S2 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA27FC0587EC for ; Wed, 21 Jun 2017 07:52:43 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17A9D61F4C; Wed, 21 Jun 2017 07:52:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA27FC0587EC 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CA27FC0587EC From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:02 +0800 Message-Id: <1498031528-1990-5-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Jun 2017 07:52: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] [PATCH v4 04/10] migration: let MigrationState be a qdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Peter Xu Reviewed-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 cdd2ec8..9b04ba7 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.7.4 From nobody Wed May 1 23:29:35 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 1498031927458759.46065030275; Wed, 21 Jun 2017 00:58:47 -0700 (PDT) Received: from localhost ([::1]:52293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaXG-0007d6-3U for importer@patchew.org; Wed, 21 Jun 2017 03:58:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRY-0002Wx-J5 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRU-0003D0-J3 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRU-0003Cj-AB for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BB3337EEF for ; Wed, 21 Jun 2017 07:52:47 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5536D61F4C; Wed, 21 Jun 2017 07:52:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BB3337EEF Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3BB3337EEF From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:03 +0800 Message-Id: <1498031528-1990-6-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 21 Jun 2017 07:52:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 05/10] migration: move global_state.optional out X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Put it into MigrationState then we can use the properties to specify whether to enable storing global state. Removing global_state_set_optional() since now we can use HW_COMPAT_2_3 for x86/power, and AccelClass.global_props for Xen. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 11 ++++++++++- include/hw/compat.h | 4 ++++ include/migration/global_state.h | 1 - migration/global_state.c | 9 ++------- migration/migration.c | 7 +++++++ migration/migration.h | 6 ++++++ 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 46a2bc4..3b51297 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -318,7 +318,6 @@ static void pc_compat_2_3(MachineState *machine) if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; } - global_state_set_optional(); savevm_skip_configuration(); } =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e877d45..edbdbfd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3580,7 +3580,6 @@ static void spapr_machine_2_3_instance_options(Machin= eState *machine) { spapr_machine_2_4_instance_options(machine); savevm_skip_section_footers(); - global_state_set_optional(); savevm_skip_configuration(); } =20 diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index d3fa705..9163a0a 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -139,19 +139,28 @@ static int xen_init(MachineState *ms) } qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); =20 - global_state_set_optional(); savevm_skip_configuration(); savevm_skip_section_footers(); =20 return 0; } =20 +GlobalProperty xen_compat_props[] =3D { + { + .driver =3D "migration", + .property =3D "store-global-state", + .value =3D "off", + }, + { .driver =3D NULL, .property =3D NULL, .value =3D NULL }, +}; + static void xen_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); ac->name =3D "Xen"; ac->init_machine =3D xen_init; ac->allowed =3D &xen_allowed; + ac->global_props =3D xen_compat_props; } =20 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") diff --git a/include/hw/compat.h b/include/hw/compat.h index 26cd585..a506a74 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -181,6 +181,10 @@ .driver =3D TYPE_PCI_DEVICE,\ .property =3D "x-pcie-lnksta-dllla",\ .value =3D "off",\ + },{\ + .driver =3D "migration",\ + .property =3D "store-global-state",\ + .value =3D "off",\ }, =20 #define HW_COMPAT_2_2 \ diff --git a/include/migration/global_state.h b/include/migration/global_st= ate.h index 90faea7..d307de8 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -16,7 +16,6 @@ #include "sysemu/sysemu.h" =20 void register_global_state(void); -void global_state_set_optional(void); int global_state_store(void); void global_state_store_running(void); bool global_state_received(void); diff --git a/migration/global_state.c b/migration/global_state.c index f792cf5..dcbbcb2 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -15,12 +15,12 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/util.h" +#include "migration.h" #include "migration/global_state.h" #include "migration/vmstate.h" #include "trace.h" =20 typedef struct { - bool optional; uint32_t size; uint8_t runstate[100]; RunState state; @@ -57,11 +57,6 @@ RunState global_state_get_runstate(void) return global_state.state; } =20 -void global_state_set_optional(void) -{ - global_state.optional =3D true; -} - static bool global_state_needed(void *opaque) { GlobalState *s =3D opaque; @@ -69,7 +64,7 @@ static bool global_state_needed(void *opaque) =20 /* If it is not optional, it is mandatory */ =20 - if (s->optional =3D=3D false) { + if (migrate_get_current()->store_global_state) { return true; } =20 diff --git a/migration/migration.c b/migration/migration.c index 2c25927..221b22c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1976,11 +1976,18 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +static Property migration_properties[] =3D { + DEFINE_PROP_BOOL("store-global-state", MigrationState, + store_global_state, true), + DEFINE_PROP_END_OF_LIST(), +}; + static void migration_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->user_creatable =3D false; + dc->props =3D migration_properties; } =20 static void migration_instance_init(Object *obj) diff --git a/migration/migration.h b/migration/migration.h index 3fca364..4b898e9 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -133,6 +133,12 @@ struct MigrationState /* Do we have to clean up -b/-i from old migrate parameters */ /* This feature is deprecated and will be removed */ bool must_remove_block_options; + + /* + * Global switch on whether we need to store the global state + * during migration. + */ + bool store_global_state; }; =20 void migrate_set_state(int *state, int old_state, int new_state); --=20 2.7.4 From nobody Wed May 1 23:29:35 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 1498031812151447.6866170854379; Wed, 21 Jun 2017 00:56:52 -0700 (PDT) Received: from localhost ([::1]:52271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaVO-0005av-V7 for importer@patchew.org; Wed, 21 Jun 2017 03:56:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRZ-0002XW-76 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRY-0003EK-80 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRX-0003Dy-VE for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E24C2C04B935 for ; Wed, 21 Jun 2017 07:52:50 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC35686337; Wed, 21 Jun 2017 07:52:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E24C2C04B935 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E24C2C04B935 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:04 +0800 Message-Id: <1498031528-1990-7-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 21 Jun 2017 07:52:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 06/10] migration: move only_migratable to MigrationState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 6bfd489..917ab05 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2314,7 +2314,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 9b04ba7..57ff065 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.7.4 From nobody Wed May 1 23:29:35 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 1498031944574392.91347440583843; Wed, 21 Jun 2017 00:59:04 -0700 (PDT) Received: from localhost ([::1]:52308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaXW-0007tF-EB for importer@patchew.org; Wed, 21 Jun 2017 03:59:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRi-0002gQ-FF for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRe-0003N1-IM for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRe-0003LB-A2 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:52:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4236785376 for ; Wed, 21 Jun 2017 07:52:57 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D5E482475; Wed, 21 Jun 2017 07:52:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4236785376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4236785376 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:05 +0800 Message-Id: <1498031528-1990-8-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Jun 2017 07:52:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 07/10] migration: move skip_configuration out X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(). Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 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 edbdbfd..29fac1b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3580,7 +3580,6 @@ static void spapr_machine_2_3_instance_options(Machin= eState *machine) { spapr_machine_2_4_instance_options(machine); savevm_skip_section_footers(); - 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 9163a0a..6e52fb0 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 @@ GlobalProperty xen_compat_props[] =3D { .property =3D "store-global-state", .value =3D "off", }, + { + .driver =3D "migration", + .property =3D "send-configuration", + .value =3D "off", + }, { .driver =3D NULL, .property =3D NULL, .value =3D NULL }, }; =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 917ab05..f1e144d 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.7.4 From nobody Wed May 1 23:29:35 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 1498032018213803.3513720254855; Wed, 21 Jun 2017 01:00:18 -0700 (PDT) Received: from localhost ([::1]:52339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaYh-0000Xs-Bs for importer@patchew.org; Wed, 21 Jun 2017 04:00:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRl-0002jB-KM for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRj-0003Sx-Vt for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRj-0003SD-NM for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF5C27D0C6 for ; Wed, 21 Jun 2017 07:53:02 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD5F061F4C; Wed, 21 Jun 2017 07:52:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AF5C27D0C6 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AF5C27D0C6 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:06 +0800 Message-Id: <1498031528-1990-9-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 21 Jun 2017 07:53:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 08/10] migration: move skip_section_footers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(). Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - hw/xen/xen-common.c | 8 +++++--- include/hw/compat.h | 4 ++++ include/migration/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 29fac1b..7c40fdf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3579,7 +3579,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 6e52fb0..04512f4 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 @@ GlobalProperty xen_compat_props[] =3D { .property =3D "send-configuration", .value =3D "off", }, + { + .driver =3D "migration", + .property =3D "send-section-footer", + .value =3D "off", + }, { .driver =3D NULL, .property =3D NULL, .value =3D NULL }, }; =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 f1e144d..28fa1d5 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.7.4 From nobody Wed May 1 23:29:35 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 1498031818195454.07233254732; Wed, 21 Jun 2017 00:56:58 -0700 (PDT) Received: from localhost ([::1]:52272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaVU-0005gZ-Vk for importer@patchew.org; Wed, 21 Jun 2017 03:56:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRt-0002pn-EQ for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRn-0003Xw-H7 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRn-0003XH-8W for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4143E81127 for ; Wed, 21 Jun 2017 07:53:06 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C0E761F4C; Wed, 21 Jun 2017 07:53:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4143E81127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4143E81127 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:07 +0800 Message-Id: <1498031528-1990-10-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 21 Jun 2017 07:53:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 09/10] 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: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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). Signed-off-by: Peter Xu Reviewed-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 28fa1d5..6b1a9a5 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.7.4 From nobody Wed May 1 23:29:35 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 1498032087802580.6363650657139; Wed, 21 Jun 2017 01:01:27 -0700 (PDT) Received: from localhost ([::1]:52351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaZp-0001Ca-GM for importer@patchew.org; Wed, 21 Jun 2017 04:01:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNaRu-0002po-TD for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNaRr-0003an-17 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37654) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dNaRq-0003ZJ-PI for qemu-devel@nongnu.org; Wed, 21 Jun 2017 03:53:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0A527486C for ; Wed, 21 Jun 2017 07:53:09 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-74.pek2.redhat.com [10.72.12.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF64782475; Wed, 21 Jun 2017 07:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0A527486C 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B0A527486C From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 15:52:08 +0800 Message-Id: <1498031528-1990-11-git-send-email-peterx@redhat.com> In-Reply-To: <1498031528-1990-1-git-send-email-peterx@redhat.com> References: <1498031528-1990-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 21 Jun 2017 07:53:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 10/10] 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: Laurent Vivier , Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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) Signed-off-by: Peter Xu Reviewed-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.7.4