All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
@ 2018-12-04 14:20 Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
                   ` (20 more replies)
  0 siblings, 21 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

Hi,

During "[PATCH v2 05/10] qom/globals: generalize
object_property_set_globals()" review, Eduardo suggested to rework the
GlobalProperty handling, so that -global is limited to QDev only and
we avoid mixing the machine compats and the user-provided -global
properties (instead of generalizing -global to various object kinds,
like I proposed in v2).

"qdev: do not mix compat props with global props" patch decouples a
bit user-provided -global from machine compat properties. This allows
to get rid of "user_provided" and "errp" fields in following patches.

Instead of explcitely calling object_apply_global_props() in the
various object post_init, I opted for creating a new TYPE_COMPAT_PROPS
interface. The interface approach gives a lot more flexibility on
which objects can have compat props. This requires some interface
improvments in "qom: teach interfaces to implement post-init".

A new compat property "x-use-canonical-path-for-ramblock-id" is added
to hostmem for legacy canonical path names, set to true for -file and
-memfd with qemu < 4.0.

(this series was initially titled "[PATCH v2 00/10] hostmem: use
object "id" for memory region name with >= 3.1", but its focus is more
in refactoring the global and compatilibity properties handling now)

v5:
- replace the SET_COMPAT macros, use normal function instead
  (suggested by Eduardo)
- replace the TYPE_COMPAT_PROPS interface approach for explicit
  object_apply_compat_props(), solving post-init ordering issues.
- get back to coupling compat properties with machine, in qdev
  (although there is still some discussion how to improve this, it
   can be changed later)
- mark the "arm: replace instance_post_init()" as RFC, since it is not
  longer required for this series
- change machines version from 3.2 to 4.0
- add some r-b tags

v4:
- fix accel/machine compat props apply order inversion
- split "qdev: do not mix compat props with global props": replace
  using current_machine by new compat_props global, introduce
  SET_COMPAT() macro, use GPtrArray.
- add a comment about "qdev-props: call object_apply_global_props()"
  error reporting
- add "arm: replace instance_post_init()", to solve the post-init
  ordering issue
- add "hw/arm/virt: add virt-3.2 machine type" for completeness
- commit message improvements
- rebased, add r-b tags

v3:
- GlobalProperties improvements/cleanups
- drop generalizing the -global idea
- "replace" the set_globals flag with a TYPE_COMPAT_PROPS interface
- update hw/i386 machine version to 3.2
- add "qom: make interface types abstract" interface cleanup

v2:
- replace "qom/user-creatable: add a few helper macros" patch for a
  more optimized "qom: make user_creatable_complete() specific to
  UserCreatable"
- rename register_global_list() to register_global_properties()
- call object_property_set_globals() after post-init
- add and use a ObjectClass.set_globals flag, instead of dynamically
  check object class in object_property_set_globals()
- use object "id" in >= 3.1 instead of canonical path, add compat
  property "x-use-canonical-path-for-ramblock-id" in base hostmem
  class.

Marc-André Lureau (19):
  tests: qdev_prop_check_globals() doesn't return "all_used"
  qom: make interface types abstract
  qom: make user_creatable_complete() specific to UserCreatable
  accel: register global_props like machine globals
  qdev: move qdev_prop_register_global_list() to tests
  qom: remove unimplemented class_finalize
  hw: apply accel compat properties without touching globals
  hw: apply machine compat properties without touching globals
  hw: remove SET_MACHINE_COMPAT
  qdev: make a separate helper function to apply compat properties
  qdev: all globals are now user-provided
  qdev-props: convert global_props to GPtrArray
  qdev-props: remove errp from GlobalProperty
  qdev-props: call object_apply_global_props()
  qom: add object_class_get_class_data()
  RFC: arm: replace instance_post_init()
  hw/i386: add pc-i440fx-4.0 & pc-q35-4.0
  hw/arm/virt: add virt-4.0 machine type
  hostmem: use object id for memory region name with >= 4.0

 include/hw/acpi/acpi_dev_interface.h |   6 +-
 include/hw/arm/linux-boot-if.h       |   5 +-
 include/hw/boards.h                  |  19 +-
 include/hw/compat.h                  |  11 +
 include/hw/fw-path-provider.h        |   4 +-
 include/hw/hotplug.h                 |   6 +-
 include/hw/i386/pc.h                 |   3 +
 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/qdev-core.h               |  21 +-
 include/hw/qdev-properties.h         |  30 --
 include/hw/stream.h                  |   4 +-
 include/hw/timer/m48t59.h            |   4 +-
 include/qom/object.h                 |  19 +-
 include/qom/object_interfaces.h      |  10 +-
 include/sysemu/accel.h               |   4 +-
 include/sysemu/hostmem.h             |   3 +-
 include/sysemu/tpm.h                 |   4 +-
 target/arm/cpu.h                     |   2 +
 target/arm/idau.h                    |   4 +-
 accel/accel.c                        |   7 +-
 backends/hostmem-file.c              |   8 +-
 backends/hostmem-memfd.c             |   2 +-
 backends/hostmem-ram.c               |   9 +-
 backends/hostmem.c                   |  36 ++
 hw/arm/virt.c                        |  70 ++-
 hw/core/machine.c                    |  30 +-
 hw/core/qdev-properties.c            |  73 +---
 hw/core/qdev.c                       |  15 +
 hw/i386/pc_piix.c                    | 607 ++++++++++++++++-----------
 hw/i386/pc_q35.c                     |  88 +++-
 hw/misc/ivshmem.c                    |   2 +-
 hw/ppc/spapr.c                       | 209 +++++----
 hw/s390x/s390-virtio-ccw.c           | 220 +++++-----
 hw/virtio/virtio-rng.c               |   2 +-
 hw/xen/xen-common.c                  |   9 +-
 qom/cpu.c                            |   1 -
 qom/object.c                         |  54 ++-
 qom/object_interfaces.c              |  14 +-
 target/arm/cpu.c                     |  15 +-
 target/arm/cpu64.c                   |  11 +-
 target/i386/cpu.c                    |   1 -
 target/sparc/cpu.c                   |   1 -
 tests/check-qom-interface.c          |   4 +-
 tests/test-qdev-global-props.c       |  79 +---
 vl.c                                 |   4 -
 49 files changed, 963 insertions(+), 787 deletions(-)

-- 
2.20.0.rc1

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used"
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract Marc-André Lureau
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

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=105 not used
warning: global nondevice-type.prop6 has invalid class name

Clarify the function return value.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 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;
 
     qdev_prop_register_global_list(props);
 
@@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 1);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 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(void)
         { TYPE_NONDEVICE, "prop6", "106" },
         {}
     };
-    int all_used;
+    int global_error;
 
     qdev_prop_register_global_list(props);
 
@@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 0);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 0);
     g_assert(props[0].used);
     g_assert(props[1].used);
     g_assert(!props[2].used);
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 03/19] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Michael S. Tsirkin,
	Corey Minyard, Hervé Poussineau, Andreas Färber,
	Stefan Berger, Peter Maydell, open list:PReP, open list:ARM

Interfaces don't have instance, let's make the interface type really
abstract to avoid confusion.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 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_dev_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)
 
-
-typedef struct AcpiDeviceIf {
-    /* <private> */
-    Object Parent;
-} AcpiDeviceIf;
+typedef struct AcpiDeviceIf AcpiDeviceIf;
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
 
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)
 
-typedef struct ARMLinuxBootIf {
-    /*< private >*/
-    Object parent_obj;
-} ARMLinuxBootIf;
+typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 
 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)
 
-typedef struct FWPathProvider {
-    Object parent_obj;
-} FWPathProvider;
+typedef struct FWPathProvider FWPathProvider;
 
 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)
 
-
-typedef struct HotplugHandler {
-    /* <private> */
-    Object Parent;
-} HotplugHandler;
+typedef struct HotplugHandler HotplugHandler;
 
 /**
  * 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)
 
-typedef struct InterruptStatsProvider {
-    Object parent;
-} InterruptStatsProvider;
+typedef struct InterruptStatsProvider InterruptStatsProvider;
 
 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)
 
-typedef struct IPMIInterface {
-    Object parent;
-} IPMIInterface;
+typedef struct IPMIInterface IPMIInterface;
 
 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)
 
-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)
 
-typedef struct MemoryDeviceState {
-    Object parent_obj;
-} MemoryDeviceState;
+typedef struct MemoryDeviceState MemoryDeviceState;
 
 /**
  * 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)
 
-typedef struct NMIState {
-    Object parent_obj;
-} NMIState;
+typedef struct NMIState NMIState;
 
 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)
 
-typedef struct StreamSlave {
-    Object Parent;
-} StreamSlave;
+typedef struct StreamSlave StreamSlave;
 
 typedef void (*StreamCanPushNotifyFn)(void *opaque);
 
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)
 
-typedef struct Nvram {
-    Object parent;
-} Nvram;
+typedef struct Nvram Nvram;
 
 typedef struct NvramClass {
     InterfaceClass parent;
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.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)
 
-
-typedef struct UserCreatable {
-    /* <private> */
-    Object Parent;
-} UserCreatable;
+typedef struct UserCreatable UserCreatable;
 
 /**
  * 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)
 
-typedef struct TPMIf {
-    Object parent_obj;
-} TPMIf;
+typedef struct TPMIf TPMIf;
 
 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)
 
-typedef struct IDAUInterface {
-    Object parent;
-} IDAUInterface;
+typedef struct IDAUInterface IDAUInterface;
 
 #define IREGION_NOTVALID -1
 
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)
 
-typedef struct TestIf {
-    Object parent_obj;
-} TestIf;
+typedef struct TestIf TestIf;
 
 typedef struct TestIfClass {
     InterfaceClass parent_class;
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 03/19] qom: make user_creatable_complete() specific to UserCreatable
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 04/19] accel: register global_props like machine globals Marc-André Lureau
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Amit Shah,
	Michael S. Tsirkin, Andreas Färber

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é Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 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_interfaces.h
index 652a16d2ba..682ba1d9b0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -51,14 +51,14 @@ typedef struct UserCreatableClass {
 
 /**
  * user_creatable_complete:
- * @obj: the object whose complete() method is called if defined
+ * @uc: the user-creatable object whose complete() method is called if defined
  * @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);
 
 /**
  * user_creatable_can_be_deleted:
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index ecfd10a29a..8213659602 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -1280,7 +1280,7 @@ static void desugar_shm(IVShmemState *s)
     object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
                               &error_abort);
     object_unref(obj);
-    user_creatable_complete(obj, &error_abort);
+    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
     s->hostmem = MEMORY_BACKEND(obj);
 }
 
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 == NULL) {
         vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
 
-        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 = NULL;
     Object *obj;
+    UserCreatable *uc;
 
     object_initialize(childobj, size, type);
     obj = OBJECT(childobj);
@@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
         goto out;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (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 = NULL;
+    UserCreatable *uc;
 
     klass = object_class_by_name(typename);
     if (!klass) {
@@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
         goto error;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (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"
 
-void user_creatable_complete(Object *obj, Error **errp)
+void user_creatable_complete(UserCreatable *uc, Error **errp)
 {
+    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
 
-    UserCreatableClass *ucc;
-    UserCreatable *uc =
-        (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
-
-    if (!uc) {
-        return;
-    }
-
-    ucc = 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 char *id,
         goto out;
     }
 
-    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);
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 04/19] accel: register global_props like machine globals
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (2 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 03/19] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 05/19] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

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é Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 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 *dev,
                                     Property *prop, const char *value);
 
-/**
- * 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"
 
 static const TypeInfo accel_type = {
     .name = TYPE_ACCEL,
@@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms)
 void accel_register_compat_props(AccelState *accel)
 {
     AccelClass *class = ACCEL_GET_CLASS(accel);
-    register_compat_props_array(class->global_props);
+    GlobalProperty *prop = class->global_props;
+
+    for (; prop && prop->driver; prop++) {
+        /* Any compat_props must never cause error */
+        prop->errp = &error_abort;
+        qdev_prop_register_global(prop);
+    }
 }
 
 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 = g_list_append(global_props, prop);
 }
 
-void register_compat_prop(const char *driver,
-                          const char *property,
-                          const char *value)
-{
-    GlobalProperty *p = g_new0(GlobalProperty, 1);
-
-    /* Any compat_props must never cause error */
-    p->errp = &error_abort;
-    p->driver = driver;
-    p->property = property;
-    p->value = 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;
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 05/19] qdev: move qdev_prop_register_global_list() to tests
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (3 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 04/19] accel: register global_props like machine globals Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 06/19] qom: remove unimplemented class_finalize Marc-André Lureau
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Philippe Mathieu-Daudé

The function is only used by a test, move it there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 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 *name, int value);
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
 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 *dev,
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 = g_list_append(global_props, prop);
 }
 
-void qdev_prop_register_global_list(GlobalProperty *props)
-{
-    int i;
-
-    for (i = 0; props[i].driver != 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("");
 }
 
+static void register_global_properties(GlobalProperty *props)
+{
+    int i;
+
+    for (i = 0; props[i].driver != 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)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = 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;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
     };
     int global_error;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
     qdev_init_nofail(DEVICE(mt));
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 06/19] qom: remove unimplemented class_finalize
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (4 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 05/19] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20   ` Marc-André Lureau
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Marcel Apfelbaum,
	Andreas Färber

Instead of trying to implement something that isn't well specified,
remove it. (it would be tricky to implement, since a class struct is
memcpy on children types...)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qom/object.h |  7 ++-----
 hw/core/machine.c    | 11 -----------
 qom/object.c         |  2 --
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index f0b0bf39cc..0139838b69 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -455,10 +455,8 @@ struct Object
  *   parent class initialization has occurred, but before the class itself
  *   is initialized.  This is the function to use to undo the effects of
  *   memcpy from the parent class to the descendants.
- * @class_finalize: This function is called during class destruction and is
- *   meant to release and dynamic parameters allocated by @class_init.
- * @class_data: Data to pass to the @class_init, @class_base_init and
- *   @class_finalize functions.  This can be useful when building dynamic
+ * @class_data: Data to pass to the @class_init,
+ *   @class_base_init. This can be useful when building dynamic
  *   classes.
  * @interfaces: The list of interfaces associated with this type.  This
  *   should point to a static array that's terminated with a zero filled
@@ -479,7 +477,6 @@ struct TypeInfo
 
     void (*class_init)(ObjectClass *klass, void *data);
     void (*class_base_init)(ObjectClass *klass, void *data);
-    void (*class_finalize)(ObjectClass *klass, void *data);
     void *class_data;
 
     InterfaceInfo *interfaces;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index da50ad6de7..c51423b647 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -834,16 +834,6 @@ void machine_run_board_init(MachineState *machine)
     machine_class->init(machine);
 }
 
-static void machine_class_finalize(ObjectClass *klass, void *data)
-{
-    MachineClass *mc = MACHINE_CLASS(klass);
-
-    if (mc->compat_props) {
-        g_array_free(mc->compat_props, true);
-    }
-    g_free(mc->name);
-}
-
 void machine_register_compat_props(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -869,7 +859,6 @@ static const TypeInfo machine_info = {
     .class_size = sizeof(MachineClass),
     .class_init    = machine_class_init,
     .class_base_init = machine_class_base_init,
-    .class_finalize = machine_class_finalize,
     .instance_size = sizeof(MachineState),
     .instance_init = machine_initfn,
     .instance_finalize = machine_finalize,
diff --git a/qom/object.c b/qom/object.c
index eb770dbf7f..17921c0a71 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -49,7 +49,6 @@ struct TypeImpl
 
     void (*class_init)(ObjectClass *klass, void *data);
     void (*class_base_init)(ObjectClass *klass, void *data);
-    void (*class_finalize)(ObjectClass *klass, void *data);
 
     void *class_data;
 
@@ -114,7 +113,6 @@ static TypeImpl *type_new(const TypeInfo *info)
 
     ti->class_init = info->class_init;
     ti->class_base_init = info->class_base_init;
-    ti->class_finalize = info->class_finalize;
     ti->class_data = info->class_data;
 
     ti->instance_init = info->instance_init;
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
@ 2018-12-04 14:20   ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract Marc-André Lureau
                     ` (19 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Stefano Stabellini,
	Anthony Perard, Andreas Färber, Paolo Bonzini,
	open list:X86

Instead of registering compat properties as globals, let's keep them
in their own array, to avoid mixing with user globals.

Introduce object_apply_global_props() function, to apply compatibility
properties from a GPtrArray.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h | 10 ++++++++++
 include/qom/object.h   |  3 +++
 include/sysemu/accel.h |  4 +---
 accel/accel.c          | 12 ------------
 hw/core/qdev.c         |  9 +++++++++
 hw/xen/xen-common.c    |  9 ++++++---
 qom/object.c           | 25 +++++++++++++++++++++++++
 vl.c                   |  1 -
 8 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd566..aeaa6dbbb8 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -267,6 +267,16 @@ typedef struct GlobalProperty {
     Error **errp;
 } GlobalProperty;
 
+static inline void
+compat_props_add(GPtrArray *arr,
+                 GlobalProperty props[], size_t nelem)
+{
+    int i;
+    for (i = 0; i < nelem; i++) {
+        g_ptr_array_add(arr, (void *)&props[i]);
+    }
+}
+
 /*** Board API.  This should go away once we have a machine config file.  ***/
 
 DeviceState *qdev_create(BusState *bus, const char *name);
diff --git a/include/qom/object.h b/include/qom/object.h
index 0139838b69..5183c587f3 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -676,6 +676,9 @@ Object *object_new_with_propv(const char *typename,
                               Error **errp,
                               va_list vargs);
 
+void object_apply_global_props(Object *obj, const GPtrArray *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..f331d128e9 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;
+    GPtrArray *compat_props;
 } AccelClass;
 
 #define TYPE_ACCEL "accel"
@@ -67,8 +67,6 @@ typedef struct AccelClass {
 extern unsigned long tcg_tb_size;
 
 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);
 
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)
     }
 }
 
-void accel_register_compat_props(AccelState *accel)
-{
-    AccelClass *class = ACCEL_GET_CLASS(accel);
-    GlobalProperty *prop = class->global_props;
-
-    for (; prop && prop->driver; prop++) {
-        /* Any compat_props must never cause error */
-        prop->errp = &error_abort;
-        qdev_prop_register_global(prop);
-    }
-}
-
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..53b507164f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,6 +972,15 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
+    if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
+        MachineState *m = MACHINE(qdev_get_machine());
+        AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);
+
+        if (ac->compat_props) {
+            object_apply_global_props(obj, ac->compat_props, &error_abort);
+        }
+    }
+
     qdev_prop_set_globals(DEVICE(obj));
 }
 
diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index 6ec14c73ca..4532aa8632 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
         .driver = "migration",
         .property = "send-section-footer",
         .value = "off",
-    },
-    { /* end of list */ },
+    }
 };
 
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
+
     ac->name = "Xen";
     ac->init_machine = xen_init;
     ac->setup_post = xen_setup_post;
     ac->allowed = &xen_allowed;
-    ac->global_props = xen_compat_props;
+    ac->compat_props = g_ptr_array_new();
+
+    compat_props_add(ac->compat_props,
+                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
diff --git a/qom/object.c b/qom/object.c
index 17921c0a71..dbdab0aead 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
     }
 }
 
+void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
+{
+    Error *err = NULL;
+    int i;
+
+    if (!props) {
+        return;
+    }
+
+    for (i = 0; i < props->len; i++) {
+        GlobalProperty *p = g_ptr_array_index(props, i);
+
+        if (object_dynamic_cast(obj, p->driver) == NULL) {
+            continue;
+        }
+        p->used = true;
+        object_property_parse(obj, p->value, p->property, &err);
+        if (err != NULL) {
+            error_prepend(&err, "can't apply global %s.%s=%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 = data;
diff --git a/vl.c b/vl.c
index a5ae5f23d2..88ba658572 100644
--- a/vl.c
+++ b/vl.c
@@ -2968,7 +2968,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();
 }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-04 14:20   ` Marc-André Lureau
  0 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefano Stabellini, ehabkost, open list:X86, Paolo Bonzini,
	Marc-André Lureau, Anthony Perard, imammedo,
	Andreas Färber

Instead of registering compat properties as globals, let's keep them
in their own array, to avoid mixing with user globals.

Introduce object_apply_global_props() function, to apply compatibility
properties from a GPtrArray.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h | 10 ++++++++++
 include/qom/object.h   |  3 +++
 include/sysemu/accel.h |  4 +---
 accel/accel.c          | 12 ------------
 hw/core/qdev.c         |  9 +++++++++
 hw/xen/xen-common.c    |  9 ++++++---
 qom/object.c           | 25 +++++++++++++++++++++++++
 vl.c                   |  1 -
 8 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd566..aeaa6dbbb8 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -267,6 +267,16 @@ typedef struct GlobalProperty {
     Error **errp;
 } GlobalProperty;
 
+static inline void
+compat_props_add(GPtrArray *arr,
+                 GlobalProperty props[], size_t nelem)
+{
+    int i;
+    for (i = 0; i < nelem; i++) {
+        g_ptr_array_add(arr, (void *)&props[i]);
+    }
+}
+
 /*** Board API.  This should go away once we have a machine config file.  ***/
 
 DeviceState *qdev_create(BusState *bus, const char *name);
diff --git a/include/qom/object.h b/include/qom/object.h
index 0139838b69..5183c587f3 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -676,6 +676,9 @@ Object *object_new_with_propv(const char *typename,
                               Error **errp,
                               va_list vargs);
 
+void object_apply_global_props(Object *obj, const GPtrArray *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..f331d128e9 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;
+    GPtrArray *compat_props;
 } AccelClass;
 
 #define TYPE_ACCEL "accel"
@@ -67,8 +67,6 @@ typedef struct AccelClass {
 extern unsigned long tcg_tb_size;
 
 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);
 
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)
     }
 }
 
-void accel_register_compat_props(AccelState *accel)
-{
-    AccelClass *class = ACCEL_GET_CLASS(accel);
-    GlobalProperty *prop = class->global_props;
-
-    for (; prop && prop->driver; prop++) {
-        /* Any compat_props must never cause error */
-        prop->errp = &error_abort;
-        qdev_prop_register_global(prop);
-    }
-}
-
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..53b507164f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,6 +972,15 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
+    if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
+        MachineState *m = MACHINE(qdev_get_machine());
+        AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);
+
+        if (ac->compat_props) {
+            object_apply_global_props(obj, ac->compat_props, &error_abort);
+        }
+    }
+
     qdev_prop_set_globals(DEVICE(obj));
 }
 
diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index 6ec14c73ca..4532aa8632 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
         .driver = "migration",
         .property = "send-section-footer",
         .value = "off",
-    },
-    { /* end of list */ },
+    }
 };
 
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
+
     ac->name = "Xen";
     ac->init_machine = xen_init;
     ac->setup_post = xen_setup_post;
     ac->allowed = &xen_allowed;
-    ac->global_props = xen_compat_props;
+    ac->compat_props = g_ptr_array_new();
+
+    compat_props_add(ac->compat_props,
+                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
diff --git a/qom/object.c b/qom/object.c
index 17921c0a71..dbdab0aead 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
     }
 }
 
