All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] qom: Convert some properties to class properties
@ 2020-11-11 18:38 Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
                   ` (12 more replies)
  0 siblings, 13 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as it
doesn't require an object to be instantiated.  This series
converts a few existing object_property_add*() calls to register
class properties instead.

Changes v1 -> v2:
* Bug fix at "i386: Register feature bit properties as class properties"
* Included patches that were originally submnitted as part of
  "qom: Make all -object types use only class properties"
* All other patches are unchanged from v1

Eduardo Habkost (12):
  vexpress: Register "secure" as class property
  vexpress-a15: Register "virtualization" as class property
  tmp421: Register properties as class properties
  i386: Register feature bit properties as class properties
  arm/virt: Register most properties as class properties
  virt: Register "its" as class property
  arm/cpu64: Register "aarch64" as class property
  can_host: Use class properties
  colo: Use class properties
  netfilter: Reorder functions
  netfilter: Use class properties
  input: Use class properties

 hw/arm/vexpress.c     | 25 ++++++------
 hw/arm/virt.c         | 88 +++++++++++++++++++++++--------------------
 hw/misc/tmp421.c      | 30 +++++++--------
 net/can/can_host.c    | 16 +++-----
 net/colo-compare.c    | 57 ++++++++++++++--------------
 net/dump.c            | 10 ++---
 net/filter-buffer.c   | 26 ++++++-------
 net/filter-mirror.c   | 64 +++++++++++++++----------------
 net/filter-rewriter.c |  7 ++--
 net/filter.c          | 24 ++++++------
 target/arm/cpu64.c    | 16 +++-----
 target/i386/cpu.c     | 40 ++++++++------------
 ui/input-barrier.c    | 22 +++++++++++
 ui/input-linux.c      | 14 +++++++
 14 files changed, 231 insertions(+), 208 deletions(-)

-- 
2.28.0




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

* [PATCH v2 01/12] vexpress: Register "secure" as class property
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 19:59   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 02/12] vexpress-a15: Register "virtualization" " Eduardo Habkost
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, John Snow, qemu-arm, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/arm/vexpress.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 531f3a122a..da25ce3b2c 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -755,11 +755,6 @@ static void vexpress_instance_init(Object *obj)
 
     /* EL3 is enabled by default on vexpress */
     vms->secure = true;
-    object_property_add_bool(obj, "secure", vexpress_get_secure,
-                             vexpress_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
 }
 
 static void vexpress_a15_instance_init(Object *obj)
@@ -796,6 +791,12 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = 4;
     mc->ignore_memory_transaction_failures = true;
     mc->default_ram_id = "vexpress.highmem";
+
+    object_class_property_add_bool(oc, "secure", vexpress_get_secure,
+                                   vexpress_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Security Extensions (TrustZone)");
 }
 
 static void vexpress_a9_class_init(ObjectClass *oc, void *data)
-- 
2.28.0



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

* [PATCH v2 02/12] vexpress-a15: Register "virtualization" as class property
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 19:59   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 03/12] tmp421: Register properties as class properties Eduardo Habkost
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, John Snow, qemu-arm, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/arm/vexpress.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index da25ce3b2c..c228567ce9 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -766,12 +766,6 @@ static void vexpress_a15_instance_init(Object *obj)
      * but can also be specifically set to on or off.
      */
     vms->virt = true;
-    object_property_add_bool(obj, "virtualization", vexpress_get_virt,
-                             vexpress_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Virtualization Extensions "
-                                    "(defaults to same as 'secure')");
 }
 
 static void vexpress_a9_instance_init(Object *obj)
@@ -819,6 +813,14 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
 
     vmc->daughterboard = &a15_daughterboard;
+
+    object_class_property_add_bool(oc, "virtualization", vexpress_get_virt,
+                                   vexpress_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Virtualization Extensions "
+                                          "(defaults to same as 'secure')");
+
 }
 
 static const TypeInfo vexpress_info = {
-- 
2.28.0



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

* [PATCH v2 03/12] tmp421: Register properties as class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 02/12] vexpress-a15: Register "virtualization" " Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 19:59   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 04/12] i386: Register feature bit " Eduardo Habkost
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: qemu-devel@nongnu.org
---
 hw/misc/tmp421.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index ef3c682e32..a3db57dcb5 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -337,22 +337,6 @@ static void tmp421_realize(DeviceState *dev, Error **errp)
     tmp421_reset(&s->i2c);
 }
 
-static void tmp421_initfn(Object *obj)
-{
-    object_property_add(obj, "temperature0", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature1", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature2", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature3", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-}
-
 static void tmp421_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -365,6 +349,19 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
     k->send = tmp421_tx;
     dc->vmsd = &vmstate_tmp421;
     sc->dev = (DeviceInfo *) data;
+
+    object_class_property_add(klass, "temperature0", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature1", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature2", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature3", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
 }
 
 static const TypeInfo tmp421_info = {
@@ -372,7 +369,6 @@ static const TypeInfo tmp421_info = {
     .parent        = TYPE_I2C_SLAVE,
     .instance_size = sizeof(TMP421State),
     .class_size    = sizeof(TMP421Class),
-    .instance_init = tmp421_initfn,
     .abstract      = true,
 };
 
-- 
2.28.0



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

* [PATCH v2 04/12] i386: Register feature bit properties as class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (2 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 03/12] tmp421: Register properties as class properties Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-12-15 14:11   ` Markus Armbruster
  2020-11-11 18:38 ` [PATCH v2 05/12] arm/virt: Register most " Eduardo Habkost
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: John Snow, Richard Henderson, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Remove x86_cpu_release_bit_prop() function, as we will allocate
  BitProperty only once and never free the class property list

---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
 target/i386/cpu.c | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0d8606958e..dbba1151f2 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6823,29 +6823,23 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
     cpu->env.user_features[fp->w] |= fp->mask;
 }
 
-static void x86_cpu_release_bit_prop(Object *obj, const char *name,
-                                     void *opaque)
-{
-    BitProperty *prop = opaque;
-    g_free(prop);
-}
-
 /* Register a boolean property to get/set a single bit in a uint32_t field.
  *
  * The same property name can be registered multiple times to make it affect
  * multiple bits in the same FeatureWord. In that case, the getter will return
  * true only if all bits are set.
  */
-static void x86_cpu_register_bit_prop(X86CPU *cpu,
+static void x86_cpu_register_bit_prop(X86CPUClass *xcc,
                                       const char *prop_name,
                                       FeatureWord w,
                                       int bitnr)
 {
+    ObjectClass *oc = OBJECT_CLASS(xcc);
     BitProperty *fp;
     ObjectProperty *op;
     uint64_t mask = (1ULL << bitnr);
 
-    op = object_property_find(OBJECT(cpu), prop_name);
+    op = object_class_property_find(oc, prop_name);
     if (op) {
         fp = op->opaque;
         assert(fp->w == w);
@@ -6854,14 +6848,14 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
         fp = g_new0(BitProperty, 1);
         fp->w = w;
         fp->mask = mask;
-        object_property_add(OBJECT(cpu), prop_name, "bool",
-                            x86_cpu_get_bit_prop,
-                            x86_cpu_set_bit_prop,
-                            x86_cpu_release_bit_prop, fp);
+        object_class_property_add(oc, prop_name, "bool",
+                                  x86_cpu_get_bit_prop,
+                                  x86_cpu_set_bit_prop,
+                                  NULL, fp);
     }
 }
 
-static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
+static void x86_cpu_register_feature_bit_props(X86CPUClass *xcc,
                                                FeatureWord w,
                                                int bitnr)
 {
@@ -6880,7 +6874,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
     /* aliases don't use "|" delimiters anymore, they are registered
      * manually using object_property_add_alias() */
     assert(!strchr(name, '|'));
-    x86_cpu_register_bit_prop(cpu, name, w, bitnr);
+    x86_cpu_register_bit_prop(xcc, name, w, bitnr);
 }
 
 #if !defined(CONFIG_USER_ONLY)
@@ -6934,7 +6928,6 @@ static void x86_cpu_initfn(Object *obj)
     X86CPU *cpu = X86_CPU(obj);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
     CPUX86State *env = &cpu->env;
-    FeatureWord w;
 
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
@@ -6946,14 +6939,6 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);
 
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        int bitnr;
-
-        for (bitnr = 0; bitnr < 64; bitnr++) {
-            x86_cpu_register_feature_bit_props(cpu, w, bitnr);
-        }
-    }
-
     object_property_add_alias(obj, "sse3", obj, "pni");
     object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq");
     object_property_add_alias(obj, "sse4-1", obj, "sse4.1");
@@ -7239,6 +7224,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     X86CPUClass *xcc = X86_CPU_CLASS(oc);
     CPUClass *cc = CPU_CLASS(oc);
     DeviceClass *dc = DEVICE_CLASS(oc);
+    FeatureWord w;
 
     device_class_set_parent_realize(dc, x86_cpu_realizefn,
                                     &xcc->parent_realize);
@@ -7328,6 +7314,12 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
                               x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
 #endif
 
+    for (w = 0; w < FEATURE_WORDS; w++) {
+        int bitnr;
+        for (bitnr = 0; bitnr < 64; bitnr++) {
+            x86_cpu_register_feature_bit_props(xcc, w, bitnr);
+        }
+    }
 }
 
 static const TypeInfo x86_cpu_type_info = {
-- 
2.28.0



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

* [PATCH v2 05/12] arm/virt: Register most properties as class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (3 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 04/12] i386: Register feature bit " Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 20:03   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 06/12] virt: Register "its" as class property Eduardo Habkost
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, John Snow, qemu-arm, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 35 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 27dbeb549e..53fcaf5e4f 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2484,6 +2484,47 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
         NULL, NULL);
     object_class_property_set_description(oc, "acpi",
         "Enable ACPI");
+    object_class_property_add_bool(oc, "secure", virt_get_secure,
+                                   virt_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                                "Set on/off to enable/disable the ARM "
+                                                "Security Extensions (TrustZone)");
+
+    object_class_property_add_bool(oc, "virtualization", virt_get_virt,
+                                   virt_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Virtualization Extensions");
+
+    object_class_property_add_bool(oc, "highmem", virt_get_highmem,
+                                   virt_set_highmem);
+    object_class_property_set_description(oc, "highmem",
+                                          "Set on/off to enable/disable using "
+                                          "physical address space above 32 bits");
+
+    object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
+                                  virt_set_gic_version);
+    object_class_property_set_description(oc, "gic-version",
+                                          "Set GIC version. "
+                                          "Valid values are 2, 3, host and max");
+
+    object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
+    object_class_property_set_description(oc, "iommu",
+                                          "Set the IOMMU type. "
+                                          "Valid values are none and smmuv3");
+
+    object_class_property_add_bool(oc, "ras", virt_get_ras,
+                                   virt_set_ras);
+    object_class_property_set_description(oc, "ras",
+                                          "Set on/off to enable/disable reporting host memory errors "
+                                          "to a KVM guest using ACPI and guest external abort exceptions");
+
+    object_class_property_add_bool(oc, "mte", virt_get_mte, virt_set_mte);
+    object_class_property_set_description(oc, "mte",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Memory Tagging Extension");
 }
 
 static void virt_instance_init(Object *obj)
@@ -2496,34 +2537,13 @@ static void virt_instance_init(Object *obj)
      * boot UEFI blobs which assume no TrustZone support.
      */
     vms->secure = false;
-    object_property_add_bool(obj, "secure", virt_get_secure,
-                             virt_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
 
     /* EL2 is also disabled by default, for similar reasons */
     vms->virt = false;
-    object_property_add_bool(obj, "virtualization", virt_get_virt,
-                             virt_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Virtualization Extensions");
 
     /* High memory is enabled by default */
     vms->highmem = true;
-    object_property_add_bool(obj, "highmem", virt_get_highmem,
-                             virt_set_highmem);
-    object_property_set_description(obj, "highmem",
-                                    "Set on/off to enable/disable using "
-                                    "physical address space above 32 bits");
     vms->gic_version = VIRT_GIC_VERSION_NOSEL;
-    object_property_add_str(obj, "gic-version", virt_get_gic_version,
-                        virt_set_gic_version);
-    object_property_set_description(obj, "gic-version",
-                                    "Set GIC version. "
-                                    "Valid values are 2, 3, host and max");
 
     vms->highmem_ecam = !vmc->no_highmem_ecam;
 
@@ -2541,26 +2561,12 @@ static void virt_instance_init(Object *obj)
 
     /* Default disallows iommu instantiation */
     vms->iommu = VIRT_IOMMU_NONE;
-    object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu);
-    object_property_set_description(obj, "iommu",
-                                    "Set the IOMMU type. "
-                                    "Valid values are none and smmuv3");
 
     /* Default disallows RAS instantiation */
     vms->ras = false;
-    object_property_add_bool(obj, "ras", virt_get_ras,
-                             virt_set_ras);
-    object_property_set_description(obj, "ras",
-                                    "Set on/off to enable/disable reporting host memory errors "
-                                    "to a KVM guest using ACPI and guest external abort exceptions");
 
     /* MTE is disabled by default.  */
     vms->mte = false;
-    object_property_add_bool(obj, "mte", virt_get_mte, virt_set_mte);
-    object_property_set_description(obj, "mte",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Memory Tagging Extension");
 
     vms->irqmap = a15irqmap;
 
-- 
2.28.0



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

* [PATCH v2 06/12] virt: Register "its" as class property
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (4 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 05/12] arm/virt: Register most " Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 20:03   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 07/12] arm/cpu64: Register "aarch64" " Eduardo Habkost
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, John Snow, qemu-arm, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Note: "its" is currently registered conditionally, but this makes
the feature be registered unconditionally.  The only side effect
is that it will be now possible to set its=on on virt-2.7 and
older.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/arm/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 53fcaf5e4f..37a020c149 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2525,6 +2525,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set on/off to enable/disable emulating a "
                                           "guest CPU which implements the ARM "
                                           "Memory Tagging Extension");
+
+    object_class_property_add_bool(oc, "its", virt_get_its,
+                                   virt_set_its);
+    object_class_property_set_description(oc, "its",
+                                          "Set on/off to enable/disable "
+                                          "ITS instantiation");
+
 }
 
 static void virt_instance_init(Object *obj)
@@ -2552,11 +2559,6 @@ static void virt_instance_init(Object *obj)
     } else {
         /* Default allows ITS instantiation */
         vms->its = true;
-        object_property_add_bool(obj, "its", virt_get_its,
-                                 virt_set_its);
-        object_property_set_description(obj, "its",
-                                        "Set on/off to enable/disable "
-                                        "ITS instantiation");
     }
 
     /* Default disallows iommu instantiation */
-- 
2.28.0



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

* [PATCH v2 07/12] arm/cpu64: Register "aarch64" as class property
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (5 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 06/12] virt: Register "its" as class property Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 20:04   ` Peter Maydell
  2020-11-11 18:38 ` [PATCH v2 08/12] can_host: Use class properties Eduardo Habkost
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, John Snow, qemu-arm, Daniel P. Berrange, Paolo Bonzini

Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org
---
 target/arm/cpu64.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 649213082f..7cf9fc4bc6 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -762,15 +762,6 @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
     }
 }
 
-static void aarch64_cpu_initfn(Object *obj)
-{
-    object_property_add_bool(obj, "aarch64", aarch64_cpu_get_aarch64,
-                             aarch64_cpu_set_aarch64);
-    object_property_set_description(obj, "aarch64",
-                                    "Set on/off to enable/disable aarch64 "
-                                    "execution state ");
-}
-
 static void aarch64_cpu_finalizefn(Object *obj)
 {
 }
@@ -790,6 +781,12 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_num_core_regs = 34;
     cc->gdb_core_xml_file = "aarch64-core.xml";
     cc->gdb_arch_name = aarch64_gdb_arch_name;
+
+    object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64,
+                                   aarch64_cpu_set_aarch64);
+    object_class_property_set_description(oc, "aarch64",
+                                          "Set on/off to enable/disable aarch64 "
+                                          "execution state ");
 }
 
 static void aarch64_cpu_instance_init(Object *obj)
@@ -827,7 +824,6 @@ static const TypeInfo aarch64_cpu_type_info = {
     .name = TYPE_AARCH64_CPU,
     .parent = TYPE_ARM_CPU,
     .instance_size = sizeof(ARMCPU),
-    .instance_init = aarch64_cpu_initfn,
     .instance_finalize = aarch64_cpu_finalizefn,
     .abstract = true,
     .class_size = sizeof(AArch64CPUClass),
-- 
2.28.0



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

* [PATCH v2 08/12] can_host: Use class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (6 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 07/12] arm/cpu64: Register "aarch64" " Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 23:02   ` Pavel Pisa
  2020-11-11 18:38 ` [PATCH v2 09/12] colo: " Eduardo Habkost
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Vikram Garhwal, Daniel P. Berrange, Jason Wang, Paolo Bonzini,
	John Snow, Pavel Pisa

Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com
---
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org
---
 net/can/can_host.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/net/can/can_host.c b/net/can/can_host.c
index be4547d913..bec88b9620 100644
--- a/net/can/can_host.c
+++ b/net/can/can_host.c
@@ -72,21 +72,16 @@ static void can_host_complete(UserCreatable *uc, Error **errp)
     can_host_connect(CAN_HOST(uc), errp);
 }
 
-static void can_host_instance_init(Object *obj)
-{
-    CanHostState *ch = CAN_HOST(obj);
-
-    object_property_add_link(obj, "canbus", TYPE_CAN_BUS,
-                             (Object **)&ch->bus,
-                             object_property_allow_set_link,
-                             OBJ_PROP_LINK_STRONG);
-}
-
 static void can_host_class_init(ObjectClass *klass,
                                 void *class_data G_GNUC_UNUSED)
 {
     UserCreatableClass *uc_klass = USER_CREATABLE_CLASS(klass);
 
+    object_class_property_add_link(klass, "canbus", TYPE_CAN_BUS,
+                                   offsetof(CanHostState, bus),
+                                   object_property_allow_set_link,
+                                   OBJ_PROP_LINK_STRONG);
+
     klass->unparent = can_host_unparent;
     uc_klass->complete = can_host_complete;
 }
@@ -97,7 +92,6 @@ static const TypeInfo can_host_info = {
     .instance_size = sizeof(CanHostState),
     .class_size = sizeof(CanHostClass),
     .abstract = true,
-    .instance_init = can_host_instance_init,
     .class_init = can_host_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_USER_CREATABLE },
-- 
2.28.0



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

* [PATCH v2 09/12] colo: Use class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (7 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 08/12] can_host: Use class properties Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-13  3:04   ` Zhang, Chen
  2020-11-11 18:38 ` [PATCH v2 10/12] netfilter: Reorder functions Eduardo Habkost
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Li Zhijian, Jason Wang, Zhang Chen,
	Paolo Bonzini, John Snow

Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com
---
Cc: Zhang Chen <chen.zhang@intel.com>
Cc: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org
---
 net/colo-compare.c | 57 +++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 3a45d64175..017e82dd8b 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -1375,6 +1375,35 @@ static void colo_compare_class_init(ObjectClass *oc, void *data)
 {
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
+    object_class_property_add_str(oc, "primary_in",
+                                  compare_get_pri_indev, compare_set_pri_indev);
+    object_class_property_add_str(oc, "secondary_in",
+                                  compare_get_sec_indev, compare_set_sec_indev);
+    object_class_property_add_str(oc, "outdev",
+                                  compare_get_outdev, compare_set_outdev);
+    object_class_property_add_link(oc, "iothread", TYPE_IOTHREAD,
+                                  offsetof(CompareState, iothread),
+                                  object_property_allow_set_link,
+                                  OBJ_PROP_LINK_STRONG);
+    /* This parameter just for Xen COLO */
+    object_class_property_add_str(oc, "notify_dev",
+                                  compare_get_notify_dev, compare_set_notify_dev);
+
+    object_class_property_add(oc, "compare_timeout", "uint32",
+                              compare_get_timeout,
+                              compare_set_timeout, NULL, NULL);
+
+    object_class_property_add(oc, "expired_scan_cycle", "uint32",
+                              compare_get_expired_scan_cycle,
+                              compare_set_expired_scan_cycle, NULL, NULL);
+
+    object_class_property_add(oc, "max_queue_size", "uint32",
+                              get_max_queue_size,
+                              set_max_queue_size, NULL, NULL);
+
+    object_class_property_add_bool(oc, "vnet_hdr_support", compare_get_vnet_hdr,
+                                   compare_set_vnet_hdr);
+
     ucc->complete = colo_compare_complete;
 }
 
@@ -1382,35 +1411,7 @@ static void colo_compare_init(Object *obj)
 {
     CompareState *s = COLO_COMPARE(obj);
 
-    object_property_add_str(obj, "primary_in",
-                            compare_get_pri_indev, compare_set_pri_indev);
-    object_property_add_str(obj, "secondary_in",
-                            compare_get_sec_indev, compare_set_sec_indev);
-    object_property_add_str(obj, "outdev",
-                            compare_get_outdev, compare_set_outdev);
-    object_property_add_link(obj, "iothread", TYPE_IOTHREAD,
-                            (Object **)&s->iothread,
-                            object_property_allow_set_link,
-                            OBJ_PROP_LINK_STRONG);
-    /* This parameter just for Xen COLO */
-    object_property_add_str(obj, "notify_dev",
-                            compare_get_notify_dev, compare_set_notify_dev);
-
-    object_property_add(obj, "compare_timeout", "uint32",
-                        compare_get_timeout,
-                        compare_set_timeout, NULL, NULL);
-
-    object_property_add(obj, "expired_scan_cycle", "uint32",
-                        compare_get_expired_scan_cycle,
-                        compare_set_expired_scan_cycle, NULL, NULL);
-
-    object_property_add(obj, "max_queue_size", "uint32",
-                        get_max_queue_size,
-                        set_max_queue_size, NULL, NULL);
-
     s->vnet_hdr = false;
-    object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
-                             compare_set_vnet_hdr);
 }
 
 static void colo_compare_finalize(Object *obj)
-- 
2.28.0



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

* [PATCH v2 10/12] netfilter: Reorder functions
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (8 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 09/12] colo: " Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 11/12] netfilter: Use class properties Eduardo Habkost
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Li Zhijian, Jason Wang, Zhang Chen,
	Paolo Bonzini, John Snow

Trivial code reordering in some filter backends, to make the next
changes easier to review.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com
---
Cc: Jason Wang <jasowang@redhat.com>
Cc: Zhang Chen <chen.zhang@intel.com>
Cc: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org
---
 net/filter-buffer.c | 20 ++++++++++----------
 net/filter-mirror.c | 36 ++++++++++++++++++------------------
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index d8392be53c..95e384865f 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -144,16 +144,6 @@ static void filter_buffer_status_changed(NetFilterState *nf, Error **errp)
     }
 }
 
-static void filter_buffer_class_init(ObjectClass *oc, void *data)
-{
-    NetFilterClass *nfc = NETFILTER_CLASS(oc);
-
-    nfc->setup = filter_buffer_setup;
-    nfc->cleanup = filter_buffer_cleanup;
-    nfc->receive_iov = filter_buffer_receive_iov;
-    nfc->status_changed = filter_buffer_status_changed;
-}
-
 static void filter_buffer_get_interval(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
@@ -182,6 +172,16 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v,
     s->interval = value;
 }
 
+static void filter_buffer_class_init(ObjectClass *oc, void *data)
+{
+    NetFilterClass *nfc = NETFILTER_CLASS(oc);
+
+    nfc->setup = filter_buffer_setup;
+    nfc->cleanup = filter_buffer_cleanup;
+    nfc->receive_iov = filter_buffer_receive_iov;
+    nfc->status_changed = filter_buffer_status_changed;
+}
+
 static void filter_buffer_init(Object *obj)
 {
     object_property_add(obj, "interval", "uint32",
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 088d4dcace..26b783011a 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -284,24 +284,6 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
     }
 }
 
-static void filter_mirror_class_init(ObjectClass *oc, void *data)
-{
-    NetFilterClass *nfc = NETFILTER_CLASS(oc);
-
-    nfc->setup = filter_mirror_setup;
-    nfc->cleanup = filter_mirror_cleanup;
-    nfc->receive_iov = filter_mirror_receive_iov;
-}
-
-static void filter_redirector_class_init(ObjectClass *oc, void *data)
-{
-    NetFilterClass *nfc = NETFILTER_CLASS(oc);
-
-    nfc->setup = filter_redirector_setup;
-    nfc->cleanup = filter_redirector_cleanup;
-    nfc->receive_iov = filter_redirector_receive_iov;
-}
-
 static char *filter_redirector_get_indev(Object *obj, Error **errp)
 {
     MirrorState *s = FILTER_REDIRECTOR(obj);
@@ -388,6 +370,24 @@ static void filter_redirector_set_vnet_hdr(Object *obj,
     s->vnet_hdr = value;
 }
 
+static void filter_mirror_class_init(ObjectClass *oc, void *data)
+{
+    NetFilterClass *nfc = NETFILTER_CLASS(oc);
+
+    nfc->setup = filter_mirror_setup;
+    nfc->cleanup = filter_mirror_cleanup;
+    nfc->receive_iov = filter_mirror_receive_iov;
+}
+
+static void filter_redirector_class_init(ObjectClass *oc, void *data)
+{
+    NetFilterClass *nfc = NETFILTER_CLASS(oc);
+
+    nfc->setup = filter_redirector_setup;
+    nfc->cleanup = filter_redirector_cleanup;
+    nfc->receive_iov = filter_redirector_receive_iov;
+}
+
 static void filter_mirror_init(Object *obj)
 {
     MirrorState *s = FILTER_MIRROR(obj);
-- 
2.28.0



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

* [PATCH v2 11/12] netfilter: Use class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (9 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 10/12] netfilter: Reorder functions Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 18:38 ` [PATCH v2 12/12] input: " Eduardo Habkost
  2020-12-11 21:00 ` [PATCH v2 00/12] qom: Convert some properties to " Eduardo Habkost
  12 siblings, 0 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrange, Li Zhijian, Jason Wang, Zhang Chen,
	Paolo Bonzini, John Snow

Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com
---
Cc: Jason Wang <jasowang@redhat.com>
Cc: Zhang Chen <chen.zhang@intel.com>
Cc: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org
---
 net/dump.c            | 10 +++++-----
 net/filter-buffer.c   | 12 ++++--------
 net/filter-mirror.c   | 28 ++++++++++++++--------------
 net/filter-rewriter.c |  7 ++++---
 net/filter.c          | 24 ++++++++++++------------
 5 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/net/dump.c b/net/dump.c
index 7fd448d2e1..4d538d82a6 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -224,11 +224,6 @@ static void filter_dump_instance_init(Object *obj)
     NetFilterDumpState *nfds = FILTER_DUMP(obj);
 
     nfds->maxlen = 65536;
-
-    object_property_add(obj, "maxlen", "uint32", filter_dump_get_maxlen,
-                        filter_dump_set_maxlen, NULL, NULL);
-    object_property_add_str(obj, "file", file_dump_get_filename,
-                            file_dump_set_filename);
 }
 
 static void filter_dump_instance_finalize(Object *obj)
@@ -242,6 +237,11 @@ static void filter_dump_class_init(ObjectClass *oc, void *data)
 {
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add(oc, "maxlen", "uint32", filter_dump_get_maxlen,
+                              filter_dump_set_maxlen, NULL, NULL);
+    object_class_property_add_str(oc, "file", file_dump_get_filename,
+                                  file_dump_set_filename);
+
     nfc->setup = filter_dump_setup;
     nfc->cleanup = filter_dump_cleanup;
     nfc->receive_iov = filter_dump_receive_iov;
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index 95e384865f..283dc9cbe6 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -176,24 +176,20 @@ static void filter_buffer_class_init(ObjectClass *oc, void *data)
 {
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add(oc, "interval", "uint32",
+                              filter_buffer_get_interval,
+                              filter_buffer_set_interval, NULL, NULL);
+
     nfc->setup = filter_buffer_setup;
     nfc->cleanup = filter_buffer_cleanup;
     nfc->receive_iov = filter_buffer_receive_iov;
     nfc->status_changed = filter_buffer_status_changed;
 }
 
-static void filter_buffer_init(Object *obj)
-{
-    object_property_add(obj, "interval", "uint32",
-                        filter_buffer_get_interval,
-                        filter_buffer_set_interval, NULL, NULL);
-}
-
 static const TypeInfo filter_buffer_info = {
     .name = TYPE_FILTER_BUFFER,
     .parent = TYPE_NETFILTER,
     .class_init = filter_buffer_class_init,
-    .instance_init = filter_buffer_init,
     .instance_size = sizeof(FilterBufferState),
 };
 
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 26b783011a..f8e65007c0 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -374,6 +374,12 @@ static void filter_mirror_class_init(ObjectClass *oc, void *data)
 {
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add_str(oc, "outdev", filter_mirror_get_outdev,
+                                  filter_mirror_set_outdev);
+    object_class_property_add_bool(oc, "vnet_hdr_support",
+                                   filter_mirror_get_vnet_hdr,
+                                   filter_mirror_set_vnet_hdr);
+
     nfc->setup = filter_mirror_setup;
     nfc->cleanup = filter_mirror_cleanup;
     nfc->receive_iov = filter_mirror_receive_iov;
@@ -383,6 +389,14 @@ static void filter_redirector_class_init(ObjectClass *oc, void *data)
 {
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add_str(oc, "indev", filter_redirector_get_indev,
+                                  filter_redirector_set_indev);
+    object_class_property_add_str(oc, "outdev", filter_redirector_get_outdev,
+                                  filter_redirector_set_outdev);
+    object_class_property_add_bool(oc, "vnet_hdr_support",
+                                   filter_redirector_get_vnet_hdr,
+                                   filter_redirector_set_vnet_hdr);
+
     nfc->setup = filter_redirector_setup;
     nfc->cleanup = filter_redirector_cleanup;
     nfc->receive_iov = filter_redirector_receive_iov;
@@ -392,28 +406,14 @@ static void filter_mirror_init(Object *obj)
 {
     MirrorState *s = FILTER_MIRROR(obj);
 
-    object_property_add_str(obj, "outdev", filter_mirror_get_outdev,
-                            filter_mirror_set_outdev);
-
     s->vnet_hdr = false;
-    object_property_add_bool(obj, "vnet_hdr_support",
-                             filter_mirror_get_vnet_hdr,
-                             filter_mirror_set_vnet_hdr);
 }
 
 static void filter_redirector_init(Object *obj)
 {
     MirrorState *s = FILTER_REDIRECTOR(obj);
 
-    object_property_add_str(obj, "indev", filter_redirector_get_indev,
-                            filter_redirector_set_indev);
-    object_property_add_str(obj, "outdev", filter_redirector_get_outdev,
-                            filter_redirector_set_outdev);
-
     s->vnet_hdr = false;
-    object_property_add_bool(obj, "vnet_hdr_support",
-                             filter_redirector_get_vnet_hdr,
-                             filter_redirector_set_vnet_hdr);
 }
 
 static void filter_mirror_fini(Object *obj)
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index dc3c27a489..ae358059d9 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -416,15 +416,16 @@ static void filter_rewriter_init(Object *obj)
 
     s->vnet_hdr = false;
     s->failover_mode = FAILOVER_MODE_OFF;
-    object_property_add_bool(obj, "vnet_hdr_support",
-                             filter_rewriter_get_vnet_hdr,
-                             filter_rewriter_set_vnet_hdr);
 }
 
 static void colo_rewriter_class_init(ObjectClass *oc, void *data)
 {
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add_bool(oc, "vnet_hdr_support",
+                                   filter_rewriter_get_vnet_hdr,
+                                   filter_rewriter_set_vnet_hdr);
+
     nfc->setup = colo_rewriter_setup;
     nfc->cleanup = colo_rewriter_cleanup;
     nfc->receive_iov = colo_rewriter_receive_iov;
diff --git a/net/filter.c b/net/filter.c
index eac8ba1e9c..3fe88fa43f 100644
--- a/net/filter.c
+++ b/net/filter.c
@@ -212,18 +212,6 @@ static void netfilter_init(Object *obj)
     nf->on = true;
     nf->insert_before_flag = false;
     nf->position = g_strdup("tail");
-
-    object_property_add_str(obj, "netdev",
-                            netfilter_get_netdev_id, netfilter_set_netdev_id);
-    object_property_add_enum(obj, "queue", "NetFilterDirection",
-                             &NetFilterDirection_lookup,
-                             netfilter_get_direction, netfilter_set_direction);
-    object_property_add_str(obj, "status",
-                            netfilter_get_status, netfilter_set_status);
-    object_property_add_str(obj, "position",
-                            netfilter_get_position, netfilter_set_position);
-    object_property_add_str(obj, "insert",
-                            netfilter_get_insert, netfilter_set_insert);
 }
 
 static void netfilter_complete(UserCreatable *uc, Error **errp)
@@ -350,6 +338,18 @@ static void netfilter_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
     NetFilterClass *nfc = NETFILTER_CLASS(oc);
 
+    object_class_property_add_str(oc, "netdev",
+                                  netfilter_get_netdev_id, netfilter_set_netdev_id);
+    object_class_property_add_enum(oc, "queue", "NetFilterDirection",
+                                   &NetFilterDirection_lookup,
+                                   netfilter_get_direction, netfilter_set_direction);
+    object_class_property_add_str(oc, "status",
+                                  netfilter_get_status, netfilter_set_status);
+    object_class_property_add_str(oc, "position",
+                                  netfilter_get_position, netfilter_set_position);
+    object_class_property_add_str(oc, "insert",
+                                  netfilter_get_insert, netfilter_set_insert);
+
     ucc->complete = netfilter_complete;
     nfc->handle_event = default_handle_event;
 }
-- 
2.28.0



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

* [PATCH v2 12/12] input: Use class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (10 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 11/12] netfilter: Use class properties Eduardo Habkost
@ 2020-11-11 18:38 ` Eduardo Habkost
  2020-11-11 21:48   ` Eduardo Habkost
  2020-12-11 21:00 ` [PATCH v2 00/12] qom: Convert some properties to " Eduardo Habkost
  12 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 18:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Daniel P. Berrange, Gerd Hoffmann, Paolo Bonzini

Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com
---
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
---
 ui/input-barrier.c | 22 ++++++++++++++++++++++
 ui/input-linux.c   | 14 ++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/ui/input-barrier.c b/ui/input-barrier.c
