Skip to contentSkip to conversation

Machine props patches

GIT PULL Applied Marc-André Lureau 3 participants 34 messages Jan 7, 2019 – Jul 8, 2019 Arm STM32

lore
Share & tools
lore
#0 lore raw

The following changes since commit e59dbbac0364344a3ad84c3497a98c56003d3fb8:

Merge remote-tracking branch 'remotes/philmd/tags/fw_cfg-20190104-pull-request' into staging (2019-01-04 18:23:13 +0000)

are available in the Git repository at:

https://github.com/elmarco/qemu.git tags/machine-props-pull-request

for you to fetch changes up to fa0cb34d2210cc749b9a70db99bb41c56ad20831:

hostmem: use object id for memory region name with >= 4.0 (2019-01-07 16:18:42 +0400)

----------------------------------------------------------------
Generalize machine compatibility properties

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.

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)

----------------------------------------------------------------

Marc-André Lureau (28):
hw: apply accel compat properties without touching globals
machines: replace COMPAT define with a static array
hw: apply machine compat properties without touching globals
machine: move compat properties out of globals
hw: remove SET_MACHINE_COMPAT
compat: replace PC_COMPAT_3_1 & HW_COMPAT_3_1 macros
compat: replace PC_COMPAT_3_0 & HW_COMPAT_3_0 macros
compat: replace PC_COMPAT_2_12 & HW_COMPAT_2_12 macros
compat: replace PC_COMPAT_2_11 & HW_COMPAT_2_11 macros
compat: replace PC_COMPAT_2_10 & HW_COMPAT_2_10 macros
compat: replace PC_COMPAT_2_9 & HW_COMPAT_2_9 macros
compat: replace PC_COMPAT_2_8 & HW_COMPAT_2_8 macros
compat: replace PC_COMPAT_2_7 & HW_COMPAT_2_7 macros
compat: replace PC_COMPAT_2_6 & HW_COMPAT_2_6 macros
compat: replace PC_COMPAT_2_5 & HW_COMPAT_2_5 macros
compat: replace PC_COMPAT_2_4 & HW_COMPAT_2_4 macros
compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros
compat: replace PC_COMPAT_2_2 & HW_COMPAT_2_2 macros
compat: replace PC_COMPAT_2_1 & HW_COMPAT_2_1 macros
include: remove compat.h
compat: remove remaining PC_COMPAT macros
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()
arm: replace instance_post_init()
hostmem: use object id for memory region name with >= 4.0

 include/hw/boards.h            |  59 ++-
 include/hw/compat.h            | 299 --------------
 include/hw/i386/pc.h           | 689 +++------------------------------
 include/hw/qdev-core.h         |  23 +-
 include/qom/object.h           |   3 +
 include/sysemu/accel.h         |   4 +-
 include/sysemu/hostmem.h       |   3 +-
 target/arm/cpu-qom.h           |   3 +
 target/arm/cpu.h               |   2 +
 accel/accel.c                  |  12 -
 backends/hostmem-file.c        |   8 +-
 backends/hostmem-memfd.c       |   2 +-
 backends/hostmem-ram.c         |   9 +-
 backends/hostmem.c             |  36 ++
 hw/arm/virt.c                  |  46 +--
 hw/core/machine.c              | 347 ++++++++++++++++-
 hw/core/qdev-properties.c      |  49 +--
 hw/core/qdev.c                 |  15 +
 hw/i386/pc.c                   | 674 ++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c              | 508 ++++++++++++------------
 hw/i386/pc_q35.c               |  36 +-
 hw/ppc/spapr.c                 | 207 +++++-----
 hw/s390x/s390-virtio-ccw.c     | 196 +++++-----
 hw/xen/xen-common.c            |  41 +-
 qom/cpu.c                      |   1 -
 qom/object.c                   |  35 ++
 target/arm/cpu.c               |  30 +-
 target/arm/cpu64.c             |  24 +-
 target/i386/cpu.c              |   1 -
 target/sparc/cpu.c             |   1 -
 tests/test-qdev-global-props.c |  57 +--
 vl.c                           |   4 -
 32 files changed, 1786 insertions(+), 1638 deletions(-)
 delete mode 100644 include/hw/compat.h
Signature · 1 line
2.20.1.2.gb21ebb671b
#1 lore raw

[Qemu-devel] [PULL v2 01/28] hw: apply accel compat properties without touching globals

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.

---
 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(-)
include/hw/qdev-core.h +10 -0
index 92851e55df..84e612f473 100644
@@ -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);
include/qom/object.h +3 -0
index bcae3f4951..e0262962b5 100644
@@ -675,6 +675,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
include/sysemu/accel.h +1 -3
index 637358f430..f331d128e9 100644
@@ -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);
 
accel/accel.c +0 -12
index 3da26eb90f..6db5d8f4df 100644
@@ -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;
hw/core/qdev.c +9 -0
index 6b3cc55b27..53b507164f 100644
@@ -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));
 }
 
hw/xen/xen-common.c +6 -3
index 6ec14c73ca..4532aa8632 100644
@@ -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")
qom/object.c +25 -0
index 17921c0a71..dbdab0aead 100644
@@ -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;
vl.c +0 -1
index 0db5ad0246..936d0c2587 100644
@@ -2996,7 +2996,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();
 }
Signature · 1 line
2.20.1.2.gb21ebb671b
#2 lore raw

Re: [Qemu-devel] [PULL v2 01/28] hw: apply accel compat properties without touching globals

Quoted 16 lines · Marc-André Lureau

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.

hw/core/qdev.c +1 -0
index 6b3cc55b27..53b507164f 100644
@@ -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)) {

hw/core/qdev.c static void device_initfn(Object *obj) · line 985

Quoted 10 lines
hw/core/qdev.c +8 -0
+        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));
 }

Hi; I've just noticed that this commit seems to break "-device whatever,help" :

$ gdb --args ./build/x86/arm-softmmu/qemu-system-arm -device iotkit,help -M virt
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
[...]
(gdb) r
Starting program:
/home/petmay01/linaro/qemu-from-laptop/qemu/build/x86/arm-softmmu/qemu-system-arm
-device iotkit,help -M virt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffce6c1700 (LWP 23277)]

Thread 1 "qemu-system-arm" received signal SIGSEGV, Segmentation fault. 0x0000555555d985d1 in object_get_class (obj=0x0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:857
857         return obj->class;
(gdb) bt
#0  0x0000555555d985d1 in object_get_class (obj=0x0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:857
#1  0x0000555555b5675d in object_apply_compat_props (obj=0x555556b42600)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev.c:978
#2  0x0000555555b567f0 in device_post_init (obj=0x555556b42600)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev.c:989
#3  0x0000555555d97294 in object_post_init_with_type
(obj=0x555556b42600, ti=0x5555569f7840)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:365
#4  0x0000555555d972c2 in object_post_init_with_type
(obj=0x555556b42600, ti=0x5555569f8640)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:369
#5  0x0000555555d972c2 in object_post_init_with_type
(obj=0x555556b42600, ti=0x555556a12c60)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:369

#6 0x0000555555d97572 in object_initialize_with_type (data=0x555556b42600, size=1056, type=0x555556a12c60) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:425 #7 0x0000555555d975b0 in object_initialize (data=0x555556b42600, size=1056, typename=0x555555ff3ee1 "armv7m_systick") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #8 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40fa0, propname=0x555555ff3f36 "systick-reg-ns", childobj=0x555556b42600, size=1056, type=0x555555ff3ee1 "armv7m_systick", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffd7c0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#9 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40fa0, propname=0x555555ff3f36 "systick-reg-ns", childobj=0x555556b42600, size=1056, type=0x555555ff3ee1 "armv7m_systick", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #10 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40fa0, childname=0x555555ff3f36 "systick-reg-ns", child=0x555556b42600, childsize=1056, childtype=0x555555ff3ee1 "armv7m_systick")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#11 0x00005555559231b0 in armv7m_nvic_instance_init (obj=0x555556b40fa0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/intc/armv7m_nvic.c:2393
#12 0x0000555555d97263 in object_init_with_type (obj=0x555556b40fa0,
ti=0x5555569cbce0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#13 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40fa0, size=7840, type=0x5555569cbce0) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #14 0x0000555555d975b0 in object_initialize (data=0x555556b40fa0, size=7840, typename=0x555556019af8 "armv7m_nvic") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #15 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40c90, propname=0x555556019b04 "nvnic", childobj=0x555556b40fa0, size=7840, type=0x555556019af8 "armv7m_nvic", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffda90)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#16 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40c90, propname=0x555556019b04 "nvnic", childobj=0x555556b40fa0, size=7840, type=0x555556019af8 "armv7m_nvic", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #17 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40c90, childname=0x555556019b04 "nvnic", child=0x555556b40fa0, childsize=7840, childtype=0x555556019af8 "armv7m_nvic")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#18 0x00005555559c63ba in armv7m_instance_init (obj=0x555556b40c90)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/arm/armv7m.c:137
#19 0x0000555555d97263 in object_init_with_type (obj=0x555556b40c90,
ti=0x5555569db4c0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#20 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40c90, size=11152, type=0x5555569db4c0) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #21 0x0000555555d975b0 in object_initialize (data=0x555556b40c90, size=11152, typename=0x555556022fd1 "armv7m") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #22 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40980, propname=0x555556022fd1 "armv7m", childobj=0x555556b40c90, size=11152, type=0x555556022fd1 "armv7m", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffdd50)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#23 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40980, propname=0x555556022fd1 "armv7m", childobj=0x555556b40c90, size=11152, type=0x555556022fd1 "armv7m", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #24 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40980, childname=0x555556022fd1 "armv7m", child=0x555556b40c90, childsize=11152, childtype=0x555556022fd1 "armv7m")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#25 0x00005555559f3fdc in iotkit_init (obj=0x555556b40980)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/arm/iotkit.c:115
#26 0x0000555555d97263 in object_init_with_type (obj=0x555556b40980,
ti=0x5555569df840)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#27 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40980, size=50080, type=0x5555569df840) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #28 0x0000555555d97bb9 in object_new_with_type (type=0x5555569df840)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:588
#29 0x0000555555d97bf6 in object_new (typename=0x555556a2b230 "iotkit")
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:598

#30 0x0000555555aafe8c in qmp_device_list_properties (typename=0x555556a2b230 "iotkit", errp=0x7fffffffe050) at /home/petmay01/linaro/qemu-from-laptop/qemu/qmp.c:519
#31 0x0000555555a8607a in qdev_device_help (opts=0x555556a2b1c0)
at /home/petmay01/linaro/qemu-from-laptop/qemu/qdev-monitor.c:283
#32 0x0000555555a8f77e in device_help_func (opaque=0x0, opts=0x555556a2b1c0, errp=0x0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/vl.c:2299
#33 0x0000555555ef5b21 in qemu_opts_foreach (list=0x555556787040
<qemu_device_opts>, func=0x555555a8f75e <device_help_func>,
opaque=0x0, errp=0x0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/util/qemu-option.c:1171
#34 0x0000555555a94310 in main (argc=5, argv=0x7fffffffe408,
envp=0x7fffffffe438)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/vl.c:4323

Looking at the backtrace, this seems to happen because in device_post_init we look at m->accelerator, but m->accelerator is only set when vl.c calls configure_accelerator(), so if this function gets called before then, it will cause an assert. In particular, the handling of -device foo,help happens before the accelerator is configured. (Possibly other things may cause device init before then too?)

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PULL v2 01/28] hw: apply accel compat properties without touching globals

Hi Peter

Quoted 25 lines · Peter Maydell
Quoted 22 lines · Marc-André Lureau

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.

hw/core/qdev.c +7 -0
index 6b3cc55b27..53b507164f 100644
@@ -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);
+        }
Quoted 8 lines

hw/core/qdev.c static void device_initfn(Object *obj) · line 985

Quoted 4 lines
hw/core/qdev.c +2 -0
+    }
+
     qdev_prop_set_globals(DEVICE(obj));
 }

Hi; I've just noticed that this commit seems to break "-device whatever,help" :

[Qemu-devel] [PATCH] qdev: fix -device scsi-hd,help regression

This should now be queued, afaik.

Quoted 144 lines
$ gdb --args ./build/x86/arm-softmmu/qemu-system-arm -device iotkit,help -M virt
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
[...]
(gdb) r
Starting program:
/home/petmay01/linaro/qemu-from-laptop/qemu/build/x86/arm-softmmu/qemu-system-arm
-device iotkit,help -M virt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffce6c1700 (LWP 23277)]

Thread 1 "qemu-system-arm" received signal SIGSEGV, Segmentation fault. 0x0000555555d985d1 in object_get_class (obj=0x0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:857
857         return obj->class;
(gdb) bt
#0  0x0000555555d985d1 in object_get_class (obj=0x0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:857
#1  0x0000555555b5675d in object_apply_compat_props (obj=0x555556b42600)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev.c:978
#2  0x0000555555b567f0 in device_post_init (obj=0x555556b42600)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev.c:989
#3  0x0000555555d97294 in object_post_init_with_type
(obj=0x555556b42600, ti=0x5555569f7840)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:365
#4  0x0000555555d972c2 in object_post_init_with_type
(obj=0x555556b42600, ti=0x5555569f8640)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:369
#5  0x0000555555d972c2 in object_post_init_with_type
(obj=0x555556b42600, ti=0x555556a12c60)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:369

#6 0x0000555555d97572 in object_initialize_with_type (data=0x555556b42600, size=1056, type=0x555556a12c60) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:425 #7 0x0000555555d975b0 in object_initialize (data=0x555556b42600, size=1056, typename=0x555555ff3ee1 "armv7m_systick") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #8 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40fa0, propname=0x555555ff3f36 "systick-reg-ns", childobj=0x555556b42600, size=1056, type=0x555555ff3ee1 "armv7m_systick", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffd7c0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#9 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40fa0, propname=0x555555ff3f36 "systick-reg-ns", childobj=0x555556b42600, size=1056, type=0x555555ff3ee1 "armv7m_systick", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #10 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40fa0, childname=0x555555ff3f36 "systick-reg-ns", child=0x555556b42600, childsize=1056, childtype=0x555555ff3ee1 "armv7m_systick")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#11 0x00005555559231b0 in armv7m_nvic_instance_init (obj=0x555556b40fa0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/intc/armv7m_nvic.c:2393
#12 0x0000555555d97263 in object_init_with_type (obj=0x555556b40fa0,
ti=0x5555569cbce0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#13 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40fa0, size=7840, type=0x5555569cbce0) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #14 0x0000555555d975b0 in object_initialize (data=0x555556b40fa0, size=7840, typename=0x555556019af8 "armv7m_nvic") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #15 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40c90, propname=0x555556019b04 "nvnic", childobj=0x555556b40fa0, size=7840, type=0x555556019af8 "armv7m_nvic", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffda90)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#16 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40c90, propname=0x555556019b04 "nvnic", childobj=0x555556b40fa0, size=7840, type=0x555556019af8 "armv7m_nvic", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #17 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40c90, childname=0x555556019b04 "nvnic", child=0x555556b40fa0, childsize=7840, childtype=0x555556019af8 "armv7m_nvic")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#18 0x00005555559c63ba in armv7m_instance_init (obj=0x555556b40c90)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/arm/armv7m.c:137
#19 0x0000555555d97263 in object_init_with_type (obj=0x555556b40c90,
ti=0x5555569db4c0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#20 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40c90, size=11152, type=0x5555569db4c0) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #21 0x0000555555d975b0 in object_initialize (data=0x555556b40c90, size=11152, typename=0x555556022fd1 "armv7m") at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:432 #22 0x0000555555d976fd in object_initialize_childv (parentobj=0x555556b40980, propname=0x555556022fd1 "armv7m", childobj=0x555556b40c90, size=11152, type=0x555556022fd1 "armv7m", errp=0x5555569775f8 <error_abort>, vargs=0x7fffffffdd50)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:455

#23 0x0000555555d97689 in object_initialize_child (parentobj=0x555556b40980, propname=0x555556022fd1 "armv7m", childobj=0x555556b40c90, size=11152, type=0x555556022fd1 "armv7m", errp=0x5555569775f8 <error_abort>) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:442 #24 0x0000555555b5d049 in sysbus_init_child_obj (parent=0x555556b40980, childname=0x555556022fd1 "armv7m", child=0x555556b40c90, childsize=11152, childtype=0x555556022fd1 "armv7m")

    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/sysbus.c:376
#25 0x00005555559f3fdc in iotkit_init (obj=0x555556b40980)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/hw/arm/iotkit.c:115
#26 0x0000555555d97263 in object_init_with_type (obj=0x555556b40980,
ti=0x5555569df840)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:358