+void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
+{
+    Error *err = NULL;
+    int i;
+
+    if (!props) {
+        return;
+    }
+
+    for (i = 0; i < props->len; i++) {
+        GlobalProperty *p = g_ptr_array_index(props, i);
+
+        if (object_dynamic_cast(obj, p->driver) == NULL) {
+            continue;
+        }
+        p->used = true;
+        object_property_parse(obj, p->value, p->property, &err);
+        if (err != NULL) {
+            error_prepend(&err, "can't apply global %s.%s=%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 = data;
diff --git a/vl.c b/vl.c
index a5ae5f23d2..88ba658572 100644
--- a/vl.c
+++ b/vl.c
@@ -2968,7 +2968,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();
 }
-- 
2.20.0.rc1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (6 preceding siblings ...)
  2018-12-04 14:20   ` Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-10 17:31   ` Eduardo Habkost
  2018-12-11 14:23   ` Eduardo Habkost
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 09/19] hw: remove SET_MACHINE_COMPAT Marc-André Lureau
                   ` (12 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Peter Maydell,
	Marcel Apfelbaum, Michael S. Tsirkin, Paolo Bonzini,
	Richard Henderson, David Gibson, David Hildenbrand,
	Cornelia Huck, Christian Borntraeger, open list:Virt,
	open list:sPAPR, open list:S390

Similarly to accel properties, move compat properties out of globals
registration, and apply the machine compat properties during
device_post_init().

As suggested during review, populating the arrays can be done directly
without resorting to using macros.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h        |   3 +-
 hw/arm/virt.c              |  48 ++-
 hw/core/machine.c          |  19 +-
 hw/core/qdev.c             |   2 +
 hw/i386/pc_piix.c          | 588 +++++++++++++++++++++----------------
 hw/i386/pc_q35.c           |  70 ++++-
 hw/ppc/spapr.c             | 209 +++++++------
 hw/s390x/s390-virtio-ccw.c | 220 +++++++-------
 vl.c                       |   1 -
 9 files changed, 673 insertions(+), 487 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index f82f28468b..28c2b0af41 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,
@@ -191,7 +190,7 @@ struct MachineClass {
     const char *default_machine_opts;
     const char *default_boot_order;
     const char *default_display;
-    GArray *compat_props;
+    GPtrArray *compat_props;
     const char *hw_version;
     ram_addr_t default_ram_size;
     const char *default_cpu_type;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index f69e7eb399..530c8ca89d 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1872,8 +1872,9 @@ static void virt_machine_3_1_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
 
-#define VIRT_COMPAT_3_0 \
+static GlobalProperty virt_compat_3_0[] = {
     HW_COMPAT_3_0
+};
 
 static void virt_3_0_instance_init(Object *obj)
 {
@@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
 static void virt_machine_3_0_options(MachineClass *mc)
 {
     virt_machine_3_1_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
+    compat_props_add(mc->compat_props,
+                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
 }
 DEFINE_VIRT_MACHINE(3, 0)
 
-#define VIRT_COMPAT_2_12 \
+static GlobalProperty virt_compat_2_12[] = {
     HW_COMPAT_2_12
+};
 
 static void virt_2_12_instance_init(Object *obj)
 {
@@ -1900,14 +1903,16 @@ static void virt_machine_2_12_options(MachineClass *mc)
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
 
     virt_machine_3_0_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_12);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_12, G_N_ELEMENTS(virt_compat_2_12));
     vmc->no_highmem_ecam = true;
     mc->max_cpus = 255;
 }
 DEFINE_VIRT_MACHINE(2, 12)
 
-#define VIRT_COMPAT_2_11 \
+static GlobalProperty virt_compat_2_11[] = {
     HW_COMPAT_2_11
+};
 
 static void virt_2_11_instance_init(Object *obj)
 {
@@ -1919,13 +1924,15 @@ static void virt_machine_2_11_options(MachineClass *mc)
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
 
     virt_machine_2_12_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_11, G_N_ELEMENTS(virt_compat_2_11));
     vmc->smbios_old_sys_ver = true;
 }
 DEFINE_VIRT_MACHINE(2, 11)
 
-#define VIRT_COMPAT_2_10 \
+static GlobalProperty virt_compat_2_10[] = {
     HW_COMPAT_2_10
+};
 
 static void virt_2_10_instance_init(Object *obj)
 {
@@ -1935,14 +1942,16 @@ static void virt_2_10_instance_init(Object *obj)
 static void virt_machine_2_10_options(MachineClass *mc)
 {
     virt_machine_2_11_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_10);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_10, G_N_ELEMENTS(virt_compat_2_10));
     /* before 2.11 we never faulted accesses to bad addresses */
     mc->ignore_memory_transaction_failures = true;
 }
 DEFINE_VIRT_MACHINE(2, 10)
 
-#define VIRT_COMPAT_2_9 \
+static GlobalProperty virt_compat_2_9[] = {
     HW_COMPAT_2_9
+};
 
 static void virt_2_9_instance_init(Object *obj)
 {
@@ -1952,12 +1961,14 @@ static void virt_2_9_instance_init(Object *obj)
 static void virt_machine_2_9_options(MachineClass *mc)
 {
     virt_machine_2_10_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_9);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_9, G_N_ELEMENTS(virt_compat_2_9));
 }
 DEFINE_VIRT_MACHINE(2, 9)
 
-#define VIRT_COMPAT_2_8 \
+static GlobalProperty virt_compat_2_8[] = {
     HW_COMPAT_2_8
+};
 
 static void virt_2_8_instance_init(Object *obj)
 {
@@ -1969,7 +1980,8 @@ static void virt_machine_2_8_options(MachineClass *mc)
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
 
     virt_machine_2_9_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_8);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_8, G_N_ELEMENTS(virt_compat_2_8));
     /* For 2.8 and earlier we falsely claimed in the DT that
      * our timers were edge-triggered, not level-triggered.
      */
@@ -1977,8 +1989,9 @@ static void virt_machine_2_8_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE(2, 8)
 
-#define VIRT_COMPAT_2_7 \
+static GlobalProperty virt_compat_2_7[] = {
     HW_COMPAT_2_7
+};
 
 static void virt_2_7_instance_init(Object *obj)
 {
@@ -1990,7 +2003,8 @@ static void virt_machine_2_7_options(MachineClass *mc)
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
 
     virt_machine_2_8_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_7);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_7, G_N_ELEMENTS(virt_compat_2_7));
     /* ITS was introduced with 2.8 */
     vmc->no_its = true;
     /* Stick with 1K pages for migration compatibility */
@@ -1998,8 +2012,9 @@ static void virt_machine_2_7_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE(2, 7)
 
-#define VIRT_COMPAT_2_6 \
+static GlobalProperty virt_compat_2_6[] = {
     HW_COMPAT_2_6
+};
 
 static void virt_2_6_instance_init(Object *obj)
 {
@@ -2011,7 +2026,8 @@ static void virt_machine_2_6_options(MachineClass *mc)
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
 
     virt_machine_2_7_options(mc);
-    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_6);
+    compat_props_add(mc->compat_props,
+                     virt_compat_2_6, G_N_ELEMENTS(virt_compat_2_6));
     vmc->disallow_affinity_adjustment = true;
     /* Disable PMU for 2.6 as PMU support was first introduced in 2.7 */
     vmc->no_pmu = true;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c51423b647..6e24924aba 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -647,6 +647,7 @@ static void machine_class_base_init(ObjectClass *oc, void *data)
         assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
         mc->name = g_strndup(cname,
                             strlen(cname) - strlen(TYPE_MACHINE_SUFFIX));
+        mc->compat_props = g_ptr_array_new();
     }
 }
 
@@ -834,24 +835,6 @@ void machine_run_board_init(MachineState *machine)
     machine_class->init(machine);
 }
 
-void machine_register_compat_props(MachineState *machine)
-{
-    MachineClass *mc = MACHINE_GET_CLASS(machine);
-    int i;
-    GlobalProperty *p;
-
-    if (!mc->compat_props) {
-        return;
-    }
-
-    for (i = 0; i < mc->compat_props->len; i++) {
-        p = g_array_index(mc->compat_props, GlobalProperty *, i);
-        /* Machine compat_props must never cause errors: */
-        p->errp = &error_abort;
-        qdev_prop_register_global(p);
-    }
-}
-
 static const TypeInfo machine_info = {
     .name = TYPE_MACHINE,
     .parent = TYPE_OBJECT,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 53b507164f..d510340bac 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -974,11 +974,13 @@ static void device_post_init(Object *obj)
 {
     if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
         MachineState *m = MACHINE(qdev_get_machine());
+        MachineClass *mc = MACHINE_GET_CLASS(m);
         AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);
 
         if (ac->compat_props) {
             object_apply_global_props(obj, ac->compat_props, &error_abort);
         }
+        object_apply_global_props(obj, mc->compat_props, &error_abort);
     }
 
     qdev_prop_set_globals(DEVICE(obj));
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7092d6d13f..575566e466 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -438,74 +438,112 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
 DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
                       pc_i440fx_3_1_machine_options);
 
+static GlobalProperty pc_compat_3_0[] = {
+    PC_COMPAT_3_0
+};
+
 static void pc_i440fx_3_0_machine_options(MachineClass *m)
 {
     pc_i440fx_3_1_machine_options(m);
     m->is_default = 0;
     m->alias = NULL;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+
+    compat_props_add(m->compat_props,
+                     pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
 }
 
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
+static GlobalProperty pc_compat_2_12[] = {
+    PC_COMPAT_2_12
+};
+
 static void pc_i440fx_2_12_machine_options(MachineClass *m)
 {
     pc_i440fx_3_0_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_12, G_N_ELEMENTS(pc_compat_2_12));
 }
 
 DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
                       pc_i440fx_2_12_machine_options);
 
+static GlobalProperty pc_compat_2_11[] = {
+    PC_COMPAT_2_11
+};
+
 static void pc_i440fx_2_11_machine_options(MachineClass *m)
 {
     pc_i440fx_2_12_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_11);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_11, G_N_ELEMENTS(pc_compat_2_11));
 }
 
 DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL,
                       pc_i440fx_2_11_machine_options);
 
+static GlobalProperty pc_compat_2_10[] = {
+    PC_COMPAT_2_10
+};
+
 static void pc_i440fx_2_10_machine_options(MachineClass *m)
 {
     pc_i440fx_2_11_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_10);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_10, G_N_ELEMENTS(pc_compat_2_10));
     m->auto_enable_numa_with_memhp = false;
 }
 
 DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL,
                       pc_i440fx_2_10_machine_options);
 
+static GlobalProperty pc_compat_2_9[] = {
+    PC_COMPAT_2_9
+};
+
 static void pc_i440fx_2_9_machine_options(MachineClass *m)
 {
     pc_i440fx_2_10_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_9);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_9, G_N_ELEMENTS(pc_compat_2_9));
     m->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
 }
 
 DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL,
                       pc_i440fx_2_9_machine_options);
 
+static GlobalProperty pc_compat_2_8[] = {
+    PC_COMPAT_2_8
+};
+
 static void pc_i440fx_2_8_machine_options(MachineClass *m)
 {
     pc_i440fx_2_9_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_8);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_8, G_N_ELEMENTS(pc_compat_2_8));
 }
 
 DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL,
                       pc_i440fx_2_8_machine_options);
 
+static GlobalProperty pc_compat_2_7[] = {
+    PC_COMPAT_2_7
+};
 
 static void pc_i440fx_2_7_machine_options(MachineClass *m)
 {
     pc_i440fx_2_8_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_7);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_7, G_N_ELEMENTS(pc_compat_2_7));
 }
 
 DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL,
                       pc_i440fx_2_7_machine_options);
 
+static GlobalProperty pc_compat_2_6[] = {
+    PC_COMPAT_2_6
+};
 
 static void pc_i440fx_2_6_machine_options(MachineClass *m)
 {
@@ -513,12 +551,16 @@ static void pc_i440fx_2_6_machine_options(MachineClass *m)
     pc_i440fx_2_7_machine_options(m);
     pcmc->legacy_cpu_hotplug = true;
     pcmc->linuxboot_dma_enabled = false;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_6);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_6, G_N_ELEMENTS(pc_compat_2_6));
 }
 
 DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL,
                       pc_i440fx_2_6_machine_options);
 
+static GlobalProperty pc_compat_2_5[] = {
+    PC_COMPAT_2_5
+};
 
 static void pc_i440fx_2_5_machine_options(MachineClass *m)
 {
@@ -526,12 +568,16 @@ static void pc_i440fx_2_5_machine_options(MachineClass *m)
     pc_i440fx_2_6_machine_options(m);
     pcmc->save_tsc_khz = false;
     m->legacy_fw_cfg_order = 1;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_5);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_5, G_N_ELEMENTS(pc_compat_2_5));
 }
 
 DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
                       pc_i440fx_2_5_machine_options);
 
+static GlobalProperty pc_compat_2_4[] = {
+    PC_COMPAT_2_4
+};
 
 static void pc_i440fx_2_4_machine_options(MachineClass *m)
 {
@@ -539,36 +585,48 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
     pc_i440fx_2_5_machine_options(m);
     m->hw_version = "2.4.0";
     pcmc->broken_reserved_end = true;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_4, G_N_ELEMENTS(pc_compat_2_4));
 }
 
 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
-                      pc_i440fx_2_4_machine_options)
+                      pc_i440fx_2_4_machine_options);
 
+static GlobalProperty pc_compatp_2_3[] = {
+    PC_COMPAT_2_3
+};
 
 static void pc_i440fx_2_3_machine_options(MachineClass *m)
 {
     pc_i440fx_2_4_machine_options(m);
     m->hw_version = "2.3.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
+    compat_props_add(m->compat_props,
+                     pc_compatp_2_3, G_N_ELEMENTS(pc_compatp_2_3));
 }
 
 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
                       pc_i440fx_2_3_machine_options);
 
+static GlobalProperty pc_compatp_2_2[] = {
+    PC_COMPAT_2_2
+};
 
 static void pc_i440fx_2_2_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_2_3_machine_options(m);
     m->hw_version = "2.2.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
+    compat_props_add(m->compat_props,
+                     pc_compatp_2_2, G_N_ELEMENTS(pc_compatp_2_2));
     pcmc->rsdp_in_ram = false;
 }
 
 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
                       pc_i440fx_2_2_machine_options);
 
+static GlobalProperty pc_compatp_2_1[] = {
+    PC_COMPAT_2_1
+};
 
 static void pc_i440fx_2_1_machine_options(MachineClass *m)
 {
@@ -576,7 +634,8 @@ static void pc_i440fx_2_1_machine_options(MachineClass *m)
     pc_i440fx_2_2_machine_options(m);
     m->hw_version = "2.1.0";
     m->default_display = NULL;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
+    compat_props_add(m->compat_props,
+                     pc_compatp_2_1, G_N_ELEMENTS(pc_compatp_2_1));
     pcmc->smbios_uuid_encoded = false;
     pcmc->enforce_aligned_dimm = false;
 }
@@ -584,14 +643,17 @@ static void pc_i440fx_2_1_machine_options(MachineClass *m)
 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
                       pc_i440fx_2_1_machine_options);
 
-
+static GlobalProperty pc_compatp_2_0[] = {
+    PC_COMPAT_2_0
+};
 
 static void pc_i440fx_2_0_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_2_1_machine_options(m);
     m->hw_version = "2.0.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
