qom: Convert some properties to class properties
Subsystems (3)
v2 cover qom: Convert some properties to class properties
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(-)
Signature · 1 line
2.28.0
PATCH v2 1/12 vexpress: Register "secure" as class property
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- hw/arm/vexpress.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/arm/vexpress.c +6 -5
@@ -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)
Signature · 1 line
2.28.0
Re: [PATCH v2 01/12] vexpress: Register "secure" as class property
Quoted 10 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
thanks
-- PMM
PATCH v2 2/12 vexpress-a15: Register "virtualization" as class property
In reply to Eduardo HabkostClass properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- hw/arm/vexpress.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
hw/arm/vexpress.c +8 -6
@@ -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 = {
Signature · 1 line
2.28.0
Re: [PATCH v2 02/12] vexpress-a15: Register "virtualization" as class property
Quoted 4 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Quoted 9 lines
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]--- hw/arm/vexpress.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
thanks
-- PMM
PATCH v2 3/12 tmp421: Register properties as class properties
In reply to Eduardo HabkostClass properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
Cc: [email protected]
--- hw/misc/tmp421.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
hw/misc/tmp421.c +13 -17
@@ -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, };
Signature · 1 line
2.28.0
Re: [PATCH v2 03/12] tmp421: Register properties as class properties
Quoted 6 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>---
thanks
-- PMM
PATCH v2 4/12 i386: Register feature bit properties as class properties
In reply to Eduardo HabkostClass properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
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 <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
--- target/i386/cpu.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-)
target/i386/cpu.c +16 -24
@@ -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 = {
Signature · 1 line
2.28.0
Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
Quoted 4 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>
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.
Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
Quoted 23 lines · Markus Armbruster
Quoted 4 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>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():
Quoted 5 lines
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!
Quoted 3 lines
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/nullBefore:
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)Signature · 1 line
Eduardo
Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
Quoted 50 lines · Eduardo Habkost
Quoted 23 lines · Markus Armbruster
Quoted 4 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>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():Quoted 5 lines
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!
Quoted 3 lines
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/nullBefore:
Quoted 7 lines
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!
PATCH v2 5/12 arm/virt: Register most properties as class properties
In reply to Eduardo HabkostClass properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 35 deletions(-)
hw/arm/virt.c +41 -35
@@ -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;
Signature · 1 line
2.28.0
Re: [PATCH v2 05/12] arm/virt: Register most properties as class properties
Quoted 18 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]--- hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 35 deletions(-)hw/arm/virt.c +0
-0
hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 2491
Quoted 8 lines
hw/arm/virt.c +5
-0@@ -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
(Side note: a 37-character function name seems a bit unwieldy.)
thanks
-- PMM
PATCH v2 6/12 virt: Register "its" as class property
In reply to Eduardo HabkostClass 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.
---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- hw/arm/virt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
hw/arm/virt.c +7 -5
@@ -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 */
Signature · 1 line
2.28.0
Re: [PATCH v2 06/12] virt: Register "its" as class property
Quoted 9 lines · Eduardo Habkost
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.
Quoted 5 lines
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
thanks
-- PMM
PATCH v2 7/12 arm/cpu64: Register "aarch64" as class property
In reply to Eduardo HabkostClass properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- target/arm/cpu64.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
target/arm/cpu64.c +6 -10
@@ -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),
Signature · 1 line
2.28.0
Re: [PATCH v2 07/12] arm/cpu64: Register "aarch64" as class property
Quoted 4 lines · Eduardo Habkost
Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.
Quoted 8 lines
Signed-off-by Eduardo Habkost <[email protected]>---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]--- target/arm/cpu64.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
thanks
-- PMM
PATCH v2 8/12 can_host: Use class properties
In reply to Eduardo HabkostInstance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties.
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
---
Cc: Pavel Pisa <[email protected]>
Cc: Vikram Garhwal <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]
--- net/can/can_host.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
net/can/can_host.c +5 -11
@@ -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 },
Signature · 1 line
2.28.0
Re: [PATCH v2 08/12] can_host: Use class properties
Hello Eduardo,
thanks for contribution.
Quoted 50 lines · 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 <[email protected]>---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-ehabkost@redhat
.com ---
Cc: Pavel Pisa <[email protected]>
Cc: Vikram Garhwal <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]--- net/can/can_host.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)net/can/can_host.c +5
-10@@ -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; }
net/can/can_host.c static const TypeInfo can_host_info = { · line 97
Quoted 7 lines
net/can/can_host.c +0
-1@@ -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
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
PATCH v2 9/12 colo: Use class properties
In reply to Eduardo HabkostInstance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties.
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
---
Cc: Zhang Chen <[email protected]>
Cc: Li Zhijian <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]
--- net/colo-compare.c | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-)
net/colo-compare.c +29 -28
@@ -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)
Signature · 1 line
2.28.0
RE: [PATCH v2 09/12] colo: Use class properties
Looks good for me, but Qemu still have lots of parts use object_property_add, do you have plan to change it?
Thanks
Chen
Quoted 109 lines
-----Original Message-----
From: Eduardo Habkost <[email protected]>
Sent: Thursday, November 12, 2020 2:38 AM
To: [email protected]
Cc: Daniel P. Berrange <[email protected]>; John Snow <[email protected]>; Paolo Bonzini <[email protected]>; Zhang, Chen <[email protected]>; Li Zhijian <[email protected]>; Jason Wang <[email protected]>
Subject: [PATCH v2 09/12] colo: Use class propertiesInstance properties make introspection hard and are not shown by "- object ...,help". Convert them to class properties.
Signed-off-by Eduardo Habkost <[email protected]>---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/20201009160122.1662082-1-
[email protected]
---
Cc: Zhang Chen <[email protected]>
Cc: Li Zhijian <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]--- net/colo-compare.c | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-)net/colo-compare.c index renamed from net/colo-compare.c +0
-0
3a45d64175..017e82dd8b100644net/colo-compare.c +31
-29@@ -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
Re: [PATCH v2 09/12] colo: Use class properties
Quoted 2 lines · Chen
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).
Signature · 1 line
Eduardo
PATCH v2 10/12 netfilter: Reorder functions
In reply to Eduardo HabkostTrivial code reordering in some filter backends, to make the next changes easier to review.
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
---
Cc: Jason Wang <[email protected]>
Cc: Zhang Chen <[email protected]>
Cc: Li Zhijian <[email protected]>
Cc: [email protected]
--- net/filter-buffer.c | 20 ++++++++++---------- net/filter-mirror.c | 36 ++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 28 deletions(-)
net/filter-buffer.c +10 -10
@@ -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",
net/filter-mirror.c +18 -18
@@ -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);
Signature · 1 line
2.28.0
PATCH v2 11/12 netfilter: Use class properties
In reply to Eduardo HabkostInstance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties.
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
---
Cc: Jason Wang <[email protected]>
Cc: Zhang Chen <[email protected]>
Cc: Li Zhijian <[email protected]>
Cc: [email protected]
--- 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(-)
net/dump.c +5 -5
@@ -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;
net/filter-buffer.c +4 -8
@@ -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), };
net/filter-mirror.c +14 -14
@@ -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)
net/filter-rewriter.c +4 -3
@@ -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;
net/filter.c +12 -12
@@ -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; }
Signature · 1 line
2.28.0
PATCH v2 12/12 input: Use class properties
In reply to Eduardo HabkostInstance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties.
---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
---
Cc: Gerd Hoffmann <[email protected]>
Cc: [email protected]
--- ui/input-barrier.c | 22 ++++++++++++++++++++++ ui/input-linux.c | 14 ++++++++++++++ 2 files changed, 36 insertions(+)
ui/input-barrier.c +22 -0
@@ -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",
ui/input-linux.c +14 -0
@@ -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",
Signature · 1 line
2.28.0
Re: [PATCH v2 12/12] input: Use class properties
Quoted 9 lines · Eduardo Habkost
Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties.
Signed-off-by Eduardo Habkost <[email protected]>---
This was originally submitted as part of the series:
Subject: [PATCH 00/12] qom: Make all -object types use only class properties
Message-Id: <[email protected]>
https://lore.kernel.org/qemu-devel/[email protected]
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.
Signature · 1 line
Eduardo
Quoted 10 lines · Eduardo Habkost
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.
Signature · 1 line
Eduardo