#27 0x0000555555d9755f in object_initialize_with_type (data=0x555556b40980, size=50080, type=0x5555569df840) at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:424 #28 0x0000555555d97bb9 in object_new_with_type (type=0x5555569df840)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:588
#29 0x0000555555d97bf6 in object_new (typename=0x555556a2b230 "iotkit")
    at /home/petmay01/linaro/qemu-from-laptop/qemu/qom/object.c:598

#30 0x0000555555aafe8c in qmp_device_list_properties (typename=0x555556a2b230 "iotkit", errp=0x7fffffffe050) at /home/petmay01/linaro/qemu-from-laptop/qemu/qmp.c:519
#31 0x0000555555a8607a in qdev_device_help (opts=0x555556a2b1c0)
at /home/petmay01/linaro/qemu-from-laptop/qemu/qdev-monitor.c:283
#32 0x0000555555a8f77e in device_help_func (opaque=0x0, opts=0x555556a2b1c0, errp=0x0)

    at /home/petmay01/linaro/qemu-from-laptop/qemu/vl.c:2299
#33 0x0000555555ef5b21 in qemu_opts_foreach (list=0x555556787040
<qemu_device_opts>, func=0x555555a8f75e <device_help_func>,
opaque=0x0, errp=0x0)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/util/qemu-option.c:1171
#34 0x0000555555a94310 in main (argc=5, argv=0x7fffffffe408,
envp=0x7fffffffe438)
    at /home/petmay01/linaro/qemu-from-laptop/qemu/vl.c:4323

Looking at the backtrace, this seems to happen because in device_post_init we look at m->accelerator, but m->accelerator is only set when vl.c calls configure_accelerator(), so if this function gets called before then, it will cause an assert. In particular, the handling of -device foo,help happens before the accelerator is configured. (Possibly other things may cause device init before then too?)

thanks
-- PMM

#4 lore raw

[Qemu-devel] [PULL v2 04/28] machine: move compat properties out of globals

In reply to Marc-André Lureau

Move the compat arrays inside functions that use them.

---
 hw/arm/virt.c              |  94 +++---
 hw/i386/pc_piix.c          | 607 ++++++++++++++++++-------------------
 hw/i386/pc_q35.c           | 121 ++++----
 hw/ppc/spapr.c             | 254 ++++++++--------
 hw/s390x/s390-virtio-ccw.c | 239 +++++++--------
 hw/xen/xen-common.c        |  38 ++-
 6 files changed, 637 insertions(+), 716 deletions(-)
hw/arm/virt.c +40 -54
index 275ef8bc02..19bec3fe59 100644
@@ -1872,98 +1872,88 @@ 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_machine_3_1_options(MachineClass *mc)
 {
+    static GlobalProperty compat[] = {
+        HW_COMPAT_3_1
+    };
+
     virt_machine_4_0_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_3_1, G_N_ELEMENTS(virt_compat_3_1));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_VIRT_MACHINE(3, 1)
 
-static GlobalProperty virt_compat_3_0[] = {
-    HW_COMPAT_3_0
-};
-
 static void virt_machine_3_0_options(MachineClass *mc)
 {
+    static GlobalProperty compat[] = {
+        HW_COMPAT_3_0
+    };
+
     virt_machine_3_1_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_3_0, G_N_ELEMENTS(virt_compat_3_0));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_VIRT_MACHINE(3, 0)
 
-static GlobalProperty virt_compat_2_12[] = {
-    HW_COMPAT_2_12
-};
-
 static void virt_machine_2_12_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_12
+    };
 
     virt_machine_3_0_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_12, G_N_ELEMENTS(virt_compat_2_12));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     vmc->no_highmem_ecam = true;
     mc->max_cpus = 255;
 }
 DEFINE_VIRT_MACHINE(2, 12)
 
-static GlobalProperty virt_compat_2_11[] = {
-    HW_COMPAT_2_11
-};
-
 static void virt_machine_2_11_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_11
+    };
 
     virt_machine_2_12_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_11, G_N_ELEMENTS(virt_compat_2_11));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     vmc->smbios_old_sys_ver = true;
 }
 DEFINE_VIRT_MACHINE(2, 11)
 
-static GlobalProperty virt_compat_2_10[] = {
-    HW_COMPAT_2_10
-};
-
 static void virt_machine_2_10_options(MachineClass *mc)
 {
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_10
+    };
+
     virt_machine_2_11_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_10, G_N_ELEMENTS(virt_compat_2_10));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     /* before 2.11 we never faulted accesses to bad addresses */
     mc->ignore_memory_transaction_failures = true;
 }
 DEFINE_VIRT_MACHINE(2, 10)
 
-static GlobalProperty virt_compat_2_9[] = {
-    HW_COMPAT_2_9
-};
-
 static void virt_machine_2_9_options(MachineClass *mc)
 {
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_9
+    };
+
     virt_machine_2_10_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_9, G_N_ELEMENTS(virt_compat_2_9));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_VIRT_MACHINE(2, 9)
 
-static GlobalProperty virt_compat_2_8[] = {
-    HW_COMPAT_2_8
-};
-
 static void virt_machine_2_8_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_8
+    };
 
     virt_machine_2_9_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_8, G_N_ELEMENTS(virt_compat_2_8));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     /* For 2.8 and earlier we falsely claimed in the DT that
      * our timers were edge-triggered, not level-triggered.
      */
@@ -1971,17 +1961,15 @@ static void virt_machine_2_8_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE(2, 8)
 
-static GlobalProperty virt_compat_2_7[] = {
-    HW_COMPAT_2_7
-};
-
 static void virt_machine_2_7_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_7
+    };
 
     virt_machine_2_8_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_7, G_N_ELEMENTS(virt_compat_2_7));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     /* ITS was introduced with 2.8 */
     vmc->no_its = true;
     /* Stick with 1K pages for migration compatibility */
@@ -1989,17 +1977,15 @@ static void virt_machine_2_7_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE(2, 7)
 
-static GlobalProperty virt_compat_2_6[] = {
-    HW_COMPAT_2_6
-};
-
 static void virt_machine_2_6_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+    static GlobalProperty compat[] = {
+        HW_COMPAT_2_6
+    };
 
     virt_machine_2_7_options(mc);
-    compat_props_add(mc->compat_props,
-                     virt_compat_2_6, G_N_ELEMENTS(virt_compat_2_6));
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     vmc->disallow_affinity_adjustment = true;
     /* Disable PMU for 2.6 as PMU support was first introduced in 2.7 */
     vmc->no_pmu = true;
hw/i386/pc_piix.c +290 -317

876 lines not on this page · raw message

hw/i386/pc_q35.c +55 -66

226 lines not on this page · raw message

hw/ppc/spapr.c +122 -132

414 lines not on this page · raw message

hw/s390x/s390-virtio-ccw.c +112 -127

329 lines not on this page · raw message

hw/xen/xen-common.c +18 -20
index 4532aa8632..d51148b6b3 100644
@@ -159,27 +159,26 @@ static int xen_init(MachineState *ms)
     return 0;
 }
 
-static GlobalProperty xen_compat_props[] = {
-    {
-        .driver = "migration",
-        .property = "store-global-state",
-        .value = "off",
-    },
-    {
-        .driver = "migration",
-        .property = "send-configuration",
-        .value = "off",
-    },
-    {
-        .driver = "migration",
-        .property = "send-section-footer",
-        .value = "off",
-    }
-};
-
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
+    static GlobalProperty compat[] = {
+        {
+            .driver = "migration",
+            .property = "store-global-state",
+            .value = "off",
+        },
+        {
+            .driver = "migration",
+            .property = "send-configuration",
+            .value = "off",
+        },
+        {
+            .driver = "migration",
+            .property = "send-section-footer",
+            .value = "off",
+        }
+    };
 
     ac->name = "Xen";
     ac->init_machine = xen_init;
@@ -187,8 +186,7 @@ static void xen_accel_class_init(ObjectClass *oc, void *data)
     ac->allowed = &xen_allowed;
     ac->compat_props = g_ptr_array_new();
 
-    compat_props_add(ac->compat_props,
-                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
+    compat_props_add(ac->compat_props, compat, G_N_ELEMENTS(compat));
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
Signature · 1 line
2.20.1.2.gb21ebb671b
#5 lore raw

[Qemu-devel] [PULL v2 08/28] compat: replace PC_COMPAT_2_12 & HW_COMPAT_2_12 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 27 ---------------------------
 include/hw/i386/pc.h       | 21 ++-------------------
 hw/arm/virt.c              |  5 +----
 hw/core/machine.c          | 29 +++++++++++++++++++++++++++++
 hw/i386/pc.c               | 21 +++++++++++++++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 10 files changed, 62 insertions(+), 66 deletions(-)
include/hw/boards.h +3 -0
index aaa57f1f6b..c6d828e73c 100644
@@ -294,4 +294,7 @@ extern const size_t hw_compat_3_1_len;
 extern GlobalProperty hw_compat_3_0[];
 extern const size_t hw_compat_3_0_len;
 
+extern GlobalProperty hw_compat_2_12[];
+extern const size_t hw_compat_2_12_len;
+
 #endif
include/hw/compat.h +0 -27
index c08f4040bb..13242b831a 100644
@@ -1,33 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_12 \
-    {\
-        .driver   = "migration",\
-        .property = "decompress-error-check",\
-        .value    = "off",\
-    },{\
-        .driver   = "hda-audio",\
-        .property = "use-timer",\
-        .value    = "false",\
-    },{\
-        .driver   = "cirrus-vga",\
-        .property = "global-vmstate",\
-        .value    = "true",\
-    },{\
-        .driver   = "VGA",\
-        .property = "global-vmstate",\
-        .value    = "true",\
-    },{\
-        .driver   = "vmware-svga",\
-        .property = "global-vmstate",\
-        .value    = "true",\
-    },{\
-        .driver   = "qxl-vga",\
-        .property = "global-vmstate",\
-        .value    = "true",\
-    },
-
 #define HW_COMPAT_2_11 \
     {\
         .driver   = "hpet",\
include/hw/i386/pc.h +2 -19
index 197131ff9a..91cb3283f0 100644
@@ -300,25 +300,8 @@ extern const size_t pc_compat_3_1_len;
 extern GlobalProperty pc_compat_3_0[];
 extern const size_t pc_compat_3_0_len;
 
-#define PC_COMPAT_2_12 \
-    HW_COMPAT_2_12 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "legacy-cache",\
-        .value    = "on",\
-    },{\
-        .driver   = TYPE_X86_CPU,\
-        .property = "topoext",\
-        .value    = "off",\
-    },{\
-        .driver   = "EPYC-" TYPE_X86_CPU,\
-        .property = "xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "EPYC-IBPB-" TYPE_X86_CPU,\
-        .property = "xlevel",\
-        .value    = stringify(0x8000000a),\
-    },
+extern GlobalProperty pc_compat_2_12[];
+extern const size_t pc_compat_2_12_len;
 
 #define PC_COMPAT_2_11 \
     HW_COMPAT_2_11 \
hw/arm/virt.c +1 -4
index 5c541ec55e..228ee63d99 100644
@@ -1889,12 +1889,9 @@ DEFINE_VIRT_MACHINE(3, 0)
 static void virt_machine_2_12_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_12
-    };
 
     virt_machine_3_0_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
     vmc->no_highmem_ecam = true;
     mc->max_cpus = 255;
 }
hw/core/machine.c +29 -0
index f00f6381d2..ae94f5e4ca 100644
@@ -38,6 +38,35 @@ const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
 GlobalProperty hw_compat_3_0[] = {};
 const size_t hw_compat_3_0_len = G_N_ELEMENTS(hw_compat_3_0);
 
+GlobalProperty hw_compat_2_12[] = {
+    {
+        .driver   = "migration",
+        .property = "decompress-error-check",
+        .value    = "off",
+    },{
+        .driver   = "hda-audio",
+        .property = "use-timer",
+        .value    = "false",
+    },{
+        .driver   = "cirrus-vga",
+        .property = "global-vmstate",
+        .value    = "true",
+    },{
+        .driver   = "VGA",
+        .property = "global-vmstate",
+        .value    = "true",
+    },{
+        .driver   = "vmware-svga",
+        .property = "global-vmstate",
+        .value    = "true",
+    },{
+        .driver   = "qxl-vga",
+        .property = "global-vmstate",
+        .value    = "true",
+    },
+};
+const size_t hw_compat_2_12_len = G_N_ELEMENTS(hw_compat_2_12);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +21 -0
index b5799985a1..031602a005 100644
@@ -135,6 +135,27 @@ GlobalProperty pc_compat_3_0[] = {
 };
 const size_t pc_compat_3_0_len = G_N_ELEMENTS(pc_compat_3_0);
 
+GlobalProperty pc_compat_2_12[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "legacy-cache",
+        .value    = "on",
+    },{
+        .driver   = TYPE_X86_CPU,
+        .property = "topoext",
+        .value    = "off",
+    },{
+        .driver   = "EPYC-" TYPE_X86_CPU,
+        .property = "xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "EPYC-IBPB-" TYPE_X86_CPU,
+        .property = "xlevel",
+        .value    = stringify(0x8000000a),
+    },
+};
+const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index cc8b249ccc..fd3906cda6 100644
@@ -462,12 +462,9 @@ DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
 
 static void pc_i440fx_2_12_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_12
-    };
-
     pc_i440fx_3_0_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len);
+    compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
hw/i386/pc_q35.c +2 -5
index 39378ee1cd..7928f703d0 100644
@@ -345,12 +345,9 @@ DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
 
 static void pc_q35_2_12_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_12
-    };
-
     pc_q35_3_0_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len);
+    compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len);
 }
 
 DEFINE_Q35_MACHINE(v2_12, "pc-q35-2.12", NULL,
hw/ppc/spapr.c +1 -1
index 8a99e4d9b8..f1fe455c71 100644
@@ -4054,7 +4054,6 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_12
         {
             .driver = TYPE_POWERPC_CPU,
             .property = "pre-3.0-migration",
@@ -4068,6 +4067,7 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)
     };
 
     spapr_machine_3_0_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 
     /* We depend on kvm_enabled() to choose a default value for the
hw/s390x/s390-virtio-ccw.c +1 -5
index e54e6f6dd0..ce22a9d511 100644
@@ -696,12 +696,8 @@ static void ccw_machine_2_12_instance_options(MachineState *machine)
 
 static void ccw_machine_2_12_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_12
-    };
-
     ccw_machine_3_0_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
 }
 DEFINE_CCW_MACHINE(2_12, "2.12", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#6 lore raw

[Qemu-devel] [PULL v2 06/28] compat: replace PC_COMPAT_3_1 & HW_COMPAT_3_1 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 11 -----------
 include/hw/i386/pc.h       |  9 ++-------
 hw/arm/virt.c              |  6 +-----
 hw/core/machine.c          | 13 +++++++++++++
 hw/i386/pc.c               |  9 +++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  6 +-----
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 10 files changed, 34 insertions(+), 43 deletions(-)
include/hw/boards.h +3 -0
index 0566742412..b9a5c2d087 100644
@@ -288,4 +288,7 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
+extern GlobalProperty hw_compat_3_1[];
+extern const size_t hw_compat_3_1_len;
+
 #endif
include/hw/compat.h +0 -11
index 3ca85b037c..6f4d5fc647 100644
@@ -1,17 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_3_1 \
-    {\
-        .driver   = "pcie-root-port",\
-        .property = "x-speed",\
-        .value    = "2_5",\
-    },{\
-        .driver   = "pcie-root-port",\
-        .property = "x-width",\
-        .value    = "1",\
-    },
-
 #define HW_COMPAT_3_0 \
     /* empty */
 