index 81b8d04ec8..b3558c3c91 100644
--- a/ui/input-barrier.c
+++ b/ui/input-barrier.c
@@ -695,6 +695,28 @@ static void input_barrier_class_init(ObjectClass *oc, void *data)
 {
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
+    object_class_property_add_str(oc, "name",
+                                  input_barrier_get_name,
+                                  input_barrier_set_name);
+    object_class_property_add_str(oc, "server",
+                                  input_barrier_get_server,
+                                  input_barrier_set_server);
+    object_class_property_add_str(oc, "port",
+                                  input_barrier_get_port,
+                                  input_barrier_set_port);
+    object_class_property_add_str(oc, "x-origin",
+                                  input_barrier_get_x_origin,
+                                  input_barrier_set_x_origin);
+    object_class_property_add_str(oc, "y-origin",
+                                  input_barrier_get_y_origin,
+                                  input_barrier_set_y_origin);
+    object_class_property_add_str(oc, "width",
+                                  input_barrier_get_width,
+                                  input_barrier_set_width);
+    object_class_property_add_str(oc, "height",
+                                  input_barrier_get_height,
+                                  input_barrier_set_height);
+
     ucc->complete = input_barrier_complete;
 
     object_class_property_add_str(oc, "name",
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 05c0c98819..1aaaa5a375 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -496,6 +496,20 @@ static void input_linux_class_init(ObjectClass *oc, void *data)
 {
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
+    object_class_property_add_str(oc, "evdev",
+                                  input_linux_get_evdev,
+                                  input_linux_set_evdev);
+    object_class_property_add_bool(oc, "grab_all",
+                                   input_linux_get_grab_all,
+                                   input_linux_set_grab_all);
+    object_class_property_add_bool(oc, "repeat",
+                                   input_linux_get_repeat,
+                                   input_linux_set_repeat);
+    object_class_property_add_enum(oc, "grab-toggle", "GrabToggleKeys",
+                                   &GrabToggleKeys_lookup,
+                                   input_linux_get_grab_toggle,
+                                   input_linux_set_grab_toggle);
+
     ucc->complete = input_linux_complete;
 
     object_class_property_add_str(oc, "evdev",
-- 
2.28.0



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

* Re: [PATCH v2 01/12] vexpress: Register "secure" as class property
  2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
@ 2020-11-11 19:59   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 19:59 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, qemu-arm, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:38, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 02/12] vexpress-a15: Register "virtualization" as class property
  2020-11-11 18:38 ` [PATCH v2 02/12] vexpress-a15: Register "virtualization" " Eduardo Habkost
@ 2020-11-11 19:59   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 19:59 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, qemu-arm, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:38, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  hw/arm/vexpress.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 03/12] tmp421: Register properties as class properties
  2020-11-11 18:38 ` [PATCH v2 03/12] tmp421: Register properties as class properties Eduardo Habkost
@ 2020-11-11 19:59   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 19:59 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrange, John Snow, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:43, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 05/12] arm/virt: Register most properties as class properties
  2020-11-11 18:38 ` [PATCH v2 05/12] arm/virt: Register most " Eduardo Habkost
@ 2020-11-11 20:03   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 20:03 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, qemu-arm, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:39, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------
>  1 file changed, 41 insertions(+), 35 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 27dbeb549e..53fcaf5e4f 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -2484,6 +2484,47 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
>          NULL, NULL);
>      object_class_property_set_description(oc, "acpi",
>          "Enable ACPI");
> +    object_class_property_add_bool(oc, "secure", virt_get_secure,
> +                                   virt_set_secure);
> +    object_class_property_set_description(oc, "secure",
> +                                                "Set on/off to enable/disable the ARM "
> +                                                "Security Extensions (TrustZone)");

Indent seems to be off here.

Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

(Side note: a 37-character function name seems a bit unwieldy.)

thanks
-- PMM


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

* Re: [PATCH v2 06/12] virt: Register "its" as class property
  2020-11-11 18:38 ` [PATCH v2 06/12] virt: Register "its" as class property Eduardo Habkost
@ 2020-11-11 20:03   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 20:03 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, qemu-arm, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:38, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Note: "its" is currently registered conditionally, but this makes
> the feature be registered unconditionally.  The only side effect
> is that it will be now possible to set its=on on virt-2.7 and
> older.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 07/12] arm/cpu64: Register "aarch64" as class property
  2020-11-11 18:38 ` [PATCH v2 07/12] arm/cpu64: Register "aarch64" " Eduardo Habkost
@ 2020-11-11 20:04   ` Peter Maydell
  0 siblings, 0 replies; 27+ messages in thread
From: Peter Maydell @ 2020-11-11 20:04 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, qemu-arm, Daniel P. Berrange, QEMU Developers, Paolo Bonzini

On Wed, 11 Nov 2020 at 18:38, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-arm@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  target/arm/cpu64.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 12/12] input: Use class properties
  2020-11-11 18:38 ` [PATCH v2 12/12] input: " Eduardo Habkost
@ 2020-11-11 21:48   ` Eduardo Habkost
  0 siblings, 0 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-11-11 21:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Daniel P. Berrange, Gerd Hoffmann, Paolo Bonzini

