diff mbox series

[17/24] cpu/core: Register core-id and nr-threads as class properties

Message ID 20200921221045.699690-18-ehabkost@redhat.com
State New, archived
Headers show
Series qom: Convert some properties to class properties | expand

Commit Message

Eduardo Habkost Sept. 21, 2020, 10:10 p.m. UTC
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/cpu/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Igor Mammedov Sept. 22, 2020, 6:48 a.m. UTC | #1
On Mon, 21 Sep 2020 18:10:38 -0400
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: Igor Mammedov <imammedo@redhat.com>

> ---
> Cc: qemu-devel@nongnu.org
> ---
>  hw/cpu/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/cpu/core.c b/hw/cpu/core.c
> index 3a659291eae..92d3b2fbad6 100644
> --- a/hw/cpu/core.c
> +++ b/hw/cpu/core.c
> @@ -69,10 +69,6 @@ static void cpu_core_instance_init(Object *obj)
>      MachineState *ms = MACHINE(qdev_get_machine());
>      CPUCore *core = CPU_CORE(obj);
>  
> -    object_property_add(obj, "core-id", "int", core_prop_get_core_id,
> -                        core_prop_set_core_id, NULL, NULL);
> -    object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
> -                        core_prop_set_nr_threads, NULL, NULL);
>      core->nr_threads = ms->smp.threads;
>  }
>  
> @@ -81,6 +77,10 @@ static void cpu_core_class_init(ObjectClass *oc, void *data)
>      DeviceClass *dc = DEVICE_CLASS(oc);
>  
>      set_bit(DEVICE_CATEGORY_CPU, dc->categories);
> +    object_class_property_add(oc, "core-id", "int", core_prop_get_core_id,
> +                              core_prop_set_core_id, NULL, NULL);
> +    object_class_property_add(oc, "nr-threads", "int", core_prop_get_nr_threads,
> +                              core_prop_set_nr_threads, NULL, NULL);
>  }
>  
>  static const TypeInfo cpu_core_type_info = {
diff mbox series

Patch

diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index 3a659291eae..92d3b2fbad6 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -69,10 +69,6 @@  static void cpu_core_instance_init(Object *obj)
     MachineState *ms = MACHINE(qdev_get_machine());
     CPUCore *core = CPU_CORE(obj);
 
-    object_property_add(obj, "core-id", "int", core_prop_get_core_id,
-                        core_prop_set_core_id, NULL, NULL);
-    object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
-                        core_prop_set_nr_threads, NULL, NULL);
     core->nr_threads = ms->smp.threads;
 }
 
@@ -81,6 +77,10 @@  static void cpu_core_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     set_bit(DEVICE_CATEGORY_CPU, dc->categories);
+    object_class_property_add(oc, "core-id", "int", core_prop_get_core_id,
+                              core_prop_set_core_id, NULL, NULL);
+    object_class_property_add(oc, "nr-threads", "int", core_prop_get_nr_threads,
+                              core_prop_set_nr_threads, NULL, NULL);
 }
 
 static const TypeInfo cpu_core_type_info = {