+    compat_props_add(m->compat_props,
+                     pc_compatp_2_0, G_N_ELEMENTS(pc_compatp_2_0));
     pcmc->smbios_legacy_mode = true;
     pcmc->has_reserved_memory = false;
     /* This value depends on the actual DSDT and SSDT compiled into
@@ -617,6 +679,9 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m)
 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
                       pc_i440fx_2_0_machine_options);
 
+static GlobalProperty pc_compatp_1_7[] = {
+    PC_COMPAT_1_7
+};
 
 static void pc_i440fx_1_7_machine_options(MachineClass *m)
 {
@@ -625,7 +690,8 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)
     m->hw_version = "1.7.0";
     m->default_machine_opts = NULL;
     m->option_rom_has_mr = true;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_7, G_N_ELEMENTS(pc_compatp_1_7));
     pcmc->smbios_defaults = false;
     pcmc->gigabyte_align = false;
     pcmc->legacy_acpi_table_size = 6414;
@@ -634,6 +700,9 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)
 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
                       pc_i440fx_1_7_machine_options);
 
+static GlobalProperty pc_compatp_1_6[] = {
+    PC_COMPAT_1_6
+};
 
 static void pc_i440fx_1_6_machine_options(MachineClass *m)
 {
@@ -641,368 +710,391 @@ static void pc_i440fx_1_6_machine_options(MachineClass *m)
     pc_i440fx_1_7_machine_options(m);
     m->hw_version = "1.6.0";
     m->rom_file_has_mr = false;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_6, G_N_ELEMENTS(pc_compatp_1_6));
     pcmc->has_acpi_build = false;
 }
 
 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
                       pc_i440fx_1_6_machine_options);
 
+static GlobalProperty pc_compatp_1_5[] = {
+    PC_COMPAT_1_5
+};
 
 static void pc_i440fx_1_5_machine_options(MachineClass *m)
 {
     pc_i440fx_1_6_machine_options(m);
     m->hw_version = "1.5.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_5, G_N_ELEMENTS(pc_compatp_1_5));
 }
 
 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
                       pc_i440fx_1_5_machine_options);
 
+static GlobalProperty pc_compatp_1_4[] = {
+    PC_COMPAT_1_4
+};
 
 static void pc_i440fx_1_4_machine_options(MachineClass *m)
 {
     pc_i440fx_1_5_machine_options(m);
     m->hw_version = "1.4.0";
     m->hot_add_cpu = NULL;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_4, G_N_ELEMENTS(pc_compatp_1_4));
 }
 
 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
                       pc_i440fx_1_4_machine_options);
 
-
-#define PC_COMPAT_1_3 \
-        PC_CPU_MODEL_IDS("1.3.0") \
-        {\
-            .driver   = "usb-tablet",\
-            .property = "usb_version",\
-            .value    = stringify(1),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "ctrl_mac_addr",\
-            .value    = "off",      \
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "mq", \
-            .value    = "off", \
-        }, {\
-            .driver   = "e1000",\
-            .property = "autonegotiation",\
-            .value    = "off",\
-        },
-
+static GlobalProperty pc_compatp_1_3[] = {
+    PC_CPU_MODEL_IDS("1.3.0")
+    {
+        .driver   = "usb-tablet",
+        .property = "usb_version",
+        .value    = stringify(1),
+    },{
+        .driver   = "virtio-net-pci",
+        .property = "ctrl_mac_addr",
+        .value    = "off",
+    },{
+        .driver   = "virtio-net-pci",
+        .property = "mq",
+        .value    = "off",
+    }, {
+        .driver   = "e1000",
+        .property = "autonegotiation",
+        .value    = "off",
+    },
+};
 
 static void pc_i440fx_1_3_machine_options(MachineClass *m)
 {
     pc_i440fx_1_4_machine_options(m);
     m->hw_version = "1.3.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_3, G_N_ELEMENTS(pc_compatp_1_3));
 }
 
 DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
                       pc_i440fx_1_3_machine_options);
 
 
-#define PC_COMPAT_1_2 \
-        PC_CPU_MODEL_IDS("1.2.0") \
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "msi",\
-            .value    = "off",\
-        },{\
-            .driver   = "nec-usb-xhci",\
-            .property = "msix",\
-            .value    = "off",\
-        },{\
-            .driver   = "ivshmem",\
-            .property = "use64",\
-            .value    = "0",\
-        },{\
-            .driver   = "qxl",\
-            .property = "revision",\
-            .value    = stringify(3),\
-        },{\
-            .driver   = "qxl-vga",\
-            .property = "revision",\
-            .value    = stringify(3),\
-        },{\
-            .driver   = "VGA",\
-            .property = "mmio",\
-            .value    = "off",\
-        },
+static GlobalProperty pc_compatp_1_2[] = {
+    PC_CPU_MODEL_IDS("1.2.0")
+    {
+        .driver   = "nec-usb-xhci",
+        .property = "msi",
+        .value    = "off",
+    },{
+        .driver   = "nec-usb-xhci",
+        .property = "msix",
+        .value    = "off",
+    },{
+        .driver   = "ivshmem",
+        .property = "use64",
+        .value    = "0",
+    },{
+        .driver   = "qxl",
+        .property = "revision",
+        .value    = stringify(3),
+    },{
+        .driver   = "qxl-vga",
+        .property = "revision",
+        .value    = stringify(3),
+    },{
+        .driver   = "VGA",
+        .property = "mmio",
+        .value    = "off",
+    },
+};
 
 static void pc_i440fx_1_2_machine_options(MachineClass *m)
 {
     pc_i440fx_1_3_machine_options(m);
     m->hw_version = "1.2.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_2, G_N_ELEMENTS(pc_compatp_1_2));
 }
 
 DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
                       pc_i440fx_1_2_machine_options);
 
 
-#define PC_COMPAT_1_1 \
-        PC_CPU_MODEL_IDS("1.1.0") \
-        {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "hotplug",\
-            .value    = "off",\
-        },{\
-            .driver   = "virtio-scsi-pci",\
-            .property = "param_change",\
-            .value    = "off",\
-        },{\
-            .driver   = "VGA",\
-            .property = "vgamem_mb",\
-            .value    = stringify(8),\
-        },{\
-            .driver   = "vmware-svga",\
-            .property = "vgamem_mb",\
-            .value    = stringify(8),\
-        },{\
-            .driver   = "qxl-vga",\
-            .property = "vgamem_mb",\
-            .value    = stringify(8),\
-        },{\
-            .driver   = "qxl",\
-            .property = "vgamem_mb",\
-            .value    = stringify(8),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "config-wce",\
-            .value    = "off",\
-        },
+static GlobalProperty pc_compatp_1_1[] = {
+    PC_CPU_MODEL_IDS("1.1.0")
+    {
+        .driver   = "virtio-scsi-pci",
+        .property = "hotplug",
+        .value    = "off",
+    },{
+        .driver   = "virtio-scsi-pci",
+        .property = "param_change",
+        .value    = "off",
+    },{
+        .driver   = "VGA",
+        .property = "vgamem_mb",
+        .value    = stringify(8),
+    },{
+        .driver   = "vmware-svga",
+        .property = "vgamem_mb",
+        .value    = stringify(8),
+    },{
+        .driver   = "qxl-vga",
+        .property = "vgamem_mb",
+        .value    = stringify(8),
+    },{
+        .driver   = "qxl",
+        .property = "vgamem_mb",
+        .value    = stringify(8),
+    },{
+        .driver   = "virtio-blk-pci",
+        .property = "config-wce",
+        .value    = "off",
+    },
+};
 
 static void pc_i440fx_1_1_machine_options(MachineClass *m)
 {
     pc_i440fx_1_2_machine_options(m);
     m->hw_version = "1.1.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_1, G_N_ELEMENTS(pc_compatp_1_1));
 }
 
 DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
                       pc_i440fx_1_1_machine_options);
 
-
-#define PC_COMPAT_1_0 \
-        PC_CPU_MODEL_IDS("1.0") \
-        {\
-            .driver   = TYPE_ISA_FDC,\
-            .property = "check_media_rate",\
-            .value    = "off",\
-        }, {\
-            .driver   = "virtio-balloon-pci",\
-            .property = "class",\
-            .value    = stringify(PCI_CLASS_MEMORY_RAM),\
-        },{\
-            .driver   = "apic-common",\
-            .property = "vapic",\
-            .value    = "off",\
-        },{\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "full-path",\
-            .value    = "no",\
-        },
+static GlobalProperty pc_compatp_1_0[] = {
+    PC_CPU_MODEL_IDS("1.0")
+    {
+        .driver   = TYPE_ISA_FDC,
+        .property = "check_media_rate",
+        .value    = "off",
+    },{
+        .driver   = "virtio-balloon-pci",
+        .property = "class",
+        .value    = stringify(PCI_CLASS_MEMORY_RAM),
+    },{
+        .driver   = "apic-common",
+        .property = "vapic",
+        .value    = "off",
+    },{
+        .driver   = TYPE_USB_DEVICE,
+        .property = "full-path",
+        .value    = "no",
+    },
+};
 
 static void pc_i440fx_1_0_machine_options(MachineClass *m)
 {
     pc_i440fx_1_1_machine_options(m);
     m->hw_version = "1.0";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
+    compat_props_add(m->compat_props,
+                     pc_compatp_1_0, G_N_ELEMENTS(pc_compatp_1_0));
 }
 
 DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
                       pc_i440fx_1_0_machine_options);
 
 
-#define PC_COMPAT_0_15 \
-        PC_CPU_MODEL_IDS("0.15")
+static GlobalProperty pc_compatp_0_15[] = {
+    PC_CPU_MODEL_IDS("0.15")
+};
 
 static void pc_i440fx_0_15_machine_options(MachineClass *m)
 {
     pc_i440fx_1_0_machine_options(m);
     m->hw_version = "0.15";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
+    compat_props_add(m->compat_props,
+                     pc_compatp_0_15, G_N_ELEMENTS(pc_compatp_0_15));
 }
 
 DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
                       pc_i440fx_0_15_machine_options);
 
 
-#define PC_COMPAT_0_14 \
-        PC_CPU_MODEL_IDS("0.14") \
-        {\
-            .driver   = "virtio-blk-pci",\
-            .property = "event_idx",\
-            .value    = "off",\
-        },{\
-            .driver   = "virtio-serial-pci",\
-            .property = "event_idx",\
-            .value    = "off",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "event_idx",\
-            .value    = "off",\
-        },{\
-            .driver   = "virtio-balloon-pci",\
-            .property = "event_idx",\
-            .value    = "off",\
-        },{\
-            .driver   = "qxl",\
-            .property = "revision",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qxl-vga",\
-            .property = "revision",\
-            .value    = stringify(2),\
-        },
+static GlobalProperty pc_compatp_0_14[] = {
+    PC_CPU_MODEL_IDS("0.14")
+    {
+        .driver   = "virtio-blk-pci",
+        .property = "event_idx",
+        .value    = "off",
+    },{
+        .driver   = "virtio-serial-pci",
+        .property = "event_idx",
+        .value    = "off",
+    },{
+        .driver   = "virtio-net-pci",
+        .property = "event_idx",
+        .value    = "off",
+    },{
+        .driver   = "virtio-balloon-pci",
+        .property = "event_idx",
+        .value    = "off",
+    },{
+        .driver   = "qxl",
+        .property = "revision",
+        .value    = stringify(2),
+    },{
+        .driver   = "qxl-vga",
+        .property = "revision",
+        .value    = stringify(2),
+    },
+};
 
 static void pc_i440fx_0_14_machine_options(MachineClass *m)
 {
     pc_i440fx_0_15_machine_options(m);
     m->hw_version = "0.14";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
+    compat_props_add(m->compat_props,
+                     pc_compatp_0_14, G_N_ELEMENTS(pc_compatp_0_14));
 }
 
 DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
                       pc_i440fx_0_14_machine_options);
 
-
-#define PC_COMPAT_0_13 \
-        PC_CPU_MODEL_IDS("0.13") \
-        {\
-            .driver   = TYPE_PCI_DEVICE,\
-            .property = "command_serr_enable",\
-            .value    = "off",\
-        },{\
-            .driver   = "AC97",\
-            .property = "use_broken_id",\
-            .value    = stringify(1),\
-        },{\
-            .driver   = "virtio-9p-pci",\
-            .property = "vectors",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "VGA",\
-            .property = "rombar",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "vmware-svga",\
-            .property = "rombar",\
-            .value    = stringify(0),\
-        },
+static GlobalProperty pc_compatp_0_13[] = {
+    PC_CPU_MODEL_IDS("0.13")
+    {
+        .driver   = TYPE_PCI_DEVICE,
+        .property = "command_serr_enable",
+        .value    = "off",
+    },{
+        .driver   = "AC97",
+        .property = "use_broken_id",
+        .value    = stringify(1),
+    },{
+        .driver   = "virtio-9p-pci",
+        .property = "vectors",
+        .value    = stringify(0),
+    },{
+        .driver   = "VGA",
+        .property = "rombar",
+        .value    = stringify(0),
+    },{
+        .driver   = "vmware-svga",
+        .property = "rombar",
+        .value    = stringify(0),
+    },
+};
 
 static void pc_i440fx_0_13_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_0_14_machine_options(m);
     m->hw_version = "0.13";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
+    compat_props_add(m->compat_props,
+                     pc_compatp_0_13, G_N_ELEMENTS(pc_compatp_0_13));
     pcmc->kvmclock_enabled = false;
 }
 
 DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
                       pc_i440fx_0_13_machine_options);
 
-
-#define PC_COMPAT_0_12 \
-        PC_CPU_MODEL_IDS("0.12") \
-        {\
-            .driver   = "virtio-serial-pci",\
-            .property = "max_ports",\
-            .value    = stringify(1),\
-        },{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "usb-mouse",\
-            .property = "serial",\
-            .value    = "1",\
-        },{\
-            .driver   = "usb-tablet",\
-            .property = "serial",\
-            .value    = "1",\
-        },{\
-            .driver   = "usb-kbd",\
-            .property = "serial",\
-            .value    = "1",\
-        },
+static GlobalProperty pc_compat_0_12[] = {
+    PC_CPU_MODEL_IDS("0.12")
+    {
+        .driver   = "virtio-serial-pci",
+        .property = "max_ports",
+        .value    = stringify(1),
+    },{
+        .driver   = "virtio-serial-pci",
+        .property = "vectors",
+        .value    = stringify(0),
+    },{
+        .driver   = "usb-mouse",
+        .property = "serial",
+        .value    = "1",
+    },{
+        .driver   = "usb-tablet",
+        .property = "serial",
+        .value    = "1",
+    },{
+        .driver   = "usb-kbd",
+        .property = "serial",
+        .value    = "1",
+    },
+};
 
 static void pc_i440fx_0_12_machine_options(MachineClass *m)
 {
     pc_i440fx_0_13_machine_options(m);
     m->hw_version = "0.12";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
+    compat_props_add(m->compat_props,
+                     pc_compat_0_12, G_N_ELEMENTS(pc_compat_0_12));
 }
 
 DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
                       pc_i440fx_0_12_machine_options);
 
 
-#define PC_COMPAT_0_11 \
-        PC_CPU_MODEL_IDS("0.11") \
-        {\
-            .driver   = "virtio-blk-pci",\
-            .property = "vectors",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = TYPE_PCI_DEVICE,\
-            .property = "rombar",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "ide-drive",\
-            .property = "ver",\
-            .value    = "0.11",\
-        },{\
-            .driver   = "scsi-disk",\
-            .property = "ver",\
-            .value    = "0.11",\
-        },
+static GlobalProperty pc_compat_0_11[] = {
+    PC_CPU_MODEL_IDS("0.11")
+    {
+        .driver   = "virtio-blk-pci",
+        .property = "vectors",
+        .value    = stringify(0),
+    },{
+        .driver   = TYPE_PCI_DEVICE,
+        .property = "rombar",
+        .value    = stringify(0),
+    },{
+        .driver   = "ide-drive",
+        .property = "ver",
+        .value    = "0.11",
+    },{
+        .driver   = "scsi-disk",
+        .property = "ver",
+        .value    = "0.11",
+    },
+};
 
 static void pc_i440fx_0_11_machine_options(MachineClass *m)
 {
     pc_i440fx_0_12_machine_options(m);
     m->hw_version = "0.11";
     m->deprecation_reason = "use a newer machine type instead";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
+    compat_props_add(m->compat_props,
+                     pc_compat_0_11, G_N_ELEMENTS(pc_compat_0_11));
 }
 
 DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
                       pc_i440fx_0_11_machine_options);
 
-
-#define PC_COMPAT_0_10 \
-    PC_CPU_MODEL_IDS("0.10") \
-    {\
-        .driver   = "virtio-blk-pci",\
-        .property = "class",\
-        .value    = stringify(PCI_CLASS_STORAGE_OTHER),\
-    },{\
-        .driver   = "virtio-serial-pci",\
-        .property = "class",\
-        .value    = stringify(PCI_CLASS_DISPLAY_OTHER),\
-    },{\
-        .driver   = "virtio-net-pci",\
-        .property = "vectors",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "ide-drive",\
-        .property = "ver",\
-        .value    = "0.10",\
-    },{\
-        .driver   = "scsi-disk",\
-        .property = "ver",\
-        .value    = "0.10",\
+static GlobalProperty pc_compat_0_10[] = {
+    PC_CPU_MODEL_IDS("0.10")
+    {
+        .driver   = "virtio-blk-pci",
+        .property = "class",
+        .value    = stringify(PCI_CLASS_STORAGE_OTHER),
+    },{
+        .driver   = "virtio-serial-pci",
+        .property = "class",
+        .value    = stringify(PCI_CLASS_DISPLAY_OTHER),
+    },{
+        .driver   = "virtio-net-pci",
+        .property = "vectors",
+        .value    = stringify(0),
+    },{
+        .driver   = "ide-drive",
+        .property = "ver",
+        .value    = "0.10",
+    },{
+        .driver   = "scsi-disk",
+        .property = "ver",
+        .value    = "0.10",
     },
+};
 
 static void pc_i440fx_0_10_machine_options(MachineClass *m)
 {
     pc_i440fx_0_11_machine_options(m);
     m->hw_version = "0.10";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
+    compat_props_add(m->compat_props,
+                     pc_compat_0_10, G_N_ELEMENTS(pc_compat_0_10));
 }
 
 DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 4702bb13c4..701c09b43e 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -320,41 +320,61 @@ static void pc_q35_3_1_machine_options(MachineClass *m)
 DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
                    pc_q35_3_1_machine_options);
 
+static GlobalProperty pc_compat_3_0[] = {
+    PC_COMPAT_3_0
+};
+
 static void pc_q35_3_0_machine_options(MachineClass *m)
 {
     pc_q35_3_1_machine_options(m);
     m->alias = NULL;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+    compat_props_add(m->compat_props,
+                     pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
 }
 
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
+static GlobalProperty pc_compat_2_12[] = {
+    PC_COMPAT_2_12
+};
+
 static void pc_q35_2_12_machine_options(MachineClass *m)
 {
     pc_q35_3_0_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_12, G_N_ELEMENTS(pc_compat_2_12));
 }
 
 DEFINE_Q35_MACHINE(v2_12, "pc-q35-2.12", NULL,
                    pc_q35_2_12_machine_options);
 
+static GlobalProperty pc_compat_2_11[] = {
+    PC_COMPAT_2_11
+};
+
 static void pc_q35_2_11_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
 
     pc_q35_2_12_machine_options(m);
     pcmc->default_nic_model = "e1000";
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_11);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_11, G_N_ELEMENTS(pc_compat_2_11));
 }
 
 DEFINE_Q35_MACHINE(v2_11, "pc-q35-2.11", NULL,
                    pc_q35_2_11_machine_options);
 
+static GlobalProperty pc_compat_2_10[] = {
+    PC_COMPAT_2_10
+};
+
 static void pc_q35_2_10_machine_options(MachineClass *m)
 {
     pc_q35_2_11_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_10);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_10, G_N_ELEMENTS(pc_compat_2_10));
     m->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
     m->auto_enable_numa_with_memhp = false;
 }
@@ -362,65 +382,95 @@ static void pc_q35_2_10_machine_options(MachineClass *m)
 DEFINE_Q35_MACHINE(v2_10, "pc-q35-2.10", NULL,
                    pc_q35_2_10_machine_options);
 
+static GlobalProperty pc_compat_2_9[] = {
+    PC_COMPAT_2_9
+};
+
 static void pc_q35_2_9_machine_options(MachineClass *m)
 {
     pc_q35_2_10_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_9);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_9, G_N_ELEMENTS(pc_compat_2_9));
 }
 
 DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL,
                    pc_q35_2_9_machine_options);
 
+static GlobalProperty pc_compat_2_8[] = {
+    PC_COMPAT_2_8
+};
+
 static void pc_q35_2_8_machine_options(MachineClass *m)
 {
     pc_q35_2_9_machine_options(m);
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_8);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_8, G_N_ELEMENTS(pc_compat_2_8));
 }
 
 DEFINE_Q35_MACHINE(v2_8, "pc-q35-2.8", NULL,
                    pc_q35_2_8_machine_options);
 
+static GlobalProperty pc_compat_2_7[] = {
+    PC_COMPAT_2_7
+};
+
 static void pc_q35_2_7_machine_options(MachineClass *m)
 {
     pc_q35_2_8_machine_options(m);
     m->max_cpus = 255;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_7);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_7, G_N_ELEMENTS(pc_compat_2_7));
 }
 
 DEFINE_Q35_MACHINE(v2_7, "pc-q35-2.7", NULL,
                    pc_q35_2_7_machine_options);
 
+static GlobalProperty pc_compat_2_6[] = {
+    PC_COMPAT_2_6
+};
+
 static void pc_q35_2_6_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_2_7_machine_options(m);
     pcmc->legacy_cpu_hotplug = true;
     pcmc->linuxboot_dma_enabled = false;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_6);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_6, G_N_ELEMENTS(pc_compat_2_6));
 }
 
 DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL,
                    pc_q35_2_6_machine_options);
 
+static GlobalProperty pc_compat_2_5[] = {
+    PC_COMPAT_2_5
+};
+
 static void pc_q35_2_5_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_2_6_machine_options(m);
     pcmc->save_tsc_khz = false;
     m->legacy_fw_cfg_order = 1;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_5);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_5, G_N_ELEMENTS(pc_compat_2_5));
 }
 
 DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
                    pc_q35_2_5_machine_options);
 
+static GlobalProperty pc_compat_2_4[] = {
+    PC_COMPAT_2_4
+};
+
 static void pc_q35_2_4_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_2_5_machine_options(m);
     m->hw_version = "2.4.0";
     pcmc->broken_reserved_end = true;
-    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
+    compat_props_add(m->compat_props,
+                     pc_compat_2_4, G_N_ELEMENTS(pc_compat_2_4));
 }
 
 DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7afd1a175b..d801ba71eb 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3973,8 +3973,9 @@ DEFINE_SPAPR_MACHINE(3_1, "3.1", true);
 /*
  * pseries-3.0
  */
-#define SPAPR_COMPAT_3_0                                              \
+static GlobalProperty spapr_compat_3_0[] = {
     HW_COMPAT_3_0
+};
 
 static void spapr_machine_3_0_instance_options(MachineState *machine)
 {
@@ -3986,7 +3987,8 @@ static void spapr_machine_3_0_class_options(MachineClass *mc)
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
 
     spapr_machine_3_1_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_0);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_3_0, G_N_ELEMENTS(spapr_compat_3_0));
 
     smc->legacy_irq_allocation = true;
     smc->irq = &spapr_irq_xics_legacy;
@@ -3997,18 +3999,19 @@ DEFINE_SPAPR_MACHINE(3_0, "3.0", false);
 /*
  * pseries-2.12
  */
-#define SPAPR_COMPAT_2_12                                              \
-    HW_COMPAT_2_12                                                     \
-    {                                                                  \
-        .driver = TYPE_POWERPC_CPU,                                    \
-        .property = "pre-3.0-migration",                               \
-        .value    = "on",                                              \
-    },                                                                 \
-    {                                                                  \
-        .driver = TYPE_SPAPR_CPU_CORE,                                 \
-        .property = "pre-3.0-migration",                               \
-        .value    = "on",                                              \
+static GlobalProperty spapr_compat_2_12[] = {
+    HW_COMPAT_2_12
+    {
+        .driver = TYPE_POWERPC_CPU,
+        .property = "pre-3.0-migration",
+        .value    = "on",
+    },
+    {
+        .driver = TYPE_SPAPR_CPU_CORE,
+        .property = "pre-3.0-migration",
+        .value    = "on",
     },
+};
 
 static void spapr_machine_2_12_instance_options(MachineState *machine)
 {
@@ -4020,7 +4023,8 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
 
     spapr_machine_3_0_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_12, G_N_ELEMENTS(spapr_compat_2_12));
 
     /* We depend on kvm_enabled() to choose a default value for the
      * hpt-max-page-size capability. Of course we can't do it here
@@ -4052,8 +4056,9 @@ DEFINE_SPAPR_MACHINE(2_12_sxxm, "2.12-sxxm", false);
 /*
  * pseries-2.11
  */
-#define SPAPR_COMPAT_2_11                                              \
+static GlobalProperty spapr_compat_2_11[] = {
     HW_COMPAT_2_11
+};
 
 static void spapr_machine_2_11_instance_options(MachineState *machine)
 {
@@ -4066,7 +4071,8 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)
 
     spapr_machine_2_12_class_options(mc);
     smc->default_caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_ON;
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_11, G_N_ELEMENTS(spapr_compat_2_11));
 }
 
 DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
@@ -4074,8 +4080,9 @@ DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
 /*
  * pseries-2.10
  */
-#define SPAPR_COMPAT_2_10                                              \
+static GlobalProperty spapr_compat_2_10[] = {
     HW_COMPAT_2_10
+};
 
 static void spapr_machine_2_10_instance_options(MachineState *machine)
 {
@@ -4085,7 +4092,8 @@ static void spapr_machine_2_10_instance_options(MachineState *machine)
 static void spapr_machine_2_10_class_options(MachineClass *mc)
 {
     spapr_machine_2_11_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_10, G_N_ELEMENTS(spapr_compat_2_10));
 }
 
 DEFINE_SPAPR_MACHINE(2_10, "2.10", false);
@@ -4093,13 +4101,14 @@ DEFINE_SPAPR_MACHINE(2_10, "2.10", false);
 /*
  * pseries-2.9
  */
-#define SPAPR_COMPAT_2_9                                               \
-    HW_COMPAT_2_9                                                      \
-    {                                                                  \
-        .driver = TYPE_POWERPC_CPU,                                    \
-        .property = "pre-2.10-migration",                              \
-        .value    = "on",                                              \
-    },                                                                 \
+static GlobalProperty spapr_compat_2_9[] = {
+    HW_COMPAT_2_9
+    {
+        .driver = TYPE_POWERPC_CPU,
+        .property = "pre-2.10-migration",
+        .value    = "on",
+    },
+};
 
 static void spapr_machine_2_9_instance_options(MachineState *machine)
 {
@@ -4111,7 +4120,8 @@ static void spapr_machine_2_9_class_options(MachineClass *mc)
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
 
     spapr_machine_2_10_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_9, G_N_ELEMENTS(spapr_compat_2_9));
     mc->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
     smc->pre_2_10_has_unused_icps = true;
     smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED;
@@ -4122,13 +4132,14 @@ DEFINE_SPAPR_MACHINE(2_9, "2.9", false);
 /*
  * pseries-2.8
  */
-#define SPAPR_COMPAT_2_8                                        \
-    HW_COMPAT_2_8                                               \
-    {                                                           \
-        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,                 \
-        .property = "pcie-extended-configuration-space",        \
-        .value    = "off",                                      \
+static GlobalProperty spapr_compat_2_8[] = {
+    HW_COMPAT_2_8
+    {
+        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "pcie-extended-configuration-space",
+        .value    = "off",
     },
+};
 
 static void spapr_machine_2_8_instance_options(MachineState *machine)
 {
@@ -4138,7 +4149,8 @@ static void spapr_machine_2_8_instance_options(MachineState *machine)
 static void spapr_machine_2_8_class_options(MachineClass *mc)
 {
     spapr_machine_2_9_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_8);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_8, G_N_ELEMENTS(spapr_compat_2_8));
     mc->numa_mem_align_shift = 23;
 }
 
@@ -4147,28 +4159,29 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", false);
 /*
  * pseries-2.7
  */
-#define SPAPR_COMPAT_2_7                            \
-    HW_COMPAT_2_7                                   \
-    {                                               \
-        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,     \
-        .property = "mem_win_size",                 \
-        .value    = stringify(SPAPR_PCI_2_7_MMIO_WIN_SIZE),\
-    },                                              \
-    {                                               \
-        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,     \
-        .property = "mem64_win_size",               \
-        .value    = "0",                            \
-    },                                              \
-    {                                               \
-        .driver = TYPE_POWERPC_CPU,                 \
-        .property = "pre-2.8-migration",            \
-        .value    = "on",                           \
-    },                                              \
-    {                                               \
-        .driver = TYPE_SPAPR_PCI_HOST_BRIDGE,       \
-        .property = "pre-2.8-migration",            \
-        .value    = "on",                           \
+static GlobalProperty spapr_compat_2_7[] = {
+    HW_COMPAT_2_7
+    {
+        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "mem_win_size",
+        .value    = stringify(SPAPR_PCI_2_7_MMIO_WIN_SIZE),
+    },
+    {
+        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "mem64_win_size",
+        .value    = "0",
+    },
+    {
+        .driver = TYPE_POWERPC_CPU,
+        .property = "pre-2.8-migration",
+        .value    = "on",
+    },
+    {
+        .driver = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "pre-2.8-migration",
+        .value    = "on",
     },
+};
 
 static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index,
                               uint64_t *buid, hwaddr *pio,
@@ -4233,7 +4246,8 @@ static void spapr_machine_2_7_class_options(MachineClass *mc)
 
     spapr_machine_2_8_class_options(mc);
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power7_v2.3");
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_7);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_7, G_N_ELEMENTS(spapr_compat_2_7));
     smc->phb_placement = phb_placement_2_7;
 }
 
@@ -4242,13 +4256,14 @@ DEFINE_SPAPR_MACHINE(2_7, "2.7", false);
 /*
  * pseries-2.6
  */
-#define SPAPR_COMPAT_2_6 \
-    HW_COMPAT_2_6 \
-    { \
-        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,\
-        .property = "ddw",\
-        .value    = stringify(off),\
+static GlobalProperty spapr_compat_2_6[] = {
+    HW_COMPAT_2_6
+    {
+        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "ddw",
+        .value    = stringify(off),
     },
+};
 
 static void spapr_machine_2_6_instance_options(MachineState *machine)
 {
@@ -4259,7 +4274,8 @@ static void spapr_machine_2_6_class_options(MachineClass *mc)
 {
     spapr_machine_2_7_class_options(mc);
     mc->has_hotpluggable_cpus = false;
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_6);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_6, G_N_ELEMENTS(spapr_compat_2_6));
 }
 
 DEFINE_SPAPR_MACHINE(2_6, "2.6", false);
@@ -4267,13 +4283,14 @@ DEFINE_SPAPR_MACHINE(2_6, "2.6", false);
 /*
  * pseries-2.5
  */
-#define SPAPR_COMPAT_2_5 \
-    HW_COMPAT_2_5 \
-    { \
-        .driver   = "spapr-vlan", \
-        .property = "use-rx-buffer-pools", \
-        .value    = "off", \
+static GlobalProperty spapr_compat_2_5[] = {
+    HW_COMPAT_2_5
+    {
+        .driver   = "spapr-vlan",
+        .property = "use-rx-buffer-pools",
+        .value    = "off",
     },
+};
 
 static void spapr_machine_2_5_instance_options(MachineState *machine)
 {
@@ -4286,7 +4303,8 @@ static void spapr_machine_2_5_class_options(MachineClass *mc)
 
     spapr_machine_2_6_class_options(mc);
     smc->use_ohci_by_default = true;
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_5);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_5, G_N_ELEMENTS(spapr_compat_2_5));
 }
 
 DEFINE_SPAPR_MACHINE(2_5, "2.5", false);
@@ -4294,8 +4312,9 @@ DEFINE_SPAPR_MACHINE(2_5, "2.5", false);
 /*
  * pseries-2.4
  */
-#define SPAPR_COMPAT_2_4 \
-        HW_COMPAT_2_4
+static GlobalProperty spapr_compat_2_4[] = {
+    HW_COMPAT_2_4
+};
 
 static void spapr_machine_2_4_instance_options(MachineState *machine)
 {
@@ -4308,7 +4327,8 @@ static void spapr_machine_2_4_class_options(MachineClass *mc)
 
     spapr_machine_2_5_class_options(mc);
     smc->dr_lmb_enabled = false;
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_4);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_4, G_N_ELEMENTS(spapr_compat_2_4));
 }
 
 DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
@@ -4316,13 +4336,14 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
 /*
  * pseries-2.3
  */
-#define SPAPR_COMPAT_2_3 \
-        HW_COMPAT_2_3 \
-        {\
-            .driver   = "spapr-pci-host-bridge",\
-            .property = "dynamic-reconfiguration",\
-            .value    = "off",\
-        },
+static GlobalProperty spapr_compat_2_3[] = {
+    HW_COMPAT_2_3
+    {
+        .driver   = "spapr-pci-host-bridge",
+        .property = "dynamic-reconfiguration",
+        .value    = "off",
+    },
+};
 
 static void spapr_machine_2_3_instance_options(MachineState *machine)
 {
@@ -4332,21 +4353,22 @@ static void spapr_machine_2_3_instance_options(MachineState *machine)
 static void spapr_machine_2_3_class_options(MachineClass *mc)
 {
     spapr_machine_2_4_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_3);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_3, G_N_ELEMENTS(spapr_compat_2_3));
 }
 DEFINE_SPAPR_MACHINE(2_3, "2.3", false);
 
 /*
  * pseries-2.2
  */