On Wed, Nov 11, 2020 at 01:38:23PM -0500, Eduardo Habkost wrote:
> Instance properties make introspection hard and are not shown by
> "-object ...,help".  Convert them to class properties.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> This was originally submitted as part of the series:
> Subject: [PATCH 00/12] qom: Make all -object types use only class properties
> Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
> https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat.com

Oops, please ignore this one, I was too eager when cherry-picking
patches from the other series.  The original patch was already
merged to master.

-- 
Eduardo



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

* Re: [PATCH v2 08/12] can_host: Use class properties
  2020-11-11 18:38 ` [PATCH v2 08/12] can_host: Use class properties Eduardo Habkost
@ 2020-11-11 23:02   ` Pavel Pisa
  0 siblings, 0 replies; 27+ messages in thread
From: Pavel Pisa @ 2020-11-11 23:02 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Vikram Garhwal, Daniel P. Berrange, Jason Wang,
	qemu-devel, Ondrej Ille, Paolo Bonzini, John Snow

Hello Eduardo,

thanks for contribution.

On Wednesday 11 of November 2020 19:38:19 Eduardo Habkost wrote:
> Instance properties make introspection hard and are not shown by
> "-object ...,help".  Convert them to class properties.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> This was originally submitted as part of the series:
> Subject: [PATCH 00/12] qom: Make all -object types use only class
> properties Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
> https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat
>.com ---
> Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> Cc: Vikram Garhwal <fnu.vikram@xilinx.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  net/can/can_host.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/net/can/can_host.c b/net/can/can_host.c
> index be4547d913..bec88b9620 100644
> --- a/net/can/can_host.c
> +++ b/net/can/can_host.c
> @@ -72,21 +72,16 @@ static void can_host_complete(UserCreatable *uc, Error
> **errp) can_host_connect(CAN_HOST(uc), errp);
>  }
>
> -static void can_host_instance_init(Object *obj)
> -{
> -    CanHostState *ch = CAN_HOST(obj);
> -
> -    object_property_add_link(obj, "canbus", TYPE_CAN_BUS,
> -                             (Object **)&ch->bus,
> -                             object_property_allow_set_link,
> -                             OBJ_PROP_LINK_STRONG);
> -}
> -
>  static void can_host_class_init(ObjectClass *klass,
>                                  void *class_data G_GNUC_UNUSED)
>  {
>      UserCreatableClass *uc_klass = USER_CREATABLE_CLASS(klass);
>
> +    object_class_property_add_link(klass, "canbus", TYPE_CAN_BUS,
> +                                   offsetof(CanHostState, bus),
> +                                   object_property_allow_set_link,
> +                                   OBJ_PROP_LINK_STRONG);
> +
>      klass->unparent = can_host_unparent;
>      uc_klass->complete = can_host_complete;
>  }
> @@ -97,7 +92,6 @@ static const TypeInfo can_host_info = {
>      .instance_size = sizeof(CanHostState),
>      .class_size = sizeof(CanHostClass),
>      .abstract = true,
> -    .instance_init = can_host_instance_init,
>      .class_init = can_host_class_init,
>      .interfaces = (InterfaceInfo[]) {
>          { TYPE_USER_CREATABLE },

I have rerun successfully my basic test (1x SJA1000 CAN FD tolerant, 2x CTU 
CAN FD and 1x host interface) based on actual updated sources
with Peter Maydell coverity fixes. You can add my

Tested-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>

I cannot confirm that this is the right direction because I do not have
knowledge about long term intentions of core developers. But change
and description look good.

Somebody with a commit rights need to push patch to the mainline direction.

Best wishes,

Pavel Pisa


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

* RE: [PATCH v2 09/12] colo: Use class properties
  2020-11-11 18:38 ` [PATCH v2 09/12] colo: " Eduardo Habkost
@ 2020-11-13  3:04   ` Zhang, Chen
  2020-12-11 20:59     ` Eduardo Habkost
  0 siblings, 1 reply; 27+ messages in thread
From: Zhang, Chen @ 2020-11-13  3:04 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: John Snow, Jason Wang, Daniel P. Berrange, Li Zhijian, Paolo Bonzini

Looks good for me, but Qemu still have lots of parts use object_property_add, do you have plan to change it?

Reviewed-by: Zhang Chen <chen.zhang@intel.com>

Thanks
Chen

> -----Original Message-----
> From: Eduardo Habkost <ehabkost@redhat.com>
> Sent: Thursday, November 12, 2020 2:38 AM
> To: qemu-devel@nongnu.org
> Cc: Daniel P. Berrange <berrange@redhat.com>; John Snow
> <jsnow@redhat.com>; Paolo Bonzini <pbonzini@redhat.com>; Zhang, Chen
> <chen.zhang@intel.com>; Li Zhijian <lizhijian@cn.fujitsu.com>; Jason Wang
> <jasowang@redhat.com>
> Subject: [PATCH v2 09/12] colo: Use class properties
> 
> Instance properties make introspection hard and are not shown by "-
> object ...,help".  Convert them to class properties.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> This was originally submitted as part of the series:
> Subject: [PATCH 00/12] qom: Make all -object types use only class properties
> Message-Id: <20201009160122.1662082-1-ehabkost@redhat.com>
> https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-
> ehabkost@redhat.com
> ---
> Cc: Zhang Chen <chen.zhang@intel.com>
> Cc: Li Zhijian <lizhijian@cn.fujitsu.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  net/colo-compare.c | 57 +++++++++++++++++++++++-----------------------
>  1 file changed, 29 insertions(+), 28 deletions(-)
> 
> diff --git a/net/colo-compare.c b/net/colo-compare.c index
> 3a45d64175..017e82dd8b 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -1375,6 +1375,35 @@ static void colo_compare_class_init(ObjectClass
> *oc, void *data)  {
>      UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
> 
> +    object_class_property_add_str(oc, "primary_in",
> +                                  compare_get_pri_indev, compare_set_pri_indev);
> +    object_class_property_add_str(oc, "secondary_in",
> +                                  compare_get_sec_indev, compare_set_sec_indev);
> +    object_class_property_add_str(oc, "outdev",
> +                                  compare_get_outdev, compare_set_outdev);
> +    object_class_property_add_link(oc, "iothread", TYPE_IOTHREAD,
> +                                  offsetof(CompareState, iothread),
> +                                  object_property_allow_set_link,
> +                                  OBJ_PROP_LINK_STRONG);
> +    /* This parameter just for Xen COLO */
> +    object_class_property_add_str(oc, "notify_dev",
> +                                  compare_get_notify_dev,
> + compare_set_notify_dev);
> +
> +    object_class_property_add(oc, "compare_timeout", "uint32",
> +                              compare_get_timeout,
> +                              compare_set_timeout, NULL, NULL);
> +
> +    object_class_property_add(oc, "expired_scan_cycle", "uint32",
> +                              compare_get_expired_scan_cycle,
> +                              compare_set_expired_scan_cycle, NULL,
> + NULL);
> +
> +    object_class_property_add(oc, "max_queue_size", "uint32",
> +                              get_max_queue_size,
> +                              set_max_queue_size, NULL, NULL);
> +
> +    object_class_property_add_bool(oc, "vnet_hdr_support",
> compare_get_vnet_hdr,
> +                                   compare_set_vnet_hdr);
> +
>      ucc->complete = colo_compare_complete;  }
> 
> @@ -1382,35 +1411,7 @@ static void colo_compare_init(Object *obj)  {
>      CompareState *s = COLO_COMPARE(obj);
> 
> -    object_property_add_str(obj, "primary_in",
> -                            compare_get_pri_indev, compare_set_pri_indev);
> -    object_property_add_str(obj, "secondary_in",
> -                            compare_get_sec_indev, compare_set_sec_indev);
> -    object_property_add_str(obj, "outdev",
> -                            compare_get_outdev, compare_set_outdev);
> -    object_property_add_link(obj, "iothread", TYPE_IOTHREAD,
> -                            (Object **)&s->iothread,
> -                            object_property_allow_set_link,
> -                            OBJ_PROP_LINK_STRONG);
> -    /* This parameter just for Xen COLO */
> -    object_property_add_str(obj, "notify_dev",
> -                            compare_get_notify_dev, compare_set_notify_dev);
> -
> -    object_property_add(obj, "compare_timeout", "uint32",
> -                        compare_get_timeout,
> -                        compare_set_timeout, NULL, NULL);
> -
> -    object_property_add(obj, "expired_scan_cycle", "uint32",
> -                        compare_get_expired_scan_cycle,
> -                        compare_set_expired_scan_cycle, NULL, NULL);
> -
> -    object_property_add(obj, "max_queue_size", "uint32",
> -                        get_max_queue_size,
> -                        set_max_queue_size, NULL, NULL);
> -
>      s->vnet_hdr = false;
> -    object_property_add_bool(obj, "vnet_hdr_support",
> compare_get_vnet_hdr,
> -                             compare_set_vnet_hdr);
>  }
> 
>  static void colo_compare_finalize(Object *obj)
> --
> 2.28.0



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

* Re: [PATCH v2 09/12] colo: Use class properties
  2020-11-13  3:04   ` Zhang, Chen
@ 2020-12-11 20:59     ` Eduardo Habkost
  0 siblings, 0 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-12-11 20:59 UTC (permalink / raw)
  To: Zhang, Chen
  Cc: Daniel P. Berrange, Li Zhijian, Jason Wang, qemu-devel,
	Paolo Bonzini, John Snow

On Fri, Nov 13, 2020 at 03:04:55AM +0000, Zhang, Chen wrote:
> Looks good for me, but Qemu still have lots of parts use
> object_property_add, do you have plan to change it?

Thanks!

The plan is to minimize usage of object_property_add(), but
that's a huge task.  We're doing it gradually when it is more
useful (like on user-visible devices or backend objects).

-- 
Eduardo



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

* Re: [PATCH v2 00/12] qom: Convert some properties to class properties
  2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
                   ` (11 preceding siblings ...)
  2020-11-11 18:38 ` [PATCH v2 12/12] input: " Eduardo Habkost
@ 2020-12-11 21:00 ` Eduardo Habkost
  12 siblings, 0 replies; 27+ messages in thread
From: Eduardo Habkost @ 2020-12-11 21:00 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell, Pavel Pisa, Zhang, Chen
  Cc: Vikram Garhwal, Daniel P. Berrange, Li Zhijian, Jason Wang,
	Ondrej Ille, qemu-arm, Gerd Hoffmann, Paolo Bonzini, John Snow,
	Richard Henderson

On Wed, Nov 11, 2020 at 01:38:11PM -0500, Eduardo Habkost wrote:
> Class properties make QOM introspection simpler and easier, as it
> doesn't require an object to be instantiated.  This series
> converts a few existing object_property_add*() calls to register
> class properties instead.
> 
> Changes v1 -> v2:
> * Bug fix at "i386: Register feature bit properties as class properties"
> * Included patches that were originally submnitted as part of
>   "qom: Make all -object types use only class properties"
> * All other patches are unchanged from v1

I'm queueing this series, excluding patch 12/12.

-- 
Eduardo



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

* Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
  2020-11-11 18:38 ` [PATCH v2 04/12] i386: Register feature bit " Eduardo Habkost
@ 2020-12-15 14:11   ` Markus Armbruster
  2020-12-15 15:01     ` Eduardo Habkost
  0 siblings, 1 reply; 27+ messages in thread
From: Markus Armbruster @ 2020-12-15 14:11 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Daniel P. Berrange, Paolo Bonzini, John Snow, qemu-devel,
	Richard Henderson

Eduardo Habkost <ehabkost@redhat.com> writes:

> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

This is significantly more than just "simpler and easier".

The other day, I played with the QMP core to reduce its appetite for
malloc.  I came up with patches that should approximately halve it, and
felt quite pleased with myself.  I looked for a simple test to
demonstrate the effect.  Something with plenty of output.  Hmm, why not
query-cpu-definitions, it produces about 32KiB.  Instrument, instrument,
run, ... whaaaat?!?

My patches save some 7000 allocations (670 KiB total), roughly matching
my expectations.

Turns out this is a drop in the bucket: query-cpu-definitions still
takes some 180,000 allocations (almost 12 MiB total).  They're hiding
behind this line in qmp_query_cpu_definitions():

    g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);

The line takes more than a quarter second for me.

Hogging the main loop for a quarter second is not good.

Eduardo's patch reduces run time to 0.02 seconds (40,000 allocations, 9
MiB total).  It's a smaller pig now.



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

* Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
  2020-12-15 14:11   ` Markus Armbruster
@ 2020-12-15 15:01     ` Eduardo Habkost
  2020-12-16  5:35       ` Markus Armbruster
  0 siblings, 1 reply; 27+ messages in thread
From: Eduardo Habkost @ 2020-12-15 15:01 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Daniel P. Berrange, Paolo Bonzini, John Snow, qemu-devel,
	Richard Henderson

On Tue, Dec 15, 2020 at 03:11:06PM +0100, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > Class properties make QOM introspection simpler and easier, as
> > they don't require an object to be instantiated.
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> This is significantly more than just "simpler and easier".
> 
> The other day, I played with the QMP core to reduce its appetite for
> malloc.  I came up with patches that should approximately halve it, and
> felt quite pleased with myself.  I looked for a simple test to
> demonstrate the effect.  Something with plenty of output.  Hmm, why not
> query-cpu-definitions, it produces about 32KiB.  Instrument, instrument,
> run, ... whaaaat?!?
> 
> My patches save some 7000 allocations (670 KiB total), roughly matching
> my expectations.
> 
> Turns out this is a drop in the bucket: query-cpu-definitions still
> takes some 180,000 allocations (almost 12 MiB total).  They're hiding
> behind this line in qmp_query_cpu_definitions():
> 
>     g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);
> 
> The line takes more than a quarter second for me.
> 
> Hogging the main loop for a quarter second is not good.

Wow!

> 
> Eduardo's patch reduces run time to 0.02 seconds (40,000 allocations, 9
> MiB total).  It's a smaller pig now.