include/hw/i386/pc.h +2 -7
index c7c0c944e8..dd1d6fd0f3 100644
@@ -294,13 +294,8 @@ 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 \
-    {\
-        .driver   = "intel-iommu",\
-        .property = "dma-drain",\
-        .value    = "off",\
-    },
+extern GlobalProperty pc_compat_3_1[];
+extern const size_t pc_compat_3_1_len;
 
 #define PC_COMPAT_3_0 \
     HW_COMPAT_3_0 \
hw/arm/virt.c +1 -5
index 19bec3fe59..ebd5f306e4 100644
@@ -1874,12 +1874,8 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 0)
 
 static void virt_machine_3_1_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_1
-    };
-
     virt_machine_4_0_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
 }
 DEFINE_VIRT_MACHINE(3, 1)
 
hw/core/machine.c +13 -0
index bd644c976b..d6204967c3 100644
@@ -22,6 +22,19 @@
 #include "qemu/error-report.h"
 #include "sysemu/qtest.h"
 
+GlobalProperty hw_compat_3_1[] = {
+    {
+        .driver   = "pcie-root-port",
+        .property = "x-speed",
+        .value    = "2_5",
+    },{
+        .driver   = "pcie-root-port",
+        .property = "x-width",
+        .value    = "1",
+    },
+};
+const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +9 -0
index f248662e97..33d09a832a 100644
@@ -109,6 +109,15 @@ static struct e820_entry *e820_table;
 static unsigned e820_entries;
 struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX};
 
+GlobalProperty pc_compat_3_1[] = {
+    {
+        .driver   = "intel-iommu",
+        .property = "dma-drain",
+        .value    = "off",
+    },
+};
+const size_t pc_compat_3_1_len = G_N_ELEMENTS(pc_compat_3_1);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index 2423428acd..c938437627 100644
@@ -440,14 +440,11 @@ DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL,
 
 static void pc_i440fx_3_1_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_3_1
-    };
-
     pc_i440fx_4_0_machine_options(m);
     m->is_default = 0;
     m->alias = NULL;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
+    compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
 }
 
 DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
hw/i386/pc_q35.c +2 -5
index d84614546c..fad3d6da17 100644
@@ -323,14 +323,11 @@ DEFINE_Q35_MACHINE(v4_0, "pc-q35-4.0", NULL,
 
 static void pc_q35_3_1_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_3_1
-    };
-
     pc_q35_4_0_machine_options(m);
     m->default_kernel_irqchip_split = false;
     m->alias = NULL;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
+    compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
 }
 
 DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
hw/ppc/spapr.c +1 -5
index f3b8c18de3..f04135fffd 100644
@@ -4023,12 +4023,8 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true);
  */
 static void spapr_machine_3_1_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_1
-    };
-
     spapr_machine_4_0_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0");
 }
 
hw/s390x/s390-virtio-ccw.c +1 -5
index 21f3325c5a..5e8b48e75b 100644
@@ -667,12 +667,8 @@ static void ccw_machine_3_1_instance_options(MachineState *machine)
 
 static void ccw_machine_3_1_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_1
-    };
-
     ccw_machine_4_0_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
 }
 DEFINE_CCW_MACHINE(3_1, "3.1", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#7 lore raw

[Qemu-devel] [PULL v2 02/28] machines: replace COMPAT define with a static array

In reply to Marc-André Lureau
---
 include/hw/boards.h        |  10 +-
 hw/arm/virt.c              |  45 ++--
 hw/i386/pc_piix.c          | 474 +++++++++++++++++++++----------------
 hw/i386/pc_q35.c           |  66 +++++-
 hw/ppc/spapr.c             | 201 ++++++++--------
 hw/s390x/s390-virtio-ccw.c | 219 +++++++++--------
 6 files changed, 577 insertions(+), 438 deletions(-)
include/hw/boards.h +3 -7
index 362384815e..a5d8ddd68b 100644
@@ -289,18 +289,14 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
-#define SET_MACHINE_COMPAT(m, COMPAT) \
+#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];          \
+        for (i = 0; i < G_N_ELEMENTS(compat); i++) {          \
+            GlobalProperty *prop = &compat[i];          \
             g_array_append_val(m->compat_props, prop); \
         }                                              \
     } while (0)
hw/arm/virt.c +27 -18

141 lines not on this page · raw message

hw/i386/pc_piix.c +270 -204

755 lines not on this page · raw message

hw/i386/pc_q35.c +55 -11

171 lines not on this page · raw message

hw/ppc/spapr.c +107 -94

365 lines not on this page · raw message

hw/s390x/s390-virtio-ccw.c +115 -104

291 lines not on this page · raw message

Signature · 1 line
2.20.1.2.gb21ebb671b
#8 lore raw

[Qemu-devel] [PULL v2 15/28] compat: replace PC_COMPAT_2_5 & HW_COMPAT_2_5 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 24 ------------------------
 include/hw/i386/pc.h       |  4 ++--
 hw/core/machine.c          | 26 ++++++++++++++++++++++++++
 hw/i386/pc.c               |  3 +++
 hw/i386/pc_piix.c          |  6 ++----
 hw/i386/pc_q35.c           |  6 ++----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 9 files changed, 40 insertions(+), 40 deletions(-)
include/hw/boards.h +3 -0
index 1135ee23ac..0023b72b02 100644
@@ -315,4 +315,7 @@ extern const size_t hw_compat_2_7_len;
 extern GlobalProperty hw_compat_2_6[];
 extern const size_t hw_compat_2_6_len;
 
+extern GlobalProperty hw_compat_2_5[];
+extern const size_t hw_compat_2_5_len;
+
 #endif
include/hw/compat.h +0 -24
index c744233fb6..a6eced34c6 100644
@@ -1,30 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_5 \
-    {\
-        .driver   = "isa-fdc",\
-        .property = "fallback",\
-        .value    = "144",\
-    },{\
-        .driver   = "pvscsi",\
-        .property = "x-old-pci-configuration",\
-        .value    = "on",\
-    },{\
-        .driver   = "pvscsi",\
-        .property = "x-disable-pcie",\
-        .value    = "on",\
-    },\
-    {\
-        .driver   = "vmxnet3",\
-        .property = "x-old-msi-offsets",\
-        .value    = "on",\
-    },{\
-        .driver   = "vmxnet3",\
-        .property = "x-disable-pcie",\
-        .value    = "on",\
-    },
-
 #define HW_COMPAT_2_4 \
     {\
         .driver   = "virtio-blk-device",\
include/hw/i386/pc.h +2 -2
index ca62def2c9..9a32031f25 100644
@@ -321,8 +321,8 @@ extern const size_t pc_compat_2_7_len;
 extern GlobalProperty pc_compat_2_6[];
 extern const size_t pc_compat_2_6_len;
 
-#define PC_COMPAT_2_5 \
-    HW_COMPAT_2_5
+extern GlobalProperty pc_compat_2_5[];
+extern const size_t pc_compat_2_5_len;
 
 /* Helper for setting model-id for CPU models that changed model-id
  * depending on QEMU versions up to QEMU 2.4.
hw/core/machine.c +26 -0
index e27b1b5c34..4d05501775 100644
@@ -210,6 +210,32 @@ GlobalProperty hw_compat_2_6[] = {
 };
 const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
 
+GlobalProperty hw_compat_2_5[] = {
+    {
+        .driver   = "isa-fdc",
+        .property = "fallback",
+        .value    = "144",
+    },{
+        .driver   = "pvscsi",
+        .property = "x-old-pci-configuration",
+        .value    = "on",
+    },{
+        .driver   = "pvscsi",
+        .property = "x-disable-pcie",
+        .value    = "on",
+    },
+    {
+        .driver   = "vmxnet3",
+        .property = "x-old-msi-offsets",
+        .value    = "on",
+    },{
+        .driver   = "vmxnet3",
+        .property = "x-disable-pcie",
+        .value    = "on",
+    },
+};
+const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +3 -0
index 6c8ff0e928..8eb69ff054 100644
@@ -281,6 +281,9 @@ GlobalProperty pc_compat_2_6[] = {
 };
 const size_t pc_compat_2_6_len = G_N_ELEMENTS(pc_compat_2_6);
 
+GlobalProperty pc_compat_2_5[] = {};
+const size_t pc_compat_2_5_len = G_N_ELEMENTS(pc_compat_2_5);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -4
index 89e81a028a..3a31de7316 100644
@@ -539,14 +539,12 @@ DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL,
 static void pc_i440fx_2_5_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_5
-    };
 
     pc_i440fx_2_6_machine_options(m);
     pcmc->save_tsc_khz = false;
     m->legacy_fw_cfg_order = 1;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len);
+    compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
hw/i386/pc_q35.c +2 -4
index efb70fb8af..418b8387d9 100644
@@ -426,14 +426,12 @@ DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL,
 static void pc_q35_2_5_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_5
-    };
 
     pc_q35_2_6_machine_options(m);
     pcmc->save_tsc_khz = false;
     m->legacy_fw_cfg_order = 1;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len);
+    compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len);
 }
 
 DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
hw/ppc/spapr.c +1 -1
index eff015987d..6be74ae0c8 100644
@@ -4285,7 +4285,6 @@ static void spapr_machine_2_5_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_5
         {
             .driver   = "spapr-vlan",
             .property = "use-rx-buffer-pools",
@@ -4295,6 +4294,7 @@ static void spapr_machine_2_5_class_options(MachineClass *mc)
 
     spapr_machine_2_6_class_options(mc);
     smc->use_ohci_by_default = true;
+    compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 
hw/s390x/s390-virtio-ccw.c +1 -5
index 6137c97875..1ab53a1332 100644
@@ -836,12 +836,8 @@ static void ccw_machine_2_5_instance_options(MachineState *machine)
 
 static void ccw_machine_2_5_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_5
-    };
-
     ccw_machine_2_6_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len);
 }
 DEFINE_CCW_MACHINE(2_5, "2.5", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#9 lore raw

[Qemu-devel] [PULL v2 11/28] compat: replace PC_COMPAT_2_9 & HW_COMPAT_2_9 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 19 -------------------
 include/hw/i386/pc.h       |  9 ++-------
 hw/arm/virt.c              |  6 +-----
 hw/core/machine.c          | 21 +++++++++++++++++++++
 hw/i386/pc.c               |  9 +++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)
include/hw/boards.h +3 -0
index 732eb7bb73..0e69350939 100644
@@ -303,4 +303,7 @@ extern const size_t hw_compat_2_11_len;
 extern GlobalProperty hw_compat_2_10[];
 extern const size_t hw_compat_2_10_len;
 
+extern GlobalProperty hw_compat_2_9[];
+extern const size_t hw_compat_2_9_len;
+
 #endif
include/hw/compat.h +0 -19
index f414786604..ef154ca470 100644
@@ -1,25 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_9 \
-    {\
-        .driver   = "pci-bridge",\
-        .property = "shpc",\
-        .value    = "off",\
-    },{\
-        .driver   = "intel-iommu",\
-        .property = "pt",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-net-device",\
-        .property = "x-mtu-bypass-backend",\
-        .value    = "off",\
-    },{\
-        .driver   = "pcie-root-port",\
-        .property = "x-migrate-msix",\
-        .value    = "false",\
-    },
-
 #define HW_COMPAT_2_8 \
     {\
         .driver   = "fw_cfg_mem",\
include/hw/i386/pc.h +2 -7
index d77843a711..fb79f0b988 100644
@@ -309,13 +309,8 @@ extern const size_t pc_compat_2_11_len;
 extern GlobalProperty pc_compat_2_10[];
 extern const size_t pc_compat_2_10_len;
 
-#define PC_COMPAT_2_9 \
-    HW_COMPAT_2_9 \
-    {\
-        .driver   = "mch",\
-        .property = "extended-tseg-mbytes",\
-        .value    = stringify(0),\
-    },\
+extern GlobalProperty pc_compat_2_9[];
+extern const size_t pc_compat_2_9_len;
 
 #define PC_COMPAT_2_8 \
     HW_COMPAT_2_8 \
hw/arm/virt.c +1 -5
index 75ab14305a..a0898f27d3 100644
@@ -1918,12 +1918,8 @@ DEFINE_VIRT_MACHINE(2, 10)
 
 static void virt_machine_2_9_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_9
-    };
-
     virt_machine_2_10_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len);
 }
 DEFINE_VIRT_MACHINE(2, 9)
 
hw/core/machine.c +21 -0
index 7673454a66..aa5f03fba2 100644
@@ -101,6 +101,27 @@ GlobalProperty hw_compat_2_10[] = {
 };
 const size_t hw_compat_2_10_len = G_N_ELEMENTS(hw_compat_2_10);
 
+GlobalProperty hw_compat_2_9[] = {
+    {
+        .driver   = "pci-bridge",
+        .property = "shpc",
+        .value    = "off",
+    },{
+        .driver   = "intel-iommu",
+        .property = "pt",
+        .value    = "off",
+    },{
+        .driver   = "virtio-net-device",
+        .property = "x-mtu-bypass-backend",
+        .value    = "off",
+    },{
+        .driver   = "pcie-root-port",
+        .property = "x-migrate-msix",
+        .value    = "false",
+    },
+};
+const size_t hw_compat_2_9_len = G_N_ELEMENTS(hw_compat_2_9);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +9 -0
index c0bb82c454..3f6f5df363 100644
@@ -186,6 +186,15 @@ GlobalProperty pc_compat_2_10[] = {
 };
 const size_t pc_compat_2_10_len = G_N_ELEMENTS(pc_compat_2_10);
 
+GlobalProperty pc_compat_2_9[] = {
+    {
+        .driver   = "mch",
+        .property = "extended-tseg-mbytes",
+        .value    = stringify(0),
+    },
+};
+const size_t pc_compat_2_9_len = G_N_ELEMENTS(pc_compat_2_9);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index aea678dc91..02520bceb9 100644
@@ -493,12 +493,9 @@ DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL,
 
 static void pc_i440fx_2_9_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_9
-    };
-
     pc_i440fx_2_10_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len);
+    compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len);
     m->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
 }
 
hw/i386/pc_q35.c +2 -5
index a9c4fc27e4..e94d2d05c7 100644
@@ -380,12 +380,9 @@ DEFINE_Q35_MACHINE(v2_10, "pc-q35-2.10", NULL,
 
 static void pc_q35_2_9_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_9
-    };
-
     pc_q35_2_10_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len);
+    compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len);
 }
 
 DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL,
hw/ppc/spapr.c +1 -1
index 483a1373df..477ff5eb94 100644
@@ -4127,7 +4127,6 @@ static void spapr_machine_2_9_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_9
         {
             .driver = TYPE_POWERPC_CPU,
             .property = "pre-2.10-migration",
@@ -4136,6 +4135,7 @@ static void spapr_machine_2_9_class_options(MachineClass *mc)
     };
 
     spapr_machine_2_10_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     mc->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
     smc->pre_2_10_has_unused_icps = true;
hw/s390x/s390-virtio-ccw.c +1 -1
index 95ad7ba842..549f6e0231 100644
@@ -752,7 +752,6 @@ static void ccw_machine_2_9_class_options(MachineClass *mc)
 {
     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_9
         {
             .driver   = TYPE_S390_STATTRIB,
             .property = "migration-enabled",
@@ -761,6 +760,7 @@ static void ccw_machine_2_9_class_options(MachineClass *mc)
     };
 
     ccw_machine_2_10_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     s390mc->css_migration_enabled = false;
 }
Signature · 1 line
2.20.1.2.gb21ebb671b
#10 lore raw

[Qemu-devel] [PULL v2 03/28] hw: apply machine compat properties without touching globals

In reply to Marc-André Lureau

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

---
 include/hw/boards.h        |  3 +-
 hw/arm/virt.c              | 27 ++++++++-----
 hw/core/machine.c          | 19 +--------
 hw/core/qdev.c             |  2 +
 hw/i386/pc_piix.c          | 81 +++++++++++++++++++++++++-------------
 hw/i386/pc_q35.c           | 33 ++++++++++------
 hw/ppc/spapr.c             | 42 +++++++++++++-------
 hw/s390x/s390-virtio-ccw.c | 33 ++++++++++------
 vl.c                       |  1 -
 9 files changed, 148 insertions(+), 93 deletions(-)
include/hw/boards.h +1 -2
index a5d8ddd68b..f14c38bb63 100644
@@ -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;
hw/arm/virt.c +18 -9
index 6ecec1cb05..275ef8bc02 100644
@@ -1879,7 +1879,8 @@ static GlobalProperty virt_compat_3_1[] = {
 static void virt_machine_3_1_options(MachineClass *mc)
 {
     virt_machine_4_0_options(mc);
-    SET_MACHINE_COMPAT(mc, virt_compat_3_1);
+    compat_props_add(mc->compat_props,
+                     virt_compat_3_1, G_N_ELEMENTS(virt_compat_3_1));
 }
 DEFINE_VIRT_MACHINE(3, 1)
 
@@ -1890,7 +1891,8 @@ static GlobalProperty virt_compat_3_0[] = {
 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)
 
@@ -1903,7 +1905,8 @@ 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;
 }
@@ -1918,7 +1921,8 @@ 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)
@@ -1930,7 +1934,8 @@ static GlobalProperty virt_compat_2_10[] = {
 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;
 }
@@ -1943,7 +1948,8 @@ static GlobalProperty virt_compat_2_9[] = {
 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)
 
@@ -1956,7 +1962,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.
      */
@@ -1973,7 +1980,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 */
@@ -1990,7 +1998,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;
hw/core/machine.c +1 -18
index 4439ea663f..bd644c976b 100644
@@ -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();
     }
 }
 
