From nobody Fri May 3 11:17:09 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.zohomail.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 1500317573250682.5403815092335; Mon, 17 Jul 2017 11:52:53 -0700 (PDT) Received: from localhost ([::1]:52023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB8V-0004LU-U1 for importer@patchew.org; Mon, 17 Jul 2017 14:52:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6g-0003Bk-Vj for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:50:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6e-0003U1-MG for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:50:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6e-0003SC-Fc for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:50:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67EF77CE10; Mon, 17 Jul 2017 18:50:55 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDD2277BEC; Mon, 17 Jul 2017 18:50:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67EF77CE10 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 67EF77CE10 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:37 -0300 Message-Id: <20170717185051.18740-2-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Jul 2017 18:50:55 +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/15] device-crash-test: Fix regexp on whitelist 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: qemu-devel@nongnu.org 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" The "||" in the whitelist entry was not escaped, making the regexp match all strings, on every single cases where QEMU aborted. Signed-off-by: Eduardo Habkost Message-Id: <20170614144939.1115-1-ehabkost@redhat.com> --- scripts/device-crash-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 5f90e9b..e77b693 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -219,7 +219,7 @@ ERROR_WHITELIST =3D [ {'exitcode':-6, 'log':r"Object .* is not an instance of type spapr-mac= hine", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"Object .* is not an instance of type generic-p= c-machine", 'loglevel':logging.ERROR}, {'exitcode':-6, 'log':r"Object .* is not an instance of type e500-ccsr= ", 'loglevel':logging.ERROR}, - {'exitcode':-6, 'log':r"vmstate_register_with_alias_id: Assertion `!se= ->compat || se->instance_id =3D=3D 0' failed", 'loglevel':logging.ERROR}, + {'exitcode':-6, 'log':r"vmstate_register_with_alias_id: Assertion `!se= ->compat \|\| se->instance_id =3D=3D 0' failed", 'loglevel':logging.ERROR}, {'exitcode':-11, 'device':'stm32f205-soc', 'loglevel':logging.ERROR, '= expected':True}, {'exitcode':-11, 'device':'xlnx,zynqmp', 'loglevel':logging.ERROR, 'ex= pected':True}, {'exitcode':-11, 'device':'mips-cps', 'loglevel':logging.ERROR, 'expec= ted':True}, --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317728562526.8751076723868; Mon, 17 Jul 2017 11:55:28 -0700 (PDT) Received: from localhost ([::1]:52030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBB1-00072I-1z for importer@patchew.org; Mon, 17 Jul 2017 14:55:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6h-0003Bv-B2 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6g-0003XQ-Hp for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:50:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6g-0003VW-CC for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:50:58 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 523C54E047; Mon, 17 Jul 2017 18:50:57 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFAB55D9CB; Mon, 17 Jul 2017 18:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 523C54E047 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 523C54E047 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:38 -0300 Message-Id: <20170717185051.18740-3-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:50: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] [PULL 02/15] tests: Test case for object_resolve_path*() 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: qemu-devel@nongnu.org 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" Test for partial path lookup using object_resolve_path*(). Signed-off-by: Eduardo Habkost Message-Id: <20170707213052.13087-2-ehabkost@redhat.com> Tested-by: Mark Cave-Ayland Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- tests/check-qom-proplist.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 8e432e9..f6e7823 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -568,6 +568,44 @@ static void test_dummy_delchild(void) object_unparent(OBJECT(dev)); } =20 +static void test_qom_partial_path(void) +{ + Object *root =3D object_get_objects_root(); + Object *cont1 =3D container_get(root, "/cont1"); + Object *obj1 =3D object_new(TYPE_DUMMY); + Object *obj2a =3D object_new(TYPE_DUMMY); + Object *obj2b =3D object_new(TYPE_DUMMY); + bool ambiguous; + + /* Objects created: + * /cont1 + * /cont1/obj1 + * /cont1/obj2 (obj2a) + * /obj2 (obj2b) + */ + object_property_add_child(cont1, "obj1", obj1, &error_abort); + object_unref(obj1); + object_property_add_child(cont1, "obj2", obj2a, &error_abort); + object_unref(obj2a); + object_property_add_child(root, "obj2", obj2b, &error_abort); + object_unref(obj2b); + + ambiguous =3D false; + g_assert(!object_resolve_path_type("", TYPE_DUMMY, &ambiguous)); + g_assert(ambiguous); + + ambiguous =3D false; + g_assert(!object_resolve_path("obj2", &ambiguous)); + g_assert(ambiguous); + + ambiguous =3D false; + g_assert(object_resolve_path("obj1", &ambiguous) =3D=3D obj1); + g_assert(!ambiguous); + + object_unparent(obj2b); + object_unparent(cont1); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -585,6 +623,7 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); g_test_add_func("/qom/proplist/iterator", test_dummy_iterator); g_test_add_func("/qom/proplist/delchild", test_dummy_delchild); + g_test_add_func("/qom/resolve/partial", test_qom_partial_path); =20 return g_test_run(); } --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317730814567.8776664639424; Mon, 17 Jul 2017 11:55:30 -0700 (PDT) Received: from localhost ([::1]:52033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBB3-00074l-Gc for importer@patchew.org; Mon, 17 Jul 2017 14:55:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6k-0003EO-Np for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6j-0003aV-KD for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6j-0003Zf-AJ for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40D7D4A6E8; Mon, 17 Jul 2017 18:51:00 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id B822077BEB; Mon, 17 Jul 2017 18:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 40D7D4A6E8 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 40D7D4A6E8 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:39 -0300 Message-Id: <20170717185051.18740-4-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:51:00 +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/15] qdev: fix the order compat and global properties are applied 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: qemu-devel@nongnu.org, Greg Kurz 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: Greg Kurz The current code recursively applies global properties from child up to parent types. This can cause properties passed with the -global option to be silently overridden by internal compat properties. This is exactly what happened with virtio-*-pci drivers since commit: "9a4c0e220d8a hw/virtio-pci: fix virtio behaviour" Passing -device virtio-blk-pci.disable-modern=3Doff had no effect on 2.6 machine types because the internal virtio-pci.disable-modern=3Don compat property always prevailed. A workaround for this was included with commit 0bcba41f ("machine: Convert abstract typename on compat_props to subclass names"). This patch fixes the issue properly by reversing the logic: we now go through the global property list and, for each property, we check if it is applicable to the device. This results in compat properties being applied first, in the order they appear in the HW_COMPAT_* macros, followed by global properties, in the order they appear on the command line. Signed-off-by: Greg Kurz Message-Id: <148103887228.22326.478406873609299999.stgit@bahia.lab.toulouse= -stg.fr.ibm.com> Signed-off-by: Eduardo Habkost Message-Id: <20170711004303.3902-2-ehabkost@redhat.com> Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic Signed-off-by: Eduardo Habkost --- hw/core/qdev-properties.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index dcecdf0..58a8f92 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1149,8 +1149,7 @@ int qdev_prop_check_globals(void) return ret; } =20 -static void qdev_prop_set_globals_for_type(DeviceState *dev, - const char *typename) +void qdev_prop_set_globals(DeviceState *dev) { GList *l; =20 @@ -1158,7 +1157,7 @@ static void qdev_prop_set_globals_for_type(DeviceStat= e *dev, GlobalProperty *prop =3D l->data; Error *err =3D NULL; =20 - if (strcmp(typename, prop->driver) !=3D 0) { + if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { continue; } prop->used =3D true; @@ -1176,16 +1175,6 @@ static void qdev_prop_set_globals_for_type(DeviceSta= te *dev, } } =20 -void qdev_prop_set_globals(DeviceState *dev) -{ - ObjectClass *class =3D object_get_class(OBJECT(dev)); - - do { - qdev_prop_set_globals_for_type(dev, object_class_get_name(class)); - class =3D object_class_get_parent(class); - } while (class); -} - /* --- 64bit unsigned int 'size' type --- */ =20 static void get_size(Object *obj, Visitor *v, const char *name, void *opaq= ue, --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317579486491.0958197413893; Mon, 17 Jul 2017 11:52:59 -0700 (PDT) Received: from localhost ([::1]:52025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB8c-0004Qr-9M for importer@patchew.org; Mon, 17 Jul 2017 14:52:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6m-0003G2-J8 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6l-0003ce-EF for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6l-0003bb-52 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14B1A4A6E0; Mon, 17 Jul 2017 18:51:02 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D8BB60BF1; Mon, 17 Jul 2017 18:51:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 14B1A4A6E0 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 14B1A4A6E0 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:40 -0300 Message-Id: <20170717185051.18740-5-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:51: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] [PULL 04/15] test-qdev-global-props: Test global property ordering 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: qemu-devel@nongnu.org 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" Test case to detect the bug fixed by commit "qdev: fix the order compat and global properties are applied". Signed-off-by: Eduardo Habkost Message-Id: <20170711004303.3902-3-ehabkost@redhat.com> Reviewed-by: Cornelia Huck Reviewed-by: Greg Kurz Reviewed-by: Halil Pasic Signed-off-by: Eduardo Habkost --- tests/test-qdev-global-props.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index b25fe89..d81b086 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -33,6 +33,8 @@ #define STATIC_TYPE(obj) \ OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS) =20 +#define TYPE_SUBCLASS "static_prop_subtype" + #define PROP_DEFAULT 100 =20 typedef struct MyType { @@ -63,6 +65,11 @@ static const TypeInfo static_prop_type =3D { .class_init =3D static_prop_class_init, }; =20 +static const TypeInfo subclass_type =3D { + .name =3D TYPE_SUBCLASS, + .parent =3D TYPE_STATIC_PROPS, +}; + /* Test simple static property setting to default value */ static void test_static_prop_subprocess(void) { @@ -279,12 +286,35 @@ static void test_dynamic_globalprop_nouser(void) g_test_trap_assert_stdout(""); } =20 +/* Test if global props affecting subclasses are applied in the right orde= r */ +static void test_subclass_global_props(void) +{ + MyType *mt; + /* Global properties must be applied in the order they were registered= */ + static GlobalProperty props[] =3D { + { TYPE_STATIC_PROPS, "prop1", "101" }, + { TYPE_SUBCLASS, "prop1", "102" }, + { TYPE_SUBCLASS, "prop2", "103" }, + { TYPE_STATIC_PROPS, "prop2", "104" }, + {} + }; + + qdev_prop_register_global_list(props); + + mt =3D STATIC_TYPE(object_new(TYPE_SUBCLASS)); + qdev_init_nofail(DEVICE(mt)); + + g_assert_cmpuint(mt->prop1, =3D=3D, 102); + g_assert_cmpuint(mt->prop2, =3D=3D, 104); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); =20 module_call_init(MODULE_INIT_QOM); type_register_static(&static_prop_type); + type_register_static(&subclass_type); type_register_static(&dynamic_prop_type); type_register_static(&hotplug_type); type_register_static(&nohotplug_type); @@ -310,6 +340,9 @@ int main(int argc, char **argv) g_test_add_func("/qdev/properties/dynamic/global/nouser", test_dynamic_globalprop_nouser); =20 + g_test_add_func("/qdev/properties/global/subclass", + test_subclass_global_props); + g_test_run(); =20 return 0; --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 150031787837292.16514002142083; Mon, 17 Jul 2017 11:57:58 -0700 (PDT) Received: from localhost ([::1]:52045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBDQ-0000n3-3O for importer@patchew.org; Mon, 17 Jul 2017 14:57:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6s-0003Km-7G for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6n-0003ep-92 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6n-0003e1-2O for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:05 -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 ED168624BB; Mon, 17 Jul 2017 18:51:03 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8279A5D6A2; Mon, 17 Jul 2017 18:51:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED168624BB 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED168624BB From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:41 -0300 Message-Id: <20170717185051.18740-6-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Jul 2017 18:51:04 +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/15] Revert "machine: Convert abstract typename on compat_props to subclass names" 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: qemu-devel@nongnu.org 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" This reverts commit 0bcba41fe379e4c6834adcf1456d9099db31a5b2. The bug addressed by that commit is now fixed in a better way by the commit "qdev: fix the order compat and global properties are applied". Signed-off-by: Eduardo Habkost Message-Id: <20170711004303.3902-4-ehabkost@redhat.com> Acked-by: Cornelia Huck Reviewed-by: Greg Kurz Reviewed-by: Halil Pasic Signed-off-by: Eduardo Habkost --- hw/core/machine.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index dc431fa..41b53a1 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -770,18 +770,11 @@ static void machine_class_finalize(ObjectClass *klass= , void *data) g_free(mc->name); } =20 -static void machine_register_compat_for_subclass(ObjectClass *oc, void *op= aque) -{ - GlobalProperty *p =3D opaque; - register_compat_prop(object_class_get_name(oc), p->property, p->value); -} - void machine_register_compat_props(MachineState *machine) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); int i; GlobalProperty *p; - ObjectClass *oc; =20 if (!mc->compat_props) { return; @@ -789,22 +782,9 @@ void machine_register_compat_props(MachineState *machi= ne) =20 for (i =3D 0; i < mc->compat_props->len; i++) { p =3D g_array_index(mc->compat_props, GlobalProperty *, i); - oc =3D object_class_by_name(p->driver); - if (oc && object_class_is_abstract(oc)) { - /* temporary hack to make sure we do not override - * globals set explicitly on -global: if an abstract class - * is on compat_props, register globals for all its - * non-abstract subtypes instead. - * - * This doesn't solve the problem for cases where - * a non-abstract typename mentioned on compat_props - * has subclasses, like spapr-pci-host-bridge. - */ - object_class_foreach(machine_register_compat_for_subclass, - p->driver, false, p); - } else { - register_compat_prop(p->driver, p->property, p->value); - } + /* Machine compat_props must never cause errors: */ + p->errp =3D &error_abort; + qdev_prop_register_global(p); } } =20 --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317735122820.6542778439322; Mon, 17 Jul 2017 11:55:35 -0700 (PDT) Received: from localhost ([::1]:52038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBB6-00078i-Q9 for importer@patchew.org; Mon, 17 Jul 2017 14:55:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6u-0003Li-8U for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6p-0003gm-4v for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6o-0003fv-Rt for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51: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 BCEF32F86D1; Mon, 17 Jul 2017 18:51:05 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A0A5D6A2; Mon, 17 Jul 2017 18:51:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCEF32F86D1 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BCEF32F86D1 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:42 -0300 Message-Id: <20170717185051.18740-7-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@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]); Mon, 17 Jul 2017 18:51:05 +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/15] qom: Fix ambiguous path detection when ambiguous=NULL 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: Mark Cave-Ayland , qemu-devel@nongnu.org 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" object_resolve_path*() ambiguous path detection breaks when ambiguous=3D=3DNULL and the object tree have 3 objects of the same type and only 2 of them are under the same parent. e.g.: /container/obj1 (TYPE_FOO) /container/obj2 (TYPE_FOO) /obj2 (TYPE_FOO) With the above tree, object_resolve_path_type("", TYPE_FOO, NULL) will incorrectly return /obj2, because the search inside "/container" will return NULL, and the match at "/obj2" won't be detected as ambiguous. Fix that by always calling object_resolve_partial_path() with a non-NULL ambiguous parameter. Test case included. Reported-by: Igor Mammedov Cc: Mark Cave-Ayland Signed-off-by: Eduardo Habkost Message-Id: <20170707213052.13087-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- qom/object.c | 17 ++++++++--------- tests/check-qom-proplist.c | 3 +++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/qom/object.c b/qom/object.c index dfdbd50..fe6e744 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1712,15 +1712,13 @@ static Object *object_resolve_partial_path(Object *= parent, typename, ambiguous); if (found) { if (obj) { - if (ambiguous) { - *ambiguous =3D true; - } + *ambiguous =3D true; return NULL; } obj =3D found; } =20 - if (ambiguous && *ambiguous) { + if (*ambiguous) { return NULL; } } @@ -1729,7 +1727,7 @@ static Object *object_resolve_partial_path(Object *pa= rent, } =20 Object *object_resolve_path_type(const char *path, const char *typename, - bool *ambiguous) + bool *ambiguousp) { Object *obj; gchar **parts; @@ -1738,11 +1736,12 @@ Object *object_resolve_path_type(const char *path, = const char *typename, assert(parts); =20 if (parts[0] =3D=3D NULL || strcmp(parts[0], "") !=3D 0) { - if (ambiguous) { - *ambiguous =3D false; - } + bool ambiguous =3D false; obj =3D object_resolve_partial_path(object_get_root(), parts, - typename, ambiguous); + typename, &ambiguous); + if (ambiguousp) { + *ambiguousp =3D ambiguous; + } } else { obj =3D object_resolve_abs_path(object_get_root(), parts, typename= , 1); } diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index f6e7823..432b665 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -593,14 +593,17 @@ static void test_qom_partial_path(void) ambiguous =3D false; g_assert(!object_resolve_path_type("", TYPE_DUMMY, &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path_type("", TYPE_DUMMY, NULL)); =20 ambiguous =3D false; g_assert(!object_resolve_path("obj2", &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path("obj2", NULL)); =20 ambiguous =3D false; g_assert(object_resolve_path("obj1", &ambiguous) =3D=3D obj1); g_assert(!ambiguous); + g_assert(object_resolve_path("obj1", NULL) =3D=3D obj1); =20 object_unparent(obj2b); object_unparent(cont1); --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317663898629.3490105728853; Mon, 17 Jul 2017 11:54:23 -0700 (PDT) Received: from localhost ([::1]:52029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB9x-00069t-GH for importer@patchew.org; Mon, 17 Jul 2017 14:54:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6u-0003Ls-CS for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6r-0003ie-0i for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6q-0003he-Qa for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B239A4ACCC; Mon, 17 Jul 2017 18:51:07 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2647860F8A; Mon, 17 Jul 2017 18:51:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B239A4ACCC 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B239A4ACCC From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:43 -0300 Message-Id: <20170717185051.18740-8-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:51:07 +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/15] fw_cfg: switch fw_cfg_find() to locate the fw_cfg device by type rather than path 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: Mark Cave-Ayland , qemu-devel@nongnu.org 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: Mark Cave-Ayland This will enable the fw_cfg device to be placed anywhere within the QOM tree regardless of its machine location. Note that we also add a comment to document the behaviour that we return NU= LL to indicate failure where either no fw_cfg device or multiple fw_cfg devices a= re found. Signed-off-by: Mark Cave-Ayland Message-Id: <1500025208-14827-2-git-send-email-mark.cave-ayland@ilande.co.u= k> Reviewed-by: Igor Mammedov Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/nvram/fw_cfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index e881e3b..3a988b6 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1017,7 +1017,8 @@ FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr d= ata_addr) =20 FWCfgState *fw_cfg_find(void) { - return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL)); + /* Returns NULL unless there is exactly one fw_cfg device */ + return FW_CFG(object_resolve_path_type("", TYPE_FW_CFG, NULL)); } =20 static void fw_cfg_class_init(ObjectClass *klass, void *data) --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317874818134.317894560122; Mon, 17 Jul 2017 11:57:54 -0700 (PDT) Received: from localhost ([::1]:52044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBDN-0000lO-BH for importer@patchew.org; Mon, 17 Jul 2017 14:57:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6u-0003Lr-CS for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6t-0003lI-6E for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6s-0003kf-Ta for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7D25356E4; Mon, 17 Jul 2017 18:51:09 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12DAA60F8A; Mon, 17 Jul 2017 18:51:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7D25356E4 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C7D25356E4 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:44 -0300 Message-Id: <20170717185051.18740-9-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Jul 2017 18:51: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] [PULL 08/15] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers 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: Mark Cave-Ayland , qemu-devel@nongnu.org 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: Mark Cave-Ayland When looking to instantiate a TYPE_FW_CFG_MEM or TYPE_FW_CFG_IO device to be able to wire it up differently, it is much more convenient for the caller to instantiate the device and have the fw_cfg default files already preloaded during realize. Move fw_cfg_init1() to the end of both the fw_cfg_mem_realize() and fw_cfg_io_realize() functions so it no longer needs to be called manually when instantiating the device, and also rename it to fw_cfg_common_realize() which better describes its new purpose. Since it is now the responsibility of the machine to wire up the fw_cfg dev= ice it is necessary to introduce a object_property_add_child() call into fw_cfg_init_io() and fw_cfg_init_mem() to link the fw_cfg device to the root machine object as before. Finally with the previous change to fw_cfg_find() we can now remove the assert() preventing multiple fw_cfg devices being instantiated and replace them with a simple call to fw_cfg_find() at realize time instead. This allo= ws us to remove FW_CFG_NAME and FW_CFG_PATH since they are no longer required. Signed-off-by: Mark Cave-Ayland Reviewed-by: Igor Mammedov Message-Id: <1500025208-14827-3-git-send-email-mark.cave-ayland@ilande.co.u= k> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/nvram/fw_cfg.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 3a988b6..97c7677 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -37,9 +37,6 @@ =20 #define FW_CFG_FILE_SLOTS_DFLT 0x20 =20 -#define FW_CFG_NAME "fw_cfg" -#define FW_CFG_PATH "/machine/" FW_CFG_NAME - #define TYPE_FW_CFG "fw_cfg" #define TYPE_FW_CFG_IO "fw_cfg_io" #define TYPE_FW_CFG_MEM "fw_cfg_mem" @@ -909,17 +906,16 @@ static void fw_cfg_machine_ready(struct Notifier *n, = void *data) =20 =20 =20 -static void fw_cfg_init1(DeviceState *dev) +static void fw_cfg_common_realize(DeviceState *dev, Error **errp) { FWCfgState *s =3D FW_CFG(dev); MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t version =3D FW_CFG_VERSION; =20 - assert(!object_resolve_path(FW_CFG_PATH, NULL)); - - object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NUL= L); - - qdev_init_nofail(dev); + if (!fw_cfg_find()) { + error_setg(errp, "at most one %s device is permitted", TYPE_FW_CFG= ); + return; + } =20 fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16); @@ -952,7 +948,9 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_= t dma_iobase, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG, + OBJECT(dev), NULL); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); ios =3D FW_CFG_IO(dev); @@ -990,7 +988,9 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG, + OBJECT(dev), NULL); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(sbd, 0, ctl_addr); @@ -1021,6 +1021,7 @@ FWCfgState *fw_cfg_find(void) return FW_CFG(object_resolve_path_type("", TYPE_FW_CFG, NULL)); } =20 + static void fw_cfg_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -1092,6 +1093,8 @@ static void fw_cfg_io_realize(DeviceState *dev, Error= **errp) &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); } + + fw_cfg_common_realize(dev, errp); } =20 static void fw_cfg_io_class_init(ObjectClass *klass, void *data) @@ -1158,6 +1161,8 @@ static void fw_cfg_mem_realize(DeviceState *dev, Erro= r **errp) sizeof(dma_addr_t)); sysbus_init_mmio(sbd, &FW_CFG(s)->dma_iomem); } + + fw_cfg_common_realize(dev, errp); } =20 static void fw_cfg_mem_class_init(ObjectClass *klass, void *data) --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500318023096309.6571473225921; Mon, 17 Jul 2017 12:00:23 -0700 (PDT) Received: from localhost ([::1]:52057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBFj-0003Sr-FH for importer@patchew.org; Mon, 17 Jul 2017 15:00:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6w-0003NU-0O for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6v-0003nI-3O for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6u-0003m2-Q4 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A807961E51; Mon, 17 Jul 2017 18:51:11 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 392A25D9CB; Mon, 17 Jul 2017 18:51:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A807961E51 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A807961E51 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:45 -0300 Message-Id: <20170717185051.18740-10-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Jul 2017 18:51:11 +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/15] fw_cfg: move QOM type defines and fw_cfg types into fw_cfg.h 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: Mark Cave-Ayland , qemu-devel@nongnu.org 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: Mark Cave-Ayland By exposing FWCfgIoState and FWCfgMemState internals we allow the possibili= ty for the internal MemoryRegion fields to be mapped by name for boards that w= ish to wire up the fw_cfg device themselves. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek Message-Id: <1500025208-14827-4-git-send-email-mark.cave-ayland@ilande.co.u= k> Signed-off-by: Eduardo Habkost --- include/hw/nvram/fw_cfg.h | 50 +++++++++++++++++++++++++++++++++++++++++++= ++++ include/qemu/typedefs.h | 1 + hw/nvram/fw_cfg.c | 49 +------------------------------------------= --- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index b980cba..b77ea48 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -1,8 +1,19 @@ #ifndef FW_CFG_H #define FW_CFG_H =20 +#include "qemu/typedefs.h" #include "exec/hwaddr.h" #include "hw/nvram/fw_cfg_keys.h" +#include "hw/sysbus.h" +#include "sysemu/dma.h" + +#define TYPE_FW_CFG "fw_cfg" +#define TYPE_FW_CFG_IO "fw_cfg_io" +#define TYPE_FW_CFG_MEM "fw_cfg_mem" + +#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) +#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) +#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) =20 typedef struct FWCfgFile { uint32_t size; /* file size */ @@ -35,6 +46,45 @@ typedef struct FWCfgDmaAccess { =20 typedef void (*FWCfgReadCallback)(void *opaque); =20 +struct FWCfgState { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + uint16_t file_slots; + FWCfgEntry *entries[2]; + int *entry_order; + FWCfgFiles *files; + uint16_t cur_entry; + uint32_t cur_offset; + Notifier machine_ready; + + int fw_cfg_order_override; + + bool dma_enabled; + dma_addr_t dma_addr; + AddressSpace *dma_as; + MemoryRegion dma_iomem; +}; + +struct FWCfgIoState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion comb_iomem; +}; + +struct FWCfgMemState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion ctl_iomem, data_iomem; + uint32_t data_width; + MemoryRegionOps wide_data_ops; +}; + /** * fw_cfg_add_bytes: * @s: fw_cfg device being modified diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index b191591..7b0d4e7 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -30,6 +30,7 @@ typedef struct DisplaySurface DisplaySurface; typedef struct DriveInfo DriveInfo; typedef struct Error Error; typedef struct EventNotifier EventNotifier; +typedef struct FWCfgEntry FWCfgEntry; typedef struct FWCfgIoState FWCfgIoState; typedef struct FWCfgMemState FWCfgMemState; typedef struct FWCfgState FWCfgState; diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 97c7677..5bd9044 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -37,14 +37,6 @@ =20 #define FW_CFG_FILE_SLOTS_DFLT 0x20 =20 -#define TYPE_FW_CFG "fw_cfg" -#define TYPE_FW_CFG_IO "fw_cfg_io" -#define TYPE_FW_CFG_MEM "fw_cfg_mem" - -#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) -#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) -#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) - /* FW_CFG_VERSION bits */ #define FW_CFG_VERSION 0x01 #define FW_CFG_VERSION_DMA 0x02 @@ -58,51 +50,12 @@ =20 #define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */ =20 -typedef struct FWCfgEntry { +struct FWCfgEntry { uint32_t len; bool allow_write; uint8_t *data; void *callback_opaque; FWCfgReadCallback read_callback; -} FWCfgEntry; - -struct FWCfgState { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - uint16_t file_slots; - FWCfgEntry *entries[2]; - int *entry_order; - FWCfgFiles *files; - uint16_t cur_entry; - uint32_t cur_offset; - Notifier machine_ready; - - int fw_cfg_order_override; - - bool dma_enabled; - dma_addr_t dma_addr; - AddressSpace *dma_as; - MemoryRegion dma_iomem; -}; - -struct FWCfgIoState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion comb_iomem; -}; - -struct FWCfgMemState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion ctl_iomem, data_iomem; - uint32_t data_width; - MemoryRegionOps wide_data_ops; }; =20 #define JPG_FILE 0 --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317816274519.9442513976203; Mon, 17 Jul 2017 11:56:56 -0700 (PDT) Received: from localhost ([::1]:52043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBCR-0008KR-14 for importer@patchew.org; Mon, 17 Jul 2017 14:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6y-0003PO-0s for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6x-0003pQ-1O for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6w-0003ns-OS for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A34112F86C3; Mon, 17 Jul 2017 18:51:13 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 119206046A; Mon, 17 Jul 2017 18:51:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A34112F86C3 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A34112F86C3 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:46 -0300 Message-Id: <20170717185051.18740-11-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 17 Jul 2017 18:51:13 +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/15] i386: expose "TCGTCGTCGTCG" in the 0x40000000 CPUID leaf 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: qemu-devel@nongnu.org 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: "Daniel P. Berrange" Currently when running KVM, we expose "KVMKVMKVM\0\0\0" in the 0x40000000 CPUID leaf. Other hypervisors (VMWare, HyperV, Xen, BHyve) all do the same thing, which leaves TCG as the odd one out. The CPUID signature is used by software to detect which virtual environment they are running in and (potentially) change behaviour in certain ways. For example, systemd supports a ConditionVirtualization=3D setting in unit files. The virt-what command can also report the virt type it is running on Currently both these apps have to resort to custom hacks like looking for 'fw-cfg' entry in the /proc/device-tree file to identify TCG. This change thus proposes a signature "TCGTCGTCGTCG" to be reported when running under TCG. To hide this, the -cpu option tcg-cpuid=3Doff can be used. Signed-off-by: Daniel P. Berrange Message-Id: <20170509132736.10071-3-berrange@redhat.com> Signed-off-by: Eduardo Habkost --- include/hw/i386/pc.h | 5 +++++ target/i386/cpu.h | 1 + target/i386/cpu.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f48d167..d80859b 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -380,6 +380,11 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); #define PC_COMPAT_2_8 \ HW_COMPAT_2_8 \ {\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "tcg-cpuid",\ + .value =3D "off",\ + },\ + {\ .driver =3D "kvmclock",\ .property =3D "x-mach-use-reliable-get-clock",\ .value =3D "off",\ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7a228af..0518673 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1218,6 +1218,7 @@ struct X86CPU { bool check_cpuid; bool enforce_cpuid; bool expose_kvm; + bool expose_tcg; bool migratable; bool max_features; /* Enable all supported features automatically */ uint32_t apic_id; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4de91d5..71983ef 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2632,12 +2632,15 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, CPUState *cs =3D CPU(cpu); uint32_t pkg_offset; uint32_t limit; + uint32_t signature[3]; =20 /* Calculate & apply limits for different index ranges */ if (index >=3D 0xC0000000) { limit =3D env->cpuid_xlevel2; } else if (index >=3D 0x80000000) { limit =3D env->cpuid_xlevel; + } else if (index >=3D 0x40000000) { + limit =3D 0x40000001; } else { limit =3D env->cpuid_level; } @@ -2872,6 +2875,30 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } break; } + case 0x40000000: + /* + * CPUID code in kvm_arch_init_vcpu() ignores stuff + * set here, but we restrict to TCG none the less. + */ + if (tcg_enabled() && cpu->expose_tcg) { + memcpy(signature, "TCGTCGTCGTCG", 12); + *eax =3D 0x40000001; + *ebx =3D signature[0]; + *ecx =3D signature[1]; + *edx =3D signature[2]; + } else { + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + } + break; + case 0x40000001: + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + break; case 0x80000000: *eax =3D env->cpuid_xlevel; *ebx =3D env->cpuid_vendor1; @@ -4018,6 +4045,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), + DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), DEFINE_PROP_END_OF_LIST() }; =20 --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 15003180700781.2262425733098326; Mon, 17 Jul 2017 12:01:10 -0700 (PDT) Received: from localhost ([::1]:52066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBGV-0004Cs-Aq for importer@patchew.org; Mon, 17 Jul 2017 15:01:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6z-0003Qj-E5 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6y-0003qU-Od for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6y-0003pw-IQ for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74295356D6; Mon, 17 Jul 2017 18:51:15 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CCFD60464; Mon, 17 Jul 2017 18:51:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 74295356D6 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 74295356D6 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:47 -0300 Message-Id: <20170717185051.18740-12-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Jul 2017 18:51: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 11/15] i386: Update comment about XSAVES on Skylake-Client 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: qemu-devel@nongnu.org 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" Reported-by: Paolo Bonzini Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 71983ef..e702691 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1331,7 +1331,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX, /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.6). + * including v4.1 to v4.12). * KVM doesn't yet expose any XSAVES state save component, * and the only one defined in Skylake (processor tracing) * probably will block migration anyway. --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317879123122.41564158732103; Mon, 17 Jul 2017 11:57:59 -0700 (PDT) Received: from localhost ([::1]:52046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBDR-0000pN-Qs for importer@patchew.org; Mon, 17 Jul 2017 14:57:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB73-0003TT-Vg for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB70-0003rU-Kg for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB70-0003qz-Bc for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:18 -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 412CD7CB8B; Mon, 17 Jul 2017 18:51:17 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7FB05C8BA; Mon, 17 Jul 2017 18:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 412CD7CB8B 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 412CD7CB8B From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:48 -0300 Message-Id: <20170717185051.18740-13-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@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]); Mon, 17 Jul 2017 18:51:17 +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/15] i386: add Skylake-Server cpu model 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: "Boqun Feng \(Intel\)" , qemu-devel@nongnu.org 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: "Boqun Feng (Intel)" Introduce Skylake-Server cpu mode which inherits the features from Skylake-Client and supports some additional features that are: AVX512, CLWB and PGPE1GB. Signed-off-by: Boqun Feng (Intel) Message-Id: <20170621052935.20715-1-boqun.feng@gmail.com> [ehabkost: copied comment about XSAVES from Skylake-Client] Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e702691..0bbda76 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1345,6 +1345,54 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .model_id =3D "Intel Core Processor (Skylake)", }, { + .name =3D "Skylake-Server", + .level =3D 0xd, + .vendor =3D CPUID_VENDOR_INTEL, + .family =3D 6, + .model =3D 85, + .stepping =3D 4, + .features[FEAT_1_EDX] =3D + CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | + CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | + CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | + CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX] =3D + CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | + CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | + CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | + CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | + CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX] =3D + CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_RDTSCP | + CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX] =3D + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EBX] =3D + CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | + CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | + CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | + CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX | CPUID_7_0_EBX_CLWB | + CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512DQ | + CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD | + CPUID_7_0_EBX_AVX512VL, + /* Missing: XSAVES (not supported by some Linux versions, + * including v4.1 to v4.12). + * KVM doesn't yet expose any XSAVES state save component, + * and the only one defined in Skylake (processor tracing) + * probably will block migration anyway. + */ + .features[FEAT_XSAVE] =3D + CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1, + .features[FEAT_6_EAX] =3D + CPUID_6_EAX_ARAT, + .xlevel =3D 0x80000008, + .model_id =3D "Intel Xeon Processor (Skylake)", + }, + { .name =3D "Opteron_G1", .level =3D 5, .vendor =3D CPUID_VENDOR_AMD, --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500317957992532.6152930528272; Mon, 17 Jul 2017 11:59:17 -0700 (PDT) Received: from localhost ([::1]:52052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBEi-00023t-LV for importer@patchew.org; Mon, 17 Jul 2017 14:59:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB73-0003TU-W1 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB72-0003tG-GL for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB72-0003sP-70 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:20 -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 1D7C27CB9A; Mon, 17 Jul 2017 18:51:19 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id A747D5D6A2; Mon, 17 Jul 2017 18:51:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D7C27CB9A 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D7C27CB9A From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:49 -0300 Message-Id: <20170717185051.18740-14-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@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]); Mon, 17 Jul 2017 18:51:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/15] tests: Simplify abstract-interfaces check with a helper 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: qemu-devel@nongnu.org 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" Add a new type_list_find() helper to device-introspect-test.c, to simplify the code at test_abstract_interfaces(). Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost Message-Id: <20170707122215.8819-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- tests/device-introspect-test.c | 43 ++++++++++++++++++++++++--------------= ---- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index b1abb2a..f1e6ddd 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -45,6 +45,22 @@ static QList *qom_list_types(const char *implements, boo= l abstract) return ret; } =20 +/* Find an entry on a list returned by qom-list-types */ +static QDict *type_list_find(QList *types, const char *name) +{ + QListEntry *e; + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *ename =3D qdict_get_str(d, "name"); + if (!strcmp(ename, name)) { + return d; + } + } + + return NULL; +} + static QList *device_type_list(bool abstract) { return qom_list_types("device", abstract); @@ -125,7 +141,7 @@ static void test_abstract_interfaces(void) { QList *all_types; QList *obj_types; - QListEntry *ae; + QListEntry *e; =20 qtest_start(common_args); /* qom-list-types implements=3Dinterface would return any type @@ -138,24 +154,15 @@ static void test_abstract_interfaces(void) all_types =3D qom_list_types(NULL, false); obj_types =3D qom_list_types("object", false); =20 - QLIST_FOREACH_ENTRY(all_types, ae) { - QDict *at =3D qobject_to_qdict(qlist_entry_obj(ae)); - const char *aname =3D qdict_get_str(at, "name"); - QListEntry *oe; - const char *found =3D NULL; - - QLIST_FOREACH_ENTRY(obj_types, oe) { - QDict *ot =3D qobject_to_qdict(qlist_entry_obj(oe)); - const char *oname =3D qdict_get_str(ot, "name"); - if (!strcmp(aname, oname)) { - found =3D oname; - break; - } - } + QLIST_FOREACH_ENTRY(all_types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + + /* + * An interface (incorrectly) marked as non-abstract would + * appear on all_types, but not on obj_types: + */ + g_assert(type_list_find(obj_types, qdict_get_str(d, "name"))); =20 - /* Using g_assert_cmpstr() will give more useful failure - * messages than g_assert(found) */ - g_assert_cmpstr(aname, =3D=3D, found); } =20 QDECREF(all_types); --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500318201755539.1728655841732; Mon, 17 Jul 2017 12:03:21 -0700 (PDT) Received: from localhost ([::1]:52088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBIb-0005sb-CB for importer@patchew.org; Mon, 17 Jul 2017 15:03:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB75-0003UN-HI for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB74-0003vM-EA for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB74-0003uG-5w for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21CC14ACCC; Mon, 17 Jul 2017 18:51:21 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81C4460464; Mon, 17 Jul 2017 18:51:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21CC14ACCC 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 21CC14ACCC From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:50 -0300 Message-Id: <20170717185051.18740-15-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:51:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/15] qmp: Include 'abstract' field on 'qom-list-types' output 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: qemu-devel@nongnu.org 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" A client may be interested in getting the list of both abstract and non-abstract types. Instead of requiring them to make multiple queries with different filter arguments, just return an 'abstract' field in 'qom-list-types'. In addition to the new test code for validating this field, update the abstract-interfaces test case to query for all 'interface' subtypes (including abstract ones), and to look at the 'abstract' field directly. Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost Message-Id: <20170707122215.8819-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- qapi-schema.json | 5 +++- qmp.c | 1 + tests/device-introspect-test.c | 53 +++++++++++++++++++++++++++++++-------= ---- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index ab438ea..6486690 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3051,10 +3051,13 @@ # # @name: the type name found in the search # +# @abstract: the type is abstract and can't be directly instantiated. +# Omitted if false. (since 2.10) +# # Since: 1.1 ## { 'struct': 'ObjectTypeInfo', - 'data': { 'name': 'str' } } + 'data': { 'name': 'str', '*abstract': 'bool' } } =20 ## # @qom-list-types: diff --git a/qmp.c b/qmp.c index 2cd40c3..7a9de06 100644 --- a/qmp.c +++ b/qmp.c @@ -433,6 +433,7 @@ static void qom_list_types_tramp(ObjectClass *klass, vo= id *data) =20 info =3D g_malloc0(sizeof(*info)); info->name =3D g_strdup(object_class_get_name(klass)); + info->has_abstract =3D info->abstract =3D object_class_is_abstract(kla= ss); =20 e =3D g_malloc0(sizeof(*e)); e->value =3D info; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index f1e6ddd..78d4811 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -103,6 +103,33 @@ static void test_device_intro_list(void) qtest_end(); } =20 +static void test_qom_list_fields(void) +{ + QList *all_types; + QList *non_abstract; + QListEntry *e; + + qtest_start(common_args); + + all_types =3D qom_list_types(NULL, true); + non_abstract =3D qom_list_types(NULL, false); + + QLIST_FOREACH_ENTRY(all_types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + bool abstract =3D qdict_haskey(d, "abstract") ? + qdict_get_bool(d, "abstract") : + false; + bool expected_abstract =3D !type_list_find(non_abstract, name); + + g_assert(abstract =3D=3D expected_abstract); + } + + QDECREF(all_types); + QDECREF(non_abstract); + qtest_end(); +} + static void test_device_intro_none(void) { qtest_start(common_args); @@ -144,25 +171,24 @@ static void test_abstract_interfaces(void) QListEntry *e; =20 qtest_start(common_args); - /* qom-list-types implements=3Dinterface would return any type - * that implements _any_ interface (not just interface types), - * so use a trick to find the interface type names: - * - list all object types - * - list all types, and look for items that are not - * on the first list + /* + * qom-list-types implements=3Dinterface returns all types that + * implement _any_ interface (not just interface types), but + * we can filter them out because interfaces don't implement + * the "object" type. */ - all_types =3D qom_list_types(NULL, false); - obj_types =3D qom_list_types("object", false); + all_types =3D qom_list_types("interface", true); + obj_types =3D qom_list_types("object", true); =20 QLIST_FOREACH_ENTRY(all_types, e) { QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); =20 - /* - * An interface (incorrectly) marked as non-abstract would - * appear on all_types, but not on obj_types: - */ - g_assert(type_list_find(obj_types, qdict_get_str(d, "name"))); + if (type_list_find(obj_types, qdict_get_str(d, "name"))) { + /* Not an interface type */ + continue; + } =20 + g_assert(qdict_haskey(d, "abstract") && qdict_get_bool(d, "abstrac= t")); } =20 QDECREF(all_types); @@ -175,6 +201,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 qtest_add_func("device/introspect/list", test_device_intro_list); + qtest_add_func("device/introspect/list-fields", test_qom_list_fields); qtest_add_func("device/introspect/none", test_device_intro_none); qtest_add_func("device/introspect/abstract", test_device_intro_abstrac= t); qtest_add_func("device/introspect/concrete", test_device_intro_concret= e); --=20 2.9.4 From nobody Fri May 3 11:17:09 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.zohomail.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 1500318096282838.1846713549763; Mon, 17 Jul 2017 12:01:36 -0700 (PDT) Received: from localhost ([::1]:52072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBGu-0004Wj-00 for importer@patchew.org; Mon, 17 Jul 2017 15:01:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB77-0003Wq-I0 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB76-0003xI-D2 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB76-0003wP-3q for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03BCF7DCF0; Mon, 17 Jul 2017 18:51:23 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89EBE60464; Mon, 17 Jul 2017 18:51:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03BCF7DCF0 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=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 03BCF7DCF0 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:51 -0300 Message-Id: <20170717185051.18740-16-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 17 Jul 2017 18:51:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/15] qmp: Include parent type on 'qom-list-types' output 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: qemu-devel@nongnu.org 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" Include name of parent type of each type on 'qom-list-types' output. Without this, there's no way to figure out the parents of a given type without making additional 'qom-list-types' queries. In addition to the test case for the new feature, update the abstract-interface test case to use the new field and avoid the "qom-list-types implements=3Dobject" trick. Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost Message-Id: <20170707122215.8819-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- qapi-schema.json | 4 +- qmp.c | 5 +++ tests/device-introspect-test.c | 84 +++++++++++++++++++++++++++++++++++++-= ---- 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 6486690..8b015be 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3054,10 +3054,12 @@ # @abstract: the type is abstract and can't be directly instantiated. # Omitted if false. (since 2.10) # +# @parent: Name of parent type, if any (since 2.10) +# # Since: 1.1 ## { 'struct': 'ObjectTypeInfo', - 'data': { 'name': 'str', '*abstract': 'bool' } } + 'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } } =20 ## # @qom-list-types: diff --git a/qmp.c b/qmp.c index 7a9de06..b86201e 100644 --- a/qmp.c +++ b/qmp.c @@ -430,10 +430,15 @@ static void qom_list_types_tramp(ObjectClass *klass, = void *data) { ObjectTypeInfoList *e, **pret =3D data; ObjectTypeInfo *info; + ObjectClass *parent =3D object_class_get_parent(klass); =20 info =3D g_malloc0(sizeof(*info)); info->name =3D g_strdup(object_class_get_name(klass)); info->has_abstract =3D info->abstract =3D object_class_is_abstract(kla= ss); + if (parent) { + info->has_parent =3D true; + info->parent =3D g_strdup(object_class_get_name(parent)); + } =20 e =3D g_malloc0(sizeof(*e)); e->value =3D info; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index 78d4811..f7162c0 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -45,6 +45,40 @@ static QList *qom_list_types(const char *implements, boo= l abstract) return ret; } =20 +/* Build a name -> ObjectTypeInfo index from a ObjectTypeInfo list */ +static QDict *qom_type_index(QList *types) +{ + QDict *index =3D qdict_new(); + QListEntry *e; + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + QINCREF(d); + qdict_put(index, name, d); + } + return index; +} + +/* Check if @parent is present in the parent chain of @type */ +static bool qom_has_parent(QDict *index, const char *type, const char *par= ent) +{ + while (type) { + QDict *d =3D qdict_get_qdict(index, type); + const char *p =3D d && qdict_haskey(d, "parent") ? + qdict_get_str(d, "parent") : + NULL; + + if (!strcmp(type, parent)) { + return true; + } + + type =3D p; + } + + return false; +} + /* Find an entry on a list returned by qom-list-types */ static QDict *type_list_find(QList *types, const char *name) { @@ -103,6 +137,30 @@ static void test_device_intro_list(void) qtest_end(); } =20 +/* + * Ensure all entries returned by qom-list-types implements=3D + * have as a parent. + */ +static void test_qom_list_parents(const char *parent) +{ + QList *types; + QListEntry *e; + QDict *index; + + types =3D qom_list_types(parent, true); + index =3D qom_type_index(types); + + QLIST_FOREACH_ENTRY(types, e) { + QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); + + g_assert(qom_has_parent(index, name, parent)); + } + + QDECREF(types); + QDECREF(index); +} + static void test_qom_list_fields(void) { QList *all_types; @@ -125,6 +183,10 @@ static void test_qom_list_fields(void) g_assert(abstract =3D=3D expected_abstract); } =20 + test_qom_list_parents("object"); + test_qom_list_parents("device"); + test_qom_list_parents("sys-bus-device"); + QDECREF(all_types); QDECREF(non_abstract); qtest_end(); @@ -167,23 +229,25 @@ static void test_device_intro_concrete(void) static void test_abstract_interfaces(void) { QList *all_types; - QList *obj_types; QListEntry *e; + QDict *index; =20 qtest_start(common_args); - /* - * qom-list-types implements=3Dinterface returns all types that - * implement _any_ interface (not just interface types), but - * we can filter them out because interfaces don't implement - * the "object" type. - */ + all_types =3D qom_list_types("interface", true); - obj_types =3D qom_list_types("object", true); + index =3D qom_type_index(all_types); =20 QLIST_FOREACH_ENTRY(all_types, e) { QDict *d =3D qobject_to_qdict(qlist_entry_obj(e)); + const char *name =3D qdict_get_str(d, "name"); =20 - if (type_list_find(obj_types, qdict_get_str(d, "name"))) { + /* + * qom-list-types implements=3Dinterface returns all types + * that implement _any_ interface (not just interface + * types), so skip the ones that don't have "interface" + * on the parent type chain. + */ + if (!qom_has_parent(index, name, "interface")) { /* Not an interface type */ continue; } @@ -192,7 +256,7 @@ static void test_abstract_interfaces(void) } =20 QDECREF(all_types); - QDECREF(obj_types); + QDECREF(index); qtest_end(); } =20 --=20 2.9.4