Thanks for investigating this!  I'll amend the commit message with:

  Also, the hundreds of instance properties were having an impact
  on QMP commands that create temporary CPU objects.  On my
  machine, run time of qmp_query_cpu_definitions() patch changed
  from ~200ms to ~16ms after applying this patch.

Numbers were obtained with:

 $ sudo perf probe -v -x ./qemu-system-x86_64 -a 'qmp_query_cpu_definitions%return' -a 'qmp_query_cpu_definitions'
 $ echo -e '{"execute": "qmp_capabilities"}\n{"execute": "query-cpu-definitions"}\n{"execute": "quit"}' | sudo perf trace -e 'probe_qemu:*' ./qemu-system-x86_64 -S -display none -qmp stdio > /dev/null

Before:

     0.000 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94851767056275)
   204.072 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94851767056275, __probe_ret_ip: 94851768499362)

After:

     0.000 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94554723186579)
    16.445 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94554723186579, __probe_ret_ip: 94554724629631)


-- 
Eduardo



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

* Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
  2020-12-15 15:01     ` Eduardo Habkost
@ 2020-12-16  5:35       ` Markus Armbruster
  0 siblings, 0 replies; 27+ messages in thread
From: Markus Armbruster @ 2020-12-16  5:35 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: John Snow, Paolo Bonzini, Daniel P. Berrange, qemu-devel,
	Richard Henderson