-
-#define SPAPR_COMPAT_2_2 \
-        HW_COMPAT_2_2 \
-        {\
-            .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,\
-            .property = "mem_win_size",\
-            .value    = "0x20000000",\
-        },
+static GlobalProperty spapr_compat_2_2[] = {
+    HW_COMPAT_2_2
+    {
+        .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
+        .property = "mem_win_size",
+        .value    = "0x20000000",
+    },
+};
 
 static void spapr_machine_2_2_instance_options(MachineState *machine)
 {
@@ -4357,15 +4379,17 @@ static void spapr_machine_2_2_instance_options(MachineState *machine)
 static void spapr_machine_2_2_class_options(MachineClass *mc)
 {
     spapr_machine_2_3_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_2);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_2, G_N_ELEMENTS(spapr_compat_2_2));
 }
 DEFINE_SPAPR_MACHINE(2_2, "2.2", false);
 
 /*
  * pseries-2.1
  */
-#define SPAPR_COMPAT_2_1 \
-        HW_COMPAT_2_1
+static GlobalProperty spapr_compat_2_1[] = {
+    HW_COMPAT_2_1
+};
 
 static void spapr_machine_2_1_instance_options(MachineState *machine)
 {
@@ -4375,7 +4399,8 @@ static void spapr_machine_2_1_instance_options(MachineState *machine)
 static void spapr_machine_2_1_class_options(MachineClass *mc)
 {
     spapr_machine_2_2_class_options(mc);
-    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_1);
+    compat_props_add(mc->compat_props,
+                     spapr_compat_2_1, G_N_ELEMENTS(spapr_compat_2_1));
 }
 DEFINE_SPAPR_MACHINE(2_1, "2.1", false);
 
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index a0615a8b35..275cbe5da4 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -651,96 +651,106 @@ bool css_migration_enabled(void)
     }                                                                         \
     type_init(ccw_machine_register_##suffix)
 
-#define CCW_COMPAT_3_0 \
-        HW_COMPAT_3_0
-
-#define CCW_COMPAT_2_12 \
-        HW_COMPAT_2_12
-
-#define CCW_COMPAT_2_11 \
-        HW_COMPAT_2_11 \
-        {\
-            .driver   = TYPE_SCLP_EVENT_FACILITY,\
-            .property = "allow_all_mask_sizes",\
-            .value    = "off",\
-        },
-
-#define CCW_COMPAT_2_10 \
-        HW_COMPAT_2_10
-
-#define CCW_COMPAT_2_9 \
-        HW_COMPAT_2_9 \
-        {\
-            .driver   = TYPE_S390_STATTRIB,\
-            .property = "migration-enabled",\
-            .value    = "off",\
-        },
-
-#define CCW_COMPAT_2_8 \
-        HW_COMPAT_2_8 \
-        {\
-            .driver   = TYPE_S390_FLIC_COMMON,\
-            .property = "adapter_routes_max_batch",\
-            .value    = "64",\
-        },
-
-#define CCW_COMPAT_2_7 \
-        HW_COMPAT_2_7
-
-#define CCW_COMPAT_2_6 \
-        HW_COMPAT_2_6 \
-        {\
-            .driver   = TYPE_S390_IPL,\
-            .property = "iplbext_migration",\
-            .value    = "off",\
-        }, {\
-            .driver   = TYPE_VIRTUAL_CSS_BRIDGE,\
-            .property = "css_dev_path",\
-            .value    = "off",\
-        },
-
-#define CCW_COMPAT_2_5 \
-        HW_COMPAT_2_5
-
-#define CCW_COMPAT_2_4 \
-        HW_COMPAT_2_4 \
-        {\
-            .driver   = TYPE_S390_SKEYS,\
-            .property = "migration-enabled",\
-            .value    = "off",\
-        },{\
-            .driver   = "virtio-blk-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-balloon-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-serial-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-9p-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-rng-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-net-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "virtio-scsi-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },{\
-            .driver   = "vhost-scsi-ccw",\
-            .property = "max_revision",\
-            .value    = "0",\
-        },
+static GlobalProperty ccw_compat_3_0[] = {
+    HW_COMPAT_3_0
+};
+
+static GlobalProperty ccw_compat_2_12[] = {
+    HW_COMPAT_2_12
+};
+
+static GlobalProperty ccw_compat_2_11[] = {
+    HW_COMPAT_2_11
+    {
+        .driver   = TYPE_SCLP_EVENT_FACILITY,
+        .property = "allow_all_mask_sizes",
+        .value    = "off",
+    },
+};
+
+static GlobalProperty ccw_compat_2_10[] = {
+    HW_COMPAT_2_10
+};
+
+static GlobalProperty ccw_compat_2_9[] = {
+    HW_COMPAT_2_9
+    {
+        .driver   = TYPE_S390_STATTRIB,
+        .property = "migration-enabled",
+        .value    = "off",
+    },
+};
+
+static GlobalProperty ccw_compat_2_8[] = {
+    HW_COMPAT_2_8
+    {
+        .driver   = TYPE_S390_FLIC_COMMON,
+        .property = "adapter_routes_max_batch",
+        .value    = "64",
+    },
+};
+
+static GlobalProperty ccw_compat_2_7[] = {
+    HW_COMPAT_2_7
+};
+
+static GlobalProperty ccw_compat_2_6[] = {
+    HW_COMPAT_2_6
+    {
+        .driver   = TYPE_S390_IPL,
+        .property = "iplbext_migration",
+        .value    = "off",
+    }, {
+        .driver   = TYPE_VIRTUAL_CSS_BRIDGE,
+        .property = "css_dev_path",
+        .value    = "off",
+    },
+};
+
+static GlobalProperty ccw_compat_2_5[] = {
+    HW_COMPAT_2_5
+};
+
+static GlobalProperty ccw_compat_2_4[] = {
+    HW_COMPAT_2_4
+    {
+        .driver   = TYPE_S390_SKEYS,
+        .property = "migration-enabled",
+        .value    = "off",
+    },{
+        .driver   = "virtio-blk-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-balloon-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-serial-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-9p-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-rng-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-net-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "virtio-scsi-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },{
+        .driver   = "vhost-scsi-ccw",
+        .property = "max_revision",
+        .value    = "0",
+    },
+};
 
 static void ccw_machine_3_1_instance_options(MachineState *machine)
 {
@@ -762,7 +772,8 @@ static void ccw_machine_3_0_class_options(MachineClass *mc)
 
     s390mc->hpage_1m_allowed = false;
     ccw_machine_3_1_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_0);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_3_0, G_N_ELEMENTS(ccw_compat_3_0));
 }
 DEFINE_CCW_MACHINE(3_0, "3.0", false);
 
@@ -776,7 +787,8 @@ static void ccw_machine_2_12_instance_options(MachineState *machine)
 static void ccw_machine_2_12_class_options(MachineClass *mc)
 {
     ccw_machine_3_0_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_12);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_12, G_N_ELEMENTS(ccw_compat_2_12));
 }
 DEFINE_CCW_MACHINE(2_12, "2.12", false);
 
@@ -792,7 +804,8 @@ static void ccw_machine_2_11_instance_options(MachineState *machine)
 static void ccw_machine_2_11_class_options(MachineClass *mc)
 {
     ccw_machine_2_12_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_11);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_11, G_N_ELEMENTS(ccw_compat_2_11));
 }
 DEFINE_CCW_MACHINE(2_11, "2.11", false);
 
@@ -804,7 +817,8 @@ static void ccw_machine_2_10_instance_options(MachineState *machine)
 static void ccw_machine_2_10_class_options(MachineClass *mc)
 {
     ccw_machine_2_11_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_10);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_10, G_N_ELEMENTS(ccw_compat_2_10));
 }
 DEFINE_CCW_MACHINE(2_10, "2.10", false);
 
@@ -823,7 +837,8 @@ static void ccw_machine_2_9_class_options(MachineClass *mc)
     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
 
     ccw_machine_2_10_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_9, G_N_ELEMENTS(ccw_compat_2_9));
     s390mc->css_migration_enabled = false;
 }
 DEFINE_CCW_MACHINE(2_9, "2.9", false);
@@ -836,7 +851,8 @@ static void ccw_machine_2_8_instance_options(MachineState *machine)
 static void ccw_machine_2_8_class_options(MachineClass *mc)
 {
     ccw_machine_2_9_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_8);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_8, G_N_ELEMENTS(ccw_compat_2_8));
 }
 DEFINE_CCW_MACHINE(2_8, "2.8", false);
 
@@ -851,7 +867,8 @@ static void ccw_machine_2_7_class_options(MachineClass *mc)
 
     s390mc->cpu_model_allowed = false;
     ccw_machine_2_8_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_7);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_7, G_N_ELEMENTS(ccw_compat_2_7));
 }
 DEFINE_CCW_MACHINE(2_7, "2.7", false);
 
@@ -866,7 +883,8 @@ static void ccw_machine_2_6_class_options(MachineClass *mc)
 
     s390mc->ri_allowed = false;
     ccw_machine_2_7_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_6);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_6, G_N_ELEMENTS(ccw_compat_2_6));
 }
 DEFINE_CCW_MACHINE(2_6, "2.6", false);
 
@@ -878,7 +896,8 @@ static void ccw_machine_2_5_instance_options(MachineState *machine)
 static void ccw_machine_2_5_class_options(MachineClass *mc)
 {
     ccw_machine_2_6_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_5);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_5, G_N_ELEMENTS(ccw_compat_2_5));
 }
 DEFINE_CCW_MACHINE(2_5, "2.5", false);
 
@@ -890,7 +909,8 @@ static void ccw_machine_2_4_instance_options(MachineState *machine)
 static void ccw_machine_2_4_class_options(MachineClass *mc)
 {
     ccw_machine_2_5_class_options(mc);
-    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_4);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_2_4, G_N_ELEMENTS(ccw_compat_2_4));
 }
 DEFINE_CCW_MACHINE(2_4, "2.4", false);
 
diff --git a/vl.c b/vl.c
index 88ba658572..65f0dddb74 100644
--- a/vl.c
+++ b/vl.c
@@ -2968,7 +2968,6 @@ static void user_register_global_props(void)
  */
 static void register_global_properties(MachineState *ms)
 {
-    machine_register_compat_props(ms);
     user_register_global_props();
 }
 
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 09/19] hw: remove SET_MACHINE_COMPAT
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (7 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine " Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 10/19] qdev: make a separate helper function to apply compat properties Marc-André Lureau
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau, Marcel Apfelbaum

No longer needed.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 28c2b0af41..f743d9d4a4 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -287,20 +287,4 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
-#define SET_MACHINE_COMPAT(m, COMPAT) \
-    do {                              \
-        int i;                        \
-        static GlobalProperty props[] = {       \
-            COMPAT                              \
-            { /* end of list */ }               \
-        };                                      \
-        if (!m->compat_props) { \
-            m->compat_props = g_array_new(false, false, sizeof(void *)); \
-        } \
-        for (i = 0; props[i].driver != NULL; i++) {    \
-            GlobalProperty *prop = &props[i];          \
-            g_array_append_val(m->compat_props, prop); \
-        }                                              \
-    } while (0)
-
 #endif
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 10/19] qdev: make a separate helper function to apply compat properties
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (8 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 09/19] hw: remove SET_MACHINE_COMPAT Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided Marc-André Lureau
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

This will allow to apply compat properties on other objects than QDev easily.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h | 2 ++
 hw/core/qdev.c         | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index aeaa6dbbb8..4f9276f3e2 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -422,6 +422,8 @@ const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
 
+void object_apply_compat_props(Object *obj);
+
 /* FIXME: make this a link<> */
 void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
 
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d510340bac..3769a2bccb 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -970,7 +970,7 @@ static void device_initfn(Object *obj)
     QLIST_INIT(&dev->gpios);
 }
 
-static void device_post_init(Object *obj)
+void object_apply_compat_props(Object *obj)
 {
     if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
         MachineState *m = MACHINE(qdev_get_machine());
@@ -982,7 +982,11 @@ static void device_post_init(Object *obj)
         }
         object_apply_global_props(obj, mc->compat_props, &error_abort);
     }
+}
 
+static void device_post_init(Object *obj)
+{
+    object_apply_compat_props(obj);
     qdev_prop_set_globals(DEVICE(obj));
 }
 
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (9 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 10/19] qdev: make a separate helper function to apply compat properties Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-10 17:00   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
                   ` (9 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau, Paolo Bonzini

All globals are now either provided via -global or through -cpu
features (CPU features are implemented by registering globals).

If the global isn't being used, it should warn in either case.

We can thus consider that all global_props are "user-provided"
globals. No need to track this per-globals anymore.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 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 4f9276f3e2..7d25c99a77 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -249,8 +249,6 @@ struct PropertyInfo {
 
 /**
  * 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 = object_class_by_name(prop->driver);
         oc = 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 b1eb505442..60231b1372 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -216,12 +216,12 @@ static void test_dynamic_globalprop_subprocess(void)
 {
     MyType *mt;
     static GlobalProperty props[] = {
-        { 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;
@@ -256,46 +256,6 @@ static void test_dynamic_globalprop(void)
     g_test_trap_assert_stdout("");
 }
 
-/* Test setting of dynamic properties using user_provided=false properties */
-static void test_dynamic_globalprop_nouser_subprocess(void)
-{
-    MyType *mt;
-    static GlobalProperty props[] = {
-        { 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 = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
-    qdev_init_nofail(DEVICE(mt));
-
-    g_assert_cmpuint(mt->prop1, ==, 101);
-    g_assert_cmpuint(mt->prop2, ==, 102);
-    global_error = qdev_prop_check_globals();
-    g_assert_cmpuint(global_error, ==, 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/subprocess", 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 order */
 static void test_subclass_global_props(void)
 {
@@ -345,11 +305,6 @@ int main(int argc, char **argv)
     g_test_add_func("/qdev/properties/dynamic/global",
                     test_dynamic_globalprop);
 
-    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);
 
diff --git a/vl.c b/vl.c
index 65f0dddb74..dfc100f51a 100644
--- a/vl.c
+++ b/vl.c
@@ -2936,7 +2936,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->user_provided = true;
     g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (10 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-10 17:05   ` Igor Mammedov
  2018-12-11 13:04   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty Marc-André Lureau
                   ` (8 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

A step towards being able to call a common function,
object_apply_global_props().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 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..3467e0485c 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 = value;
 }
 
-static GList *global_props;
+static GPtrArray *global_props(void)
+{
+    static GPtrArray *gp;
+
+    if (!gp) {
+        gp = g_ptr_array_new();
+    }
+
+    return gp;
+}
 
 void qdev_prop_register_global(GlobalProperty *prop)
 {
-    global_props = g_list_append(global_props, prop);
+    g_ptr_array_add(global_props(), prop);
 }
 
 int qdev_prop_check_globals(void)
 {
-    GList *l;
-    int ret = 0;
+    int i, ret = 0;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         ObjectClass *oc;
         DeviceClass *dc;
+
+        prop = g_ptr_array_index(global_props(), i);
         if (prop->used) {
             continue;
         }
@@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    GList *l;
+    int i;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         Error *err = NULL;
 
+        prop = g_ptr_array_index(global_props(), i);
         if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
             continue;
         }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (11 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-10 17:20   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props() Marc-André Lureau
                   ` (7 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Paolo Bonzini,
	Richard Henderson, Mark Cave-Ayland, Artyom Tarasenko

All qdev_prop_register_global() set &error_fatal for errp, except
'-rtc driftfix=slew', which arguably should also use &error_fatal, as
otherwise failing to apply the property would only report a warning.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 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 7d25c99a77..1d4f4aa1f5 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;
 
 static inline void
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3467e0485c..a2d25d3d37 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 != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%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 *typename, char *features,
             prop->driver = typename;
             prop->property = g_strdup(featurestr);
             prop->value = g_strdup(val);
-            prop->errp = &error_fatal;
             qdev_prop_register_global(prop);
         } else {
             error_setg(errp, "Expected key=value format, found %s.",
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index f81d35e1f9..c687a9b694 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
         prop->driver = typename;
         prop->property = g_strdup(name);
         prop->value = g_strdup(val);
-        prop->errp = &error_fatal;
         qdev_prop_register_global(prop);
     }
 
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 = typename;
     prop->property = g_strdup(name);
     prop->value = g_strdup(val);
-    prop->errp = &error_fatal;
     qdev_prop_register_global(prop);
 }
 
diff --git a/vl.c b/vl.c
index dfc100f51a..1b25cb3da2 100644
--- a/vl.c
+++ b/vl.c
@@ -2936,7 +2936,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
 }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props()
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (12 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-10 17:28   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data() Marc-André Lureau
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Andreas Färber

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é Lureau <marcandre.lureau@redhat.com>
---
 hw/core/qdev-properties.c | 24 ++----------------------
 qom/object.c              | 12 +++++++++++-
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a2d25d3d37..6061090dc2 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    int i;
-
-    for (i = 0; i < global_props()->len; i++) {
-        GlobalProperty *prop;
-        Error *err = NULL;
-
-        prop = g_ptr_array_index(global_props(), i);
-        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
-            continue;
-        }
-        prop->used = true;
-        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
-        if (err != NULL) {
-            error_prepend(&err, "can't apply global %s.%s=%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);
 }
 
 /* --- 64bit unsigned int 'size' type --- */
diff --git a/qom/object.c b/qom/object.c
index dbdab0aead..aa6f3a2a71 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -390,7 +390,17 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
         if (err != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%s: ",
                           p->driver, p->property, p->value);
-            error_propagate(errp, err);
+            /*
+             * If errp != NULL, propagate error and return.
+             * If errp == NULL, report a warning, but keep going
+             * with the remaining globals.
+             */
+            if (errp) {
+                error_propagate(errp, err);
+                return;
+            } else {
+                warn_report_err(err);
+            }
         }
     }
 }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data()
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (13 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props() Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-11 16:02   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init() Marc-André Lureau
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Andreas Färber

Add a simple function to retrieve the associated class data.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qom/object.h | 9 +++++++++
 qom/object.c         | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 5183c587f3..d5266405da 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -916,6 +916,15 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
  */
 ObjectClass *object_class_get_parent(ObjectClass *klass);
 
+
+/**
+ * object_class_get_class_data:
+ * @klass: The class to obtain associated data.
+ *
+ * Returns: the class_data given when registering the type.
+ */
+void *object_class_get_class_data(ObjectClass *klass);
+
 /**
  * object_class_get_name:
  * @klass: The class to obtain the QOM typename for.
diff --git a/qom/object.c b/qom/object.c
index aa6f3a2a71..bbc6fbbc01 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -867,6 +867,11 @@ const char *object_class_get_name(ObjectClass *klass)
     return klass->type->name;
 }
 
+void *object_class_get_class_data(ObjectClass *klass)
+{
+    return klass->type->class_data;
+}
+
 ObjectClass *object_class_by_name(const char *typename)
 {
     TypeImpl *type = type_get_by_name(typename);
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init()
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (14 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data() Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-11 13:43   ` Igor Mammedov
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0 Marc-André Lureau
                   ` (4 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Peter Maydell, open list:ARM

Replace arm_cpu_post_init() instance callback by calling it from leaf
classes, to avoid potential ordering issue with other post_init callbacks.

Note: this patch is no longer needed in this series, since the
compat-props interface approach was abandoned.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Suggested-by: Igor Mammedov <imammedo@redhat.com>
---
 target/arm/cpu.h   |  2 ++
 target/arm/cpu.c   | 15 ++++++++++++---
 target/arm/cpu64.c | 11 ++++++++++-
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 2a73fed9a0..84fba2b24b 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -884,6 +884,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
     return container_of(env, ARMCPU, env);
 }
 
+void arm_cpu_post_init(Object *obj);
+
 uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
 
 #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 60411f6bfe..8a4aae7438 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -734,7 +734,7 @@ static Property arm_cpu_pmsav7_dregion_property =
 static Property arm_cpu_initsvtor_property =
             DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0);
 
-static void arm_cpu_post_init(Object *obj)
+void arm_cpu_post_init(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
 
@@ -2094,6 +2094,7 @@ static void arm_host_initfn(Object *obj)
     ARMCPU *cpu = ARM_CPU(obj);
 
     kvm_arm_set_cpu_features_from_host(cpu);
+    arm_cpu_post_init(ARM_CPU(obj));
 }
 
 static const TypeInfo host_arm_cpu_type_info = {
@@ -2108,14 +2109,23 @@ static const TypeInfo host_arm_cpu_type_info = {
 
 #endif
 
+static void arm_cpu_instance_init(Object *obj)
+{
+    const ARMCPUInfo *info = object_class_get_class_data(object_get_class(obj));
+
+    info->initfn(obj);
+    arm_cpu_post_init(obj);
+}
+
 static void cpu_register(const ARMCPUInfo *info)
 {
     TypeInfo type_info = {
         .parent = TYPE_ARM_CPU,
         .instance_size = sizeof(ARMCPU),
-        .instance_init = info->initfn,
+        .instance_init = arm_cpu_instance_init,
         .class_size = sizeof(ARMCPUClass),
         .class_init = info->class_init,
+        .class_data = (void *)info,
     };
 
     type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
@@ -2128,7 +2138,6 @@ static const TypeInfo arm_cpu_type_info = {
     .parent = TYPE_CPU,
     .instance_size = sizeof(ARMCPU),
     .instance_init = arm_cpu_initfn,
-    .instance_post_init = arm_cpu_post_init,
     .instance_finalize = arm_cpu_finalizefn,
     .abstract = true,
     .class_size = sizeof(ARMCPUClass),
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 873f059bf2..dbfc3ee490 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -447,14 +447,23 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_arch_name = aarch64_gdb_arch_name;
 }
 
+static void aarch64_cpu_instance_init(Object *obj)
+{
+    const ARMCPUInfo *info = object_class_get_class_data(object_get_class(obj));
+
+    info->initfn(obj);
+    arm_cpu_post_init(obj);
+}
+
 static void aarch64_cpu_register(const ARMCPUInfo *info)
 {
     TypeInfo type_info = {
         .parent = TYPE_AARCH64_CPU,
         .instance_size = sizeof(ARMCPU),
-        .instance_init = info->initfn,
+        .instance_init = aarch64_cpu_instance_init,
         .class_size = sizeof(ARMCPUClass),
         .class_init = info->class_init,
+        .class_data = (void *)info,
     };
 
     type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (15 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init() Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 18/19] hw/arm/virt: add virt-4.0 machine type Marc-André Lureau
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Paolo Bonzini,
	Richard Henderson, Michael S. Tsirkin, Marcel Apfelbaum

The following patch is going to add compatiblity parameters for
qemu <= 3.1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/compat.h  |  3 +++
 include/hw/i386/pc.h |  3 +++
 hw/i386/pc_piix.c    | 21 +++++++++++++++++----
 hw/i386/pc_q35.c     | 18 ++++++++++++++++--
 4 files changed, 39 insertions(+), 6 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
 
+#define HW_COMPAT_3_1 \
+    /* empty */
+
 #define HW_COMPAT_3_0 \
     /* empty */
 
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 *);
 
+#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 575566e466..34b3e924d6 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -428,13 +428,29 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_1_machine_options(MachineClass *m)
+static void pc_i440fx_4_0_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
+                      pc_i440fx_4_0_machine_options);
+
+static GlobalProperty pc_compat_3_1[] = {
+    PC_COMPAT_3_1
+};
+
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
+{
+    pc_i440fx_4_0_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    compat_props_add(m->compat_props,
+                     pc_compat_3_1, G_N_ELEMENTS(pc_compat_3_1));
+}
+
 DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
                       pc_i440fx_3_1_machine_options);
 