@@ -836,24 +837,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,
hw/core/qdev.c +2 -0
index 53b507164f..d510340bac 100644
@@ -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));
hw/i386/pc_piix.c +54 -27

243 lines not on this page · raw message

hw/i386/pc_q35.c +22 -11
index 9aabae358c..4ae6718b74 100644
@@ -330,7 +330,8 @@ static void pc_q35_3_1_machine_options(MachineClass *m)
     pc_q35_4_0_machine_options(m);
     m->default_kernel_irqchip_split = false;
     m->alias = NULL;
-    SET_MACHINE_COMPAT(m, pc_compat_3_1);
+    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,
@@ -343,7 +344,8 @@ static GlobalProperty pc_compat_3_0[] = {
 static void pc_q35_3_0_machine_options(MachineClass *m)
 {
     pc_q35_3_1_machine_options(m);
-    SET_MACHINE_COMPAT(m, pc_compat_3_0);
+    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,
@@ -356,7 +358,8 @@ static GlobalProperty 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,
@@ -372,7 +375,8 @@ static void pc_q35_2_11_machine_options(MachineClass *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,
@@ -385,7 +389,8 @@ static GlobalProperty 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;
 }
@@ -400,7 +405,8 @@ static GlobalProperty 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,
@@ -413,7 +419,8 @@ static GlobalProperty 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,
@@ -427,7 +434,8 @@ 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,
@@ -443,7 +451,8 @@ static void pc_q35_2_6_machine_options(MachineClass *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,
@@ -459,7 +468,8 @@ static void pc_q35_2_5_machine_options(MachineClass *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,
@@ -475,7 +485,8 @@ static void pc_q35_2_4_machine_options(MachineClass *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,
hw/ppc/spapr.c +28 -14

126 lines not on this page · raw message

hw/s390x/s390-virtio-ccw.c +22 -11
index 882a9796cf..f2faea585e 100644
@@ -773,7 +773,8 @@ static void ccw_machine_3_1_instance_options(MachineState *machine)
 static void ccw_machine_3_1_class_options(MachineClass *mc)
 {
     ccw_machine_4_0_class_options(mc);
-    SET_MACHINE_COMPAT(mc, ccw_compat_3_1);
+    compat_props_add(mc->compat_props,
+                     ccw_compat_3_1, G_N_ELEMENTS(ccw_compat_3_1));
 }
 DEFINE_CCW_MACHINE(3_1, "3.1", false);
 
@@ -788,7 +789,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);
 
@@ -802,7 +804,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);
 
@@ -818,7 +821,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);
 
@@ -830,7 +834,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);
 
@@ -849,7 +854,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);
@@ -862,7 +868,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);
 
@@ -877,7 +884,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);
 
@@ -892,7 +900,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);
 
@@ -904,7 +913,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);
 
@@ -916,7 +926,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);
 
vl.c +0 -1
index 936d0c2587..be986b12a9 100644
@@ -2996,7 +2996,6 @@ static void user_register_global_props(void)
  */
 static void register_global_properties(MachineState *ms)
 {
-    machine_register_compat_props(ms);
     user_register_global_props();
 }
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#11 lore raw

[Qemu-devel] [PULL v2 10/28] compat: replace PC_COMPAT_2_10 & HW_COMPAT_2_10 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 11 -----------
 include/hw/i386/pc.h       | 17 ++---------------
 hw/arm/virt.c              |  6 +-----
 hw/core/machine.c          | 13 +++++++++++++
 hw/i386/pc.c               | 17 +++++++++++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  6 +-----
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 10 files changed, 42 insertions(+), 51 deletions(-)
include/hw/boards.h +3 -0
index 67202b5a2f..732eb7bb73 100644
@@ -300,4 +300,7 @@ extern const size_t hw_compat_2_12_len;
 extern GlobalProperty hw_compat_2_11[];
 extern const size_t hw_compat_2_11_len;
 
+extern GlobalProperty hw_compat_2_10[];
+extern const size_t hw_compat_2_10_len;
+
 #endif
include/hw/compat.h +0 -11
index cf389b4e85..f414786604 100644
@@ -1,17 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_10 \
-    {\
-        .driver   = "virtio-mouse-device",\
-        .property = "wheel-axis",\
-        .value    = "false",\
-    },{\
-        .driver   = "virtio-tablet-device",\
-        .property = "wheel-axis",\
-        .value    = "false",\
-    },
-
 #define HW_COMPAT_2_9 \
     {\
         .driver   = "pci-bridge",\
include/hw/i386/pc.h +2 -15
index f0f7e76a3e..d77843a711 100644
@@ -306,21 +306,8 @@ extern const size_t pc_compat_2_12_len;
 extern GlobalProperty pc_compat_2_11[];
 extern const size_t pc_compat_2_11_len;
 
-#define PC_COMPAT_2_10 \
-    HW_COMPAT_2_10 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "x-hv-max-vps",\
-        .value    = "0x40",\
-    },{\
-        .driver   = "i440FX-pcihost",\
-        .property = "x-pci-hole64-fix",\
-        .value    = "off",\
-    },{\
-        .driver   = "q35-pcihost",\
-        .property = "x-pci-hole64-fix",\
-        .value    = "off",\
-    },
+extern GlobalProperty pc_compat_2_10[];
+extern const size_t pc_compat_2_10_len;
 
 #define PC_COMPAT_2_9 \
     HW_COMPAT_2_9 \
hw/arm/virt.c +1 -5
index 548b6efa93..75ab14305a 100644
@@ -1909,12 +1909,8 @@ DEFINE_VIRT_MACHINE(2, 11)
 
 static void virt_machine_2_10_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_10
-    };
-
     virt_machine_2_11_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
     /* before 2.11 we never faulted accesses to bad addresses */
     mc->ignore_memory_transaction_failures = true;
 }
hw/core/machine.c +13 -0
index 41f37ee4d4..7673454a66 100644
@@ -88,6 +88,19 @@ GlobalProperty hw_compat_2_11[] = {
 };
 const size_t hw_compat_2_11_len = G_N_ELEMENTS(hw_compat_2_11);
 
+GlobalProperty hw_compat_2_10[] = {
+    {
+        .driver   = "virtio-mouse-device",
+        .property = "wheel-axis",
+        .value    = "false",
+    },{
+        .driver   = "virtio-tablet-device",
+        .property = "wheel-axis",
+        .value    = "false",
+    },
+};
+const size_t hw_compat_2_10_len = G_N_ELEMENTS(hw_compat_2_10);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +17 -0
index 563ba90202..c0bb82c454 100644
@@ -169,6 +169,23 @@ GlobalProperty pc_compat_2_11[] = {
 };
 const size_t pc_compat_2_11_len = G_N_ELEMENTS(pc_compat_2_11);
 
+GlobalProperty pc_compat_2_10[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "x-hv-max-vps",
+        .value    = "0x40",
+    },{
+        .driver   = "i440FX-pcihost",
+        .property = "x-pci-hole64-fix",
+        .value    = "off",
+    },{
+        .driver   = "q35-pcihost",
+        .property = "x-pci-hole64-fix",
+        .value    = "off",
+    },
+};
+const size_t pc_compat_2_10_len = G_N_ELEMENTS(pc_compat_2_10);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index aeb51a2772..aea678dc91 100644
@@ -482,12 +482,9 @@ DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL,
 
 static void pc_i440fx_2_10_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_10
-    };
-
     pc_i440fx_2_11_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len);
+    compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len);
     m->auto_enable_numa_with_memhp = false;
 }
 
hw/i386/pc_q35.c +2 -5
index fd3187003a..a9c4fc27e4 100644
@@ -368,12 +368,9 @@ DEFINE_Q35_MACHINE(v2_11, "pc-q35-2.11", NULL,
 
 static void pc_q35_2_10_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_10
-    };
-
     pc_q35_2_11_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len);
+    compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len);
     m->numa_auto_assign_ram = numa_legacy_auto_assign_ram;
     m->auto_enable_numa_with_memhp = false;
 }
hw/ppc/spapr.c +1 -5
index 9afa22fd13..483a1373df 100644
@@ -4113,12 +4113,8 @@ DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
 
 static void spapr_machine_2_10_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_10
-    };
-
     spapr_machine_2_11_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
 }
 
 DEFINE_SPAPR_MACHINE(2_10, "2.10", false);
hw/s390x/s390-virtio-ccw.c +1 -5
index 74623becaf..95ad7ba842 100644
@@ -733,12 +733,8 @@ static void ccw_machine_2_10_instance_options(MachineState *machine)
 
 static void ccw_machine_2_10_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_10
-    };
-
     ccw_machine_2_11_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
 }
 DEFINE_CCW_MACHINE(2_10, "2.10", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#12 lore raw

[Qemu-devel] [PULL v2 17/28] compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros

In reply to Marc-André Lureau

Use static arrays instead. I decided to rename the conflicting pc_compat_2_3() function with pc_compat_2_3_fn().

---
 include/hw/boards.h  |  3 ++
 include/hw/compat.h  | 39 --------------------
 include/hw/i386/pc.h | 88 ++------------------------------------------
 hw/core/machine.c    | 41 +++++++++++++++++++++
 hw/i386/pc.c         | 86 +++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c    | 13 +++----
 hw/ppc/spapr.c       |  2 +-
 7 files changed, 139 insertions(+), 133 deletions(-)
include/hw/boards.h +3 -0
index 254b7d8919..e7e3d2bc3c 100644
@@ -321,4 +321,7 @@ extern const size_t hw_compat_2_5_len;
 extern GlobalProperty hw_compat_2_4[];
 extern const size_t hw_compat_2_4_len;
 
+extern GlobalProperty hw_compat_2_3[];
+extern const size_t hw_compat_2_3_len;
+
 #endif
include/hw/compat.h +0 -39
index 05ff05e159..fbe64d5983 100644
@@ -1,45 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_3 \
-    {\
-        .driver   = "virtio-blk-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-balloon-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-serial-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-9p-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-rng-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = TYPE_PCI_DEVICE,\
-        .property = "x-pcie-lnksta-dllla",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "send-configuration",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "send-section-footer",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "store-global-state",\
-        .value    = "off",\
-    },
-
 #define HW_COMPAT_2_2 \
     /* empty */
 
include/hw/i386/pc.h +3 -85

100 lines not on this page · raw message

hw/core/machine.c +41 -0

47 lines not on this page · raw message

hw/i386/pc.c +86 -0

92 lines not on this page · raw message

hw/i386/pc_piix.c +5 -8
index 125ab600ef..5b03f9ef80 100644
@@ -310,7 +310,7 @@ static void pc_init1(MachineState *machine,
  * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().
  */
 
-static void pc_compat_2_3(MachineState *machine)
+static void pc_compat_2_3_fn(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
     if (kvm_enabled()) {
@@ -320,7 +320,7 @@ static void pc_compat_2_3(MachineState *machine)
 
 static void pc_compat_2_2(MachineState *machine)
 {
-    pc_compat_2_3(machine);
+    pc_compat_2_3_fn(machine);
 }
 
 static void pc_compat_2_1(MachineState *machine)
@@ -566,16 +566,13 @@ DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
 
 static void pc_i440fx_2_3_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_3
-    };
-
     pc_i440fx_2_4_machine_options(m);
     m->hw_version = "2.3.0";
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len);
+    compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len);
 }
 
-DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
+DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn,
                       pc_i440fx_2_3_machine_options);
 
 static void pc_i440fx_2_2_machine_options(MachineClass *m)
hw/ppc/spapr.c +1 -1
index a42cb49109..b99ed19baf 100644
@@ -4322,7 +4322,6 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
 static void spapr_machine_2_3_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_3
         {
             .driver   = "spapr-pci-host-bridge",
             .property = "dynamic-reconfiguration",
@@ -4330,6 +4329,7 @@ static void spapr_machine_2_3_class_options(MachineClass *mc)
         },
     };
     spapr_machine_2_4_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_3, hw_compat_2_3_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_SPAPR_MACHINE(2_3, "2.3", false);
Signature · 1 line
2.20.1.2.gb21ebb671b
#13 lore raw

[Qemu-devel] [PULL v2 12/28] compat: replace PC_COMPAT_2_8 & HW_COMPAT_2_8 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 43 -----------------------------------
 include/hw/i386/pc.h       | 29 ++----------------------
 hw/arm/virt.c              |  5 +----
 hw/core/machine.c          | 46 ++++++++++++++++++++++++++++++++++++++
 hw/i386/pc.c               | 29 ++++++++++++++++++++++++
 hw/i386/pc_piix.c          |  7 ++----
 hw/i386/pc_q35.c           |  7 ++----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  2 +-
 10 files changed, 87 insertions(+), 86 deletions(-)
include/hw/boards.h +3 -0
index 0e69350939..03278a8c39 100644
@@ -306,4 +306,7 @@ extern const size_t hw_compat_2_10_len;
 extern GlobalProperty hw_compat_2_9[];
 extern const size_t hw_compat_2_9_len;
 
+extern GlobalProperty hw_compat_2_8[];
+extern const size_t hw_compat_2_8_len;
+
 #endif
include/hw/compat.h +0 -43

49 lines not on this page · raw message

include/hw/i386/pc.h +2 -27
index fb79f0b988..12c47d2506 100644
@@ -312,33 +312,8 @@ extern const size_t pc_compat_2_10_len;
 extern GlobalProperty pc_compat_2_9[];
 extern const size_t pc_compat_2_9_len;
 
-#define PC_COMPAT_2_8 \
-    HW_COMPAT_2_8 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "tcg-cpuid",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "kvmclock",\
-        .property = "x-mach-use-reliable-get-clock",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "ICH9-LPC",\
-        .property = "x-smi-broadcast",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "vmware-cpuid-freq",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "Haswell-" TYPE_X86_CPU,\
-        .property = "stepping",\
-        .value    = "1",\
-    },
+extern GlobalProperty pc_compat_2_8[];
+extern const size_t pc_compat_2_8_len;
 
 #define PC_COMPAT_2_7 \
     HW_COMPAT_2_7 \
hw/arm/virt.c +1 -4
index a0898f27d3..d4dee3ece7 100644
@@ -1926,12 +1926,9 @@ DEFINE_VIRT_MACHINE(2, 9)
 static void virt_machine_2_8_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_8
-    };
 
     virt_machine_2_9_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
     /* For 2.8 and earlier we falsely claimed in the DT that
      * our timers were edge-triggered, not level-triggered.
      */
hw/core/machine.c +46 -0

58 lines not on this page · raw message

hw/i386/pc.c +29 -0
index 3f6f5df363..b094e5b2ad 100644
@@ -195,6 +195,35 @@ GlobalProperty pc_compat_2_9[] = {
 };
 const size_t pc_compat_2_9_len = G_N_ELEMENTS(pc_compat_2_9);
 