Eduardo Habkost <ehabkost@redhat.com> writes:

> On Tue, Dec 15, 2020 at 03:11:06PM +0100, Markus Armbruster wrote:
>> Eduardo Habkost <ehabkost@redhat.com> writes:
>> 
>> > Class properties make QOM introspection simpler and easier, as
>> > they don't require an object to be instantiated.
>> >
>> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> 
>> This is significantly more than just "simpler and easier".
>> 
>> The other day, I played with the QMP core to reduce its appetite for
>> malloc.  I came up with patches that should approximately halve it, and
>> felt quite pleased with myself.  I looked for a simple test to
>> demonstrate the effect.  Something with plenty of output.  Hmm, why not
>> query-cpu-definitions, it produces about 32KiB.  Instrument, instrument,
>> run, ... whaaaat?!?
>> 
>> My patches save some 7000 allocations (670 KiB total), roughly matching
>> my expectations.
>> 
>> Turns out this is a drop in the bucket: query-cpu-definitions still
>> takes some 180,000 allocations (almost 12 MiB total).  They're hiding
>> behind this line in qmp_query_cpu_definitions():
>> 
>>     g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);
>> 
>> The line takes more than a quarter second for me.
>> 
>> Hogging the main loop for a quarter second is not good.
>
> Wow!
>
>> 
>> Eduardo's patch reduces run time to 0.02 seconds (40,000 allocations, 9
>> MiB total).  It's a smaller pig now.
>
> Thanks for investigating this!  I'll amend the commit message with:
>
>   Also, the hundreds of instance properties were having an impact
>   on QMP commands that create temporary CPU objects.  On my
>   machine, run time of qmp_query_cpu_definitions() patch changed
>   from ~200ms to ~16ms after applying this patch.
>
> Numbers were obtained with:
>
>  $ sudo perf probe -v -x ./qemu-system-x86_64 -a 'qmp_query_cpu_definitions%return' -a 'qmp_query_cpu_definitions'
>  $ echo -e '{"execute": "qmp_capabilities"}\n{"execute": "query-cpu-definitions"}\n{"execute": "quit"}' | sudo perf trace -e 'probe_qemu:*' ./qemu-system-x86_64 -S -display none -qmp stdio > /dev/null
>
> Before:
>
>      0.000 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94851767056275)
>    204.072 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94851767056275, __probe_ret_ip: 94851768499362)
>
> After:
>
>      0.000 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94554723186579)
>     16.445 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94554723186579, __probe_ret_ip: 94554724629631)