@@ -445,9 +461,6 @@ static GlobalProperty pc_compat_3_0[] = {
 static void pc_i440fx_3_0_machine_options(MachineClass *m)
 {
     pc_i440fx_3_1_machine_options(m);
-    m->is_default = 0;
-    m->alias = NULL;
-
     compat_props_add(m->compat_props,
                      pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 701c09b43e..f0874c42d8 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -311,12 +311,27 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_1_machine_options(MachineClass *m)
+static void pc_q35_4_0_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v4_0, "pc-q35-4.0", NULL,
+                   pc_q35_4_0_machine_options);
+
+static GlobalProperty pc_compat_3_1[] = {
+    PC_COMPAT_3_1
+};
+
+static void pc_q35_3_1_machine_options(MachineClass *m)
+{
+    pc_q35_4_0_machine_options(m);
+    m->alias = NULL;
+    compat_props_add(m->compat_props,
+                     pc_compat_3_1, G_N_ELEMENTS(pc_compat_3_1));
+}
+
 DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
                    pc_q35_3_1_machine_options);
 
@@ -327,7 +342,6 @@ static GlobalProperty pc_compat_3_0[] = {
 static void pc_q35_3_0_machine_options(MachineClass *m)
 {
     pc_q35_3_1_machine_options(m);
-    m->alias = NULL;
     compat_props_add(m->compat_props,
                      pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
 }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 18/19] hw/arm/virt: add virt-4.0 machine type
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (16 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0 Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 19/19] hostmem: use object id for memory region name with >= 4.0 Marc-André Lureau
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: imammedo, ehabkost, Marc-André Lureau, Peter Maydell,
	open list:Virt

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/arm/virt.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 530c8ca89d..433374f0d0 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1797,7 +1797,7 @@ static void machvirt_machine_init(void)
 }
 type_init(machvirt_machine_init);
 
-static void virt_3_1_instance_init(Object *obj)
+static void virt_4_0_instance_init(Object *obj)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
     VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
@@ -1867,10 +1867,28 @@ static void virt_3_1_instance_init(Object *obj)
     vms->irqmap = a15irqmap;
 }
 