+GlobalProperty pc_compat_2_8[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "tcg-cpuid",
+        .value    = "off",
+    },
+    {
+        .driver   = "kvmclock",
+        .property = "x-mach-use-reliable-get-clock",
+        .value    = "off",
+    },
+    {
+        .driver   = "ICH9-LPC",
+        .property = "x-smi-broadcast",
+        .value    = "off",
+    },
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "vmware-cpuid-freq",
+        .value    = "off",
+    },
+    {
+        .driver   = "Haswell-" TYPE_X86_CPU,
+        .property = "stepping",
+        .value    = "1",
+    },
+};
+const size_t pc_compat_2_8_len = G_N_ELEMENTS(pc_compat_2_8);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index 02520bceb9..b1fa038a69 100644
@@ -504,12 +504,9 @@ DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL,
 
 static void pc_i440fx_2_8_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_8
-    };
-
     pc_i440fx_2_9_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len);
+    compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL,
hw/i386/pc_q35.c +2 -5
index e94d2d05c7..7e608b3ffb 100644
@@ -390,12 +390,9 @@ DEFINE_Q35_MACHINE(v2_9, "pc-q35-2.9", NULL,
 
 static void pc_q35_2_8_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_8
-    };
-
     pc_q35_2_9_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len);
+    compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len);
 }
 
 DEFINE_Q35_MACHINE(v2_8, "pc-q35-2.8", NULL,
hw/ppc/spapr.c +1 -1
index 477ff5eb94..a19353827f 100644
@@ -4151,7 +4151,6 @@ DEFINE_SPAPR_MACHINE(2_9, "2.9", false);
 static void spapr_machine_2_8_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_8
         {
             .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
             .property = "pcie-extended-configuration-space",
@@ -4160,6 +4159,7 @@ static void spapr_machine_2_8_class_options(MachineClass *mc)
     };
 
     spapr_machine_2_9_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     mc->numa_mem_align_shift = 23;
 }
hw/s390x/s390-virtio-ccw.c +1 -1
index 549f6e0231..22e96ab353 100644
@@ -774,7 +774,6 @@ static void ccw_machine_2_8_instance_options(MachineState *machine)
 static void ccw_machine_2_8_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_8
         {
             .driver   = TYPE_S390_FLIC_COMMON,
             .property = "adapter_routes_max_batch",
@@ -783,6 +782,7 @@ static void ccw_machine_2_8_class_options(MachineClass *mc)
     };
 
     ccw_machine_2_9_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_CCW_MACHINE(2_8, "2.8", false);
Signature · 1 line
2.20.1.2.gb21ebb671b
#14 lore raw

[Qemu-devel] [PULL v2 13/28] compat: replace PC_COMPAT_2_7 & HW_COMPAT_2_7 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 23 -----------------------
 include/hw/i386/pc.h       | 34 ++--------------------------------
 hw/arm/virt.c              |  5 +----
 hw/core/machine.c          | 25 +++++++++++++++++++++++++
 hw/i386/pc.c               | 34 ++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  5 +----
 10 files changed, 71 insertions(+), 74 deletions(-)
include/hw/boards.h +3 -0
index 03278a8c39..ac4854db0f 100644
@@ -309,4 +309,7 @@ extern const size_t hw_compat_2_9_len;
 extern GlobalProperty hw_compat_2_8[];
 extern const size_t hw_compat_2_8_len;
 
+extern GlobalProperty hw_compat_2_7[];
+extern const size_t hw_compat_2_7_len;
+
 #endif
include/hw/compat.h +0 -23
index 65d6748054..7ceab17401 100644
@@ -1,29 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_7 \
-    {\
-        .driver   = "virtio-pci",\
-        .property = "page-per-vq",\
-        .value    = "on",\
-    },{\
-        .driver   = "virtio-serial-device",\
-        .property = "emergency-write",\
-        .value    = "off",\
-    },{\
-        .driver   = "ioapic",\
-        .property = "version",\
-        .value    = "0x11",\
-    },{\
-        .driver   = "intel-iommu",\
-        .property = "x-buggy-eim",\
-        .value    = "true",\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "x-ignore-backend-features",\
-        .value    = "on",\
-    },
-
 #define HW_COMPAT_2_6 \
     {\
         .driver   = "virtio-mmio",\
include/hw/i386/pc.h +2 -32
index 12c47d2506..504fbc79a9 100644
@@ -315,38 +315,8 @@ extern const size_t pc_compat_2_9_len;
 extern GlobalProperty pc_compat_2_8[];
 extern const size_t pc_compat_2_8_len;
 
-#define PC_COMPAT_2_7 \
-    HW_COMPAT_2_7 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "l3-cache",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "full-cpuid-auto-level",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,\
-        .property = "family",\
-        .value    = "15",\
-    },\
-    {\
-        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = "6",\
-    },\
-    {\
-        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,\
-        .property = "stepping",\
-        .value    = "1",\
-    },\
-    {\
-        .driver   = "isa-pcspk",\
-        .property = "migrate",\
-        .value    = "off",\
-    },
+extern GlobalProperty pc_compat_2_7[];
+extern const size_t pc_compat_2_7_len;
 
 #define PC_COMPAT_2_6 \
     HW_COMPAT_2_6 \
hw/arm/virt.c +1 -4
index d4dee3ece7..0134d0d439 100644
@@ -1939,12 +1939,9 @@ DEFINE_VIRT_MACHINE(2, 8)
 static void virt_machine_2_7_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_7
-    };
 
     virt_machine_2_8_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
     /* ITS was introduced with 2.8 */
     vmc->no_its = true;
     /* Stick with 1K pages for migration compatibility */
hw/core/machine.c +25 -0
index efda98a9ab..cc92b0cc84 100644
@@ -168,6 +168,31 @@ GlobalProperty hw_compat_2_8[] = {
 };
 const size_t hw_compat_2_8_len = G_N_ELEMENTS(hw_compat_2_8);
 
+GlobalProperty hw_compat_2_7[] = {
+    {
+        .driver   = "virtio-pci",
+        .property = "page-per-vq",
+        .value    = "on",
+    },{
+        .driver   = "virtio-serial-device",
+        .property = "emergency-write",
+        .value    = "off",
+    },{
+        .driver   = "ioapic",
+        .property = "version",
+        .value    = "0x11",
+    },{
+        .driver   = "intel-iommu",
+        .property = "x-buggy-eim",
+        .value    = "true",
+    },{
+        .driver   = "virtio-pci",
+        .property = "x-ignore-backend-features",
+        .value    = "on",
+    },
+};
+const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +34 -0
index b094e5b2ad..ed46f9c27f 100644
@@ -224,6 +224,40 @@ GlobalProperty pc_compat_2_8[] = {
 };
 const size_t pc_compat_2_8_len = G_N_ELEMENTS(pc_compat_2_8);
 
+GlobalProperty pc_compat_2_7[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "l3-cache",
+        .value    = "off",
+    },
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "full-cpuid-auto-level",
+        .value    = "off",
+    },
+    {
+        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,
+        .property = "family",
+        .value    = "15",
+    },
+    {
+        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,
+        .property = "model",
+        .value    = "6",
+    },
+    {
+        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,
+        .property = "stepping",
+        .value    = "1",
+    },
+    {
+        .driver   = "isa-pcspk",
+        .property = "migrate",
+        .value    = "off",
+    },
+};
+const size_t pc_compat_2_7_len = G_N_ELEMENTS(pc_compat_2_7);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index b1fa038a69..182d868de8 100644
@@ -514,12 +514,9 @@ DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL,
 
 static void pc_i440fx_2_7_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_7
-    };
-
     pc_i440fx_2_8_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len);
+    compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL,
hw/i386/pc_q35.c +2 -5
index 7e608b3ffb..35377524d0 100644
@@ -400,13 +400,10 @@ DEFINE_Q35_MACHINE(v2_8, "pc-q35-2.8", NULL,
 
 static void pc_q35_2_7_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_7
-    };
-
     pc_q35_2_8_machine_options(m);
     m->max_cpus = 255;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len);
+    compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len);
 }
 
 DEFINE_Q35_MACHINE(v2_7, "pc-q35-2.7", NULL,
hw/ppc/spapr.c +1 -1
index a19353827f..c83b0c0d66 100644
@@ -4223,7 +4223,6 @@ static void spapr_machine_2_7_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_7
         {
             .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
             .property = "mem_win_size",
@@ -4249,6 +4248,7 @@ 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");
     mc->default_machine_opts = "modern-hotplug-events=off";
+    compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     smc->phb_placement = phb_placement_2_7;
 }
hw/s390x/s390-virtio-ccw.c +1 -4
index 22e96ab353..f28feedd4b 100644
@@ -795,13 +795,10 @@ static void ccw_machine_2_7_instance_options(MachineState *machine)
 static void ccw_machine_2_7_class_options(MachineClass *mc)
 {
     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_7
-    };
 
     s390mc->cpu_model_allowed = false;
     ccw_machine_2_8_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
 }
 DEFINE_CCW_MACHINE(2_7, "2.7", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#15 lore raw

[Qemu-devel] [PULL v2 16/28] compat: replace PC_COMPAT_2_4 & HW_COMPAT_2_4 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 ++
 include/hw/compat.h        | 27 --------------
 include/hw/i386/pc.h       | 74 ++------------------------------------
 hw/core/machine.c          | 29 +++++++++++++++
 hw/i386/pc.c               | 71 ++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c          |  6 ++--
 hw/i386/pc_q35.c           |  6 ++--
 hw/ppc/spapr.c             |  5 +--
 hw/s390x/s390-virtio-ccw.c |  2 +-
 9 files changed, 112 insertions(+), 111 deletions(-)
include/hw/boards.h +3 -0
index 0023b72b02..254b7d8919 100644
@@ -318,4 +318,7 @@ extern const size_t hw_compat_2_6_len;
 extern GlobalProperty hw_compat_2_5[];
 extern const size_t hw_compat_2_5_len;
 
+extern GlobalProperty hw_compat_2_4[];
+extern const size_t hw_compat_2_4_len;
+
 #endif
include/hw/compat.h +0 -27
index a6eced34c6..05ff05e159 100644
@@ -1,33 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_4 \
-    {\
-        .driver   = "virtio-blk-device",\
-        .property = "scsi",\
-        .value    = "true",\
-    },{\
-        .driver   = "e1000",\
-        .property = "extra_mac_registers",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "x-disable-pcie",\
-        .value    = "on",\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "migrate-extra",\
-        .value    = "off",\
-    },{\
-        .driver   = "fw_cfg_mem",\
-        .property = "dma_enabled",\
-        .value    = "off",\
-    },{\
-        .driver   = "fw_cfg_io",\
-        .property = "dma_enabled",\
-        .value    = "off",\
-    },
-
 #define HW_COMPAT_2_3 \
     {\
         .driver   = "virtio-blk-pci",\
include/hw/i386/pc.h +3 -71

86 lines not on this page · raw message

hw/core/machine.c +29 -0
index 4d05501775..1808900c3a 100644
@@ -236,6 +236,35 @@ GlobalProperty hw_compat_2_5[] = {
 };
 const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5);
 
+GlobalProperty hw_compat_2_4[] = {
+    {
+        .driver   = "virtio-blk-device",
+        .property = "scsi",
+        .value    = "true",
+    },{
+        .driver   = "e1000",
+        .property = "extra_mac_registers",
+        .value    = "off",
+    },{
+        .driver   = "virtio-pci",
+        .property = "x-disable-pcie",
+        .value    = "on",
+    },{
+        .driver   = "virtio-pci",
+        .property = "migrate-extra",
+        .value    = "off",
+    },{
+        .driver   = "fw_cfg_mem",
+        .property = "dma_enabled",
+        .value    = "off",
+    },{
+        .driver   = "fw_cfg_io",
+        .property = "dma_enabled",
+        .value    = "off",
+    }
+};
+const size_t hw_compat_2_4_len = G_N_ELEMENTS(hw_compat_2_4);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +71 -0

77 lines not on this page · raw message

hw/i386/pc_piix.c +2 -4
index 3a31de7316..125ab600ef 100644
@@ -553,14 +553,12 @@ DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
 static void pc_i440fx_2_4_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_4
-    };
 
     pc_i440fx_2_5_machine_options(m);
     m->hw_version = "2.4.0";
     pcmc->broken_reserved_end = true;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len);
+    compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
hw/i386/pc_q35.c +2 -4
index 418b8387d9..94494e6441 100644
@@ -440,14 +440,12 @@ DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
 static void pc_q35_2_4_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_4
-    };
 
     pc_q35_2_5_machine_options(m);
     m->hw_version = "2.4.0";
     pcmc->broken_reserved_end = true;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len);
+    compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len);
 }
 
 DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
hw/ppc/spapr.c +1 -4
index 6be74ae0c8..a42cb49109 100644
@@ -4307,13 +4307,10 @@ DEFINE_SPAPR_MACHINE(2_5, "2.5", false);
 static void spapr_machine_2_4_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_4
-    };
 
     spapr_machine_2_5_class_options(mc);
     smc->dr_lmb_enabled = false;
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len);
 }
 
 DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
hw/s390x/s390-virtio-ccw.c +1 -1
index 1ab53a1332..bf5f2f463c 100644
@@ -849,7 +849,6 @@ static void ccw_machine_2_4_instance_options(MachineState *machine)
 static void ccw_machine_2_4_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_4
         {
             .driver   = TYPE_S390_SKEYS,
             .property = "migration-enabled",
@@ -890,6 +889,7 @@ static void ccw_machine_2_4_class_options(MachineClass *mc)
     };
 
     ccw_machine_2_5_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_CCW_MACHINE(2_4, "2.4", false);
Signature · 1 line
2.20.1.2.gb21ebb671b
#16 lore raw

[Qemu-devel] [PULL v2 24/28] qdev-props: convert global_props to GPtrArray

In reply to Marc-André Lureau

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

---
 hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
hw/core/qdev-properties.c +20 -9
index 84df9c06a7..fa47f39584 100644
@@ -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;
         }
Signature · 1 line
2.20.1.2.gb21ebb671b
#17 lore raw

[Qemu-devel] [PULL v2 19/28] compat: replace PC_COMPAT_2_1 & HW_COMPAT_2_1 macros

In reply to Marc-André Lureau

Use static arrays instead. I decided to rename the conflicting pc_compat_2_1() function with pc_compat_2_1_fn().

---
 include/hw/boards.h  |  3 +++
 include/hw/compat.h  | 31 -------------------------------
 include/hw/i386/pc.h | 17 +++--------------
 hw/core/machine.c    | 33 +++++++++++++++++++++++++++++++++
 hw/i386/pc.c         | 15 +++++++++++++++
 hw/i386/pc_piix.c    | 12 +++++-------
 hw/ppc/spapr.c       |  6 +-----
 7 files changed, 60 insertions(+), 57 deletions(-)
include/hw/boards.h +3 -0
index 2d82d80107..02f114085f 100644
@@ -327,4 +327,7 @@ extern const size_t hw_compat_2_3_len;
 extern GlobalProperty hw_compat_2_2[];
 extern const size_t hw_compat_2_2_len;
 
+extern GlobalProperty hw_compat_2_1[];
+extern const size_t hw_compat_2_1_len;
+
 #endif
include/hw/compat.h +0 -31
index 3bd91908e4..b2d0bdd599 100644
@@ -1,35 +1,4 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_1 \
-    {\
-        .driver   = "intel-hda",\
-        .property = "old_msi_addr",\
-        .value    = "on",\
-    },{\
-        .driver   = "VGA",\
-        .property = "qemu-extended-regs",\
-        .value    = "off",\
-    },{\
-        .driver   = "secondary-vga",\
-        .property = "qemu-extended-regs",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-scsi-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "usb-mouse",\
-        .property = "usb_version",\
-        .value    = stringify(1),\
-    },{\
-        .driver   = "usb-kbd",\
-        .property = "usb_version",\
-        .value    = stringify(1),\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "virtio-pci-bus-master-bug-migration",\
-        .value    = "on",\
-    },
-
 #endif /* HW_COMPAT_H */