Looks good, thanks!



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

end of thread, other threads:[~2020-12-16  5:36 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 02/12] vexpress-a15: Register "virtualization" " Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 03/12] tmp421: Register properties as class properties Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 04/12] i386: Register feature bit " Eduardo Habkost
2020-12-15 14:11   ` Markus Armbruster
2020-12-15 15:01     ` Eduardo Habkost
2020-12-16  5:35       ` Markus Armbruster
2020-11-11 18:38 ` [PATCH v2 05/12] arm/virt: Register most " Eduardo Habkost
2020-11-11 20:03   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 06/12] virt: Register "its" as class property Eduardo Habkost
2020-11-11 20:03   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 07/12] arm/cpu64: Register "aarch64" " Eduardo Habkost
2020-11-11 20:04   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 08/12] can_host: Use class properties Eduardo Habkost
2020-11-11 23:02   ` Pavel Pisa
2020-11-11 18:38 ` [PATCH v2 09/12] colo: " Eduardo Habkost
2020-11-13  3:04   ` Zhang, Chen
2020-12-11 20:59     ` Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 10/12] netfilter: Reorder functions Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 11/12] netfilter: Use class properties Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 12/12] input: " Eduardo Habkost
2020-11-11 21:48   ` Eduardo Habkost
2020-12-11 21:00 ` [PATCH v2 00/12] qom: Convert some properties to " Eduardo Habkost

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