+static void virt_machine_4_0_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(4, 0)
+
+static GlobalProperty virt_compat_3_1[] = {
+    HW_COMPAT_3_1
+};
+
+static void virt_3_1_instance_init(Object *obj)
+{
+    virt_4_0_instance_init(obj);
+}
+
 static void virt_machine_3_1_options(MachineClass *mc)
 {
+    virt_machine_4_0_options(mc);
+    compat_props_add(mc->compat_props,
+                     virt_compat_3_1, G_N_ELEMENTS(virt_compat_3_1));
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
+
+DEFINE_VIRT_MACHINE(3, 1)
 
 static GlobalProperty virt_compat_3_0[] = {
     HW_COMPAT_3_0
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [Qemu-devel] [PATCH for-3.2 v5 19/19] hostmem: use object id for memory region name with >= 4.0
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (17 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 18/19] hw/arm/virt: add virt-4.0 machine type Marc-André Lureau
@ 2018-12-04 14:20 ` Marc-André Lureau
  2018-12-04 14:22 ` [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
  2018-12-10 17:07 ` Eduardo Habkost
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: imammedo, ehabkost, Marc-André Lureau

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=mem,size=1G,mem-path=/tmp/foo -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-memfd,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-ram,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
                     mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

For consistency, change to use object id for -file and -memfd as well
with >= 4.0.

Having a consistent naming allows to migrate to different hostmem
backends.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 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       | 36 ++++++++++++++++++++++++++++++++++++
 6 files changed, 56 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
 
 #define HW_COMPAT_3_1 \
-    /* empty */
+    {\
+        .driver   = "memory-backend-file",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },{\
+        .driver   = "memory-backend-memfd",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },
 
 #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 {
 
     /* 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(HostMemoryBackend *backend);
 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
 bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
 size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
+char *host_memory_backend_get_name(HostMemoryBackend *backend);
 
 #endif
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 6630021226..5b87e154f3 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -43,7 +43,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
 #ifdef CONFIG_POSIX
-    gchar *path;
+    gchar *name;
 #endif
 
     if (!backend->size) {
@@ -58,14 +58,14 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
     error_setg(errp, "-mem-path not supported on this host");
 #else
     backend->force_prealloc = mem_prealloc;
-    path = object_get_canonical_path(OBJECT(backend));
+    name = 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 2eb9c827a5..98c9bf3240 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -53,7 +53,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
         return;
     }
 
-    name = object_get_canonical_path(OBJECT(backend));
+    name = host_memory_backend_get_name(backend);
     memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
                                    name, backend->size,
                                    backend->share, fd, errp);
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 @@
 
 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
 
-
 static void
 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
-    char *path;
+    char *name;
 
     if (!backend->size) {
         error_setg(errp, "can't create backend with size 0");
         return;
     }
 
-    path = object_get_canonical_path_component(OBJECT(backend));
-    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path,
+    name = 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);
 }
 
 static void
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 1a89342039..c7a7020fed 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND);
 QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE);
 #endif
 
+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)
@@ -238,6 +248,11 @@ static void host_memory_backend_init(Object *obj)
     backend->prealloc = mem_prealloc;
 }
 
+static void host_memory_backend_post_init(Object *obj)
+{
+    object_apply_compat_props(obj);
+}
+
 bool host_memory_backend_mr_inited(HostMemoryBackend *backend)
 {
     /*
@@ -386,6 +401,23 @@ static void host_memory_backend_set_share(Object *o, bool value, Error **errp)
     backend->share = value;
 }
 
+static bool
+host_memory_backend_get_use_canonical_path(Object *obj, Error **errp)
+{
+    HostMemoryBackend *self = 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 = MEMORY_BACKEND(obj);
+
+    self->use_canonical_path = value;
+}
+
 static void
 host_memory_backend_class_init(ObjectClass *oc, void *data)
 {
@@ -432,6 +464,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *data)
         &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);
 }
 
 static const TypeInfo host_memory_backend_info = {
@@ -442,6 +477,7 @@ static const TypeInfo host_memory_backend_info = {
     .class_init = host_memory_backend_class_init,
     .instance_size = sizeof(HostMemoryBackend),
     .instance_init = host_memory_backend_init,
+    .instance_post_init = host_memory_backend_post_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_USER_CREATABLE },
         { }
-- 
2.20.0.rc1

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (18 preceding siblings ...)
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 19/19] hostmem: use object id for memory region name with >= 4.0 Marc-André Lureau
@ 2018-12-04 14:22 ` Marc-André Lureau
  2018-12-10 17:07 ` Eduardo Habkost
  20 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-04 14:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Igor Mammedov, Eduardo Habkost

Sorry, I forgot to change the subject prefix, it should read for-4.0 :)

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-04 14:20   ` Marc-André Lureau
@ 2018-12-10 16:45     ` Igor Mammedov
  -1 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 16:45 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, ehabkost, Stefano Stabellini, Anthony Perard,
	Andreas Färber, Paolo Bonzini, open list:X86

On Tue,  4 Dec 2018 18:20:11 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of registering compat properties as globals, let's keep them
> in their own array, to avoid mixing with user globals.
> 
> Introduce object_apply_global_props() function, to apply compatibility
> properties from a GPtrArray.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/qdev-core.h | 10 ++++++++++
>  include/qom/object.h   |  3 +++
>  include/sysemu/accel.h |  4 +---
>  accel/accel.c          | 12 ------------
>  hw/core/qdev.c         |  9 +++++++++
>  hw/xen/xen-common.c    |  9 ++++++---
>  qom/object.c           | 25 +++++++++++++++++++++++++
>  vl.c                   |  1 -
>  8 files changed, 54 insertions(+), 19 deletions(-)
> 
[...]
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..4532aa8632 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
>          .driver = "migration",
>          .property = "send-section-footer",
>          .value = "off",
> -    },
> -    { /* end of list */ },
> +    }
>  };
>  
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +    ac->compat_props = g_ptr_array_new();
where is matching free for that?

> +
> +    compat_props_add(ac->compat_props,
> +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index 17921c0a71..dbdab0aead 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_ptr_array_index(props, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> diff --git a/vl.c b/vl.c
> index a5ae5f23d2..88ba658572 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2968,7 +2968,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();
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-10 16:45     ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 16:45 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, ehabkost, qemu-devel, open list:X86,
	Anthony Perard, Paolo Bonzini, Andreas Färber

On Tue,  4 Dec 2018 18:20:11 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of registering compat properties as globals, let's keep them
> in their own array, to avoid mixing with user globals.
> 
> Introduce object_apply_global_props() function, to apply compatibility
> properties from a GPtrArray.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/qdev-core.h | 10 ++++++++++
>  include/qom/object.h   |  3 +++
>  include/sysemu/accel.h |  4 +---
>  accel/accel.c          | 12 ------------
>  hw/core/qdev.c         |  9 +++++++++
>  hw/xen/xen-common.c    |  9 ++++++---
>  qom/object.c           | 25 +++++++++++++++++++++++++
>  vl.c                   |  1 -
>  8 files changed, 54 insertions(+), 19 deletions(-)
> 
[...]
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..4532aa8632 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
>          .driver = "migration",
>          .property = "send-section-footer",
>          .value = "off",
> -    },
> -    { /* end of list */ },
> +    }
>  };
>  
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +    ac->compat_props = g_ptr_array_new();
where is matching free for that?

> +
> +    compat_props_add(ac->compat_props,
> +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index 17921c0a71..dbdab0aead 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_ptr_array_index(props, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> diff --git a/vl.c b/vl.c
> index a5ae5f23d2..88ba658572 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2968,7 +2968,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();
>  }


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-10 16:45     ` Igor Mammedov
@ 2018-12-10 16:54       ` Igor Mammedov
  -1 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 16:54 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, ehabkost, qemu-devel, open list:X86,
	Anthony Perard, Paolo Bonzini, Andreas Färber

On Mon, 10 Dec 2018 17:45:22 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> On Tue,  4 Dec 2018 18:20:11 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
> > Instead of registering compat properties as globals, let's keep them
> > in their own array, to avoid mixing with user globals.
> > 
> > Introduce object_apply_global_props() function, to apply compatibility
> > properties from a GPtrArray.
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/hw/qdev-core.h | 10 ++++++++++
> >  include/qom/object.h   |  3 +++
> >  include/sysemu/accel.h |  4 +---
> >  accel/accel.c          | 12 ------------
> >  hw/core/qdev.c         |  9 +++++++++
> >  hw/xen/xen-common.c    |  9 ++++++---
> >  qom/object.c           | 25 +++++++++++++++++++++++++
> >  vl.c                   |  1 -
> >  8 files changed, 54 insertions(+), 19 deletions(-)
> > 
> [...]
> > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > index 6ec14c73ca..4532aa8632 100644
> > --- a/hw/xen/xen-common.c
> > +++ b/hw/xen/xen-common.c
> > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> >          .driver = "migration",
> >          .property = "send-section-footer",
> >          .value = "off",
> > -    },
> > -    { /* end of list */ },
> > +    }
> >  };
> >  
> >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> >  {
> >      AccelClass *ac = ACCEL_CLASS(oc);
> > +
> >      ac->name = "Xen";
> >      ac->init_machine = xen_init;
> >      ac->setup_post = xen_setup_post;
> >      ac->allowed = &xen_allowed;
> > -    ac->global_props = xen_compat_props;
> > +    ac->compat_props = g_ptr_array_new();
> where is matching free for that?
can we at least annotate it somehow so that valgrind won't complain about this leak?

> 
> > +
> > +    compat_props_add(ac->compat_props,
> > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> >  }
> >  
> >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > diff --git a/qom/object.c b/qom/object.c
> > index 17921c0a71..dbdab0aead 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> >      }
> >  }
> >  
> > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > +{
> > +    Error *err = NULL;
> > +    int i;
> > +
> > +    if (!props) {
> > +        return;
> > +    }
> > +
> > +    for (i = 0; i < props->len; i++) {
> > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > +
> > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > +            continue;
> > +        }
> > +        p->used = true;
> > +        object_property_parse(obj, p->value, p->property, &err);
> > +        if (err != NULL) {
> > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > diff --git a/vl.c b/vl.c
> > index a5ae5f23d2..88ba658572 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -2968,7 +2968,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();
> >  }
> 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-10 16:54       ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 16:54 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, ehabkost, qemu-devel, Paolo Bonzini,
	Anthony Perard, open list:X86, Andreas Färber

On Mon, 10 Dec 2018 17:45:22 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> On Tue,  4 Dec 2018 18:20:11 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
> > Instead of registering compat properties as globals, let's keep them
> > in their own array, to avoid mixing with user globals.
> > 
> > Introduce object_apply_global_props() function, to apply compatibility
> > properties from a GPtrArray.
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/hw/qdev-core.h | 10 ++++++++++
> >  include/qom/object.h   |  3 +++
> >  include/sysemu/accel.h |  4 +---
> >  accel/accel.c          | 12 ------------
> >  hw/core/qdev.c         |  9 +++++++++
> >  hw/xen/xen-common.c    |  9 ++++++---
> >  qom/object.c           | 25 +++++++++++++++++++++++++
> >  vl.c                   |  1 -
> >  8 files changed, 54 insertions(+), 19 deletions(-)
> > 
> [...]
> > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > index 6ec14c73ca..4532aa8632 100644
> > --- a/hw/xen/xen-common.c
> > +++ b/hw/xen/xen-common.c
> > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> >          .driver = "migration",
> >          .property = "send-section-footer",
> >          .value = "off",
> > -    },
> > -    { /* end of list */ },
> > +    }
> >  };
> >  
> >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> >  {
> >      AccelClass *ac = ACCEL_CLASS(oc);
> > +
> >      ac->name = "Xen";
> >      ac->init_machine = xen_init;
> >      ac->setup_post = xen_setup_post;
> >      ac->allowed = &xen_allowed;
> > -    ac->global_props = xen_compat_props;
> > +    ac->compat_props = g_ptr_array_new();
> where is matching free for that?
can we at least annotate it somehow so that valgrind won't complain about this leak?

> 
> > +
> > +    compat_props_add(ac->compat_props,
> > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> >  }
> >  
> >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > diff --git a/qom/object.c b/qom/object.c
> > index 17921c0a71..dbdab0aead 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> >      }
> >  }
> >  
> > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > +{
> > +    Error *err = NULL;
> > +    int i;
> > +
> > +    if (!props) {
> > +        return;
> > +    }
> > +
> > +    for (i = 0; i < props->len; i++) {
> > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > +
> > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > +            continue;
> > +        }
> > +        p->used = true;
> > +        object_property_parse(obj, p->value, p->property, &err);
> > +        if (err != NULL) {
> > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > diff --git a/vl.c b/vl.c
> > index a5ae5f23d2..88ba658572 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -2968,7 +2968,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();
> >  }
> 
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided Marc-André Lureau
@ 2018-12-10 17:00   ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 17:00 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, Paolo Bonzini, ehabkost

On Tue,  4 Dec 2018 18:20:15 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> All globals are now either provided via -global or through -cpu
> features (CPU features are implemented by registering globals).
> 
> If the global isn't being used, it should warn in either case.
> 
> We can thus consider that all global_props are "user-provided"
> globals. No need to track this per-globals anymore.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  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 4f9276f3e2..7d25c99a77 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -249,8 +249,6 @@ struct PropertyInfo {
>  
>  /**
>   * 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 = object_class_by_name(prop->driver);
>          oc = 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 b1eb505442..60231b1372 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -216,12 +216,12 @@ static void test_dynamic_globalprop_subprocess(void)
>  {
>      MyType *mt;
>      static GlobalProperty props[] = {
> -        { 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;
> @@ -256,46 +256,6 @@ static void test_dynamic_globalprop(void)
>      g_test_trap_assert_stdout("");
>  }
>  
> -/* Test setting of dynamic properties using user_provided=false properties */
> -static void test_dynamic_globalprop_nouser_subprocess(void)
> -{
> -    MyType *mt;
> -    static GlobalProperty props[] = {
> -        { 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 = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
> -    qdev_init_nofail(DEVICE(mt));
> -
> -    g_assert_cmpuint(mt->prop1, ==, 101);
> -    g_assert_cmpuint(mt->prop2, ==, 102);
> -    global_error = qdev_prop_check_globals();
> -    g_assert_cmpuint(global_error, ==, 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/subprocess", 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 order */
>  static void test_subclass_global_props(void)
>  {
> @@ -345,11 +305,6 @@ int main(int argc, char **argv)
>      g_test_add_func("/qdev/properties/dynamic/global",
>                      test_dynamic_globalprop);
>  
> -    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);
>  
> diff --git a/vl.c b/vl.c
> index 65f0dddb74..dfc100f51a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2936,7 +2936,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      g->driver   = qemu_opt_get(opts, "driver");
>      g->property = qemu_opt_get(opts, "property");
>      g->value    = qemu_opt_get(opts, "value");
> -    g->user_provided = true;
>      g->errp = &error_fatal;
>      qdev_prop_register_global(g);
>      return 0;

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
@ 2018-12-10 17:05   ` Igor Mammedov
  2018-12-11 12:12     ` Marc-André Lureau
  2018-12-11 13:04   ` Igor Mammedov
  1 sibling, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 17:05 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, ehabkost

On Tue,  4 Dec 2018 18:20:16 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> A step towards being able to call a common function,
> object_apply_global_props().
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  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..3467e0485c 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 = value;
>  }
>  
> -static GList *global_props;
> +static GPtrArray *global_props(void)
> +{
> +    static GPtrArray *gp;
> +
> +    if (!gp) {
> +        gp = g_ptr_array_new();
one more leak?

> +    }
> +
> +    return gp;
> +}
>  
>  void qdev_prop_register_global(GlobalProperty *prop)
>  {
> -    global_props = g_list_append(global_props, prop);
> +    g_ptr_array_add(global_props(), prop);
>  }
>  
>  int qdev_prop_check_globals(void)
>  {
> -    GList *l;
> -    int ret = 0;
> +    int i, ret = 0;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          ObjectClass *oc;
>          DeviceClass *dc;
> +
> +        prop = g_ptr_array_index(global_props(), i);
>          if (prop->used) {
>              continue;
>          }
> @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    GList *l;
> +    int i;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          Error *err = NULL;
>  
> +        prop = g_ptr_array_index(global_props(), i);
>          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
>              continue;
>          }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
  2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
                   ` (19 preceding siblings ...)
  2018-12-04 14:22 ` [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
@ 2018-12-10 17:07 ` Eduardo Habkost
  2018-12-10 17:31   ` Igor Mammedov
  20 siblings, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-10 17:07 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, imammedo

On Tue, Dec 04, 2018 at 06:20:04PM +0400, Marc-André Lureau wrote:
[...]
> Marc-André Lureau (19):
>   tests: qdev_prop_check_globals() doesn't return "all_used"
>   qom: make interface types abstract
>   qom: make user_creatable_complete() specific to UserCreatable
>   accel: register global_props like machine globals
>   qdev: move qdev_prop_register_global_list() to tests
>   qom: remove unimplemented class_finalize

Patches 1-6 (above) queued on machine-next.  Thanks!

>   hw: apply accel compat properties without touching globals
>   hw: apply machine compat properties without touching globals
>   hw: remove SET_MACHINE_COMPAT
>   qdev: make a separate helper function to apply compat properties
>   qdev: all globals are now user-provided
>   qdev-props: convert global_props to GPtrArray
>   qdev-props: remove errp from GlobalProperty
>   qdev-props: call object_apply_global_props()
>   qom: add object_class_get_class_data()
>   RFC: arm: replace instance_post_init()
>   hw/i386: add pc-i440fx-4.0 & pc-q35-4.0
>   hw/arm/virt: add virt-4.0 machine type
>   hostmem: use object id for memory region name with >= 4.0
> 

-- 
Eduardo

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty Marc-André Lureau
@ 2018-12-10 17:20   ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 17:20 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, ehabkost, Paolo Bonzini, Richard Henderson,
	Mark Cave-Ayland, Artyom Tarasenko

On Tue,  4 Dec 2018 18:20:17 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> All qdev_prop_register_global() set &error_fatal for errp, except
> '-rtc driftfix=slew', which arguably should also use &error_fatal, as
this one shouldn't fail if machine has mc146818rtc instantiated,
it should warn only in case when CLI is mis-configured (i.e. machine
doesn't have mc146818rtc device). I'd say let it die in this case
and make user fix CLI.

> otherwise failing to apply the property would only report a warning.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  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 7d25c99a77..1d4f4aa1f5 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;
>  
>  static inline void
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 3467e0485c..a2d25d3d37 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 != NULL) {
>              error_prepend(&err, "can't apply global %s.%s=%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 *typename, char *features,
>              prop->driver = typename;
>              prop->property = g_strdup(featurestr);
>              prop->value = g_strdup(val);
> -            prop->errp = &error_fatal;
>              qdev_prop_register_global(prop);
>          } else {
>              error_setg(errp, "Expected key=value format, found %s.",
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index f81d35e1f9..c687a9b694 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
>          prop->driver = typename;
>          prop->property = g_strdup(name);
>          prop->value = g_strdup(val);
> -        prop->errp = &error_fatal;
>          qdev_prop_register_global(prop);
>      }
>  
> 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 = typename;
>      prop->property = g_strdup(name);
>      prop->value = g_strdup(val);
> -    prop->errp = &error_fatal;
>      qdev_prop_register_global(prop);
>  }
>  
> diff --git a/vl.c b/vl.c
> index dfc100f51a..1b25cb3da2 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2936,7 +2936,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      g->driver   = qemu_opt_get(opts, "driver");
>      g->property = qemu_opt_get(opts, "property");
>      g->value    = qemu_opt_get(opts, "value");
> -    g->errp = &error_fatal;
>      qdev_prop_register_global(g);
>      return 0;
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props()
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props() Marc-André Lureau
@ 2018-12-10 17:28   ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 17:28 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, ehabkost, Andreas Färber

On Tue,  4 Dec 2018 18:20:18 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> 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é Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/core/qdev-properties.c | 24 ++----------------------
>  qom/object.c              | 12 +++++++++++-
>  2 files changed, 13 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index a2d25d3d37..6061090dc2 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    int i;
> -
> -    for (i = 0; i < global_props()->len; i++) {
> -        GlobalProperty *prop;
> -        Error *err = NULL;
> -
> -        prop = g_ptr_array_index(global_props(), i);
> -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> -            continue;
> -        }
> -        prop->used = true;
> -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> -        if (err != NULL) {
> -            error_prepend(&err, "can't apply global %s.%s=%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);
>  }
>  
>  /* --- 64bit unsigned int 'size' type --- */
> diff --git a/qom/object.c b/qom/object.c
> index dbdab0aead..aa6f3a2a71 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -390,7 +390,17 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
>          if (err != NULL) {
>              error_prepend(&err, "can't apply global %s.%s=%s: ",
>                            p->driver, p->property, p->value);
> -            error_propagate(errp, err);
> +            /*
> +             * If errp != NULL, propagate error and return.
> +             * If errp == NULL, report a warning, but keep going
> +             * with the remaining globals.
> +             */
> +            if (errp) {
> +                error_propagate(errp, err);
> +                return;
> +            } else {
> +                warn_report_err(err);
> +            }
>          }
>      }
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine " Marc-André Lureau
@ 2018-12-10 17:31   ` Eduardo Habkost
  2018-12-11 12:07     ` Marc-André Lureau
  2018-12-11 14:23   ` Eduardo Habkost
  1 sibling, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-10 17:31 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Cornelia Huck, Michael S. Tsirkin,
	David Hildenbrand, Christian Borntraeger, open list:S390,
	Paolo Bonzini, open list:sPAPR, imammedo, David Gibson,
	open list:Virt, Richard Henderson

On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> Similarly to accel properties, move compat properties out of globals
> registration, and apply the machine compat properties during
> device_post_init().
> 
> As suggested during review, populating the arrays can be done directly
> without resorting to using macros.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/boards.h        |   3 +-
>  hw/arm/virt.c              |  48 ++-
>  hw/core/machine.c          |  19 +-
>  hw/core/qdev.c             |   2 +
>  hw/i386/pc_piix.c          | 588 +++++++++++++++++++++----------------
>  hw/i386/pc_q35.c           |  70 ++++-
>  hw/ppc/spapr.c             | 209 +++++++------
>  hw/s390x/s390-virtio-ccw.c | 220 +++++++-------
>  vl.c                       |   1 -
>  9 files changed, 673 insertions(+), 487 deletions(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index f82f28468b..28c2b0af41 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,
> @@ -191,7 +190,7 @@ struct MachineClass {
>      const char *default_machine_opts;
>      const char *default_boot_order;
>      const char *default_display;
> -    GArray *compat_props;
> +    GPtrArray *compat_props;
>      const char *hw_version;
>      ram_addr_t default_ram_size;
>      const char *default_cpu_type;
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index f69e7eb399..530c8ca89d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1872,8 +1872,9 @@ static void virt_machine_3_1_options(MachineClass *mc)
>  }
>  DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
>  
> -#define VIRT_COMPAT_3_0 \
> +static GlobalProperty virt_compat_3_0[] = {
>      HW_COMPAT_3_0
> +};
[...]

All the changes to compat macros are independent from the change
you describe in the patch subject, and makes review more
difficult.  What about doing that in a separate patch?

We can replace all the virt.c, pc_piix.c, pc_q35.c, and spapr.c
hunks in this patch with the following:

diff --git a/include/hw/boards.h b/include/hw/boards.h
index f82f28468b..622bbaf939 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -290,18 +289,10 @@ struct MachineState {
 
 #define SET_MACHINE_COMPAT(m, COMPAT) \
     do {                              \
-        int i;                        \
         static GlobalProperty props[] = {       \
             COMPAT                              \
-            { /* end of list */ }               \
         };                                      \
-        if (!m->compat_props) { \
-            m->compat_props = g_array_new(false, false, sizeof(void *)); \
-        } \
-        for (i = 0; props[i].driver != NULL; i++) {    \
-            GlobalProperty *prop = &props[i];          \
-            g_array_append_val(m->compat_props, prop); \
-        }                                              \
+        compat_props_add(m->compat_props, props, G_N_ELEMENTS(props)); \
     } while (0)
 
 #endif


-- 
Eduardo

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
  2018-12-10 17:07 ` Eduardo Habkost
@ 2018-12-10 17:31   ` Igor Mammedov
  2018-12-10 17:39     ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-12-10 17:31 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Marc-André Lureau, qemu-devel

On Mon, 10 Dec 2018 15:07:18 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Tue, Dec 04, 2018 at 06:20:04PM +0400, Marc-André Lureau wrote:
> [...]
> > Marc-André Lureau (19):
> >   tests: qdev_prop_check_globals() doesn't return "all_used"
> >   qom: make interface types abstract
> >   qom: make user_creatable_complete() specific to UserCreatable
> >   accel: register global_props like machine globals
> >   qdev: move qdev_prop_register_global_list() to tests
> >   qom: remove unimplemented class_finalize
> 
> Patches 1-6 (above) queued on machine-next.  Thanks!
let's drop patch 6 for now until we decide what to do with GPtrArray leaks

> 
> >   hw: apply accel compat properties without touching globals
> >   hw: apply machine compat properties without touching globals
> >   hw: remove SET_MACHINE_COMPAT
> >   qdev: make a separate helper function to apply compat properties
> >   qdev: all globals are now user-provided
> >   qdev-props: convert global_props to GPtrArray
> >   qdev-props: remove errp from GlobalProperty
> >   qdev-props: call object_apply_global_props()
> >   qom: add object_class_get_class_data()
> >   RFC: arm: replace instance_post_init()
> >   hw/i386: add pc-i440fx-4.0 & pc-q35-4.0
> >   hw/arm/virt: add virt-4.0 machine type
> >   hostmem: use object id for memory region name with >= 4.0
> > 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
  2018-12-10 17:31   ` Igor Mammedov
@ 2018-12-10 17:39     ` Eduardo Habkost
  2018-12-11 15:11       ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-10 17:39 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: Marc-André Lureau, qemu-devel

On Mon, Dec 10, 2018 at 06:31:59PM +0100, Igor Mammedov wrote:
> On Mon, 10 Dec 2018 15:07:18 -0200
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Tue, Dec 04, 2018 at 06:20:04PM +0400, Marc-André Lureau wrote:
> > [...]
> > > Marc-André Lureau (19):
> > >   tests: qdev_prop_check_globals() doesn't return "all_used"
> > >   qom: make interface types abstract
> > >   qom: make user_creatable_complete() specific to UserCreatable
> > >   accel: register global_props like machine globals
> > >   qdev: move qdev_prop_register_global_list() to tests
> > >   qom: remove unimplemented class_finalize
> > 
> > Patches 1-6 (above) queued on machine-next.  Thanks!
> let's drop patch 6 for now until we decide what to do with GPtrArray leaks

I appreciate your effort to make sure there are no memory
allocations that could make Valgrind complain, but I don't see
the point of keeping dead code that was never called in the tree.

Are the new GPtrArray allocations different from the g_malloc0()
calls in type_new() and type_initialize()?  Doesn't Valgrind
complain about them today?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-10 17:31   ` Eduardo Habkost
@ 2018-12-11 12:07     ` Marc-André Lureau
  2018-12-11 14:02       ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-11 12:07 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, David Hildenbrand, open list:sPAPR pseries,
	Cornelia Huck, QEMU, Christian Borntraeger, Qemu-s390x list,
	open list:ARM, Michael S. Tsirkin, Igor Mammedov, Paolo Bonzini,
	Richard Henderson, David Gibson

Hi

On Mon, Dec 10, 2018 at 9:31 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> > Similarly to accel properties, move compat properties out of globals
> > registration, and apply the machine compat properties during
> > device_post_init().
> >
> > As suggested during review, populating the arrays can be done directly
> > without resorting to using macros.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/hw/boards.h        |   3 +-
> >  hw/arm/virt.c              |  48 ++-
> >  hw/core/machine.c          |  19 +-
> >  hw/core/qdev.c             |   2 +
> >  hw/i386/pc_piix.c          | 588 +++++++++++++++++++++----------------
> >  hw/i386/pc_q35.c           |  70 ++++-
> >  hw/ppc/spapr.c             | 209 +++++++------
> >  hw/s390x/s390-virtio-ccw.c | 220 +++++++-------
> >  vl.c                       |   1 -
> >  9 files changed, 673 insertions(+), 487 deletions(-)
> >
> > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > index f82f28468b..28c2b0af41 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,
> > @@ -191,7 +190,7 @@ struct MachineClass {
> >      const char *default_machine_opts;
> >      const char *default_boot_order;
> >      const char *default_display;
> > -    GArray *compat_props;
> > +    GPtrArray *compat_props;
> >      const char *hw_version;
> >      ram_addr_t default_ram_size;
> >      const char *default_cpu_type;
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > index f69e7eb399..530c8ca89d 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -1872,8 +1872,9 @@ static void virt_machine_3_1_options(MachineClass *mc)
> >  }
> >  DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
> >
> > -#define VIRT_COMPAT_3_0 \
> > +static GlobalProperty virt_compat_3_0[] = {
> >      HW_COMPAT_3_0
> > +};
> [...]
>
> All the changes to compat macros are independent from the change
> you describe in the patch subject, and makes review more
> difficult.  What about doing that in a separate patch?
>
> We can replace all the virt.c, pc_piix.c, pc_q35.c, and spapr.c
> hunks in this patch with the following:
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index f82f28468b..622bbaf939 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -290,18 +289,10 @@ struct MachineState {
>
>  #define SET_MACHINE_COMPAT(m, COMPAT) \
>      do {                              \
> -        int i;                        \
>          static GlobalProperty props[] = {       \
>              COMPAT                              \
> -            { /* end of list */ }               \
>          };                                      \
> -        if (!m->compat_props) { \
> -            m->compat_props = g_array_new(false, false, sizeof(void *)); \
> -        } \
> -        for (i = 0; props[i].driver != NULL; i++) {    \
> -            GlobalProperty *prop = &props[i];          \
> -            g_array_append_val(m->compat_props, prop); \
> -        }                                              \
> +        compat_props_add(m->compat_props, props, G_N_ELEMENTS(props)); \
>      } while (0)
>
>  #endif
>

Didn't you ask in a previous iteration to remove the macros?
"I like us to be able to
register compat properties without macro magic.  The existence of
SET_MACHINE_COMPAT is a bug and not a feature.


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray
  2018-12-10 17:05   ` Igor Mammedov
@ 2018-12-11 12:12     ` Marc-André Lureau
  2018-12-11 13:03       ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-11 12:12 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU, Eduardo Habkost

Hi

On Mon, Dec 10, 2018 at 9:07 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Tue,  4 Dec 2018 18:20:16 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
>
> > A step towards being able to call a common function,
> > object_apply_global_props().
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  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..3467e0485c 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 = value;
> >  }
> >
> > -static GList *global_props;
> > +static GPtrArray *global_props(void)
> > +{
> > +    static GPtrArray *gp;
> > +
> > +    if (!gp) {
> > +        gp = g_ptr_array_new();
> one more leak?

We leak the global_props list before and using a list is going to use
more memory than using a GPtrArray.

If you worry about the global leaks, we can adress it with
destructors. I don't think that matters here.

>
> > +    }
> > +
> > +    return gp;
> > +}
> >
> >  void qdev_prop_register_global(GlobalProperty *prop)
> >  {
> > -    global_props = g_list_append(global_props, prop);
> > +    g_ptr_array_add(global_props(), prop);
> >  }
> >
> >  int qdev_prop_check_globals(void)
> >  {
> > -    GList *l;
> > -    int ret = 0;
> > +    int i, ret = 0;
> >
> > -    for (l = global_props; l; l = l->next) {
> > -        GlobalProperty *prop = l->data;
> > +    for (i = 0; i < global_props()->len; i++) {
> > +        GlobalProperty *prop;
> >          ObjectClass *oc;
> >          DeviceClass *dc;
> > +
> > +        prop = g_ptr_array_index(global_props(), i);
> >          if (prop->used) {
> >              continue;
> >          }
> > @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
> >
> >  void qdev_prop_set_globals(DeviceState *dev)
> >  {
> > -    GList *l;
> > +    int i;
> >
> > -    for (l = global_props; l; l = l->next) {
> > -        GlobalProperty *prop = l->data;
> > +    for (i = 0; i < global_props()->len; i++) {
> > +        GlobalProperty *prop;
> >          Error *err = NULL;
> >
> > +        prop = g_ptr_array_index(global_props(), i);
> >          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> >              continue;
> >          }
>
>


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray
  2018-12-11 12:12     ` Marc-André Lureau
@ 2018-12-11 13:03       ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 13:03 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Eduardo Habkost

On Tue, 11 Dec 2018 16:12:58 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> 
> On Mon, Dec 10, 2018 at 9:07 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Tue,  4 Dec 2018 18:20:16 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >  
> > > A step towards being able to call a common function,
> > > object_apply_global_props().
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  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..3467e0485c 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 = value;
> > >  }
> > >
> > > -static GList *global_props;
> > > +static GPtrArray *global_props(void)
> > > +{
> > > +    static GPtrArray *gp;
> > > +
> > > +    if (!gp) {
> > > +        gp = g_ptr_array_new();  
> > one more leak?  
> 
> We leak the global_props list before and using a list is going to use
> more memory than using a GPtrArray.
> 
> If you worry about the global leaks, we can adress it with
> destructors. I don't think that matters here.

We don't do it for a bunch of 'static' objects, so as Eduardo
pointed out it's not worth it or more precisely it's broken
currently and it's out of the scope of this series to fix it
up.

> 
> >  
> > > +    }
> > > +
> > > +    return gp;
> > > +}
> > >
> > >  void qdev_prop_register_global(GlobalProperty *prop)
> > >  {
> > > -    global_props = g_list_append(global_props, prop);
> > > +    g_ptr_array_add(global_props(), prop);
> > >  }
> > >
> > >  int qdev_prop_check_globals(void)
> > >  {
> > > -    GList *l;
> > > -    int ret = 0;
> > > +    int i, ret = 0;
> > >
> > > -    for (l = global_props; l; l = l->next) {
> > > -        GlobalProperty *prop = l->data;
> > > +    for (i = 0; i < global_props()->len; i++) {
> > > +        GlobalProperty *prop;
> > >          ObjectClass *oc;
> > >          DeviceClass *dc;
> > > +
> > > +        prop = g_ptr_array_index(global_props(), i);
> > >          if (prop->used) {
> > >              continue;
> > >          }
> > > @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
> > >
> > >  void qdev_prop_set_globals(DeviceState *dev)
> > >  {
> > > -    GList *l;
> > > +    int i;
> > >
> > > -    for (l = global_props; l; l = l->next) {
> > > -        GlobalProperty *prop = l->data;
> > > +    for (i = 0; i < global_props()->len; i++) {
> > > +        GlobalProperty *prop;
> > >          Error *err = NULL;
> > >
> > > +        prop = g_ptr_array_index(global_props(), i);
> > >          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> > >              continue;
> > >          }  
> >
> >  
> 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
  2018-12-10 17:05   ` Igor Mammedov
@ 2018-12-11 13:04   ` Igor Mammedov
  1 sibling, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 13:04 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, ehabkost

On Tue,  4 Dec 2018 18:20:16 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> A step towards being able to call a common function,
> object_apply_global_props().
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  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..3467e0485c 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 = value;
>  }
>  
> -static GList *global_props;
> +static GPtrArray *global_props(void)
> +{
> +    static GPtrArray *gp;
> +
> +    if (!gp) {
> +        gp = g_ptr_array_new();
> +    }
> +
> +    return gp;
> +}
>  
>  void qdev_prop_register_global(GlobalProperty *prop)
>  {
> -    global_props = g_list_append(global_props, prop);
> +    g_ptr_array_add(global_props(), prop);
>  }
>  
>  int qdev_prop_check_globals(void)
>  {
> -    GList *l;
> -    int ret = 0;
> +    int i, ret = 0;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          ObjectClass *oc;
>          DeviceClass *dc;
> +
> +        prop = g_ptr_array_index(global_props(), i);
>          if (prop->used) {
>              continue;
>          }
> @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    GList *l;
> +    int i;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          Error *err = NULL;
>  
> +        prop = g_ptr_array_index(global_props(), i);
>          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
>              continue;
>          }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-04 14:20   ` Marc-André Lureau
@ 2018-12-11 13:14     ` Igor Mammedov
  -1 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 13:14 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Stefano Stabellini, ehabkost, open list:X86,
	Paolo Bonzini, Anthony Perard, Andreas Färber

On Tue,  4 Dec 2018 18:20:11 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of registering compat properties as globals, let's keep them
> in their own array, to avoid mixing with user globals.
> 
> Introduce object_apply_global_props() function, to apply compatibility
> properties from a GPtrArray.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
other than static leak looks fine, considering that we already
leak compat_props, it doesn't really matter, so:

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/qdev-core.h | 10 ++++++++++
>  include/qom/object.h   |  3 +++
>  include/sysemu/accel.h |  4 +---
>  accel/accel.c          | 12 ------------
>  hw/core/qdev.c         |  9 +++++++++
>  hw/xen/xen-common.c    |  9 ++++++---
>  qom/object.c           | 25 +++++++++++++++++++++++++
>  vl.c                   |  1 -
>  8 files changed, 54 insertions(+), 19 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index a24d0dd566..aeaa6dbbb8 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -267,6 +267,16 @@ typedef struct GlobalProperty {
>      Error **errp;
>  } GlobalProperty;
>  
> +static inline void
> +compat_props_add(GPtrArray *arr,
> +                 GlobalProperty props[], size_t nelem)
> +{
> +    int i;
> +    for (i = 0; i < nelem; i++) {
> +        g_ptr_array_add(arr, (void *)&props[i]);
> +    }
> +}
> +
>  /*** Board API.  This should go away once we have a machine config file.  ***/
>  
>  DeviceState *qdev_create(BusState *bus, const char *name);
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 0139838b69..5183c587f3 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -676,6 +676,9 @@ Object *object_new_with_propv(const char *typename,
>                                Error **errp,
>                                va_list vargs);
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *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..f331d128e9 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;
> +    GPtrArray *compat_props;
>  } AccelClass;
>  
>  #define TYPE_ACCEL "accel"
> @@ -67,8 +67,6 @@ typedef struct AccelClass {
>  extern unsigned long tcg_tb_size;
>  
>  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);
>  
> 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)
>      }
>  }
>  
> -void accel_register_compat_props(AccelState *accel)
> -{
> -    AccelClass *class = ACCEL_GET_CLASS(accel);
> -    GlobalProperty *prop = class->global_props;
> -
> -    for (; prop && prop->driver; prop++) {
> -        /* Any compat_props must never cause error */
> -        prop->errp = &error_abort;
> -        qdev_prop_register_global(prop);
> -    }
> -}
> -
>  void accel_setup_post(MachineState *ms)
>  {
>      AccelState *accel = ms->accelerator;
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..53b507164f 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -972,6 +972,15 @@ static void device_initfn(Object *obj)
>  
>  static void device_post_init(Object *obj)
>  {
> +    if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
> +        MachineState *m = MACHINE(qdev_get_machine());
> +        AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);
> +
> +        if (ac->compat_props) {
> +            object_apply_global_props(obj, ac->compat_props, &error_abort);
> +        }
> +    }
> +
>      qdev_prop_set_globals(DEVICE(obj));
>  }
>  
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..4532aa8632 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
>          .driver = "migration",
>          .property = "send-section-footer",
>          .value = "off",
> -    },
> -    { /* end of list */ },
> +    }
>  };
>  
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +    ac->compat_props = g_ptr_array_new();
> +
> +    compat_props_add(ac->compat_props,
> +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index 17921c0a71..dbdab0aead 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_ptr_array_index(props, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> diff --git a/vl.c b/vl.c
> index a5ae5f23d2..88ba658572 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2968,7 +2968,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();
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-11 13:14     ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 13:14 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, ehabkost, qemu-devel, Paolo Bonzini,
	Anthony Perard, open list:X86, Andreas Färber

On Tue,  4 Dec 2018 18:20:11 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of registering compat properties as globals, let's keep them
> in their own array, to avoid mixing with user globals.
> 
> Introduce object_apply_global_props() function, to apply compatibility
> properties from a GPtrArray.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
other than static leak looks fine, considering that we already
leak compat_props, it doesn't really matter, so:

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/qdev-core.h | 10 ++++++++++
>  include/qom/object.h   |  3 +++
>  include/sysemu/accel.h |  4 +---
>  accel/accel.c          | 12 ------------
>  hw/core/qdev.c         |  9 +++++++++
>  hw/xen/xen-common.c    |  9 ++++++---
>  qom/object.c           | 25 +++++++++++++++++++++++++
>  vl.c                   |  1 -
>  8 files changed, 54 insertions(+), 19 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index a24d0dd566..aeaa6dbbb8 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -267,6 +267,16 @@ typedef struct GlobalProperty {
>      Error **errp;
>  } GlobalProperty;
>  
> +static inline void
> +compat_props_add(GPtrArray *arr,
> +                 GlobalProperty props[], size_t nelem)
> +{
> +    int i;
> +    for (i = 0; i < nelem; i++) {
> +        g_ptr_array_add(arr, (void *)&props[i]);
> +    }
> +}
> +
>  /*** Board API.  This should go away once we have a machine config file.  ***/
>  
>  DeviceState *qdev_create(BusState *bus, const char *name);
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 0139838b69..5183c587f3 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -676,6 +676,9 @@ Object *object_new_with_propv(const char *typename,
>                                Error **errp,
>                                va_list vargs);
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *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..f331d128e9 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;
> +    GPtrArray *compat_props;
>  } AccelClass;
>  
>  #define TYPE_ACCEL "accel"
> @@ -67,8 +67,6 @@ typedef struct AccelClass {
>  extern unsigned long tcg_tb_size;
>  
>  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);
>  
> 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)
>      }
>  }
>  
> -void accel_register_compat_props(AccelState *accel)
> -{
> -    AccelClass *class = ACCEL_GET_CLASS(accel);
> -    GlobalProperty *prop = class->global_props;
> -
> -    for (; prop && prop->driver; prop++) {
> -        /* Any compat_props must never cause error */
> -        prop->errp = &error_abort;
> -        qdev_prop_register_global(prop);
> -    }
> -}
> -
>  void accel_setup_post(MachineState *ms)
>  {
>      AccelState *accel = ms->accelerator;
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..53b507164f 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -972,6 +972,15 @@ static void device_initfn(Object *obj)
>  
>  static void device_post_init(Object *obj)
>  {
> +    if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
> +        MachineState *m = MACHINE(qdev_get_machine());
> +        AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);
> +
> +        if (ac->compat_props) {
> +            object_apply_global_props(obj, ac->compat_props, &error_abort);
> +        }
> +    }
> +
>      qdev_prop_set_globals(DEVICE(obj));
>  }
>  
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..4532aa8632 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
>          .driver = "migration",
>          .property = "send-section-footer",
>          .value = "off",
> -    },
> -    { /* end of list */ },
> +    }
>  };
>  
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +    ac->compat_props = g_ptr_array_new();
> +
> +    compat_props_add(ac->compat_props,
> +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index 17921c0a71..dbdab0aead 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_ptr_array_index(props, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> diff --git a/vl.c b/vl.c
> index a5ae5f23d2..88ba658572 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2968,7 +2968,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();
>  }


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init()
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init() Marc-André Lureau
@ 2018-12-11 13:43   ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 13:43 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, open list:ARM, ehabkost, Andrew Jones

On Tue,  4 Dec 2018 18:20:20 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Replace arm_cpu_post_init() instance callback by calling it from leaf
> classes, to avoid potential ordering issue with other post_init callbacks.
> 
> Note: this patch is no longer needed in this series, since the
> compat-props interface approach was abandoned.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
Current call chain is
  aarch64_a57_initfn()
  arm_cpu_post_init()
  device_post_init()

so no compats nor globals influence arm_cpu_post_init() flow,
so it's save to squash it in initfn.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
 
> ---
>  target/arm/cpu.h   |  2 ++
>  target/arm/cpu.c   | 15 ++++++++++++---
>  target/arm/cpu64.c | 11 ++++++++++-
>  3 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 2a73fed9a0..84fba2b24b 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -884,6 +884,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
>      return container_of(env, ARMCPU, env);
>  }
>  
> +void arm_cpu_post_init(Object *obj);
> +
>  uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);
>  
>  #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 60411f6bfe..8a4aae7438 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -734,7 +734,7 @@ static Property arm_cpu_pmsav7_dregion_property =
>  static Property arm_cpu_initsvtor_property =
>              DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0);
>  
> -static void arm_cpu_post_init(Object *obj)
> +void arm_cpu_post_init(Object *obj)
>  {
>      ARMCPU *cpu = ARM_CPU(obj);
>  
> @@ -2094,6 +2094,7 @@ static void arm_host_initfn(Object *obj)
>      ARMCPU *cpu = ARM_CPU(obj);
>  
>      kvm_arm_set_cpu_features_from_host(cpu);
> +    arm_cpu_post_init(ARM_CPU(obj));
>  }
>  
>  static const TypeInfo host_arm_cpu_type_info = {
> @@ -2108,14 +2109,23 @@ static const TypeInfo host_arm_cpu_type_info = {
>  
>  #endif
>  
> +static void arm_cpu_instance_init(Object *obj)
> +{
> +    const ARMCPUInfo *info = object_class_get_class_data(object_get_class(obj));
> +
> +    info->initfn(obj);
> +    arm_cpu_post_init(obj);
> +}
> +
>  static void cpu_register(const ARMCPUInfo *info)
>  {
>      TypeInfo type_info = {
>          .parent = TYPE_ARM_CPU,
>          .instance_size = sizeof(ARMCPU),
> -        .instance_init = info->initfn,
> +        .instance_init = arm_cpu_instance_init,
>          .class_size = sizeof(ARMCPUClass),
>          .class_init = info->class_init,
> +        .class_data = (void *)info,
>      };
>  
>      type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
> @@ -2128,7 +2138,6 @@ static const TypeInfo arm_cpu_type_info = {
>      .parent = TYPE_CPU,
>      .instance_size = sizeof(ARMCPU),
>      .instance_init = arm_cpu_initfn,
> -    .instance_post_init = arm_cpu_post_init,
>      .instance_finalize = arm_cpu_finalizefn,
>      .abstract = true,
>      .class_size = sizeof(ARMCPUClass),
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 873f059bf2..dbfc3ee490 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -447,14 +447,23 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
>      cc->gdb_arch_name = aarch64_gdb_arch_name;
>  }
>  
> +static void aarch64_cpu_instance_init(Object *obj)
> +{
> +    const ARMCPUInfo *info = object_class_get_class_data(object_get_class(obj));
> +
> +    info->initfn(obj);
> +    arm_cpu_post_init(obj);
> +}
> +
>  static void aarch64_cpu_register(const ARMCPUInfo *info)
>  {
>      TypeInfo type_info = {
>          .parent = TYPE_AARCH64_CPU,
>          .instance_size = sizeof(ARMCPU),
> -        .instance_init = info->initfn,
> +        .instance_init = aarch64_cpu_instance_init,
>          .class_size = sizeof(ARMCPUClass),
>          .class_init = info->class_init,
> +        .class_data = (void *)info,
>      };
>  
>      type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-11 12:07     ` Marc-André Lureau
@ 2018-12-11 14:02       ` Eduardo Habkost
  0 siblings, 0 replies; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-11 14:02 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, David Hildenbrand, open list:sPAPR pseries,
	Cornelia Huck, QEMU, Christian Borntraeger, Qemu-s390x list,
	open list:ARM, Michael S. Tsirkin, Igor Mammedov, Paolo Bonzini,
	Richard Henderson, David Gibson

On Tue, Dec 11, 2018 at 04:07:19PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Mon, Dec 10, 2018 at 9:31 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> > > Similarly to accel properties, move compat properties out of globals
> > > registration, and apply the machine compat properties during
> > > device_post_init().
> > >
> > > As suggested during review, populating the arrays can be done directly
> > > without resorting to using macros.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  include/hw/boards.h        |   3 +-
> > >  hw/arm/virt.c              |  48 ++-
> > >  hw/core/machine.c          |  19 +-
> > >  hw/core/qdev.c             |   2 +
> > >  hw/i386/pc_piix.c          | 588 +++++++++++++++++++++----------------
> > >  hw/i386/pc_q35.c           |  70 ++++-
> > >  hw/ppc/spapr.c             | 209 +++++++------
> > >  hw/s390x/s390-virtio-ccw.c | 220 +++++++-------
> > >  vl.c                       |   1 -
> > >  9 files changed, 673 insertions(+), 487 deletions(-)
> > >
> > > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > > index f82f28468b..28c2b0af41 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,
> > > @@ -191,7 +190,7 @@ struct MachineClass {
> > >      const char *default_machine_opts;
> > >      const char *default_boot_order;
> > >      const char *default_display;
> > > -    GArray *compat_props;
> > > +    GPtrArray *compat_props;
> > >      const char *hw_version;
> > >      ram_addr_t default_ram_size;
> > >      const char *default_cpu_type;
> > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > > index f69e7eb399..530c8ca89d 100644
> > > --- a/hw/arm/virt.c
> > > +++ b/hw/arm/virt.c
> > > @@ -1872,8 +1872,9 @@ static void virt_machine_3_1_options(MachineClass *mc)
> > >  }
> > >  DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
> > >
> > > -#define VIRT_COMPAT_3_0 \
> > > +static GlobalProperty virt_compat_3_0[] = {
> > >      HW_COMPAT_3_0
> > > +};
> > [...]
> >
> > All the changes to compat macros are independent from the change
> > you describe in the patch subject, and makes review more
> > difficult.  What about doing that in a separate patch?
> >
> > We can replace all the virt.c, pc_piix.c, pc_q35.c, and spapr.c
> > hunks in this patch with the following:
> >
> > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > index f82f28468b..622bbaf939 100644
> > --- a/include/hw/boards.h
> > +++ b/include/hw/boards.h
> > @@ -290,18 +289,10 @@ struct MachineState {
> >
> >  #define SET_MACHINE_COMPAT(m, COMPAT) \
> >      do {                              \
> > -        int i;                        \
> >          static GlobalProperty props[] = {       \
> >              COMPAT                              \
> > -            { /* end of list */ }               \
> >          };                                      \
> > -        if (!m->compat_props) { \
> > -            m->compat_props = g_array_new(false, false, sizeof(void *)); \
> > -        } \
> > -        for (i = 0; props[i].driver != NULL; i++) {    \
> > -            GlobalProperty *prop = &props[i];          \
> > -            g_array_append_val(m->compat_props, prop); \
> > -        }                                              \
> > +        compat_props_add(m->compat_props, props, G_N_ELEMENTS(props)); \
> >      } while (0)
> >
> >  #endif
> >
> 
> Didn't you ask in a previous iteration to remove the macros?
> "I like us to be able to
> register compat properties without macro magic.  The existence of
> SET_MACHINE_COMPAT is a bug and not a feature.

I did ask you to not introduce a new macro in accel.c, and
removing the existing macros is really welcome.  I just don't
think we should do everything in a single patch.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine " Marc-André Lureau
  2018-12-10 17:31   ` Eduardo Habkost
@ 2018-12-11 14:23   ` Eduardo Habkost
  2018-12-11 14:30     ` Marc-André Lureau
  1 sibling, 1 reply; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-11 14:23 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Cornelia Huck, Michael S. Tsirkin,
	David Hildenbrand, Christian Borntraeger, open list:S390,
	Paolo Bonzini, open list:sPAPR, imammedo, David Gibson,
	open list:Virt, Richard Henderson

I have specific questions about the approach we are using to
eliminate the macros.

My main goal when asking this to be moved to a separate patch is
to not make this discussion block the register_global_properties() &
device_post_init() changes (which look good to me).


On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
[...]
> -#define VIRT_COMPAT_3_0 \
> +static GlobalProperty virt_compat_3_0[] = {
>      HW_COMPAT_3_0
> +};

What about moving the array inside virt_machine_3_0_options()?

>  
>  static void virt_3_0_instance_init(Object *obj)
>  {
> @@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
>  static void virt_machine_3_0_options(MachineClass *mc)
>  {
>      virt_machine_3_1_options(mc);
> -    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
> +    compat_props_add(mc->compat_props,
> +                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
>  }
>  DEFINE_VIRT_MACHINE(3, 0)

This is nice, because it's basically the same amount of
boilerplate code, but I would find a NULL-terminated array much
easier to use than having to use G_N_ELEMENTS().

This would be nice in cases like virt, because we wouldn't even
need to declare a separate array.  We could do something like:

    compat_props_add(mc->compat_props, hw_compat_3_0);

and that's all.  No need for HW_COMPAT_* macros, no need for
extra arrays to be declared.


[...]
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 7092d6d13f..575566e466 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -438,74 +438,112 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
>  DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
>                        pc_i440fx_3_1_machine_options);
>  
> +static GlobalProperty pc_compat_3_0[] = {
> +    PC_COMPAT_3_0
> +};
> +
>  static void pc_i440fx_3_0_machine_options(MachineClass *m)
>  {
>      pc_i440fx_3_1_machine_options(m);
>      m->is_default = 0;
>      m->alias = NULL;
> -    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> +
> +    compat_props_add(m->compat_props,
> +                     pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
>  }
>  
>  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
>                        pc_i440fx_3_0_machine_options);

Now, this is requiring _more_ boilerplate code than before.  I'd
like us to find a way to eliminate the macro without increasing
the amount of boilerplate code.


[...]
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 7afd1a175b..d801ba71eb 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3973,8 +3973,9 @@ DEFINE_SPAPR_MACHINE(3_1, "3.1", true);
>  /*
>   * pseries-3.0
>   */
> -#define SPAPR_COMPAT_3_0                                              \
> +static GlobalProperty spapr_compat_3_0[] = {
>      HW_COMPAT_3_0
> +};
>  
>  static void spapr_machine_3_0_instance_options(MachineState *machine)
>  {
> @@ -3986,7 +3987,8 @@ static void spapr_machine_3_0_class_options(MachineClass *mc)
>      sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
>  
>      spapr_machine_3_1_class_options(mc);
> -    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_0);
> +    compat_props_add(mc->compat_props,
> +                     spapr_compat_3_0, G_N_ELEMENTS(spapr_compat_3_0));
>  
>      smc->legacy_irq_allocation = true;
>      smc->irq = &spapr_irq_xics_legacy;
> @@ -3997,18 +3999,19 @@ DEFINE_SPAPR_MACHINE(3_0, "3.0", false);
>  /*
>   * pseries-2.12
>   */
> -#define SPAPR_COMPAT_2_12                                              \
> -    HW_COMPAT_2_12                                                     \
> -    {                                                                  \
> -        .driver = TYPE_POWERPC_CPU,                                    \
> -        .property = "pre-3.0-migration",                               \
> -        .value    = "on",                                              \
> -    },                                                                 \
> -    {                                                                  \
> -        .driver = TYPE_SPAPR_CPU_CORE,                                 \
> -        .property = "pre-3.0-migration",                               \
> -        .value    = "on",                                              \
> +static GlobalProperty spapr_compat_2_12[] = {
> +    HW_COMPAT_2_12
> +    {
> +        .driver = TYPE_POWERPC_CPU,
> +        .property = "pre-3.0-migration",
> +        .value    = "on",
> +    },
> +    {
> +        .driver = TYPE_SPAPR_CPU_CORE,
> +        .property = "pre-3.0-migration",
> +        .value    = "on",
>      },
> +};
>  
>  static void spapr_machine_2_12_instance_options(MachineState *machine)
>  {
> @@ -4020,7 +4023,8 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)
>      sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
>  
>      spapr_machine_3_0_class_options(mc);
> -    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12);
> +    compat_props_add(mc->compat_props,
> +                     spapr_compat_2_12, G_N_ELEMENTS(spapr_compat_2_12));

It would be nice to be able to write this as:

    static GlobalProperty spapr_compat_2_12[] = {
        {
            .driver = TYPE_POWERPC_CPU,
            .property = "pre-3.0-migration",
            .value    = "on",
        },
        {
            .driver = TYPE_SPAPR_CPU_CORE,
            .property = "pre-3.0-migration",
            .value    = "on",
        },
        { /* end of list */ },
    };

    compat_props_add(mc->compat_props, hw_compat_3_0);
    compat_props_add(mc->compat_props, spapr_compat_2_12);

This way we won't need the HW_COMPAT_* macros anymore.

Other than that, it's also basically the same amount of
boilerplate as before, so that's good.


>  
>      /* We depend on kvm_enabled() to choose a default value for the
>       * hpt-max-page-size capability. Of course we can't do it here
[...]
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index a0615a8b35..275cbe5da4 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -651,96 +651,106 @@ bool css_migration_enabled(void)
>      }                                                                         \
>      type_init(ccw_machine_register_##suffix)
>  
> -#define CCW_COMPAT_3_0 \
> -        HW_COMPAT_3_0
> -
> -#define CCW_COMPAT_2_12 \
> -        HW_COMPAT_2_12
> -
> -#define CCW_COMPAT_2_11 \
> -        HW_COMPAT_2_11 \
> -        {\
> -            .driver   = TYPE_SCLP_EVENT_FACILITY,\
> -            .property = "allow_all_mask_sizes",\
> -            .value    = "off",\
> -        },
[...]
> +static GlobalProperty ccw_compat_3_0[] = {
> +    HW_COMPAT_3_0
> +};
> +
> +static GlobalProperty ccw_compat_2_12[] = {
> +    HW_COMPAT_2_12
> +};
> +
> +static GlobalProperty ccw_compat_2_11[] = {
> +    HW_COMPAT_2_11
> +    {
> +        .driver   = TYPE_SCLP_EVENT_FACILITY,
> +        .property = "allow_all_mask_sizes",
> +        .value    = "off",
> +    },
> +};
[...]
>  
>  static void ccw_machine_3_1_instance_options(MachineState *machine)
>  {
> @@ -762,7 +772,8 @@ static void ccw_machine_3_0_class_options(MachineClass *mc)
>  
>      s390mc->hpage_1m_allowed = false;
>      ccw_machine_3_1_class_options(mc);
> -    SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_0);
> +    compat_props_add(mc->compat_props,
> +                     ccw_compat_3_0, G_N_ELEMENTS(ccw_compat_3_0));

Same comments from spapr apply here: getting rid of the
HW_COMPAT_* macros would be nice, but this version is good enough
because it has the same amount of boilerplate code.


>  }
>  DEFINE_CCW_MACHINE(3_0, "3.0", false);
[...]

-- 
Eduardo

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-11 14:23   ` Eduardo Habkost
@ 2018-12-11 14:30     ` Marc-André Lureau
  2018-12-11 15:52       ` Igor Mammedov
  0 siblings, 1 reply; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-11 14:30 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, David Hildenbrand, open list:sPAPR pseries,
	Cornelia Huck, QEMU, Christian Borntraeger, Qemu-s390x list,
	open list:ARM, Michael S. Tsirkin, Igor Mammedov, Paolo Bonzini,
	Richard Henderson, David Gibson

Hi

On Tue, Dec 11, 2018 at 6:24 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> I have specific questions about the approach we are using to
> eliminate the macros.
>
> My main goal when asking this to be moved to a separate patch is
> to not make this discussion block the register_global_properties() &
> device_post_init() changes (which look good to me).
>
>
> On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> [...]
> > -#define VIRT_COMPAT_3_0 \
> > +static GlobalProperty virt_compat_3_0[] = {
> >      HW_COMPAT_3_0
> > +};
>
> What about moving the array inside virt_machine_3_0_options()?

Sure

>
> >
> >  static void virt_3_0_instance_init(Object *obj)
> >  {
> > @@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
> >  static void virt_machine_3_0_options(MachineClass *mc)
> >  {
> >      virt_machine_3_1_options(mc);
> > -    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
> > +    compat_props_add(mc->compat_props,
> > +                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
> >  }
> >  DEFINE_VIRT_MACHINE(3, 0)
>
> This is nice, because it's basically the same amount of
> boilerplate code, but I would find a NULL-terminated array much
> easier to use than having to use G_N_ELEMENTS().

But easier to get wrong too. I prefer the explicit N arguments. (it
also gives some flexibility, since you can point to inner pointer +
size, although we don't care at this point)

>
> This would be nice in cases like virt, because we wouldn't even
> need to declare a separate array.  We could do something like:
>
>     compat_props_add(mc->compat_props, hw_compat_3_0);
>
> and that's all.  No need for HW_COMPAT_* macros, no need for
> extra arrays to be declared.
>
>
> [...]
> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> > index 7092d6d13f..575566e466 100644
> > --- a/hw/i386/pc_piix.c
> > +++ b/hw/i386/pc_piix.c
> > @@ -438,74 +438,112 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
> >  DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
> >                        pc_i440fx_3_1_machine_options);
> >
> > +static GlobalProperty pc_compat_3_0[] = {
> > +    PC_COMPAT_3_0
> > +};
> > +
> >  static void pc_i440fx_3_0_machine_options(MachineClass *m)
> >  {
> >      pc_i440fx_3_1_machine_options(m);
> >      m->is_default = 0;
> >      m->alias = NULL;
> > -    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> > +
> > +    compat_props_add(m->compat_props,
> > +                     pc_compat_3_0, G_N_ELEMENTS(pc_compat_3_0));
> >  }
> >
> >  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
> >                        pc_i440fx_3_0_machine_options);
>
> Now, this is requiring _more_ boilerplate code than before.  I'd
> like us to find a way to eliminate the macro without increasing
> the amount of boilerplate code.

I am open to ideas

>
>
> [...]
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index 7afd1a175b..d801ba71eb 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -3973,8 +3973,9 @@ DEFINE_SPAPR_MACHINE(3_1, "3.1", true);
> >  /*
> >   * pseries-3.0
> >   */
> > -#define SPAPR_COMPAT_3_0                                              \
> > +static GlobalProperty spapr_compat_3_0[] = {
> >      HW_COMPAT_3_0
> > +};
> >
> >  static void spapr_machine_3_0_instance_options(MachineState *machine)
> >  {
> > @@ -3986,7 +3987,8 @@ static void spapr_machine_3_0_class_options(MachineClass *mc)
> >      sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> >
> >      spapr_machine_3_1_class_options(mc);
> > -    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_0);
> > +    compat_props_add(mc->compat_props,
> > +                     spapr_compat_3_0, G_N_ELEMENTS(spapr_compat_3_0));
> >
> >      smc->legacy_irq_allocation = true;
> >      smc->irq = &spapr_irq_xics_legacy;
> > @@ -3997,18 +3999,19 @@ DEFINE_SPAPR_MACHINE(3_0, "3.0", false);
> >  /*
> >   * pseries-2.12
> >   */
> > -#define SPAPR_COMPAT_2_12                                              \
> > -    HW_COMPAT_2_12                                                     \
> > -    {                                                                  \
> > -        .driver = TYPE_POWERPC_CPU,                                    \
> > -        .property = "pre-3.0-migration",                               \
> > -        .value    = "on",                                              \
> > -    },                                                                 \
> > -    {                                                                  \
> > -        .driver = TYPE_SPAPR_CPU_CORE,                                 \
> > -        .property = "pre-3.0-migration",                               \
> > -        .value    = "on",                                              \
> > +static GlobalProperty spapr_compat_2_12[] = {
> > +    HW_COMPAT_2_12
> > +    {
> > +        .driver = TYPE_POWERPC_CPU,
> > +        .property = "pre-3.0-migration",
> > +        .value    = "on",
> > +    },
> > +    {
> > +        .driver = TYPE_SPAPR_CPU_CORE,
> > +        .property = "pre-3.0-migration",
> > +        .value    = "on",
> >      },
> > +};
> >
> >  static void spapr_machine_2_12_instance_options(MachineState *machine)
> >  {
> > @@ -4020,7 +4023,8 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)
> >      sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> >
> >      spapr_machine_3_0_class_options(mc);
> > -    SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12);
> > +    compat_props_add(mc->compat_props,
> > +                     spapr_compat_2_12, G_N_ELEMENTS(spapr_compat_2_12));
>
> It would be nice to be able to write this as:
>
>     static GlobalProperty spapr_compat_2_12[] = {
>         {
>             .driver = TYPE_POWERPC_CPU,
>             .property = "pre-3.0-migration",
>             .value    = "on",
>         },
>         {
>             .driver = TYPE_SPAPR_CPU_CORE,
>             .property = "pre-3.0-migration",
>             .value    = "on",
>         },
>         { /* end of list */ },
>     };
>
>     compat_props_add(mc->compat_props, hw_compat_3_0);
>     compat_props_add(mc->compat_props, spapr_compat_2_12);
>
> This way we won't need the HW_COMPAT_* macros anymore.

That could be done on top, I imagine. I can give it a try.

>
> Other than that, it's also basically the same amount of
> boilerplate as before, so that's good.
>
>
> >
> >      /* We depend on kvm_enabled() to choose a default value for the
> >       * hpt-max-page-size capability. Of course we can't do it here
> [...]
> > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> > index a0615a8b35..275cbe5da4 100644
> > --- a/hw/s390x/s390-virtio-ccw.c
> > +++ b/hw/s390x/s390-virtio-ccw.c
> > @@ -651,96 +651,106 @@ bool css_migration_enabled(void)
> >      }                                                                         \
> >      type_init(ccw_machine_register_##suffix)
> >
> > -#define CCW_COMPAT_3_0 \
> > -        HW_COMPAT_3_0
> > -
> > -#define CCW_COMPAT_2_12 \
> > -        HW_COMPAT_2_12
> > -
> > -#define CCW_COMPAT_2_11 \
> > -        HW_COMPAT_2_11 \
> > -        {\
> > -            .driver   = TYPE_SCLP_EVENT_FACILITY,\
> > -            .property = "allow_all_mask_sizes",\
> > -            .value    = "off",\
> > -        },
> [...]
> > +static GlobalProperty ccw_compat_3_0[] = {
> > +    HW_COMPAT_3_0
> > +};
> > +
> > +static GlobalProperty ccw_compat_2_12[] = {
> > +    HW_COMPAT_2_12
> > +};
> > +
> > +static GlobalProperty ccw_compat_2_11[] = {
> > +    HW_COMPAT_2_11
> > +    {
> > +        .driver   = TYPE_SCLP_EVENT_FACILITY,
> > +        .property = "allow_all_mask_sizes",
> > +        .value    = "off",
> > +    },
> > +};
> [...]
> >
> >  static void ccw_machine_3_1_instance_options(MachineState *machine)
> >  {
> > @@ -762,7 +772,8 @@ static void ccw_machine_3_0_class_options(MachineClass *mc)
> >
> >      s390mc->hpage_1m_allowed = false;
> >      ccw_machine_3_1_class_options(mc);
> > -    SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_0);
> > +    compat_props_add(mc->compat_props,
> > +                     ccw_compat_3_0, G_N_ELEMENTS(ccw_compat_3_0));
>
> Same comments from spapr apply here: getting rid of the
> HW_COMPAT_* macros would be nice, but this version is good enough
> because it has the same amount of boilerplate code.
>
>

thanks

> >  }
> >  DEFINE_CCW_MACHINE(3_0, "3.0", false);
> [...]
>
> --
> Eduardo
>


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties
  2018-12-10 17:39     ` Eduardo Habkost
@ 2018-12-11 15:11       ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 15:11 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Marc-André Lureau, qemu-devel

On Mon, 10 Dec 2018 15:39:32 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, Dec 10, 2018 at 06:31:59PM +0100, Igor Mammedov wrote:
> > On Mon, 10 Dec 2018 15:07:18 -0200
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> >   
> > > On Tue, Dec 04, 2018 at 06:20:04PM +0400, Marc-André Lureau wrote:
> > > [...]  
> > > > Marc-André Lureau (19):
> > > >   tests: qdev_prop_check_globals() doesn't return "all_used"
> > > >   qom: make interface types abstract
> > > >   qom: make user_creatable_complete() specific to UserCreatable
> > > >   accel: register global_props like machine globals
> > > >   qdev: move qdev_prop_register_global_list() to tests
> > > >   qom: remove unimplemented class_finalize  
> > > 
> > > Patches 1-6 (above) queued on machine-next.  Thanks!  
> > let's drop patch 6 for now until we decide what to do with GPtrArray leaks  
> 
> I appreciate your effort to make sure there are no memory
> allocations that could make Valgrind complain, but I don't see
> the point of keeping dead code that was never called in the tree.
ps:
it looks like machine_finalize() isn't called either,
but it at least documents what should be cleaned up.
Maybe we should keep code removed by 6, for the same reasons. 


> Are the new GPtrArray allocations different from the g_malloc0()
> calls in type_new() and type_initialize()?  Doesn't Valgrind
> complain about them today?
Currently we don't clean a bunch of onetime allocations,
so I guess we can continue to ignore them in this case as well.

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-11 14:30     ` Marc-André Lureau
@ 2018-12-11 15:52       ` Igor Mammedov
  2018-12-11 17:43         ` Eduardo Habkost
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 15:52 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Eduardo Habkost, Peter Maydell, Michael S. Tsirkin,
	David Hildenbrand, Cornelia Huck, QEMU, Christian Borntraeger,
	Qemu-s390x list, open list:ARM, open list:sPAPR pseries,
	Paolo Bonzini, David Gibson, Richard Henderson

On Tue, 11 Dec 2018 18:30:32 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> 
> On Tue, Dec 11, 2018 at 6:24 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > I have specific questions about the approach we are using to
> > eliminate the macros.
> >
> > My main goal when asking this to be moved to a separate patch is
> > to not make this discussion block the register_global_properties() &
> > device_post_init() changes (which look good to me).
> >
> >
> > On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> > [...]  
> > > -#define VIRT_COMPAT_3_0 \
> > > +static GlobalProperty virt_compat_3_0[] = {
> > >      HW_COMPAT_3_0
> > > +};  
> >
> > What about moving the array inside virt_machine_3_0_options()?  
> 
> Sure
> 
> >  
> > >
> > >  static void virt_3_0_instance_init(Object *obj)
> > >  {
> > > @@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
> > >  static void virt_machine_3_0_options(MachineClass *mc)
> > >  {
> > >      virt_machine_3_1_options(mc);
> > > -    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
> > > +    compat_props_add(mc->compat_props,
> > > +                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
> > >  }
> > >  DEFINE_VIRT_MACHINE(3, 0)  
> >
> > This is nice, because it's basically the same amount of
> > boilerplate code, but I would find a NULL-terminated array much
> > easier to use than having to use G_N_ELEMENTS().  
> 
> But easier to get wrong too. I prefer the explicit N arguments. (it
> also gives some flexibility, since you can point to inner pointer +
> size, although we don't care at this point)
+1 to explicit array size,
it also allows to drop terminating NULL entry in compat declarations

[...]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data()
  2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data() Marc-André Lureau
@ 2018-12-11 16:02   ` Igor Mammedov
  2018-12-12 18:48     ` Marc-André Lureau
  0 siblings, 1 reply; 53+ messages in thread
From: Igor Mammedov @ 2018-12-11 16:02 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, ehabkost, Andreas Färber

On Tue,  4 Dec 2018 18:20:19 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Add a simple function to retrieve the associated class data.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 9 +++++++++
>  qom/object.c         | 5 +++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 5183c587f3..d5266405da 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -916,6 +916,15 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
>   */
>  ObjectClass *object_class_get_parent(ObjectClass *klass);
>  
> +
> +/**
> + * object_class_get_class_data:
> + * @klass: The class to obtain associated data.
> + *
> + * Returns: the class_data given when registering the type.
> + */
> +void *object_class_get_class_data(ObjectClass *klass);
> +
>  /**
>   * object_class_get_name:
>   * @klass: The class to obtain the QOM typename for.
> diff --git a/qom/object.c b/qom/object.c
> index aa6f3a2a71..bbc6fbbc01 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -867,6 +867,11 @@ const char *object_class_get_name(ObjectClass *klass)
>      return klass->type->name;
>  }
>  
> +void *object_class_get_class_data(ObjectClass *klass)
> +{
> +    return klass->type->class_data;
> +}
> +
>  ObjectClass *object_class_by_name(const char *typename)
>  {
>      TypeImpl *type = type_get_by_name(typename);

alternatively to what's done in 16/19 which requires this helper
you can drop it and use x86 cpu approach, see:

static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data)               
{                                                                                
    X86CPUDefinition *cpudef = data;                                             
    X86CPUClass *xcc = X86_CPU_CLASS(oc);                                        
                                                                                 
    xcc->cpu_def = cpudef;
    ...

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine compat properties without touching globals
  2018-12-11 15:52       ` Igor Mammedov
@ 2018-12-11 17:43         ` Eduardo Habkost
  0 siblings, 0 replies; 53+ messages in thread
From: Eduardo Habkost @ 2018-12-11 17:43 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Marc-André Lureau, Peter Maydell, Michael S. Tsirkin,
	David Hildenbrand, Cornelia Huck, QEMU, Christian Borntraeger,
	Qemu-s390x list, open list:ARM, open list:sPAPR pseries,
	Paolo Bonzini, David Gibson, Richard Henderson

On Tue, Dec 11, 2018 at 04:52:29PM +0100, Igor Mammedov wrote:
> On Tue, 11 Dec 2018 18:30:32 +0400
> Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
> 
> > Hi
> > 
> > On Tue, Dec 11, 2018 at 6:24 PM Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >
> > > I have specific questions about the approach we are using to
> > > eliminate the macros.
> > >
> > > My main goal when asking this to be moved to a separate patch is
> > > to not make this discussion block the register_global_properties() &
> > > device_post_init() changes (which look good to me).
> > >
> > >
> > > On Tue, Dec 04, 2018 at 06:20:12PM +0400, Marc-André Lureau wrote:
> > > [...]  
> > > > -#define VIRT_COMPAT_3_0 \
> > > > +static GlobalProperty virt_compat_3_0[] = {
> > > >      HW_COMPAT_3_0
> > > > +};  
> > >
> > > What about moving the array inside virt_machine_3_0_options()?  
> > 
> > Sure
> > 
> > >  
> > > >
> > > >  static void virt_3_0_instance_init(Object *obj)
> > > >  {
> > > > @@ -1883,12 +1884,14 @@ static void virt_3_0_instance_init(Object *obj)
> > > >  static void virt_machine_3_0_options(MachineClass *mc)
> > > >  {
> > > >      virt_machine_3_1_options(mc);
> > > > -    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
> > > > +    compat_props_add(mc->compat_props,
> > > > +                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
> > > >  }
> > > >  DEFINE_VIRT_MACHINE(3, 0)  
> > >
> > > This is nice, because it's basically the same amount of
> > > boilerplate code, but I would find a NULL-terminated array much
> > > easier to use than having to use G_N_ELEMENTS().  
> > 
> > But easier to get wrong too. I prefer the explicit N arguments. (it
> > also gives some flexibility, since you can point to inner pointer +
> > size, although we don't care at this point)
> +1 to explicit array size,
> it also allows to drop terminating NULL entry in compat declarations

I don't mind using G_N_ELEMENTS if you really think it's better,
but I wonder if it will be an obstacle for making
  compat_props_add(compat_props, hw_compat_3_0, ...)
work, because the size of hw_compat_3_0 won't be known by
compat.h or spapr.c.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-10 16:54       ` Igor Mammedov
@ 2018-12-12 12:00         ` Marc-André Lureau
  -1 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-12 12:00 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Stefano Stabellini, Eduardo Habkost, QEMU, Paolo Bonzini,
	Anthony Perard, xen-devel, Andreas Färber

Hi
On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Mon, 10 Dec 2018 17:45:22 +0100
> Igor Mammedov <imammedo@redhat.com> wrote:
>
> > On Tue,  4 Dec 2018 18:20:11 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >
> > > Instead of registering compat properties as globals, let's keep them
> > > in their own array, to avoid mixing with user globals.
> > >
> > > Introduce object_apply_global_props() function, to apply compatibility
> > > properties from a GPtrArray.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  include/hw/qdev-core.h | 10 ++++++++++
> > >  include/qom/object.h   |  3 +++
> > >  include/sysemu/accel.h |  4 +---
> > >  accel/accel.c          | 12 ------------
> > >  hw/core/qdev.c         |  9 +++++++++
> > >  hw/xen/xen-common.c    |  9 ++++++---
> > >  qom/object.c           | 25 +++++++++++++++++++++++++
> > >  vl.c                   |  1 -
> > >  8 files changed, 54 insertions(+), 19 deletions(-)
> > >
> > [...]
> > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > > index 6ec14c73ca..4532aa8632 100644
> > > --- a/hw/xen/xen-common.c
> > > +++ b/hw/xen/xen-common.c
> > > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> > >          .driver = "migration",
> > >          .property = "send-section-footer",
> > >          .value = "off",
> > > -    },
> > > -    { /* end of list */ },
> > > +    }
> > >  };
> > >
> > >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> > >  {
> > >      AccelClass *ac = ACCEL_CLASS(oc);
> > > +
> > >      ac->name = "Xen";
> > >      ac->init_machine = xen_init;
> > >      ac->setup_post = xen_setup_post;
> > >      ac->allowed = &xen_allowed;
> > > -    ac->global_props = xen_compat_props;
> > > +    ac->compat_props = g_ptr_array_new();
> > where is matching free for that?
> can we at least annotate it somehow so that valgrind won't complain about this leak?

If you check my commits on qemu, you should see that I do care (too
much?) about leaks :)

In this case though, I don't see valgrind or asan complaining, I guess
it's still a reachable reference.
Do you think a FIXME comment would be helpful?

(/me wish we had a proper object system, GObject, but that ship as
long sailed..)

>
> >
> > > +
> > > +    compat_props_add(ac->compat_props,
> > > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> > >  }
> > >
> > >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > > diff --git a/qom/object.c b/qom/object.c
> > > index 17921c0a71..dbdab0aead 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> > >      }
> > >  }
> > >
> > > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > > +{
> > > +    Error *err = NULL;
> > > +    int i;
> > > +
> > > +    if (!props) {
> > > +        return;
> > > +    }
> > > +
> > > +    for (i = 0; i < props->len; i++) {
> > > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > > +
> > > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > > +            continue;
> > > +        }
> > > +        p->used = true;
> > > +        object_property_parse(obj, p->value, p->property, &err);
> > > +        if (err != NULL) {
> > > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > > diff --git a/vl.c b/vl.c
> > > index a5ae5f23d2..88ba658572 100644
> > > --- a/vl.c
> > > +++ b/vl.c
> > > @@ -2968,7 +2968,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();
> > >  }
> >
> >
>
>


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-12 12:00         ` Marc-André Lureau
  0 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-12 12:00 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Stefano Stabellini, Eduardo Habkost, QEMU, xen-devel,
	Anthony Perard, Paolo Bonzini, Andreas Färber

Hi
On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Mon, 10 Dec 2018 17:45:22 +0100
> Igor Mammedov <imammedo@redhat.com> wrote:
>
> > On Tue,  4 Dec 2018 18:20:11 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >
> > > Instead of registering compat properties as globals, let's keep them
> > > in their own array, to avoid mixing with user globals.
> > >
> > > Introduce object_apply_global_props() function, to apply compatibility
> > > properties from a GPtrArray.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  include/hw/qdev-core.h | 10 ++++++++++
> > >  include/qom/object.h   |  3 +++
> > >  include/sysemu/accel.h |  4 +---
> > >  accel/accel.c          | 12 ------------
> > >  hw/core/qdev.c         |  9 +++++++++
> > >  hw/xen/xen-common.c    |  9 ++++++---
> > >  qom/object.c           | 25 +++++++++++++++++++++++++
> > >  vl.c                   |  1 -
> > >  8 files changed, 54 insertions(+), 19 deletions(-)
> > >
> > [...]
> > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > > index 6ec14c73ca..4532aa8632 100644
> > > --- a/hw/xen/xen-common.c
> > > +++ b/hw/xen/xen-common.c
> > > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> > >          .driver = "migration",
> > >          .property = "send-section-footer",
> > >          .value = "off",
> > > -    },
> > > -    { /* end of list */ },
> > > +    }
> > >  };
> > >
> > >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> > >  {
> > >      AccelClass *ac = ACCEL_CLASS(oc);
> > > +
> > >      ac->name = "Xen";
> > >      ac->init_machine = xen_init;
> > >      ac->setup_post = xen_setup_post;
> > >      ac->allowed = &xen_allowed;
> > > -    ac->global_props = xen_compat_props;
> > > +    ac->compat_props = g_ptr_array_new();
> > where is matching free for that?
> can we at least annotate it somehow so that valgrind won't complain about this leak?

If you check my commits on qemu, you should see that I do care (too
much?) about leaks :)

In this case though, I don't see valgrind or asan complaining, I guess
it's still a reachable reference.
Do you think a FIXME comment would be helpful?

(/me wish we had a proper object system, GObject, but that ship as
long sailed..)

>
> >
> > > +
> > > +    compat_props_add(ac->compat_props,
> > > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> > >  }
> > >
> > >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > > diff --git a/qom/object.c b/qom/object.c
> > > index 17921c0a71..dbdab0aead 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> > >      }
> > >  }
> > >
> > > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > > +{
> > > +    Error *err = NULL;
> > > +    int i;
> > > +
> > > +    if (!props) {
> > > +        return;
> > > +    }
> > > +
> > > +    for (i = 0; i < props->len; i++) {
> > > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > > +
> > > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > > +            continue;
> > > +        }
> > > +        p->used = true;
> > > +        object_property_parse(obj, p->value, p->property, &err);
> > > +        if (err != NULL) {
> > > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > > diff --git a/vl.c b/vl.c
> > > index a5ae5f23d2..88ba658572 100644
> > > --- a/vl.c
> > > +++ b/vl.c
> > > @@ -2968,7 +2968,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();
> > >  }
> >
> >
>
>


-- 
Marc-André Lureau

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data()
  2018-12-11 16:02   ` Igor Mammedov
@ 2018-12-12 18:48     ` Marc-André Lureau
  0 siblings, 0 replies; 53+ messages in thread
From: Marc-André Lureau @ 2018-12-12 18:48 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: QEMU, Andreas Färber, Eduardo Habkost

Hi

On Tue, Dec 11, 2018 at 8:24 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Tue,  4 Dec 2018 18:20:19 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
>
> > Add a simple function to retrieve the associated class data.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/qom/object.h | 9 +++++++++
> >  qom/object.c         | 5 +++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 5183c587f3..d5266405da 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -916,6 +916,15 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
> >   */
> >  ObjectClass *object_class_get_parent(ObjectClass *klass);
> >
> > +
> > +/**
> > + * object_class_get_class_data:
> > + * @klass: The class to obtain associated data.
> > + *
> > + * Returns: the class_data given when registering the type.
> > + */
> > +void *object_class_get_class_data(ObjectClass *klass);
> > +
> >  /**
> >   * object_class_get_name:
> >   * @klass: The class to obtain the QOM typename for.
> > diff --git a/qom/object.c b/qom/object.c
> > index aa6f3a2a71..bbc6fbbc01 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -867,6 +867,11 @@ const char *object_class_get_name(ObjectClass *klass)
> >      return klass->type->name;
> >  }
> >
> > +void *object_class_get_class_data(ObjectClass *klass)
> > +{
> > +    return klass->type->class_data;
> > +}
> > +
> >  ObjectClass *object_class_by_name(const char *typename)
> >  {
> >      TypeImpl *type = type_get_by_name(typename);
>
> alternatively to what's done in 16/19 which requires this helper
> you can drop it and use x86 cpu approach, see:
>
> static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data)
> {
>     X86CPUDefinition *cpudef = data;
>     X86CPUClass *xcc = X86_CPU_CLASS(oc);
>
>     xcc->cpu_def = cpudef;
>     ...
>

Indeed, that's perhaps a better alternative. I'll update the patch.

-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
  2018-12-12 12:00         ` Marc-André Lureau
@ 2018-12-13 12:06           ` Igor Mammedov
  -1 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-13 12:06 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, Eduardo Habkost, QEMU, Paolo Bonzini,
	Anthony Perard, xen-devel, Andreas Färber

On Wed, 12 Dec 2018 16:00:06 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 10 Dec 2018 17:45:22 +0100
> > Igor Mammedov <imammedo@redhat.com> wrote:
> >  
> > > On Tue,  4 Dec 2018 18:20:11 +0400
> > > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> > >  
> > > > Instead of registering compat properties as globals, let's keep them
> > > > in their own array, to avoid mixing with user globals.
> > > >
> > > > Introduce object_apply_global_props() function, to apply compatibility
> > > > properties from a GPtrArray.
> > > >
> > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > > ---
> > > >  include/hw/qdev-core.h | 10 ++++++++++
> > > >  include/qom/object.h   |  3 +++
> > > >  include/sysemu/accel.h |  4 +---
> > > >  accel/accel.c          | 12 ------------
> > > >  hw/core/qdev.c         |  9 +++++++++
> > > >  hw/xen/xen-common.c    |  9 ++++++---
> > > >  qom/object.c           | 25 +++++++++++++++++++++++++
> > > >  vl.c                   |  1 -
> > > >  8 files changed, 54 insertions(+), 19 deletions(-)
> > > >  
> > > [...]  
> > > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > > > index 6ec14c73ca..4532aa8632 100644
> > > > --- a/hw/xen/xen-common.c
> > > > +++ b/hw/xen/xen-common.c
> > > > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> > > >          .driver = "migration",
> > > >          .property = "send-section-footer",
> > > >          .value = "off",
> > > > -    },
> > > > -    { /* end of list */ },
> > > > +    }
> > > >  };
> > > >
> > > >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> > > >  {
> > > >      AccelClass *ac = ACCEL_CLASS(oc);
> > > > +
> > > >      ac->name = "Xen";
> > > >      ac->init_machine = xen_init;
> > > >      ac->setup_post = xen_setup_post;
> > > >      ac->allowed = &xen_allowed;
> > > > -    ac->global_props = xen_compat_props;
> > > > +    ac->compat_props = g_ptr_array_new();  
> > > where is matching free for that?  
> > can we at least annotate it somehow so that valgrind won't complain about this leak?  
> 
> If you check my commits on qemu, you should see that I do care (too
> much?) about leaks :)
> 
> In this case though, I don't see valgrind or asan complaining, I guess
> it's still a reachable reference.
> Do you think a FIXME comment would be helpful?
I've looked at other cases were we leak, and well we leak a lot so it's
probably futile exercise. But the comment won't hurt and will work as remainder.


> (/me wish we had a proper object system, GObject, but that ship as
> long sailed..)
> 
> >  
> > >  
> > > > +
> > > > +    compat_props_add(ac->compat_props,
> > > > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> > > >  }
> > > >
> > > >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > > > diff --git a/qom/object.c b/qom/object.c
> > > > index 17921c0a71..dbdab0aead 100644
> > > > --- a/qom/object.c
> > > > +++ b/qom/object.c
> > > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> > > >      }
> > > >  }
> > > >
> > > > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > > > +{
> > > > +    Error *err = NULL;
> > > > +    int i;
> > > > +
> > > > +    if (!props) {
> > > > +        return;
> > > > +    }
> > > > +
> > > > +    for (i = 0; i < props->len; i++) {
> > > > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > > > +
> > > > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > > > +            continue;
> > > > +        }
> > > > +        p->used = true;
> > > > +        object_property_parse(obj, p->value, p->property, &err);
> > > > +        if (err != NULL) {
> > > > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > > > diff --git a/vl.c b/vl.c
> > > > index a5ae5f23d2..88ba658572 100644
> > > > --- a/vl.c
> > > > +++ b/vl.c
> > > > @@ -2968,7 +2968,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();
> > > >  }  
> > >
> > >  
> >
> >  
> 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
@ 2018-12-13 12:06           ` Igor Mammedov
  0 siblings, 0 replies; 53+ messages in thread
From: Igor Mammedov @ 2018-12-13 12:06 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Stefano Stabellini, Eduardo Habkost, QEMU, xen-devel,
	Anthony Perard, Paolo Bonzini, Andreas Färber

On Wed, 12 Dec 2018 16:00:06 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Mon, 10 Dec 2018 17:45:22 +0100
> > Igor Mammedov <imammedo@redhat.com> wrote:
> >  
> > > On Tue,  4 Dec 2018 18:20:11 +0400
> > > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> > >  
> > > > Instead of registering compat properties as globals, let's keep them
> > > > in their own array, to avoid mixing with user globals.
> > > >
> > > > Introduce object_apply_global_props() function, to apply compatibility
> > > > properties from a GPtrArray.
> > > >
> > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > > ---
> > > >  include/hw/qdev-core.h | 10 ++++++++++
> > > >  include/qom/object.h   |  3 +++
> > > >  include/sysemu/accel.h |  4 +---
> > > >  accel/accel.c          | 12 ------------
> > > >  hw/core/qdev.c         |  9 +++++++++
> > > >  hw/xen/xen-common.c    |  9 ++++++---
> > > >  qom/object.c           | 25 +++++++++++++++++++++++++
> > > >  vl.c                   |  1 -
> > > >  8 files changed, 54 insertions(+), 19 deletions(-)
> > > >  
> > > [...]  
> > > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> > > > index 6ec14c73ca..4532aa8632 100644
> > > > --- a/hw/xen/xen-common.c
> > > > +++ b/hw/xen/xen-common.c
> > > > @@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
> > > >          .driver = "migration",
> > > >          .property = "send-section-footer",
> > > >          .value = "off",
> > > > -    },
> > > > -    { /* end of list */ },
> > > > +    }
> > > >  };
> > > >
> > > >  static void xen_accel_class_init(ObjectClass *oc, void *data)
> > > >  {
> > > >      AccelClass *ac = ACCEL_CLASS(oc);
> > > > +
> > > >      ac->name = "Xen";
> > > >      ac->init_machine = xen_init;
> > > >      ac->setup_post = xen_setup_post;
> > > >      ac->allowed = &xen_allowed;
> > > > -    ac->global_props = xen_compat_props;
> > > > +    ac->compat_props = g_ptr_array_new();  
> > > where is matching free for that?  
> > can we at least annotate it somehow so that valgrind won't complain about this leak?  
> 
> If you check my commits on qemu, you should see that I do care (too
> much?) about leaks :)
> 
> In this case though, I don't see valgrind or asan complaining, I guess
> it's still a reachable reference.
> Do you think a FIXME comment would be helpful?
I've looked at other cases were we leak, and well we leak a lot so it's
probably futile exercise. But the comment won't hurt and will work as remainder.