include/hw/i386/pc.h +3 -14
index 49b45bb79d..784ea7a92c 100644
@@ -333,6 +333,9 @@ extern const size_t pc_compat_2_3_len;
 extern GlobalProperty pc_compat_2_2[];
 extern const size_t pc_compat_2_2_len;
 
+extern GlobalProperty pc_compat_2_1[];
+extern const size_t pc_compat_2_1_len;
+
 /* Helper for setting model-id for CPU models that changed model-id
  * depending on QEMU versions up to QEMU 2.4.
  */
@@ -353,20 +356,6 @@ extern const size_t pc_compat_2_2_len;
         .value    = "QEMU Virtual CPU version " v,\
     },
 
-#define PC_COMPAT_2_1 \
-    HW_COMPAT_2_1 \
-    PC_CPU_MODEL_IDS("2.1.0") \
-    {\
-        .driver = "coreduo" "-" TYPE_X86_CPU,\
-        .property = "vmx",\
-        .value = "on",\
-    },\
-    {\
-        .driver = "core2duo" "-" TYPE_X86_CPU,\
-        .property = "vmx",\
-        .value = "on",\
-    },
-
 #define PC_COMPAT_2_0 \
     PC_CPU_MODEL_IDS("2.0.0") \
     {\
hw/core/machine.c +33 -0
index cfa9a5d95f..84a4c8cdc3 100644
@@ -309,6 +309,39 @@ const size_t hw_compat_2_3_len = G_N_ELEMENTS(hw_compat_2_3);
 GlobalProperty hw_compat_2_2[] = {};
 const size_t hw_compat_2_2_len = G_N_ELEMENTS(hw_compat_2_2);
 
+GlobalProperty hw_compat_2_1[] = {
+    {
+        .driver   = "intel-hda",
+        .property = "old_msi_addr",
+        .value    = "on",
+    },{
+        .driver   = "VGA",
+        .property = "qemu-extended-regs",
+        .value    = "off",
+    },{
+        .driver   = "secondary-vga",
+        .property = "qemu-extended-regs",
+        .value    = "off",
+    },{
+        .driver   = "virtio-scsi-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = "usb-mouse",
+        .property = "usb_version",
+        .value    = stringify(1),
+    },{
+        .driver   = "usb-kbd",
+        .property = "usb_version",
+        .value    = stringify(1),
+    },{
+        .driver   = "virtio-pci",
+        .property = "virtio-pci-bus-master-bug-migration",
+        .value    = "on",
+    },
+};
+const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +15 -0
index b92d1900da..731d2010c8 100644
@@ -536,6 +536,21 @@ GlobalProperty pc_compat_2_2[] = {
 };
 const size_t pc_compat_2_2_len = G_N_ELEMENTS(pc_compat_2_2);
 
+GlobalProperty pc_compat_2_1[] = {
+    PC_CPU_MODEL_IDS("2.1.0")
+    {
+        .driver = "coreduo" "-" TYPE_X86_CPU,
+        .property = "vmx",
+        .value = "on",
+    },
+    {
+        .driver = "core2duo" "-" TYPE_X86_CPU,
+        .property = "vmx",
+        .value = "on",
+    },
+};
+const size_t pc_compat_2_1_len = G_N_ELEMENTS(pc_compat_2_1);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +5 -7
index d2a2bacba4..7b48b1c816 100644
@@ -323,7 +323,7 @@ static void pc_compat_2_2_fn(MachineState *machine)
     pc_compat_2_3_fn(machine);
 }
 
-static void pc_compat_2_1(MachineState *machine)
+static void pc_compat_2_1_fn(MachineState *machine)
 {
     pc_compat_2_2_fn(machine);
     x86_cpu_change_kvm_default("svm", NULL);
@@ -331,7 +331,7 @@ static void pc_compat_2_1(MachineState *machine)
 
 static void pc_compat_2_0(MachineState *machine)
 {
-    pc_compat_2_1(machine);
+    pc_compat_2_1_fn(machine);
 }
 
 static void pc_compat_1_7(MachineState *machine)
@@ -593,19 +593,17 @@ DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn,
 static void pc_i440fx_2_1_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_1
-    };
 
     pc_i440fx_2_2_machine_options(m);
     m->hw_version = "2.1.0";
     m->default_display = NULL;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_1, hw_compat_2_1_len);
+    compat_props_add(m->compat_props, pc_compat_2_1, pc_compat_2_1_len);
     pcmc->smbios_uuid_encoded = false;
     pcmc->enforce_aligned_dimm = false;
 }
 
-DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
+DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn,
                       pc_i440fx_2_1_machine_options);
 
 static void pc_i440fx_2_0_machine_options(MachineClass *m)
hw/ppc/spapr.c +1 -5
index 449c5dd58d..8aba66a32f 100644
@@ -4361,12 +4361,8 @@ DEFINE_SPAPR_MACHINE(2_2, "2.2", false);
 
 static void spapr_machine_2_1_class_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_1
-    };
-
     spapr_machine_2_2_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_1, hw_compat_2_1_len);
 }
 DEFINE_SPAPR_MACHINE(2_1, "2.1", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#18 lore raw

[Qemu-devel] [PULL v2 07/28] compat: replace PC_COMPAT_3_0 & HW_COMPAT_3_0 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        |  3 ---
 include/hw/i386/pc.h       | 17 ++---------------
 hw/arm/virt.c              |  6 +-----
 hw/core/machine.c          |  3 +++
 hw/i386/pc.c               | 17 +++++++++++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  5 +----
 hw/s390x/s390-virtio-ccw.c |  5 +----
 10 files changed, 32 insertions(+), 41 deletions(-)
include/hw/boards.h +3 -0
index b9a5c2d087..aaa57f1f6b 100644
@@ -291,4 +291,7 @@ struct MachineState {
 extern GlobalProperty hw_compat_3_1[];
 extern const size_t hw_compat_3_1_len;
 
+extern GlobalProperty hw_compat_3_0[];
+extern const size_t hw_compat_3_0_len;
+
 #endif
include/hw/compat.h +0 -3
index 6f4d5fc647..c08f4040bb 100644
@@ -1,9 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_3_0 \
-    /* empty */
-
 #define HW_COMPAT_2_12 \
     {\
         .driver   = "migration",\
include/hw/i386/pc.h +2 -15
index dd1d6fd0f3..197131ff9a 100644
@@ -297,21 +297,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 extern GlobalProperty pc_compat_3_1[];
 extern const size_t pc_compat_3_1_len;
 
-#define PC_COMPAT_3_0 \
-    HW_COMPAT_3_0 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "x-hv-synic-kvm-only",\
-        .value    = "on",\
-    },{\
-        .driver   = "Skylake-Server" "-" TYPE_X86_CPU,\
-        .property = "pku",\
-        .value    = "off",\
-    },{\
-        .driver   = "Skylake-Server-IBRS" "-" TYPE_X86_CPU,\
-        .property = "pku",\
-        .value    = "off",\
-    },
+extern GlobalProperty pc_compat_3_0[];
+extern const size_t pc_compat_3_0_len;
 
 #define PC_COMPAT_2_12 \
     HW_COMPAT_2_12 \
hw/arm/virt.c +1 -5
index ebd5f306e4..5c541ec55e 100644
@@ -1881,12 +1881,8 @@ DEFINE_VIRT_MACHINE(3, 1)
 
 static void virt_machine_3_0_options(MachineClass *mc)
 {
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_0
-    };
-
     virt_machine_3_1_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
 }
 DEFINE_VIRT_MACHINE(3, 0)
 
hw/core/machine.c +3 -0
index d6204967c3..f00f6381d2 100644
@@ -35,6 +35,9 @@ GlobalProperty hw_compat_3_1[] = {
 };
 const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
 
+GlobalProperty hw_compat_3_0[] = {};
+const size_t hw_compat_3_0_len = G_N_ELEMENTS(hw_compat_3_0);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +17 -0
index 33d09a832a..b5799985a1 100644
@@ -118,6 +118,23 @@ GlobalProperty pc_compat_3_1[] = {
 };
 const size_t pc_compat_3_1_len = G_N_ELEMENTS(pc_compat_3_1);
 
+GlobalProperty pc_compat_3_0[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "x-hv-synic-kvm-only",
+        .value    = "on",
+    },{
+        .driver   = "Skylake-Server" "-" TYPE_X86_CPU,
+        .property = "pku",
+        .value    = "off",
+    },{
+        .driver   = "Skylake-Server-IBRS" "-" TYPE_X86_CPU,
+        .property = "pku",
+        .value    = "off",
+    },
+};
+const size_t pc_compat_3_0_len = G_N_ELEMENTS(pc_compat_3_0);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index c938437627..cc8b249ccc 100644
@@ -452,12 +452,9 @@ DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL,
 
 static void pc_i440fx_3_0_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_3_0
-    };
-
     pc_i440fx_3_1_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len);
+    compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len);
 }
 
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
hw/i386/pc_q35.c +2 -5
index fad3d6da17..39378ee1cd 100644
@@ -335,12 +335,9 @@ DEFINE_Q35_MACHINE(v3_1, "pc-q35-3.1", NULL,
 
 static void pc_q35_3_0_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_3_0
-    };
-
     pc_q35_3_1_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len);
+    compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len);
 }
 
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
hw/ppc/spapr.c +1 -4
index f04135fffd..8a99e4d9b8 100644
@@ -4037,12 +4037,9 @@ DEFINE_SPAPR_MACHINE(3_1, "3.1", false);
 static void spapr_machine_3_0_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_0
-    };
 
     spapr_machine_3_1_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
 
     smc->legacy_irq_allocation = true;
     smc->irq = &spapr_irq_xics_legacy;
hw/s390x/s390-virtio-ccw.c +1 -4
index 5e8b48e75b..e54e6f6dd0 100644
@@ -680,13 +680,10 @@ static void ccw_machine_3_0_instance_options(MachineState *machine)
 static void ccw_machine_3_0_class_options(MachineClass *mc)
 {
     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
-    static GlobalProperty compat[] = {
-        HW_COMPAT_3_0
-    };
 
     s390mc->hpage_1m_allowed = false;
     ccw_machine_3_1_class_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
 }
 DEFINE_CCW_MACHINE(3_0, "3.0", false);
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#19 lore raw

[Qemu-devel] [PULL v2 05/28] hw: remove SET_MACHINE_COMPAT

In reply to Marc-André Lureau

No longer needed.

---
 include/hw/boards.h | 12 ------------
 1 file changed, 12 deletions(-)
include/hw/boards.h +0 -12
index f14c38bb63..0566742412 100644
@@ -288,16 +288,4 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
-#define SET_MACHINE_COMPAT(m, compat) \
-    do {                              \
-        int i;                        \
-        if (!m->compat_props) { \
-            m->compat_props = g_array_new(false, false, sizeof(void *)); \
-        } \
-        for (i = 0; i < G_N_ELEMENTS(compat); i++) {          \
-            GlobalProperty *prop = &compat[i];          \
-            g_array_append_val(m->compat_props, prop); \
-        }                                              \
-    } while (0)
-
 #endif
Signature · 1 line
2.20.1.2.gb21ebb671b
#20 lore raw

[Qemu-devel] [PULL v2 09/28] compat: replace PC_COMPAT_2_11 & HW_COMPAT_2_11 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 19 -------------------
 include/hw/i386/pc.h       | 13 ++-----------
 hw/arm/virt.c              |  5 +----
 hw/core/machine.c          | 21 +++++++++++++++++++++
 hw/i386/pc.c               | 13 +++++++++++++
 hw/i386/pc_piix.c          |  7 ++-----
 hw/i386/pc_q35.c           |  7 ++-----
 hw/ppc/spapr.c             |  5 +----
 hw/s390x/s390-virtio-ccw.c |  2 +-
 10 files changed, 46 insertions(+), 49 deletions(-)
include/hw/boards.h +3 -0
index c6d828e73c..67202b5a2f 100644
@@ -297,4 +297,7 @@ extern const size_t hw_compat_3_0_len;
 extern GlobalProperty hw_compat_2_12[];
 extern const size_t hw_compat_2_12_len;
 
+extern GlobalProperty hw_compat_2_11[];
+extern const size_t hw_compat_2_11_len;
+
 #endif
include/hw/compat.h +0 -19
index 13242b831a..cf389b4e85 100644
@@ -1,25 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_11 \
-    {\
-        .driver   = "hpet",\
-        .property = "hpet-offset-saved",\
-        .value    = "false",\
-    },{\
-        .driver   = "virtio-blk-pci",\
-        .property = "vectors",\
-        .value    = "2",\
-    },{\
-        .driver   = "vhost-user-blk-pci",\
-        .property = "vectors",\
-        .value    = "2",\
-    },{\
-        .driver   = "e1000",\
-        .property = "migrate_tso_props",\
-        .value    = "off",\
-    },
-
 #define HW_COMPAT_2_10 \
     {\
         .driver   = "virtio-mouse-device",\
include/hw/i386/pc.h +2 -11
index 91cb3283f0..f0f7e76a3e 100644
@@ -303,17 +303,8 @@ extern const size_t pc_compat_3_0_len;
 extern GlobalProperty pc_compat_2_12[];
 extern const size_t pc_compat_2_12_len;
 
-#define PC_COMPAT_2_11 \
-    HW_COMPAT_2_11 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "x-migrate-smi-count",\
-        .value    = "off",\
-    },{\
-        .driver   = "Skylake-Server" "-" TYPE_X86_CPU,\
-        .property = "clflushopt",\
-        .value    = "off",\
-    },
+extern GlobalProperty pc_compat_2_11[];
+extern const size_t pc_compat_2_11_len;
 
 #define PC_COMPAT_2_10 \
     HW_COMPAT_2_10 \
hw/arm/virt.c +1 -4
index 228ee63d99..548b6efa93 100644
@@ -1900,12 +1900,9 @@ DEFINE_VIRT_MACHINE(2, 12)
 static void virt_machine_2_11_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_11
-    };
 
     virt_machine_2_12_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
     vmc->smbios_old_sys_ver = true;
 }
 DEFINE_VIRT_MACHINE(2, 11)
hw/core/machine.c +21 -0
index ae94f5e4ca..41f37ee4d4 100644
@@ -67,6 +67,27 @@ GlobalProperty hw_compat_2_12[] = {
 };
 const size_t hw_compat_2_12_len = G_N_ELEMENTS(hw_compat_2_12);
 
+GlobalProperty hw_compat_2_11[] = {
+    {
+        .driver   = "hpet",
+        .property = "hpet-offset-saved",
+        .value    = "false",
+    },{
+        .driver   = "virtio-blk-pci",
+        .property = "vectors",
+        .value    = "2",
+    },{
+        .driver   = "vhost-user-blk-pci",
+        .property = "vectors",
+        .value    = "2",
+    },{
+        .driver   = "e1000",
+        .property = "migrate_tso_props",
+        .value    = "off",
+    },
+};
+const size_t hw_compat_2_11_len = G_N_ELEMENTS(hw_compat_2_11);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +13 -0
index 031602a005..563ba90202 100644
@@ -156,6 +156,19 @@ GlobalProperty pc_compat_2_12[] = {
 };
 const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12);
 
+GlobalProperty pc_compat_2_11[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "x-migrate-smi-count",
+        .value    = "off",
+    },{
+        .driver   = "Skylake-Server" "-" TYPE_X86_CPU,
+        .property = "clflushopt",
+        .value    = "off",
+    },
+};
+const size_t pc_compat_2_11_len = G_N_ELEMENTS(pc_compat_2_11);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -5
index fd3906cda6..aeb51a2772 100644
@@ -472,12 +472,9 @@ DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL,
 
 static void pc_i440fx_2_11_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_11
-    };
-
     pc_i440fx_2_12_machine_options(m);
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len);
+    compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL,
hw/i386/pc_q35.c +2 -5
index 7928f703d0..fd3187003a 100644
@@ -356,14 +356,11 @@ DEFINE_Q35_MACHINE(v2_12, "pc-q35-2.12", NULL,
 static void pc_q35_2_11_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_11
-    };
-
 
     pc_q35_2_12_machine_options(m);
     pcmc->default_nic_model = "e1000";
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len);
+    compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len);
 }
 
 DEFINE_Q35_MACHINE(v2_11, "pc-q35-2.11", NULL,
hw/ppc/spapr.c +1 -4
index f1fe455c71..9afa22fd13 100644
@@ -4099,13 +4099,10 @@ DEFINE_SPAPR_MACHINE(2_12_sxxm, "2.12-sxxm", false);
 static void spapr_machine_2_11_class_options(MachineClass *mc)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_11
-    };
 
     spapr_machine_2_12_class_options(mc);
     smc->default_caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_ON;
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
 }
 
 DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
