From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154159436201786.24589504723497; Wed, 7 Nov 2018 04:39:22 -0800 (PST) Received: from localhost ([::1]:47611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN77-0007Zb-3p for importer@patchew.org; Wed, 07 Nov 2018 07:39:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5J-00045Z-1c for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5F-00067x-4r for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN59-00060q-Ji; Wed, 07 Nov 2018 07:37:15 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3EBE30D49D8; Wed, 7 Nov 2018 12:37:11 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5B4926368; Wed, 7 Nov 2018 12:37:05 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:39 +0400 Message-Id: <20181107123652.23417-2-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 07 Nov 2018 12:37:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used" 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead, it returns 1 if an error was detected, which is the case for: /qdev/properties/dynamic/global/subprocess: warning: global dynamic-prop-type-bad.prop3 has invalid class name warning: global nohotplug-type.prop5=3D105 not used warning: global nondevice-type.prop6 has invalid class name Clarify the function return value. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Igor Mammedov --- tests/test-qdev-global-props.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index d81b0862d5..ccdf6c57c1 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -214,7 +214,7 @@ static void test_dynamic_globalprop_subprocess(void) { TYPE_NONDEVICE, "prop6", "106", true }, {} }; - int all_used; + int global_error; =20 qdev_prop_register_global_list(props); =20 @@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void) =20 g_assert_cmpuint(mt->prop1, =3D=3D, 101); g_assert_cmpuint(mt->prop2, =3D=3D, 102); - all_used =3D qdev_prop_check_globals(); - g_assert_cmpuint(all_used, =3D=3D, 1); + global_error =3D qdev_prop_check_globals(); + g_assert_cmpuint(global_error, =3D=3D, 1); g_assert(props[0].used); g_assert(props[1].used); g_assert(!props[2].used); @@ -259,7 +259,7 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) { TYPE_NONDEVICE, "prop6", "106" }, {} }; - int all_used; + int global_error; =20 qdev_prop_register_global_list(props); =20 @@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) =20 g_assert_cmpuint(mt->prop1, =3D=3D, 101); g_assert_cmpuint(mt->prop2, =3D=3D, 102); - all_used =3D qdev_prop_check_globals(); - g_assert_cmpuint(all_used, =3D=3D, 0); + global_error =3D qdev_prop_check_globals(); + g_assert_cmpuint(global_error, =3D=3D, 0); g_assert(props[0].used); g_assert(props[1].used); g_assert(!props[2].used); --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594389809116.79342063440231; Wed, 7 Nov 2018 04:39:49 -0800 (PST) Received: from localhost ([::1]:47612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7c-00082G-Ed for importer@patchew.org; Wed, 07 Nov 2018 07:39:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5a-0004TC-Dz for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5T-0006HJ-45 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5F-00065V-6E; Wed, 07 Nov 2018 07:37:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 561C2144051; Wed, 7 Nov 2018 12:37:17 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEB0526341; Wed, 7 Nov 2018 12:37:15 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:40 +0400 Message-Id: <20181107123652.23417-3-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 07 Nov 2018 12:37:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Interfaces don't have instance, let's make the interface type really abstract to avoid confusion. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Igor Mammedov --- include/hw/acpi/acpi_dev_interface.h | 6 +----- include/hw/arm/linux-boot-if.h | 5 +---- include/hw/fw-path-provider.h | 4 +--- include/hw/hotplug.h | 6 +----- include/hw/intc/intc.h | 4 +--- include/hw/ipmi/ipmi.h | 4 +--- include/hw/isa/isa.h | 4 ---- include/hw/mem/memory-device.h | 4 +--- include/hw/nmi.h | 4 +--- include/hw/stream.h | 4 +--- include/hw/timer/m48t59.h | 4 +--- include/qom/object_interfaces.h | 6 +----- include/sysemu/tpm.h | 4 +--- target/arm/idau.h | 4 +--- tests/check-qom-interface.c | 4 +--- 15 files changed, 14 insertions(+), 53 deletions(-) diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index dabf4c4fc9..43ff119179 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -25,11 +25,7 @@ typedef enum { INTERFACE_CHECK(AcpiDeviceIf, (obj), \ TYPE_ACPI_DEVICE_IF) =20 - -typedef struct AcpiDeviceIf { - /* */ - Object Parent; -} AcpiDeviceIf; +typedef struct AcpiDeviceIf AcpiDeviceIf; =20 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event); =20 diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h index aba4479a14..7bbdfd1cc6 100644 --- a/include/hw/arm/linux-boot-if.h +++ b/include/hw/arm/linux-boot-if.h @@ -16,10 +16,7 @@ #define ARM_LINUX_BOOT_IF(obj) \ INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF) =20 -typedef struct ARMLinuxBootIf { - /*< private >*/ - Object parent_obj; -} ARMLinuxBootIf; +typedef struct ARMLinuxBootIf ARMLinuxBootIf; =20 typedef struct ARMLinuxBootIfClass { /*< private >*/ diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h index 050cb05d92..5df893a3d8 100644 --- a/include/hw/fw-path-provider.h +++ b/include/hw/fw-path-provider.h @@ -30,9 +30,7 @@ #define FW_PATH_PROVIDER(obj) \ INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER) =20 -typedef struct FWPathProvider { - Object parent_obj; -} FWPathProvider; +typedef struct FWPathProvider FWPathProvider; =20 typedef struct FWPathProviderClass { InterfaceClass parent_class; diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h index 1a0516a479..6321e292fd 100644 --- a/include/hw/hotplug.h +++ b/include/hw/hotplug.h @@ -23,11 +23,7 @@ #define HOTPLUG_HANDLER(obj) \ INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER) =20 - -typedef struct HotplugHandler { - /* */ - Object Parent; -} HotplugHandler; +typedef struct HotplugHandler HotplugHandler; =20 /** * hotplug_fn: diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h index 27d9828943..fb3e8e621f 100644 --- a/include/hw/intc/intc.h +++ b/include/hw/intc/intc.h @@ -15,9 +15,7 @@ INTERFACE_CHECK(InterruptStatsProvider, (obj), \ TYPE_INTERRUPT_STATS_PROVIDER) =20 -typedef struct InterruptStatsProvider { - Object parent; -} InterruptStatsProvider; +typedef struct InterruptStatsProvider InterruptStatsProvider; =20 typedef struct InterruptStatsProviderClass { InterfaceClass parent; diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index 0affe5a4d8..99661d2bf0 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -114,9 +114,7 @@ uint32_t ipmi_next_uuid(void); #define IPMI_INTERFACE_GET_CLASS(class) \ OBJECT_GET_CLASS(IPMIInterfaceClass, (class), TYPE_IPMI_INTERFACE) =20 -typedef struct IPMIInterface { - Object parent; -} IPMIInterface; +typedef struct IPMIInterface IPMIInterface; =20 typedef struct IPMIInterfaceClass { InterfaceClass parent; diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index b9dbab24b4..e62ac91c19 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -43,10 +43,6 @@ static inline uint16_t applesmc_port(void) #define ISADMA(obj) \ INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA) =20 -struct IsaDma { - Object parent; -}; - typedef enum { ISADMA_TRANSFER_VERIFY, ISADMA_TRANSFER_READ, diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h index e904e194d5..0293a96abb 100644 --- a/include/hw/mem/memory-device.h +++ b/include/hw/mem/memory-device.h @@ -25,9 +25,7 @@ #define MEMORY_DEVICE(obj) \ INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE) =20 -typedef struct MemoryDeviceState { - Object parent_obj; -} MemoryDeviceState; +typedef struct MemoryDeviceState MemoryDeviceState; =20 /** * MemoryDeviceClass: diff --git a/include/hw/nmi.h b/include/hw/nmi.h index d092c684a1..ad857f3832 100644 --- a/include/hw/nmi.h +++ b/include/hw/nmi.h @@ -34,9 +34,7 @@ #define NMI(obj) \ INTERFACE_CHECK(NMI, (obj), TYPE_NMI) =20 -typedef struct NMIState { - Object parent_obj; -} NMIState; +typedef struct NMIState NMIState; =20 typedef struct NMIClass { InterfaceClass parent_class; diff --git a/include/hw/stream.h b/include/hw/stream.h index c370ba0c66..15774f07ab 100644 --- a/include/hw/stream.h +++ b/include/hw/stream.h @@ -14,9 +14,7 @@ #define STREAM_SLAVE(obj) \ INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE) =20 -typedef struct StreamSlave { - Object Parent; -} StreamSlave; +typedef struct StreamSlave StreamSlave; =20 typedef void (*StreamCanPushNotifyFn)(void *opaque); =20 diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h index db5e43a8da..6f8db04fce 100644 --- a/include/hw/timer/m48t59.h +++ b/include/hw/timer/m48t59.h @@ -13,9 +13,7 @@ #define NVRAM(obj) \ INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM) =20 -typedef struct Nvram { - Object parent; -} Nvram; +typedef struct Nvram Nvram; =20 typedef struct NvramClass { InterfaceClass parent; diff --git a/include/qom/object_interfaces.h b/include/qom/object_interface= s.h index 4d513fb329..652a16d2ba 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -16,11 +16,7 @@ INTERFACE_CHECK(UserCreatable, (obj), \ TYPE_USER_CREATABLE) =20 - -typedef struct UserCreatable { - /* */ - Object Parent; -} UserCreatable; +typedef struct UserCreatable UserCreatable; =20 /** * UserCreatableClass: diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 17a97ed77a..5b541a71c8 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -33,9 +33,7 @@ typedef enum TPMVersion { #define TPM_IF(obj) \ INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF) =20 -typedef struct TPMIf { - Object parent_obj; -} TPMIf; +typedef struct TPMIf TPMIf; =20 typedef struct TPMIfClass { InterfaceClass parent_class; diff --git a/target/arm/idau.h b/target/arm/idau.h index cac27b95fa..7c0e4e3776 100644 --- a/target/arm/idau.h +++ b/target/arm/idau.h @@ -38,9 +38,7 @@ #define IDAU_INTERFACE_GET_CLASS(obj) \ OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE) =20 -typedef struct IDAUInterface { - Object parent; -} IDAUInterface; +typedef struct IDAUInterface IDAUInterface; =20 #define IREGION_NOTVALID -1 =20 diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c index f87c9aaa8a..2177f0dce5 100644 --- a/tests/check-qom-interface.c +++ b/tests/check-qom-interface.c @@ -23,9 +23,7 @@ #define TEST_IF(obj) \ INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF) =20 -typedef struct TestIf { - Object parent_obj; -} TestIf; +typedef struct TestIf TestIf; =20 typedef struct TestIfClass { InterfaceClass parent_class; --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594579396764.1108750162812; Wed, 7 Nov 2018 04:42:59 -0800 (PST) Received: from localhost ([::1]:47645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNAY-0002Fe-7l for importer@patchew.org; Wed, 07 Nov 2018 07:42:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5l-0005Jn-Ch for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5j-0006Zw-MX for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5a-0006EM-RO; Wed, 07 Nov 2018 07:37:44 -0500 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 851E3144043; Wed, 7 Nov 2018 12:37:26 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B2E05D6AA; Wed, 7 Nov 2018 12:37:20 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:41 +0400 Message-Id: <20181107123652.23417-4-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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, 07 Nov 2018 12:37:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of accepting any Object*, change user_creatable_complete() to require a UserCreatable*. Modify the callers to pass the appropriate argument, removing redundant dynamic cast checks in object creation. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Igor Mammedov --- include/qom/object_interfaces.h | 4 ++-- hw/misc/ivshmem.c | 2 +- hw/virtio/virtio-rng.c | 2 +- qom/object.c | 12 ++++++++---- qom/object_interfaces.c | 14 +++----------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/qom/object_interfaces.h b/include/qom/object_interface= s.h index 652a16d2ba..682ba1d9b0 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -51,14 +51,14 @@ typedef struct UserCreatableClass { =20 /** * user_creatable_complete: - * @obj: the object whose complete() method is called if defined + * @uc: the user-creatable object whose complete() method is called if def= ined * @errp: if an error occurs, a pointer to an area to store the error * * Wrapper to call complete() method if one of types it's inherited * from implements USER_CREATABLE interface, otherwise the call does * nothing. */ -void user_creatable_complete(Object *obj, Error **errp); +void user_creatable_complete(UserCreatable *uc, Error **errp); =20 /** * user_creatable_can_be_deleted: diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index f88910e55c..478f41044c 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s) object_property_set_bool(obj, true, "share", &error_abort); object_property_add_child(OBJECT(s), "internal-shm-backend", obj, &error_abort); - user_creatable_complete(obj, &error_abort); + user_creatable_complete(USER_CREATABLE(obj), &error_abort); s->hostmem =3D MEMORY_BACKEND(obj); } =20 diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 855f1b41d1..30493a2586 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev,= Error **errp) if (vrng->conf.rng =3D=3D NULL) { vrng->conf.default_backend =3D RNG_RANDOM(object_new(TYPE_RNG_RAND= OM)); =20 - user_creatable_complete(OBJECT(vrng->conf.default_backend), + user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend), &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/qom/object.c b/qom/object.c index 547dcf97c3..eb770dbf7f 100644 --- a/qom/object.c +++ b/qom/object.c @@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const = char *propname, { Error *local_err =3D NULL; Object *obj; + UserCreatable *uc; =20 object_initialize(childobj, size, type); obj =3D OBJECT(childobj); @@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const = char *propname, goto out; } =20 - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { - user_creatable_complete(obj, &local_err); + uc =3D (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); + if (uc) { + user_creatable_complete(uc, &local_err); if (local_err) { object_unparent(obj); goto out; @@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename, Object *obj; ObjectClass *klass; Error *local_err =3D NULL; + UserCreatable *uc; =20 klass =3D object_class_by_name(typename); if (!klass) { @@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename, goto error; } =20 - if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { - user_creatable_complete(obj, &local_err); + uc =3D (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); + if (uc) { + user_creatable_complete(uc, &local_err); if (local_err) { object_unparent(obj); goto error; diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 97b79b48bb..db85d1eb75 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -8,18 +8,10 @@ #include "qapi/opts-visitor.h" #include "qemu/config-file.h" =20 -void user_creatable_complete(Object *obj, Error **errp) +void user_creatable_complete(UserCreatable *uc, Error **errp) { + UserCreatableClass *ucc =3D USER_CREATABLE_GET_CLASS(uc); =20 - UserCreatableClass *ucc; - UserCreatable *uc =3D - (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); - - if (!uc) { - return; - } - - ucc =3D USER_CREATABLE_GET_CLASS(uc); if (ucc->complete) { ucc->complete(uc, errp); } @@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const c= har *id, goto out; } =20 - user_creatable_complete(obj, &local_err); + user_creatable_complete(USER_CREATABLE(obj), &local_err); if (local_err) { object_property_del(object_get_objects_root(), id, &error_abort); --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15415945671449.313825536159698; Wed, 7 Nov 2018 04:42:47 -0800 (PST) Received: from localhost ([::1]:47644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNAT-0002Bu-VU for importer@patchew.org; Wed, 07 Nov 2018 07:42:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5l-0005Ki-IH for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5j-0006a4-SV for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5a-0006J8-NH; Wed, 07 Nov 2018 07:37:42 -0500 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 03E8FA53D6; Wed, 7 Nov 2018 12:37:38 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BFD84D732; Wed, 7 Nov 2018 12:37:29 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:42 +0400 Message-Id: <20181107123652.23417-5-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 07 Nov 2018 12:37:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 04/14] accel: register global_props like machine 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" global_props is only used for Xen xen_compat_props. It's a static array of GlobalProperty, like machine globals in SET_MACHINE_COMPAT(). Let's register the globals the same way, without extra copy allocation. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Igor Mammedov --- include/hw/qdev-properties.h | 29 ----------------------------- accel/accel.c | 9 ++++++++- hw/core/qdev-properties.c | 21 --------------------- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 4f60cc88f3..a95f4a73eb 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -255,35 +255,6 @@ 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 -/** - * register_compat_prop: - * - * Register internal (not user-provided) global property, changing the - * default value of a given property in a device type. This can be used - * for enabling machine-type compatibility or for enabling - * accelerator-specific defaults in devices. - * - * The property values set using this function must be always valid and - * never report setter errors, as the property will have - * GlobalProperty::errp set to &error_abort. - * - * User-provided global properties should override internal global - * properties, so callers of this function should ensure that it is - * called before user-provided global properties are registered. - * - * @driver: Device type to be affected - * @property: Property whose default value is going to be changed - * @value: New default value for the property - */ -void register_compat_prop(const char *driver, const char *property, - const char *value); -/* - * register_compat_props_array(): using register_compat_prop(), which - * only registers internal global properties (which has lower priority - * than user-provided global properties) - */ -void register_compat_props_array(GlobalProperty *prop); - /** * qdev_property_add_static: * @dev: Device to add the property to. diff --git a/accel/accel.c b/accel/accel.c index 966b2d8f53..3da26eb90f 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -34,6 +34,7 @@ #include "qom/object.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qapi/error.h" =20 static const TypeInfo accel_type =3D { .name =3D TYPE_ACCEL, @@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms) void accel_register_compat_props(AccelState *accel) { AccelClass *class =3D ACCEL_GET_CLASS(accel); - register_compat_props_array(class->global_props); + GlobalProperty *prop =3D class->global_props; + + for (; prop && prop->driver; prop++) { + /* Any compat_props must never cause error */ + prop->errp =3D &error_abort; + qdev_prop_register_global(prop); + } } =20 void accel_setup_post(MachineState *ms) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 35072dec1e..ab61d502fd 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1180,27 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop) global_props =3D g_list_append(global_props, prop); } =20 -void register_compat_prop(const char *driver, - const char *property, - const char *value) -{ - GlobalProperty *p =3D g_new0(GlobalProperty, 1); - - /* Any compat_props must never cause error */ - p->errp =3D &error_abort; - p->driver =3D driver; - p->property =3D property; - p->value =3D value; - qdev_prop_register_global(p); -} - -void register_compat_props_array(GlobalProperty *prop) -{ - for (; prop && prop->driver; prop++) { - register_compat_prop(prop->driver, prop->property, prop->value); - } -} - void qdev_prop_register_global_list(GlobalProperty *props) { int i; --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594400479153.85621579843803; Wed, 7 Nov 2018 04:40:00 -0800 (PST) Received: from localhost ([::1]:47613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7n-0008CL-Cb for importer@patchew.org; Wed, 07 Nov 2018 07:39:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5l-0005KC-Fr for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5j-0006Zo-Ij for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:37:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52928) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5d-0006O7-6D; Wed, 07 Nov 2018 07:37:46 -0500 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 12292C0C49D1; Wed, 7 Nov 2018 12:37:43 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B234D730; Wed, 7 Nov 2018 12:37:41 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:43 +0400 Message-Id: <20181107123652.23417-6-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 07 Nov 2018 12:37:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The function is only used by a test, move it there. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eduardo Habkost Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-properties.h | 1 - hw/core/qdev-properties.c | 9 --------- tests/test-qdev-global-props.c | 18 ++++++++++++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index a95f4a73eb..3ab9cd2eb6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *n= ame, int value); void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); =20 void qdev_prop_register_global(GlobalProperty *prop); -void qdev_prop_register_global_list(GlobalProperty *props); int qdev_prop_check_globals(void); void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *de= v, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ab61d502fd..bd84c4ea4c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop) global_props =3D g_list_append(global_props, prop); } =20 -void qdev_prop_register_global_list(GlobalProperty *props) -{ - int i; - - for (i =3D 0; props[i].driver !=3D NULL; i++) { - qdev_prop_register_global(props+i); - } -} - int qdev_prop_check_globals(void) { GList *l; diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index ccdf6c57c1..b1eb505442 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -89,6 +89,16 @@ static void test_static_prop(void) g_test_trap_assert_stdout(""); } =20 +static void register_global_properties(GlobalProperty *props) +{ + int i; + + for (i =3D 0; props[i].driver !=3D NULL; i++) { + qdev_prop_register_global(props + i); + } +} + + /* Test setting of static property using global properties */ static void test_static_globalprop_subprocess(void) { @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void) {} }; =20 - qdev_prop_register_global_list(props); + register_global_properties(props); =20 mt =3D STATIC_TYPE(object_new(TYPE_STATIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void) }; int global_error; =20 - qdev_prop_register_global_list(props); + register_global_properties(props); =20 mt =3D DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(v= oid) }; int global_error; =20 - qdev_prop_register_global_list(props); + register_global_properties(props); =20 mt =3D DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -299,7 +309,7 @@ static void test_subclass_global_props(void) {} }; =20 - qdev_prop_register_global_list(props); + register_global_properties(props); =20 mt =3D STATIC_TYPE(object_new(TYPE_SUBCLASS)); qdev_init_nofail(DEVICE(mt)); --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594781632497.7531752777048; Wed, 7 Nov 2018 04:46:21 -0800 (PST) Received: from localhost ([::1]:47671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNDw-0007Qf-DT for importer@patchew.org; Wed, 07 Nov 2018 07:46:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN5t-0005vV-Gw for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN5s-0006fa-5i for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39086) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5n-0006bX-GE; Wed, 07 Nov 2018 07:37:55 -0500 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 7CE9E30B7DF5; Wed, 7 Nov 2018 12:37:54 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCF4F18E3D; Wed, 7 Nov 2018 12:37:46 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:44 +0400 Message-Id: <20181107123652.23417-7-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.48]); Wed, 07 Nov 2018 12:37:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Machine & Accel props are not provided by user. Let's not mix them with the global properties. Call a new helper function object_apply_global_props() during device_post_init(). Add a stub for current_machine, so qemu-user and tests can find a fallback symbol when linking with QDev. The following patches is going to reuse object_apply_global_props() for qdev globals. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/boards.h | 1 - include/qom/object.h | 2 ++ include/sysemu/accel.h | 4 +--- accel/accel.c | 12 ------------ hw/core/machine.c | 18 ------------------ hw/core/qdev.c | 8 ++++++++ hw/xen/xen-common.c | 9 ++++++++- qom/object.c | 25 +++++++++++++++++++++++++ stubs/machine.c | 4 ++++ tests/test-qdev-global-props.c | 1 - vl.c | 2 -- stubs/Makefile.objs | 1 + 12 files changed, 49 insertions(+), 38 deletions(-) create mode 100644 stubs/machine.c diff --git a/include/hw/boards.h b/include/hw/boards.h index f82f28468b..c02190fc52 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); -void machine_register_compat_props(MachineState *machine); HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, diff --git a/include/qom/object.h b/include/qom/object.h index f0b0bf39cc..e58eeb280f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -679,6 +679,8 @@ Object *object_new_with_propv(const char *typename, Error **errp, va_list vargs); =20 +void object_apply_global_props(Object *obj, GArray *props, Error **errp); + /** * object_set_props: * @obj: the object instance to set properties on diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 637358f430..f4f71134b5 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -49,7 +49,7 @@ typedef struct AccelClass { * global properties may be overridden by machine-type * compat_props or user-provided global properties. */ - GlobalProperty *global_props; + GArray *compat_props; } AccelClass; =20 #define TYPE_ACCEL "accel" @@ -67,8 +67,6 @@ typedef struct AccelClass { extern unsigned long tcg_tb_size; =20 void configure_accelerator(MachineState *ms); -/* Register accelerator specific global properties */ -void accel_register_compat_props(AccelState *accel); /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); =20 diff --git a/accel/accel.c b/accel/accel.c index 3da26eb90f..6db5d8f4df 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms) } } =20 -void accel_register_compat_props(AccelState *accel) -{ - AccelClass *class =3D ACCEL_GET_CLASS(accel); - GlobalProperty *prop =3D class->global_props; - - for (; prop && prop->driver; prop++) { - /* Any compat_props must never cause error */ - prop->errp =3D &error_abort; - qdev_prop_register_global(prop); - } -} - void accel_setup_post(MachineState *ms) { AccelState *accel =3D ms->accelerator; diff --git a/hw/core/machine.c b/hw/core/machine.c index da50ad6de7..4444d45945 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -844,24 +844,6 @@ static void machine_class_finalize(ObjectClass *klass,= void *data) g_free(mc->name); } =20 -void machine_register_compat_props(MachineState *machine) -{ - MachineClass *mc =3D MACHINE_GET_CLASS(machine); - int i; - GlobalProperty *p; - - if (!mc->compat_props) { - return; - } - - for (i =3D 0; i < mc->compat_props->len; i++) { - p =3D g_array_index(mc->compat_props, GlobalProperty *, i); - /* Machine compat_props must never cause errors: */ - p->errp =3D &error_abort; - qdev_prop_register_global(p); - } -} - static const TypeInfo machine_info =3D { .name =3D TYPE_MACHINE, .parent =3D TYPE_OBJECT, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6b3cc55b27..30890f2c8d 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -972,6 +972,14 @@ static void device_initfn(Object *obj) =20 static void device_post_init(Object *obj) { + if (current_machine) { + MachineClass *mc =3D MACHINE_GET_CLASS(current_machine); + AccelClass *ac =3D ACCEL_GET_CLASS(current_machine->accelerator); + + object_apply_global_props(obj, mc->compat_props, &error_abort); + object_apply_global_props(obj, ac->compat_props, &error_abort); + } + qdev_prop_set_globals(DEVICE(obj)); } =20 diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index 6ec14c73ca..d1ef7a53cc 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -181,11 +181,18 @@ static GlobalProperty xen_compat_props[] =3D { static void xen_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); + int i; + ac->name =3D "Xen"; ac->init_machine =3D xen_init; ac->setup_post =3D xen_setup_post; ac->allowed =3D &xen_allowed; - ac->global_props =3D xen_compat_props; + + ac->compat_props =3D g_array_new(false, false, sizeof(void *)); + for (i =3D 0; xen_compat_props[i].driver !=3D NULL; i++) { + GlobalProperty *prop =3D &xen_compat_props[i]; + g_array_append_val(ac->compat_props, prop); + } } =20 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") diff --git a/qom/object.c b/qom/object.c index eb770dbf7f..9acdf9e16d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -372,6 +372,31 @@ static void object_post_init_with_type(Object *obj, Ty= peImpl *ti) } } =20 +void object_apply_global_props(Object *obj, GArray *props, Error **errp) +{ + Error *err =3D NULL; + int i; + + if (!props) { + return; + } + + for (i =3D 0; i < props->len; i++) { + GlobalProperty *p =3D g_array_index(props, GlobalProperty *, i); + + if (object_dynamic_cast(obj, p->driver) =3D=3D NULL) { + continue; + } + p->used =3D true; + object_property_parse(obj, p->value, p->property, &err); + if (err !=3D NULL) { + error_prepend(&err, "can't apply global %s.%s=3D%s: ", + p->driver, p->property, p->value); + error_propagate(errp, err); + } + } +} + static void object_initialize_with_type(void *data, size_t size, TypeImpl = *type) { Object *obj =3D data; diff --git a/stubs/machine.c b/stubs/machine.c new file mode 100644 index 0000000000..51d40fd677 --- /dev/null +++ b/stubs/machine.c @@ -0,0 +1,4 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" + +MachineClass *current_machine; diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index b1eb505442..3a8d3170a0 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -28,7 +28,6 @@ #include "qom/object.h" #include "qapi/visitor.h" =20 - #define TYPE_STATIC_PROPS "static_prop_type" #define STATIC_TYPE(obj) \ OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS) diff --git a/vl.c b/vl.c index 55bab005b6..2aea884c9d 100644 --- a/vl.c +++ b/vl.c @@ -2963,8 +2963,6 @@ static void user_register_global_props(void) */ static void register_global_properties(MachineState *ms) { - accel_register_compat_props(ms->accelerator); - machine_register_compat_props(ms); user_register_global_props(); } =20 diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 5dd0aeeec6..6ce33ae46f 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -18,6 +18,7 @@ stub-obj-y +=3D iothread-lock.o stub-obj-y +=3D is-daemonized.o stub-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o stub-obj-y +=3D machine-init-done.o +stub-obj-y +=3D machine.o stub-obj-y +=3D migr-blocker.o stub-obj-y +=3D change-state-handler.o stub-obj-y +=3D monitor.o --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154159475437298.00173065219053; Wed, 7 Nov 2018 04:45:54 -0800 (PST) Received: from localhost ([::1]:47664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNDV-000705-3r for importer@patchew.org; Wed, 07 Nov 2018 07:45:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN62-0006Rs-0R for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN61-0006jU-0P for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43968) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN5y-0006id-Mr; Wed, 07 Nov 2018 07:38:06 -0500 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 D968E30D4DA0; Wed, 7 Nov 2018 12:38:05 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 897D14D730; Wed, 7 Nov 2018 12:37:58 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:45 +0400 Message-Id: <20181107123652.23417-8-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.42]); Wed, 07 Nov 2018 12:38:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Considering that CPU features are provided via command line, the global_props are now all user-provided globals. No need to track this anymore for qdev_prop_check_globals(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 3 -- hw/core/qdev-properties.c | 4 --- tests/test-qdev-global-props.c | 57 ++++------------------------------ vl.c | 1 - 4 files changed, 6 insertions(+), 59 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index a24d0dd566..baaf097212 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -249,8 +249,6 @@ struct PropertyInfo { =20 /** * GlobalProperty: - * @user_provided: Set to true if property comes from user-provided config - * (command-line or config file). * @used: Set to true if property was used when initializing a device. * @errp: Error destination, used like first argument of error_setg() * in case property setting fails later. If @errp is NULL, we @@ -262,7 +260,6 @@ typedef struct GlobalProperty { const char *driver; const char *property; const char *value; - bool user_provided; bool used; Error **errp; } GlobalProperty; diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index bd84c4ea4c..43c30a57f4 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1192,9 +1192,6 @@ int qdev_prop_check_globals(void) if (prop->used) { continue; } - if (!prop->user_provided) { - continue; - } oc =3D object_class_by_name(prop->driver); oc =3D object_class_dynamic_cast(oc, TYPE_DEVICE); if (!oc) { @@ -1233,7 +1230,6 @@ void qdev_prop_set_globals(DeviceState *dev) if (!dev->hotplugged && prop->errp) { error_propagate(prop->errp, err); } else { - assert(prop->user_provided); warn_report_err(err); } } diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index 3a8d3170a0..f49a1b70b5 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -215,12 +215,12 @@ static void test_dynamic_globalprop_subprocess(void) { MyType *mt; static GlobalProperty props[] =3D { - { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, - { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, - { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, - { TYPE_UNUSED_HOTPLUG, "prop4", "104", true }, - { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, - { TYPE_NONDEVICE, "prop6", "106", true }, + { TYPE_DYNAMIC_PROPS, "prop1", "101", }, + { TYPE_DYNAMIC_PROPS, "prop2", "102", }, + { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", }, + { TYPE_UNUSED_HOTPLUG, "prop4", "104", }, + { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", }, + { TYPE_NONDEVICE, "prop6", "106", }, {} }; int global_error; @@ -255,46 +255,6 @@ static void test_dynamic_globalprop(void) g_test_trap_assert_stdout(""); } =20 -/* Test setting of dynamic properties using user_provided=3Dfalse properti= es */ -static void test_dynamic_globalprop_nouser_subprocess(void) -{ - MyType *mt; - static GlobalProperty props[] =3D { - { TYPE_DYNAMIC_PROPS, "prop1", "101" }, - { TYPE_DYNAMIC_PROPS, "prop2", "102" }, - { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" }, - { TYPE_UNUSED_HOTPLUG, "prop4", "104" }, - { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" }, - { TYPE_NONDEVICE, "prop6", "106" }, - {} - }; - int global_error; - - register_global_properties(props); - - mt =3D DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); - qdev_init_nofail(DEVICE(mt)); - - g_assert_cmpuint(mt->prop1, =3D=3D, 101); - g_assert_cmpuint(mt->prop2, =3D=3D, 102); - global_error =3D qdev_prop_check_globals(); - g_assert_cmpuint(global_error, =3D=3D, 0); - g_assert(props[0].used); - g_assert(props[1].used); - g_assert(!props[2].used); - g_assert(!props[3].used); - g_assert(!props[4].used); - g_assert(!props[5].used); -} - -static void test_dynamic_globalprop_nouser(void) -{ - g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subproc= ess", 0, 0); - g_test_trap_assert_passed(); - g_test_trap_assert_stderr(""); - g_test_trap_assert_stdout(""); -} - /* Test if global props affecting subclasses are applied in the right orde= r */ static void test_subclass_global_props(void) { @@ -344,11 +304,6 @@ int main(int argc, char **argv) g_test_add_func("/qdev/properties/dynamic/global", test_dynamic_globalprop); =20 - g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess", - test_dynamic_globalprop_nouser_subprocess); - g_test_add_func("/qdev/properties/dynamic/global/nouser", - test_dynamic_globalprop_nouser); - g_test_add_func("/qdev/properties/global/subclass", test_subclass_global_props); =20 diff --git a/vl.c b/vl.c index 2aea884c9d..d11b070e70 100644 --- a/vl.c +++ b/vl.c @@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *o= pts, Error **errp) g->driver =3D qemu_opt_get(opts, "driver"); g->property =3D qemu_opt_get(opts, "property"); g->value =3D qemu_opt_get(opts, "value"); - g->user_provided =3D true; g->errp =3D &error_fatal; qdev_prop_register_global(g); return 0; --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594915295196.76128904086897; Wed, 7 Nov 2018 04:48:35 -0800 (PST) Received: from localhost ([::1]:47685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNG1-0001dh-4m for importer@patchew.org; Wed, 07 Nov 2018 07:48:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN6j-0007hE-Rt for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN6f-00074j-Ov for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:38:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN6K-0006lP-KI; Wed, 07 Nov 2018 07:38:29 -0500 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 4DD7730D4DAA; Wed, 7 Nov 2018 12:38:14 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77BCE6012D; Wed, 7 Nov 2018 12:38:09 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:46 +0400 Message-Id: <20181107123652.23417-9-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.42]); Wed, 07 Nov 2018 12:38:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A step towards being able to call object_apply_global_props(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/core/qdev-properties.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 43c30a57f4..353e67c05a 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char= *name, void *value) *ptr =3D value; } =20 -static GList *global_props; +static GArray *global_props(void) +{ + static GArray *gp; + + if (!gp) { + gp =3D g_array_new(false, false, sizeof(GlobalProperty *)); + } + + return gp; +} =20 void qdev_prop_register_global(GlobalProperty *prop) { - global_props =3D g_list_append(global_props, prop); + g_array_append_val(global_props(), prop); } =20 int qdev_prop_check_globals(void) { - GList *l; - int ret =3D 0; + int i, ret =3D 0; =20 - for (l =3D global_props; l; l =3D l->next) { - GlobalProperty *prop =3D l->data; + for (i =3D 0; i < global_props()->len; i++) { + GlobalProperty *prop; ObjectClass *oc; DeviceClass *dc; + + prop =3D g_array_index(global_props(), GlobalProperty *, i); if (prop->used) { continue; } @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void) =20 void qdev_prop_set_globals(DeviceState *dev) { - GList *l; + int i; =20 - for (l =3D global_props; l; l =3D l->next) { - GlobalProperty *prop =3D l->data; + for (i =3D 0; i < global_props()->len; i++) { + GlobalProperty *prop; Error *err =3D NULL; =20 + prop =3D g_array_index(global_props(), GlobalProperty *, i); if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { continue; } --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594642785950.5706733508931; Wed, 7 Nov 2018 04:44:02 -0800 (PST) Received: from localhost ([::1]:47648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNBh-0004pB-NS for importer@patchew.org; Wed, 07 Nov 2018 07:44:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN6t-0007qQ-QD for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN6p-00079K-9u for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN6Z-0006qH-DZ; Wed, 07 Nov 2018 07:38:47 -0500 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 9C62431F40F; Wed, 7 Nov 2018 12:38:19 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CB0560196; Wed, 7 Nov 2018 12:38:17 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:47 +0400 Message-Id: <20181107123652.23417-10-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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]); Wed, 07 Nov 2018 12:38:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" All qdev_prop_register_global() set &error_fatal for errp, except '-rtc driftfix=3Dslew', which arguably should also use &error_fatal, as otherwise failing to apply the property would only report a warning. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 6 ------ hw/core/qdev-properties.c | 4 ++-- qom/cpu.c | 1 - target/i386/cpu.c | 1 - target/sparc/cpu.c | 1 - vl.c | 1 - 6 files changed, 2 insertions(+), 12 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index baaf097212..3a45889c34 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -250,18 +250,12 @@ struct PropertyInfo { /** * GlobalProperty: * @used: Set to true if property was used when initializing a device. - * @errp: Error destination, used like first argument of error_setg() - * in case property setting fails later. If @errp is NULL, we - * print warnings instead of ignoring errors silently. For - * hotplugged devices, errp is always ignored and warnings are - * printed instead. */ typedef struct GlobalProperty { const char *driver; const char *property; const char *value; bool used; - Error **errp; } GlobalProperty; =20 /*** Board API. This should go away once we have a machine config file. = ***/ diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 353e67c05a..8728cbab9f 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1238,8 +1238,8 @@ void qdev_prop_set_globals(DeviceState *dev) if (err !=3D NULL) { error_prepend(&err, "can't apply global %s.%s=3D%s: ", prop->driver, prop->property, prop->value); - if (!dev->hotplugged && prop->errp) { - error_propagate(prop->errp, err); + if (!dev->hotplugged) { + error_propagate(&error_fatal, err); } else { warn_report_err(err); } diff --git a/qom/cpu.c b/qom/cpu.c index 9ad1372d57..5442a7323b 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -312,7 +312,6 @@ static void cpu_common_parse_features(const char *typen= ame, char *features, prop->driver =3D typename; prop->property =3D g_strdup(featurestr); prop->value =3D g_strdup(val); - prop->errp =3D &error_fatal; qdev_prop_register_global(prop); } else { error_setg(errp, "Expected key=3Dvalue format, found %s.", diff --git a/target/i386/cpu.c b/target/i386/cpu.c index af7e9f09cc..1d2dba671e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *type= name, char *features, prop->driver =3D typename; prop->property =3D g_strdup(name); prop->value =3D g_strdup(val); - prop->errp =3D &error_fatal; qdev_prop_register_global(prop); } =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 0f090ece54..4a4445bdf5 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -111,7 +111,6 @@ cpu_add_feat_as_prop(const char *typename, const char *= name, const char *val) prop->driver =3D typename; prop->property =3D g_strdup(name); prop->value =3D g_strdup(val); - prop->errp =3D &error_fatal; qdev_prop_register_global(prop); } =20 diff --git a/vl.c b/vl.c index d11b070e70..8ee6f7a688 100644 --- a/vl.c +++ b/vl.c @@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *o= pts, Error **errp) g->driver =3D qemu_opt_get(opts, "driver"); g->property =3D qemu_opt_get(opts, "property"); g->value =3D qemu_opt_get(opts, "value"); - g->errp =3D &error_fatal; qdev_prop_register_global(g); return 0; } --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541595099818672.3235180059951; Wed, 7 Nov 2018 04:51:39 -0800 (PST) Received: from localhost ([::1]:47713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNJ4-0004p5-KV for importer@patchew.org; Wed, 07 Nov 2018 07:51:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7F-0008Ag-8Q for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN79-0007QB-VN for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN6z-0006rP-JB; Wed, 07 Nov 2018 07:39:09 -0500 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 D82F630C914D; Wed, 7 Nov 2018 12:38:28 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72D1A60BEE; Wed, 7 Nov 2018 12:38:23 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:48 +0400 Message-Id: <20181107123652.23417-11-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.43]); Wed, 07 Nov 2018 12:38:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It's now possible to use the common function. Teach object_apply_global_props() to warn if Error argument is NULL. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/core/qdev-properties.c | 24 ++---------------------- qom/object.c | 6 +++++- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 8728cbab9f..239535a4cb 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void) =20 void qdev_prop_set_globals(DeviceState *dev) { - int i; - - for (i =3D 0; i < global_props()->len; i++) { - GlobalProperty *prop; - Error *err =3D NULL; - - prop =3D g_array_index(global_props(), GlobalProperty *, i); - if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { - continue; - } - prop->used =3D true; - object_property_parse(OBJECT(dev), prop->value, prop->property, &e= rr); - if (err !=3D NULL) { - error_prepend(&err, "can't apply global %s.%s=3D%s: ", - prop->driver, prop->property, prop->value); - if (!dev->hotplugged) { - error_propagate(&error_fatal, err); - } else { - warn_report_err(err); - } - } - } + object_apply_global_props(OBJECT(dev), global_props(), + dev->hotplugged ? NULL : &error_fatal); } =20 /* --- 64bit unsigned int 'size' type --- */ diff --git a/qom/object.c b/qom/object.c index 9acdf9e16d..b1a7f70550 100644 --- a/qom/object.c +++ b/qom/object.c @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *pr= ops, Error **errp) if (err !=3D NULL) { error_prepend(&err, "can't apply global %s.%s=3D%s: ", p->driver, p->property, p->value); - error_propagate(errp, err); + if (errp) { + error_propagate(errp, err); + } else { + warn_report_err(err); + } } } } --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541594944814685.0111461747786; Wed, 7 Nov 2018 04:49:04 -0800 (PST) Received: from localhost ([::1]:47691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNGZ-0003CR-Pw for importer@patchew.org; Wed, 07 Nov 2018 07:49:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7D-00088m-6Z for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN74-0007Nz-2y for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN6x-000713-4i; Wed, 07 Nov 2018 07:39:08 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 775F930B7DE6; Wed, 7 Nov 2018 12:38:40 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 245F126328; Wed, 7 Nov 2018 12:38:32 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:49 +0400 Message-Id: <20181107123652.23417-12-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 07 Nov 2018 12:38:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The following patches are going to implement post_init callbacks for settings properties. The interface post_init are called before the instance post_init, so the default interface behaviour can be overriden if necessary. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qom/object.c | 8 +++++++- tests/check-qom-interface.c | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index b1a7f70550..980eeb8283 100644 --- a/qom/object.c +++ b/qom/object.c @@ -290,7 +290,6 @@ static void type_initialize(TypeImpl *ti) assert(ti->instance_size =3D=3D 0); assert(ti->abstract); assert(!ti->instance_init); - assert(!ti->instance_post_init); assert(!ti->instance_finalize); assert(!ti->num_interfaces); } @@ -363,6 +362,13 @@ static void object_init_with_type(Object *obj, TypeImp= l *ti) =20 static void object_post_init_with_type(Object *obj, TypeImpl *ti) { + GSList *e; + + for (e =3D ti->class->interfaces; e; e =3D e->next) { + TypeImpl *itype =3D OBJECT_CLASS(e->data)->type; + object_post_init_with_type(obj, itype); + } + if (ti->instance_post_init) { ti->instance_post_init(obj); } diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c index 2177f0dce5..cd2dd6dcee 100644 --- a/tests/check-qom-interface.c +++ b/tests/check-qom-interface.c @@ -31,9 +31,27 @@ typedef struct TestIfClass { uint32_t test; } TestIfClass; =20 +typedef struct DirectImpl { + Object parent_obj; + + bool if_post_init; +} DirectImpl; + +#define TYPE_DIRECT_IMPL "direct-impl" +#define DIRECT_IMPL(obj) \ + OBJECT_CHECK(DirectImpl, (obj), TYPE_DIRECT_IMPL) + +static void test_if_post_init(Object *obj) +{ + DirectImpl *d =3D DIRECT_IMPL(obj); + + d->if_post_init =3D true; +} + static const TypeInfo test_if_info =3D { .name =3D TYPE_TEST_IF, .parent =3D TYPE_INTERFACE, + .instance_post_init =3D test_if_post_init, .class_size =3D sizeof(TestIfClass), }; =20 @@ -47,11 +65,10 @@ static void test_class_init(ObjectClass *oc, void *data) tc->test =3D PATTERN; } =20 -#define TYPE_DIRECT_IMPL "direct-impl" - static const TypeInfo direct_impl_info =3D { .name =3D TYPE_DIRECT_IMPL, .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(DirectImpl), .class_init =3D test_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_TEST_IF }, @@ -70,10 +87,12 @@ static void test_interface_impl(const char *type) { Object *obj =3D object_new(type); TestIf *iobj =3D TEST_IF(obj); + DirectImpl *d =3D DIRECT_IMPL(obj); TestIfClass *ioc =3D TEST_IF_GET_CLASS(iobj); =20 g_assert(iobj); g_assert(ioc->test =3D=3D PATTERN); + g_assert(d->if_post_init =3D=3D true); object_unref(obj); } =20 --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541595203541276.7141173415648; Wed, 7 Nov 2018 04:53:23 -0800 (PST) Received: from localhost ([::1]:47730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNKk-00080j-6J for importer@patchew.org; Wed, 07 Nov 2018 07:53:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7S-0008N7-Nj for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN7F-0007WV-0C for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN70-00075y-6j; Wed, 07 Nov 2018 07:39:10 -0500 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 9182D30084CB; Wed, 7 Nov 2018 12:38:51 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 375C060F89; Wed, 7 Nov 2018 12:38:43 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:50 +0400 Message-Id: <20181107123652.23417-13-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.40]); Wed, 07 Nov 2018 12:38:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 12/14] machine: add compat-props interface 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's make compatiblity properties an interface, so that objects other than QDev can benefit from having machine compatiblity properties. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/boards.h | 2 ++ hw/core/compat-props.c | 43 ++++++++++++++++++++++++++++++++++++++++++ hw/core/qdev.c | 12 ++++-------- MAINTAINERS | 1 + hw/core/Makefile.objs | 1 + tests/Makefile.include | 1 + 6 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 hw/core/compat-props.c diff --git a/include/hw/boards.h b/include/hw/boards.h index c02190fc52..e09cbe70a4 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -9,6 +9,8 @@ #include "qom/object.h" #include "qom/cpu.h" =20 +#define TYPE_COMPAT_PROPS "compat-props" + /** * memory_region_allocate_system_memory - Allocate a board's main memory * @mr: the #MemoryRegion to be initialized diff --git a/hw/core/compat-props.c b/hw/core/compat-props.c new file mode 100644 index 0000000000..1edeadb6a3 --- /dev/null +++ b/hw/core/compat-props.c @@ -0,0 +1,43 @@ +/* + * QEMU Machine compat properties + * + * Copyright (C) 2018 Red Hat Inc + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "qapi/error.h" + +typedef struct CompatProps CompatProps; + +typedef struct CompatPropsClass { + InterfaceClass parent_class; +} CompatPropsClass; + +static void compat_props_post_init(Object *obj) +{ + if (current_machine) { + MachineClass *mc =3D MACHINE_GET_CLASS(current_machine); + AccelClass *ac =3D ACCEL_GET_CLASS(current_machine->accelerator); + + object_apply_global_props(obj, mc->compat_props, &error_abort); + object_apply_global_props(obj, ac->compat_props, &error_abort); + } +} + +static void compat_props_register_types(void) +{ + static const TypeInfo cp_interface_info =3D { + .name =3D TYPE_COMPAT_PROPS, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(CompatPropsClass), + .instance_post_init =3D compat_props_post_init, + }; + + type_register_static(&cp_interface_info); +} + +type_init(compat_props_register_types) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 30890f2c8d..b0ee05f837 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -972,14 +972,6 @@ static void device_initfn(Object *obj) =20 static void device_post_init(Object *obj) { - if (current_machine) { - MachineClass *mc =3D MACHINE_GET_CLASS(current_machine); - AccelClass *ac =3D ACCEL_GET_CLASS(current_machine->accelerator); - - object_apply_global_props(obj, mc->compat_props, &error_abort); - object_apply_global_props(obj, ac->compat_props, &error_abort); - } - qdev_prop_set_globals(DEVICE(obj)); } =20 @@ -1112,6 +1104,10 @@ static const TypeInfo device_type_info =3D { .class_init =3D device_class_init, .abstract =3D true, .class_size =3D sizeof(DeviceClass), + .interfaces =3D (InterfaceInfo[]) { + { TYPE_COMPAT_PROPS }, + { } + } }; =20 static void qdev_register_types(void) diff --git a/MAINTAINERS b/MAINTAINERS index 0499e11593..60af287386 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1024,6 +1024,7 @@ Machine core M: Eduardo Habkost M: Marcel Apfelbaum S: Supported +F: hw/core/compat-props.c F: hw/core/machine.c F: hw/core/null-machine.c F: include/hw/boards.h diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index a799c83815..f15b3c970a 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -1,5 +1,6 @@ # core qdev-related obj files, also used by *-user: common-obj-y +=3D qdev.o qdev-properties.o +common-obj-y +=3D compat-props.o common-obj-y +=3D bus.o reset.o common-obj-$(CONFIG_SOFTMMU) +=3D qdev-fw.o common-obj-$(CONFIG_SOFTMMU) +=3D fw-path-provider.o diff --git a/tests/Makefile.include b/tests/Makefile.include index 074eece558..4bfde2e7b0 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -565,6 +565,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-= global-props.o \ hw/core/irq.o \ hw/core/fw-path-provider.o \ hw/core/reset.o \ + hw/core/compat-props.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541595089892622.5705549790302; Wed, 7 Nov 2018 04:51:29 -0800 (PST) Received: from localhost ([::1]:47712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNIm-0004de-7t for importer@patchew.org; Wed, 07 Nov 2018 07:51:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7F-0008Aj-8l for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN79-0007Q7-VJ for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN6z-0007AF-0Z; Wed, 07 Nov 2018 07:39:09 -0500 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 443BDC0C7CA2; Wed, 7 Nov 2018 12:39:00 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BBB15D75C; Wed, 7 Nov 2018 12:38:54 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:51 +0400 Message-Id: <20181107123652.23417-14-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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, 07 Nov 2018 12:39:00 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The following patch is going to add compatiblity parameters for qemu <=3D 3.1. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/compat.h | 3 +++ include/hw/i386/pc.h | 3 +++ hw/i386/pc_piix.c | 21 ++++++++++++++++++--- hw/i386/pc_q35.c | 19 +++++++++++++++++-- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 6f4d5fc647..70958328fe 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -1,6 +1,9 @@ #ifndef HW_COMPAT_H #define HW_COMPAT_H =20 +#define HW_COMPAT_3_1 \ + /* empty */ + #define HW_COMPAT_3_0 \ /* empty */ =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 136fe497b6..c37d4333a0 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -294,6 +294,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); int e820_get_num_entries(void); bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); =20 +#define PC_COMPAT_3_1 \ + HW_COMPAT_3_1 + #define PC_COMPAT_3_0 \ HW_COMPAT_3_0 \ {\ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index dc09466b3e..ba371bfcd7 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -428,21 +428,36 @@ static void pc_i440fx_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); } =20 -static void pc_i440fx_3_0_machine_options(MachineClass *m) +static void pc_i440fx_3_2_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D 1; } =20 +DEFINE_I440FX_MACHINE(v3_2, "pc-i440fx-3.2", NULL, + pc_i440fx_3_2_machine_options); + +static void pc_i440fx_3_1_machine_options(MachineClass *m) +{ + pc_i440fx_3_2_machine_options(m); + m->is_default =3D 0; + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_3_1); +} + +static void pc_i440fx_3_0_machine_options(MachineClass *m) +{ + pc_i440fx_3_1_machine_options(m); + SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); +} + DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, pc_i440fx_3_0_machine_options); =20 static void pc_i440fx_2_12_machine_options(MachineClass *m) { pc_i440fx_3_0_machine_options(m); - m->is_default =3D 0; - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 532241e3f8..64d6ea65d5 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -311,19 +311,34 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =3D 288; } =20 -static void pc_q35_3_0_machine_options(MachineClass *m) +static void pc_q35_3_2_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias =3D "q35"; } =20 +DEFINE_Q35_MACHINE(v3_2, "pc-q35-3.2", NULL, + pc_q35_3_2_machine_options); + +static void pc_q35_3_1_machine_options(MachineClass *m) +{ + pc_q35_3_2_machine_options(m); + m->alias =3D NULL; + SET_MACHINE_COMPAT(m, PC_COMPAT_3_1); +} + +static void pc_q35_3_0_machine_options(MachineClass *m) +{ + pc_q35_3_1_machine_options(m); + SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); +} + DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL, pc_q35_3_0_machine_options); =20 static void pc_q35_2_12_machine_options(MachineClass *m) { pc_q35_3_0_machine_options(m); - m->alias =3D NULL; SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); } =20 --=20 2.19.1.708.g4ede3d42df From nobody Mon Apr 29 22:00:49 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154159468761746.66344928483829; Wed, 7 Nov 2018 04:44:47 -0800 (PST) Received: from localhost ([::1]:47656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNCH-0005yX-Am for importer@patchew.org; Wed, 07 Nov 2018 07:44:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKN7b-00005N-I8 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKN7Y-0007lW-SN for qemu-devel@nongnu.org; Wed, 07 Nov 2018 07:39:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44172) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKN7A-0007NR-HA; Wed, 07 Nov 2018 07:39:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9156130D4DD9; Wed, 7 Nov 2018 12:39:11 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7E791054FD5; Wed, 7 Nov 2018 12:39:03 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 16:36:52 +0400 Message-Id: <20181107123652.23417-15-marcandre.lureau@redhat.com> In-Reply-To: <20181107123652.23417-1-marcandre.lureau@redhat.com> References: <20181107123652.23417-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 07 Nov 2018 12:39:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1 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: Peter Maydell , Stefano Stabellini , xen-devel@lists.xenproject.org, Corey Minyard , Amit Shah , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , "Michael S. Tsirkin" , Mark Cave-Ayland , dgilbert@redhat.com, Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Anthony Perard , Paolo Bonzini , Stefan Berger , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" hostmem-file and hostmem-memfd use the whole object path for the memory region name, and hostname-ram uses only the path component (the object id, or canonical path basename): qemu -m 1024 -object memory-backend-file,id=3Dmem,size=3D1G,mem-path=3D/tmp= /foo -numa node,memdev=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 qemu -m 1024 -object memory-backend-memfd,id=3Dmem,size=3D1G -numa node,mem= dev=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 qemu -m 1024 -object memory-backend-ram,id=3Dmem,size=3D1G -numa node,memde= v=3Dmem -monitor stdio (qemu) info ramblock Block Name PSize Offset Used = Total mem 4 KiB 0x0000000000000000 0x0000000040000000 0x= 0000000040000000 Use the object id for -file and -memfd with >=3D 3.1 for consistency. Having a consistent naming allow to migrate to different hostmem backends. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/compat.h | 10 +++++++++- include/sysemu/hostmem.h | 3 ++- backends/hostmem-file.c | 8 ++++---- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 9 ++++----- backends/hostmem.c | 31 +++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 70958328fe..99cf6b1e03 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -2,7 +2,15 @@ #define HW_COMPAT_H =20 #define HW_COMPAT_3_1 \ - /* empty */ + {\ + .driver =3D "memory-backend-file",\ + .property =3D "x-use-canonical-path-for-ramblock-id",\ + .value =3D "true",\ + },{\ + .driver =3D "memory-backend-memfd",\ + .property =3D "x-use-canonical-path-for-ramblock-id",\ + .value =3D "true",\ + }, =20 #define HW_COMPAT_3_0 \ /* empty */ diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 6e6bd2c1cb..a023b372a4 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -53,7 +53,7 @@ struct HostMemoryBackend { =20 /* protected */ uint64_t size; - bool merge, dump; + bool merge, dump, use_canonical_path; bool prealloc, force_prealloc, is_mapped, share; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; @@ -67,5 +67,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBa= ckend *backend); void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mappe= d); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); size_t host_memory_backend_pagesize(HostMemoryBackend *memdev); +char *host_memory_backend_get_name(HostMemoryBackend *backend); =20 #endif diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 639c8d4307..c01a7cdf8d 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -55,16 +55,16 @@ file_backend_memory_alloc(HostMemoryBackend *backend, E= rror **errp) error_setg(errp, "-mem-path not supported on this host"); #else if (!host_memory_backend_mr_inited(backend)) { - gchar *path; + gchar *name; backend->force_prealloc =3D mem_prealloc; - path =3D object_get_canonical_path(OBJECT(backend)); + name =3D host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), - path, + name, backend->size, fb->align, (backend->share ? RAM_SHARED : 0) | (fb->is_pmem ? RAM_PMEM : 0), fb->mem_path, errp); - g_free(path); + g_free(name); } #endif } diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index b6836b28e5..c5a4a9b530 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -57,7 +57,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) return; } =20 - name =3D object_get_canonical_path(OBJECT(backend)); + name =3D host_memory_backend_get_name(backend); memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, true, fd, errp); g_free(name); diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 7ddd08d370..24b65d9ae3 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,21 +16,20 @@ =20 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" =20 - static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { - char *path; + char *name; =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); return; } =20 - path =3D object_get_canonical_path_component(OBJECT(backend)); - memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend),= path, + name =3D host_memory_backend_get_name(backend); + memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend),= name, backend->size, backend->share, errp); - g_free(path); + g_free(name); } =20 static void diff --git a/backends/hostmem.c b/backends/hostmem.c index 1a89342039..35c665fca2 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND !=3D MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE !=3D MPOL_INTERLEAVE); #endif =20 +char * +host_memory_backend_get_name(HostMemoryBackend *self) +{ + if (!self->use_canonical_path) { + return object_get_canonical_path_component(OBJECT(self)); + } + + return object_get_canonical_path(OBJECT(self)); +} + static void host_memory_backend_get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -386,6 +396,23 @@ static void host_memory_backend_set_share(Object *o, b= ool value, Error **errp) backend->share =3D value; } =20 +static bool +host_memory_backend_get_use_canonical_path(Object *obj, Error **errp) +{ + HostMemoryBackend *self =3D MEMORY_BACKEND(obj); + + return self->use_canonical_path; +} + +static void +host_memory_backend_set_use_canonical_path(Object *obj, bool value, + Error **errp) +{ + HostMemoryBackend *self =3D MEMORY_BACKEND(obj); + + self->use_canonical_path =3D value; +} + static void host_memory_backend_class_init(ObjectClass *oc, void *data) { @@ -432,6 +459,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *d= ata) &error_abort); object_class_property_set_description(oc, "share", "Mark the memory as private to QEMU or shared", &error_abort); + object_class_property_add_bool(oc, "x-use-canonical-path-for-ramblock-= id", + host_memory_backend_get_use_canonical_path, + host_memory_backend_set_use_canonical_path, &error_abort); } =20 static const TypeInfo host_memory_backend_info =3D { @@ -444,6 +474,7 @@ static const TypeInfo host_memory_backend_info =3D { .instance_init =3D host_memory_backend_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, + { TYPE_COMPAT_PROPS }, { } } }; --=20 2.19.1.708.g4ede3d42df