> (/me wish we had a proper object system, GObject, but that ship as
> long sailed..)
> 
> >  
> > >  
> > > > +
> > > > +    compat_props_add(ac->compat_props,
> > > > +                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
> > > >  }
> > > >
> > > >  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> > > > diff --git a/qom/object.c b/qom/object.c
> > > > index 17921c0a71..dbdab0aead 100644
> > > > --- a/qom/object.c
> > > > +++ b/qom/object.c
> > > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> > > >      }
> > > >  }
> > > >
> > > > +void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> > > > +{
> > > > +    Error *err = NULL;
> > > > +    int i;
> > > > +
> > > > +    if (!props) {
> > > > +        return;
> > > > +    }
> > > > +
> > > > +    for (i = 0; i < props->len; i++) {
> > > > +        GlobalProperty *p = g_ptr_array_index(props, i);
> > > > +
> > > > +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> > > > +            continue;
> > > > +        }
> > > > +        p->used = true;
> > > > +        object_property_parse(obj, p->value, p->property, &err);
> > > > +        if (err != NULL) {
> > > > +            error_prepend(&err, "can't apply global %s.%s=%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 = data;
> > > > diff --git a/vl.c b/vl.c
> > > > index a5ae5f23d2..88ba658572 100644
> > > > --- a/vl.c
> > > > +++ b/vl.c
> > > > @@ -2968,7 +2968,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();
> > > >  }  
> > >
> > >  
> >
> >  
> 
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2018-12-13 12:07 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 14:20 [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 01/19] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 02/19] qom: make interface types abstract Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 03/19] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 04/19] accel: register global_props like machine globals Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 05/19] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 06/19] qom: remove unimplemented class_finalize Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals Marc-André Lureau
2018-12-04 14:20   ` Marc-André Lureau
2018-12-10 16:45   ` [Qemu-devel] " Igor Mammedov
2018-12-10 16:45     ` Igor Mammedov
2018-12-10 16:54     ` [Qemu-devel] " Igor Mammedov
2018-12-10 16:54       ` Igor Mammedov
2018-12-12 12:00       ` Marc-André Lureau
2018-12-12 12:00         ` Marc-André Lureau
2018-12-13 12:06         ` Igor Mammedov
2018-12-13 12:06           ` Igor Mammedov
2018-12-11 13:14   ` Igor Mammedov
2018-12-11 13:14     ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 08/19] hw: apply machine " Marc-André Lureau
2018-12-10 17:31   ` Eduardo Habkost
2018-12-11 12:07     ` Marc-André Lureau
2018-12-11 14:02       ` Eduardo Habkost
2018-12-11 14:23   ` Eduardo Habkost
2018-12-11 14:30     ` Marc-André Lureau
2018-12-11 15:52       ` Igor Mammedov
2018-12-11 17:43         ` Eduardo Habkost
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 09/19] hw: remove SET_MACHINE_COMPAT Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 10/19] qdev: make a separate helper function to apply compat properties Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 11/19] qdev: all globals are now user-provided Marc-André Lureau
2018-12-10 17:00   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray Marc-André Lureau
2018-12-10 17:05   ` Igor Mammedov
2018-12-11 12:12     ` Marc-André Lureau
2018-12-11 13:03       ` Igor Mammedov
2018-12-11 13:04   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 13/19] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-12-10 17:20   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 14/19] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-12-10 17:28   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 15/19] qom: add object_class_get_class_data() Marc-André Lureau
2018-12-11 16:02   ` Igor Mammedov
2018-12-12 18:48     ` Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 16/19] RFC: arm: replace instance_post_init() Marc-André Lureau
2018-12-11 13:43   ` Igor Mammedov
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 17/19] hw/i386: add pc-i440fx-4.0 & pc-q35-4.0 Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 18/19] hw/arm/virt: add virt-4.0 machine type Marc-André Lureau
2018-12-04 14:20 ` [Qemu-devel] [PATCH for-3.2 v5 19/19] hostmem: use object id for memory region name with >= 4.0 Marc-André Lureau
2018-12-04 14:22 ` [Qemu-devel] [PATCH for-3.2 v5 00/19] Generalize machine compatibility properties Marc-André Lureau
2018-12-10 17:07 ` Eduardo Habkost
2018-12-10 17:31   ` Igor Mammedov
2018-12-10 17:39     ` Eduardo Habkost
2018-12-11 15:11       ` Igor Mammedov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.