hw/s390x/s390-virtio-ccw.c +1 -1
index ce22a9d511..74623becaf 100644
@@ -713,7 +713,6 @@ static void ccw_machine_2_11_instance_options(MachineState *machine)
 static void ccw_machine_2_11_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_11
         {
             .driver   = TYPE_SCLP_EVENT_FACILITY,
             .property = "allow_all_mask_sizes",
@@ -722,6 +721,7 @@ static void ccw_machine_2_11_class_options(MachineClass *mc)
     };
 
     ccw_machine_2_12_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_CCW_MACHINE(2_11, "2.11", false);
Signature · 1 line
2.20.1.2.gb21ebb671b
#21 lore raw

[Qemu-devel] [PULL v2 18/28] compat: replace PC_COMPAT_2_2 & HW_COMPAT_2_2 macros

In reply to Marc-André Lureau

Use static arrays instead. I decided to rename the conflicting pc_compat_2_2() function with pc_compat_2_2_fn().

---
 include/hw/boards.h  |  3 ++
 include/hw/compat.h  |  3 --
 include/hw/i386/pc.h | 97 ++------------------------------------------
 hw/core/machine.c    |  3 ++
 hw/i386/pc.c         | 95 +++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c    | 12 +++---
 hw/ppc/spapr.c       |  2 +-
 7 files changed, 110 insertions(+), 105 deletions(-)
include/hw/boards.h +3 -0
index e7e3d2bc3c..2d82d80107 100644
@@ -324,4 +324,7 @@ extern const size_t hw_compat_2_4_len;
 extern GlobalProperty hw_compat_2_3[];
 extern const size_t hw_compat_2_3_len;
 
+extern GlobalProperty hw_compat_2_2[];
+extern const size_t hw_compat_2_2_len;
+
 #endif
include/hw/compat.h +0 -3
index fbe64d5983..3bd91908e4 100644
@@ -1,9 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_2 \
-    /* empty */
-
 #define HW_COMPAT_2_1 \
     {\
         .driver   = "intel-hda",\
include/hw/i386/pc.h +3 -94

109 lines not on this page · raw message

hw/core/machine.c +3 -0
index d37cdc3153..cfa9a5d95f 100644
@@ -306,6 +306,9 @@ GlobalProperty hw_compat_2_3[] = {
 };
 const size_t hw_compat_2_3_len = G_N_ELEMENTS(hw_compat_2_3);
 
+GlobalProperty hw_compat_2_2[] = {};
+const size_t hw_compat_2_2_len = G_N_ELEMENTS(hw_compat_2_2);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +95 -0

101 lines not on this page · raw message

hw/i386/pc_piix.c +5 -7
index 5b03f9ef80..d2a2bacba4 100644
@@ -318,14 +318,14 @@ static void pc_compat_2_3_fn(MachineState *machine)
     }
 }
 
-static void pc_compat_2_2(MachineState *machine)
+static void pc_compat_2_2_fn(MachineState *machine)
 {
     pc_compat_2_3_fn(machine);
 }
 
 static void pc_compat_2_1(MachineState *machine)
 {
-    pc_compat_2_2(machine);
+    pc_compat_2_2_fn(machine);
     x86_cpu_change_kvm_default("svm", NULL);
 }
 
@@ -578,18 +578,16 @@ DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn,
 static void pc_i440fx_2_2_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_2
-    };
 
     pc_i440fx_2_3_machine_options(m);
     m->hw_version = "2.2.0";
     m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on";
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len);
+    compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len);
     pcmc->rsdp_in_ram = false;
 }
 
-DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
+DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn,
                       pc_i440fx_2_2_machine_options);
 
 static void pc_i440fx_2_1_machine_options(MachineClass *m)
hw/ppc/spapr.c +1 -1
index b99ed19baf..449c5dd58d 100644
@@ -4341,7 +4341,6 @@ DEFINE_SPAPR_MACHINE(2_3, "2.3", false);
 static void spapr_machine_2_2_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_2
         {
             .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
             .property = "mem_win_size",
@@ -4350,6 +4349,7 @@ static void spapr_machine_2_2_class_options(MachineClass *mc)
     };
 
     spapr_machine_2_3_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_2, hw_compat_2_2_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     mc->default_machine_opts = "modern-hotplug-events=off,suppress-vmdesc=on";
 }
Signature · 1 line
2.20.1.2.gb21ebb671b
#22 lore raw

[Qemu-devel] [PULL v2 21/28] compat: remove remaining PC_COMPAT macros

In reply to Marc-André Lureau

Use static arrays instead. I decided to rename the conflicting pc_compat_2_1() function with pc_compat_2_1_fn().

---
 include/hw/i386/pc.h | 236 +++----------------------------------------
 hw/i386/pc.c         | 232 ++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c    |  57 ++++-------
 3 files changed, 267 insertions(+), 258 deletions(-)
include/hw/i386/pc.h +15 -221
index 6b7bf334cd..84720bede9 100644
@@ -335,6 +335,21 @@ extern const size_t pc_compat_2_2_len;
 extern GlobalProperty pc_compat_2_1[];
 extern const size_t pc_compat_2_1_len;
 
+extern GlobalProperty pc_compat_2_0[];
+extern const size_t pc_compat_2_0_len;
+
+extern GlobalProperty pc_compat_1_7[];
+extern const size_t pc_compat_1_7_len;
+
+extern GlobalProperty pc_compat_1_6[];
+extern const size_t pc_compat_1_6_len;
+
+extern GlobalProperty pc_compat_1_5[];
+extern const size_t pc_compat_1_5_len;
+
+extern GlobalProperty pc_compat_1_4[];
+extern const size_t pc_compat_1_4_len;
+
 /* Helper for setting model-id for CPU models that changed model-id
  * depending on QEMU versions up to QEMU 2.4.
  */
@@ -355,227 +370,6 @@ extern const size_t pc_compat_2_1_len;
         .value    = "QEMU Virtual CPU version " v,\
     },
 
-#define PC_COMPAT_2_0 \
-    PC_CPU_MODEL_IDS("2.0.0") \
-    {\
-        .driver   = "virtio-scsi-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "PIIX4_PM",\
-        .property = "memory-hotplug-support",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "apic",\
-        .property = "version",\
-        .value    = stringify(0x11),\
-    },\
-    {\
-        .driver   = "nec-usb-xhci",\
-        .property = "superspeed-ports-first",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "nec-usb-xhci",\
-        .property = "force-pcie-endcap",\
-        .value    = "on",\
-    },\
-    {\
-        .driver   = "pci-serial",\
-        .property = "prog_if",\
-        .value    = stringify(0),\
-    },\
-    {\
-        .driver   = "pci-serial-2x",\
-        .property = "prog_if",\
-        .value    = stringify(0),\
-    },\
-    {\
-        .driver   = "pci-serial-4x",\
-        .property = "prog_if",\
-        .value    = stringify(0),\
-    },\
-    {\
-        .driver   = "virtio-net-pci",\
-        .property = "guest_announce",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "ICH9-LPC",\
-        .property = "memory-hotplug-support",\
-        .value    = "off",\
-    },{\
-        .driver   = "xio3130-downstream",\
-        .property = COMPAT_PROP_PCP,\
-        .value    = "off",\
-    },{\
-        .driver   = "ioh3420",\
-        .property = COMPAT_PROP_PCP,\
-        .value    = "off",\
-    },
-
-#define PC_COMPAT_1_7 \
-    PC_CPU_MODEL_IDS("1.7.0") \
-    {\
-        .driver   = TYPE_USB_DEVICE,\
-        .property = "msos-desc",\
-        .value    = "no",\
-    },\
-    {\
-        .driver   = "PIIX4_PM",\
-        .property = "acpi-pci-hotplug-with-bridge-support",\
-        .value    = "off",\
-    },\
-    {\
-        .driver   = "hpet",\
-        .property = HPET_INTCAP,\
-        .value    = stringify(4),\
-    },
-
-#define PC_COMPAT_1_6 \
-    PC_CPU_MODEL_IDS("1.6.0") \
-    {\
-        .driver   = "e1000",\
-        .property = "mitigation",\
-        .value    = "off",\
-    },{\
-        .driver   = "qemu64-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "qemu32-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(3),\
-    },{\
-        .driver   = "i440FX-pcihost",\
-        .property = "short_root_bus",\
-        .value    = stringify(1),\
-    },{\
-        .driver   = "q35-pcihost",\
-        .property = "short_root_bus",\
-        .value    = stringify(1),\
-    },
-
-#define PC_COMPAT_1_5 \
-    PC_CPU_MODEL_IDS("1.5.0") \
-    {\
-        .driver   = "Conroe-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "Conroe-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "Penryn-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "Penryn-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "Nehalem-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "Nehalem-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "virtio-net-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver = TYPE_X86_CPU,\
-        .property = "pmu",\
-        .value = "on",\
-    },{\
-        .driver   = "i440FX-pcihost",\
-        .property = "short_root_bus",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "q35-pcihost",\
-        .property = "short_root_bus",\
-        .value    = stringify(0),\
-    },
-
-#define PC_COMPAT_1_4 \
-    PC_CPU_MODEL_IDS("1.4.0") \
-    {\
-        .driver   = "scsi-hd",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "scsi-cd",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "scsi-disk",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "ide-hd",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "ide-cd",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "ide-drive",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "virtio-blk-pci",\
-        .property = "discard_granularity",\
-        .value    = stringify(0),\
-    },{\
-        .driver   = "virtio-serial-pci",\
-        .property = "vectors",\
-        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-        .value    = stringify(0xFFFFFFFF),\
-    },{ \
-        .driver   = "virtio-net-pci", \
-        .property = "ctrl_guest_offloads", \
-        .value    = "off", \
-    },{\
-        .driver   = "e1000",\
-        .property = "romfile",\
-        .value    = "pxe-e1000.rom",\
-    },{\
-        .driver   = "ne2k_pci",\
-        .property = "romfile",\
-        .value    = "pxe-ne2k_pci.rom",\
-    },{\
-        .driver   = "pcnet",\
-        .property = "romfile",\
-        .value    = "pxe-pcnet.rom",\
-    },{\
-        .driver   = "rtl8139",\
-        .property = "romfile",\
-        .value    = "pxe-rtl8139.rom",\
-    },{\
-        .driver   = "virtio-net-pci",\
-        .property = "romfile",\
-        .value    = "pxe-virtio.rom",\
-    },{\
-        .driver   = "486-" TYPE_X86_CPU,\
-        .property = "model",\
-        .value    = stringify(0),\
-    },\
-    {\
-        .driver = "n270" "-" TYPE_X86_CPU,\
-        .property = "movbe",\
-        .value = "off",\
-    },\
-    {\
-        .driver = "Westmere" "-" TYPE_X86_CPU,\
-        .property = "pclmulqdq",\
-        .value = "off",\
-    },
-
 #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
     static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
     { \
hw/i386/pc.c +232 -0

244 lines not on this page · raw message

hw/i386/pc_piix.c +20 -37

141 lines not on this page · raw message

Signature · 1 line
2.20.1.2.gb21ebb671b
#23 lore raw

[Qemu-devel] [PULL v2 20/28] include: remove compat.h

In reply to Marc-André Lureau

The header is now empty.

---
 include/hw/compat.h        | 4 ----
 include/hw/i386/pc.h       | 1 -
 hw/arm/virt.c              | 1 -
 hw/ppc/spapr.c             | 1 -
 hw/s390x/s390-virtio-ccw.c | 1 -
 5 files changed, 8 deletions(-)
 delete mode 100644 include/hw/compat.h
include/hw/compat.h deleted +0 -4
deleted file mode 100644
index b2d0bdd599..0000000000
@@ -1,4 +0,0 @@
-#ifndef HW_COMPAT_H
-#define HW_COMPAT_H
-
-#endif /* HW_COMPAT_H */
include/hw/i386/pc.h +0 -1
index 784ea7a92c..6b7bf334cd 100644
@@ -13,7 +13,6 @@
 #include "qemu/bitmap.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
-#include "hw/compat.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/mem/nvdimm.h"
 #include "hw/acpi/acpi_dev_interface.h"
hw/arm/virt.c +0 -1
index d3174f1402..99c2b6e60d 100644
@@ -43,7 +43,6 @@
 #include "sysemu/numa.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
-#include "hw/compat.h"
 #include "hw/loader.h"
 #include "exec/address-spaces.h"
 #include "qemu/bitops.h"
hw/ppc/spapr.c +0 -1
index 8aba66a32f..5671608cea 100644
@@ -70,7 +70,6 @@
 #include "hw/nmi.h"
 #include "hw/intc/intc.h"
 
-#include "hw/compat.h"
 #include "qemu/cutils.h"
 #include "hw/ppc/spapr_cpu_core.h"
 #include "hw/mem/memory-device.h"
hw/s390x/s390-virtio-ccw.c +0 -1
index bf5f2f463c..c737507053 100644
@@ -28,7 +28,6 @@
 #include "hw/s390x/storage-keys.h"
 #include "hw/s390x/storage-attributes.h"
 #include "hw/s390x/event-facility.h"
-#include "hw/compat.h"
 #include "ipl.h"
 #include "hw/s390x/s390-virtio-ccw.h"
 #include "hw/s390x/css-bridge.h"
Signature · 1 line
2.20.1.2.gb21ebb671b
#24 lore raw

[Qemu-devel] [PULL v2 14/28] compat: replace PC_COMPAT_2_6 & HW_COMPAT_2_6 macros

In reply to Marc-André Lureau

Use static arrays instead.

---
 include/hw/boards.h        |  3 +++
 include/hw/compat.h        | 15 ---------------
 include/hw/i386/pc.h       | 23 ++---------------------
 hw/arm/virt.c              |  5 +----
 hw/core/machine.c          | 17 +++++++++++++++++
 hw/i386/pc.c               | 23 +++++++++++++++++++++++
 hw/i386/pc_piix.c          |  6 ++----
 hw/i386/pc_q35.c           |  6 ++----
 hw/ppc/spapr.c             |  2 +-
 hw/s390x/s390-virtio-ccw.c |  2 +-
 10 files changed, 52 insertions(+), 50 deletions(-)
include/hw/boards.h +3 -0
index ac4854db0f..1135ee23ac 100644
@@ -312,4 +312,7 @@ extern const size_t hw_compat_2_8_len;
 extern GlobalProperty hw_compat_2_7[];
 extern const size_t hw_compat_2_7_len;
 
+extern GlobalProperty hw_compat_2_6[];
+extern const size_t hw_compat_2_6_len;
+
 #endif
include/hw/compat.h +0 -15
index 7ceab17401..c744233fb6 100644
@@ -1,21 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_6 \
-    {\
-        .driver   = "virtio-mmio",\
-        .property = "format_transport_address",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "disable-modern",\
-        .value    = "on",\
-    },{\
-        .driver   = "virtio-pci",\
-        .property = "disable-legacy",\
-        .value    = "off",\
-    },
-
 #define HW_COMPAT_2_5 \
     {\
         .driver   = "isa-fdc",\
include/hw/i386/pc.h +2 -21
index 504fbc79a9..ca62def2c9 100644
@@ -318,27 +318,8 @@ extern const size_t pc_compat_2_8_len;
 extern GlobalProperty pc_compat_2_7[];
 extern const size_t pc_compat_2_7_len;
 
-#define PC_COMPAT_2_6 \
-    HW_COMPAT_2_6 \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "cpuid-0xb",\
-        .value    = "off",\
-    },{\
-        .driver   = "vmxnet3",\
-        .property = "romfile",\
-        .value    = "",\
-    },\
-    {\
-        .driver = TYPE_X86_CPU,\
-        .property = "fill-mtrr-mask",\
-        .value = "off",\
-    },\
-    {\
-        .driver   = "apic-common",\
-        .property = "legacy-instance-id",\
-        .value    = "on",\
-    },
+extern GlobalProperty pc_compat_2_6[];
+extern const size_t pc_compat_2_6_len;
 
 #define PC_COMPAT_2_5 \
     HW_COMPAT_2_5
hw/arm/virt.c +1 -4
index 0134d0d439..d3174f1402 100644
@@ -1952,12 +1952,9 @@ DEFINE_VIRT_MACHINE(2, 7)
 static void virt_machine_2_6_options(MachineClass *mc)
 {
     VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
-    static GlobalProperty compat[] = {
-        HW_COMPAT_2_6
-    };
 
     virt_machine_2_7_options(mc);
-    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
     vmc->disallow_affinity_adjustment = true;
     /* Disable PMU for 2.6 as PMU support was first introduced in 2.7 */
     vmc->no_pmu = true;
hw/core/machine.c +17 -0
index cc92b0cc84..e27b1b5c34 100644
@@ -193,6 +193,23 @@ GlobalProperty hw_compat_2_7[] = {
 };
 const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
 
+GlobalProperty hw_compat_2_6[] = {
+    {
+        .driver   = "virtio-mmio",
+        .property = "format_transport_address",
+        .value    = "off",
+    },{
+        .driver   = "virtio-pci",
+        .property = "disable-modern",
+        .value    = "on",
+    },{
+        .driver   = "virtio-pci",
+        .property = "disable-legacy",
+        .value    = "off",
+    },
+};
+const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
hw/i386/pc.c +23 -0
index ed46f9c27f..6c8ff0e928 100644
@@ -258,6 +258,29 @@ GlobalProperty pc_compat_2_7[] = {
 };
 const size_t pc_compat_2_7_len = G_N_ELEMENTS(pc_compat_2_7);
 
+GlobalProperty pc_compat_2_6[] = {
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "cpuid-0xb",
+        .value    = "off",
+    },{
+        .driver   = "vmxnet3",
+        .property = "romfile",
+        .value    = "",
+    },
+    {
+        .driver = TYPE_X86_CPU,
+        .property = "fill-mtrr-mask",
+        .value = "off",
+    },
+    {
+        .driver   = "apic-common",
+        .property = "legacy-instance-id",
+        .value    = "on",
+    }
+};
+const size_t pc_compat_2_6_len = G_N_ELEMENTS(pc_compat_2_6);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
hw/i386/pc_piix.c +2 -4
index 182d868de8..89e81a028a 100644
@@ -525,14 +525,12 @@ DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL,
 static void pc_i440fx_2_6_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_6
-    };
 
     pc_i440fx_2_7_machine_options(m);
     pcmc->legacy_cpu_hotplug = true;
     pcmc->linuxboot_dma_enabled = false;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len);
+    compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len);
 }
 
 DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL,
hw/i386/pc_q35.c +2 -4
index 35377524d0..efb70fb8af 100644
@@ -412,14 +412,12 @@ DEFINE_Q35_MACHINE(v2_7, "pc-q35-2.7", NULL,
 static void pc_q35_2_6_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_6
-    };
 
     pc_q35_2_7_machine_options(m);
     pcmc->legacy_cpu_hotplug = true;
     pcmc->linuxboot_dma_enabled = false;
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len);
+    compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len);
 }
 
 DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL,
hw/ppc/spapr.c +1 -1
index c83b0c0d66..eff015987d 100644
@@ -4262,7 +4262,6 @@ DEFINE_SPAPR_MACHINE(2_7, "2.7", false);
 static void spapr_machine_2_6_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_6
         {
             .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
             .property = "ddw",
@@ -4272,6 +4271,7 @@ static void spapr_machine_2_6_class_options(MachineClass *mc)
 
     spapr_machine_2_7_class_options(mc);
     mc->has_hotpluggable_cpus = false;
+    compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 
hw/s390x/s390-virtio-ccw.c +1 -1
index f28feedd4b..6137c97875 100644
@@ -811,7 +811,6 @@ static void ccw_machine_2_6_class_options(MachineClass *mc)
 {
     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_6
         {
             .driver   = TYPE_S390_IPL,
             .property = "iplbext_migration",
@@ -825,6 +824,7 @@ static void ccw_machine_2_6_class_options(MachineClass *mc)
 
     s390mc->ri_allowed = false;
     ccw_machine_2_7_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_CCW_MACHINE(2_6, "2.6", false);
Signature · 1 line
2.20.1.2.gb21ebb671b
#25 lore raw

[Qemu-devel] [PULL v2 26/28] qdev-props: call object_apply_global_props()

In reply to Marc-André Lureau

It's now possible to use the common function.

Teach object_apply_global_props() to warn if Error argument is NULL.

---
 hw/core/qdev-properties.c | 24 ++----------------------
 qom/object.c              | 12 +++++++++++-
 2 files changed, 13 insertions(+), 23 deletions(-)
hw/core/qdev-properties.c +2 -22
index 5f9046b84a..5da1439a8b 100644
@@ -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 --- */
qom/object.c +11 -1
index dbdab0aead..aa6f3a2a71 100644
@@ -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);
+            }
         }
     }
 }
Signature · 1 line
2.20.1.2.gb21ebb671b
#26 lore raw

[Qemu-devel] [PULL v2 22/28] qdev: make a separate helper function to apply compat properties

In reply to Marc-André Lureau

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

---
 include/hw/qdev-core.h | 2 ++
 hw/core/qdev.c         | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
include/hw/qdev-core.h +2 -0
index 84e612f473..5989fb6565 100644
@@ -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);
 
hw/core/qdev.c +5 -1
index d510340bac..3769a2bccb 100644
@@ -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));
 }
 
Signature · 1 line
2.20.1.2.gb21ebb671b
#27 lore raw

[Qemu-devel] [PULL v2 23/28] qdev: all globals are now user-provided

In reply to Marc-André Lureau

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.

---
 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(-)
include/hw/qdev-core.h +0 -3
index 5989fb6565..86b05baeeb 100644
@@ -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;
hw/core/qdev-properties.c +0 -4
index 943dc2654b..84df9c06a7 100644
@@ -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);
             }
         }
tests/test-qdev-global-props.c +6 -51

75 lines not on this page · raw message

vl.c +0 -1
index be986b12a9..2334d75159 100644
@@ -2964,7 +2964,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;
Signature · 1 line
2.20.1.2.gb21ebb671b
#28 lore raw

[Qemu-devel] [PULL v2 25/28] qdev-props: remove errp from GlobalProperty

In reply to Marc-André Lureau

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.

---
 include/hw/qdev-core.h    | 8 ++------
 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, 4 insertions(+), 12 deletions(-)
include/hw/qdev-core.h +2 -6
index 86b05baeeb..bc014c1c9f 100644
@@ -250,18 +250,14 @@ 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.
+ *
+ * An error is fatal for non-hotplugged devices, when the global is applied.
  */
 typedef struct GlobalProperty {
     const char *driver;
     const char *property;
     const char *value;
     bool used;
-    Error **errp;
 } GlobalProperty;
 
 static inline void
hw/core/qdev-properties.c +2 -2
index fa47f39584..5f9046b84a 100644
@@ -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);
             }
qom/cpu.c +0 -1
index 9ad1372d57..5442a7323b 100644
@@ -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.",
target/i386/cpu.c +0 -1
index 677a3bd5fb..fa37203d89 100644
@@ -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);
     }
 
target/sparc/cpu.c +0 -1
index 0f090ece54..4a4445bdf5 100644
@@ -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);
 }
 
vl.c +0 -1
index 2334d75159..064872cc98 100644
@@ -2964,7 +2964,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;
 }
Signature · 1 line
2.20.1.2.gb21ebb671b
#29 lore raw

[Qemu-devel] [PULL v2 28/28] hostmem: use object id for memory region name with >= 4.0

In reply to 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.

---
 include/sysemu/hostmem.h |  3 ++-
 backends/hostmem-file.c  |  8 ++++----
 backends/hostmem-memfd.c |  2 +-
 backends/hostmem-ram.c   |  9 ++++-----
 backends/hostmem.c       | 36 ++++++++++++++++++++++++++++++++++++
 hw/core/machine.c        |  8 ++++++++
 6 files changed, 55 insertions(+), 11 deletions(-)
include/sysemu/hostmem.h +2 -1
index 6e6bd2c1cb..a023b372a4 100644
@@ -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
backends/hostmem-file.c +4 -4
index 78f058dee2..7a34e25c43 100644
@@ -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
 }
 
backends/hostmem-memfd.c +1 -1
index 2eb9c827a5..98c9bf3240 100644
@@ -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);
backends/hostmem-ram.c +4 -5
index 7ddd08d370..24b65d9ae3 100644
@@ -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
backends/hostmem.c +36 -0
index af800284e0..0c8ef17653 100644
@@ -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 *backend)
+{
+    if (!backend->use_canonical_path) {
+        return object_get_canonical_path_component(OBJECT(backend));
+    }
+
+    return object_get_canonical_path(OBJECT(backend));
+}
+
 static void
 host_memory_backend_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
@@ -247,6 +257,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)
 {
     /*
@@ -395,6 +410,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 *backend = MEMORY_BACKEND(obj);
+
+    return backend->use_canonical_path;
+}
+
+static void
+host_memory_backend_set_use_canonical_path(Object *obj, bool value,
+                                           Error **errp)
+{
+    HostMemoryBackend *backend = MEMORY_BACKEND(obj);
+
+    backend->use_canonical_path = value;
+}
+
 static void
 host_memory_backend_class_init(ObjectClass *oc, void *data)
 {
@@ -441,6 +473,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 = {
@@ -451,6 +486,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 },
         { }
hw/core/machine.c +8 -0
index 84a4c8cdc3..f8563efb86 100644
@@ -32,6 +32,14 @@ GlobalProperty hw_compat_3_1[] = {
         .driver   = "pcie-root-port",
         .property = "x-width",
         .value    = "1",
+    },{
+        .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",
     },
 };
 const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
Signature · 1 line
2.20.1.2.gb21ebb671b
#30 lore raw

[Qemu-devel] [PULL v2 27/28] arm: replace instance_post_init()

In reply to Marc-André Lureau

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

---
 target/arm/cpu-qom.h |  3 +++
 target/arm/cpu.h     |  2 ++
 target/arm/cpu.c     | 30 ++++++++++++++++++++++++------
 target/arm/cpu64.c   | 24 ++++++++++++++++++++----
 4 files changed, 49 insertions(+), 10 deletions(-)
target/arm/cpu-qom.h +3 -0
index d135ff8e06..2049fa9612 100644
@@ -35,6 +35,8 @@ struct arm_boot_info;
 
 #define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPU
 
+typedef struct ARMCPUInfo ARMCPUInfo;
+
 /**
  * ARMCPUClass:
  * @parent_realize: The parent class' realize handler.
@@ -47,6 +49,7 @@ typedef struct ARMCPUClass {
     CPUClass parent_class;
     /*< public >*/
 
+    const ARMCPUInfo *info;
     DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
 } ARMCPUClass;
target/arm/cpu.h +2 -0
index c943f35dd9..3aedfeeaf1 100644
@@ -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))
target/arm/cpu.c +24 -6
index c8505eaaee..4c4e9e169e 100644
@@ -740,7 +740,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);
 
@@ -1457,8 +1457,10 @@ static void cortex_m33_initfn(Object *obj)
 
 static void arm_v7m_class_init(ObjectClass *oc, void *data)
 {
+    ARMCPUClass *acc = ARM_CPU_CLASS(oc);
     CPUClass *cc = CPU_CLASS(oc);
 
+    acc->info = data;
 #ifndef CONFIG_USER_ONLY
     cc->do_interrupt = arm_v7m_cpu_do_interrupt;
 #endif
@@ -1959,11 +1961,11 @@ static void arm_max_initfn(Object *obj)
 
 #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */
 
-typedef struct ARMCPUInfo {
+struct ARMCPUInfo {
     const char *name;
     void (*initfn)(Object *obj);
     void (*class_init)(ObjectClass *oc, void *data);
-} ARMCPUInfo;
+};
 
 static const ARMCPUInfo arm_cpus[] = {
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
@@ -2113,6 +2115,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(obj);
 }
 
 static const TypeInfo host_arm_cpu_type_info = {
@@ -2127,14 +2130,30 @@ static const TypeInfo host_arm_cpu_type_info = {
 
 #endif
 
+static void arm_cpu_instance_init(Object *obj)
+{
+    ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj);
+
+    acc->info->initfn(obj);
+    arm_cpu_post_init(obj);
+}
+
+static void cpu_register_class_init(ObjectClass *oc, void *data)
+{
+    ARMCPUClass *acc = ARM_CPU_CLASS(oc);
+
+    acc->info = data;
+}
+
 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_init = info->class_init ?: cpu_register_class_init,
+        .class_data = (void *)info,
     };
 
     type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
@@ -2147,7 +2166,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),
target/arm/cpu64.c +20 -4
index 1d57be0c91..4b544a1c58 100644
@@ -364,11 +364,11 @@ static void aarch64_max_initfn(Object *obj)
     }
 }
 
-typedef struct ARMCPUInfo {
+struct ARMCPUInfo {
     const char *name;
     void (*initfn)(Object *obj);
     void (*class_init)(ObjectClass *oc, void *data);
-} ARMCPUInfo;
+};
 
 static const ARMCPUInfo aarch64_cpus[] = {
     { .name = "cortex-a57",         .initfn = aarch64_a57_initfn },
@@ -452,14 +452,30 @@ 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)
+{
+    ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj);
+
+    acc->info->initfn(obj);
+    arm_cpu_post_init(obj);
+}
+
+static void cpu_register_class_init(ObjectClass *oc, void *data)
+{
+    ARMCPUClass *acc = ARM_CPU_CLASS(oc);
+
+    acc->info = data;
+}
+
 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_init = info->class_init ?: cpu_register_class_init,
+        .class_data = (void *)info,
     };
 
     type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
Signature · 1 line
2.20.1.2.gb21ebb671b
#31 lore raw
In reply to Marc-André Lureau
Quoted 31 lines · Marc-André Lureau

The following changes since commit e59dbbac0364344a3ad84c3497a98c56003d3fb8:

Merge remote-tracking branch 'remotes/philmd/tags/fw_cfg-20190104-pull-request' into staging (2019-01-04 18:23:13 +0000)

are available in the Git repository at:

https://github.com/elmarco/qemu.git tags/machine-props-pull-request

for you to fetch changes up to fa0cb34d2210cc749b9a70db99bb41c56ad20831:

hostmem: use object id for memory region name with >= 4.0 (2019-01-07 16:18:42 +0400)

----------------------------------------------------------------
Generalize machine compatibility properties

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.

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.

Quoted 5 lines

(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)

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.

-- PMM

#32 lore raw
In reply to Marc-André Lureau
Quoted 14 lines · Marc-André Lureau

----------------------------------------------------------------
Generalize machine compatibility properties

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.

Quoted 7 lines

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)

Hi; I've just noticed that this refactoring that removed all the HW_COMPAT and PC_COMPAT macros left a couple of references to them behind in documentation/comments:

$ git grep HW_COMPAT
docs/devel/migration.rst:   b) Add an entry to the ``HW_COMPAT_`` for
the previous version that sets
hw/i386/pc_piix.c: * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().

Could you write a patch which updates these bits of documentation to refer to the new scheme, please?

thanks
-- PMM

#33 lore raw

Hi

Quoted 29 lines · Peter Maydell
Quoted 14 lines · Marc-André Lureau

----------------------------------------------------------------
Generalize machine compatibility properties

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.

Quoted 7 lines

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)

Hi; I've just noticed that this refactoring that removed all the HW_COMPAT and PC_COMPAT macros left a couple of references to them behind in documentation/comments:

Quoted 7 lines
$ git grep HW_COMPAT
docs/devel/migration.rst:   b) Add an entry to the ``HW_COMPAT_`` for
the previous version that sets
hw/i386/pc_piix.c: * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().

Could you write a patch which updates these bits of documentation to refer to the new scheme, please?

Ok, patch sent. (it is trivial, as I didn't see any need to change the documentation further)

thanks

Signature · 1 line
Marc-André Lureau