qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [PATCH] cpu: Register QOM links at /machine/cpus/<index>
@ 2015-04-30 20:21 Andreas Färber
  2015-04-30 21:47 ` Paolo Bonzini
  2015-05-01 12:08 ` Eduardo Habkost
  0 siblings, 2 replies; 17+ messages in thread
From: Andreas Färber @ 2015-04-30 20:21 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: peter.maydell, mimu, bharata, agraf, qemu-devel, borntraeger,
	Paolo Bonzini, cornelia.huck, Igor Mammedov, david

First I did not participate in that discussion, second nack to that self pointer. Please hold off on this until I'm back. Andreas

Eduardo Habkost <ehabkost@redhat.com> schrieb:

>This will provide a predictable path for the CPU objects, and a more
>powerful alternative for the query-cpus QMP command, as now every QOM
>property on CPU objects can be easily queried.
>
>Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>---
>Note that this doesn't replace any future topology enumeration
>mechanisms we may choose to implement. It just replaces the existing
>topology-unaware VCPU enumeration mechanism that is query-cpus.
>
>Reference to previous discussion:
>
>  Date: Thu, 23 Apr 2015 10:17:36 -0300
>  From: Eduardo Habkost <ehabkost@redhat.com>
>  Subject: Re: [Qemu-devel] cpu modelling and hotplug (was: [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1)
>  Message-ID: <20150423131736.GA17796@thinpad.lan.raisama.net>
>---
> exec.c            | 16 ++++++++++++++++
> include/qom/cpu.h |  3 +++
> 2 files changed, 19 insertions(+)
>
>diff --git a/exec.c b/exec.c
>index ae37b98..8bdfa65 100644
>--- a/exec.c
>+++ b/exec.c
>@@ -519,6 +519,20 @@ void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as)
> }
> #endif
> 
>+static void cpu_add_qom_link(CPUState *cpu)
>+{
>+#if !defined(CONFIG_USER_ONLY)
>+    Object *cobj = OBJECT(cpu);
>+    Object *cpu_container = container_get(OBJECT(current_machine), "/cpus");
>+    char *path = g_strdup_printf("%d", cpu->cpu_index);
>+
>+    cpu->self = cobj;
>+    object_property_add_link(cpu_container, path, TYPE_CPU, &cpu->self, NULL,
>+                             OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
>+    g_free(path);
>+#endif
>+}
>+
> void cpu_exec_init(CPUArchState *env)
> {
>     CPUState *cpu = ENV_GET_CPU(env);
>@@ -558,6 +572,8 @@ void cpu_exec_init(CPUArchState *env)
>     if (cc->vmsd != NULL) {
>         vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
>     }
>+
>+    cpu_add_qom_link(cpu);
> }
> 
> #if defined(CONFIG_USER_ONLY)
>diff --git a/include/qom/cpu.h b/include/qom/cpu.h
>index 39f0f19..c253420 100644
>--- a/include/qom/cpu.h
>+++ b/include/qom/cpu.h
>@@ -246,6 +246,9 @@ struct CPUState {
>     DeviceState parent_obj;
>     /*< public >*/
> 
>+    /* Needed for the /machine/cpus/<index> link */
>+    Object *self;
>+
>     int nr_cores;
>     int nr_threads;
>     int numa_node;
>-- 
>2.1.0
>

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH] cpu: Register QOM links at /machine/cpus/<index>
@ 2015-04-30 19:19 Eduardo Habkost
  2015-05-01  1:51 ` Peter Crosthwaite
  2015-05-04  9:47 ` Igor Mammedov
  0 siblings, 2 replies; 17+ messages in thread
From: Eduardo Habkost @ 2015-04-30 19:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, mimu, bharata, agraf, borntraeger, Paolo Bonzini,
	cornelia.huck, Igor Mammedov, Andreas Färber, david

This will provide a predictable path for the CPU objects, and a more
powerful alternative for the query-cpus QMP command, as now every QOM
property on CPU objects can be easily queried.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Note that this doesn't replace any future topology enumeration
mechanisms we may choose to implement. It just replaces the existing
topology-unaware VCPU enumeration mechanism that is query-cpus.

Reference to previous discussion:

  Date: Thu, 23 Apr 2015 10:17:36 -0300
  From: Eduardo Habkost <ehabkost@redhat.com>
  Subject: Re: [Qemu-devel] cpu modelling and hotplug (was: [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1)
  Message-ID: <20150423131736.GA17796@thinpad.lan.raisama.net>
---
 exec.c            | 16 ++++++++++++++++
 include/qom/cpu.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/exec.c b/exec.c
index ae37b98..8bdfa65 100644
--- a/exec.c
+++ b/exec.c
@@ -519,6 +519,20 @@ void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as)
 }
 #endif
 
+static void cpu_add_qom_link(CPUState *cpu)
+{
+#if !defined(CONFIG_USER_ONLY)
+    Object *cobj = OBJECT(cpu);
+    Object *cpu_container = container_get(OBJECT(current_machine), "/cpus");
+    char *path = g_strdup_printf("%d", cpu->cpu_index);
+
+    cpu->self = cobj;
+    object_property_add_link(cpu_container, path, TYPE_CPU, &cpu->self, NULL,
+                             OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
+    g_free(path);
+#endif
+}
+
 void cpu_exec_init(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
@@ -558,6 +572,8 @@ void cpu_exec_init(CPUArchState *env)
     if (cc->vmsd != NULL) {
         vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
     }
+
+    cpu_add_qom_link(cpu);
 }
 
 #if defined(CONFIG_USER_ONLY)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 39f0f19..c253420 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -246,6 +246,9 @@ struct CPUState {
     DeviceState parent_obj;
     /*< public >*/
 
+    /* Needed for the /machine/cpus/<index> link */
+    Object *self;
+
     int nr_cores;
     int nr_threads;
     int numa_node;
-- 
2.1.0

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

end of thread, other threads:[~2015-05-05 10:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-30 20:21 [Qemu-devel] [PATCH] cpu: Register QOM links at /machine/cpus/<index> Andreas Färber
2015-04-30 21:47 ` Paolo Bonzini
2015-05-01  1:54   ` Peter Crosthwaite
2015-05-01 11:59   ` Eduardo Habkost
2015-05-05 10:23     ` Paolo Bonzini
2015-05-01 12:08 ` Eduardo Habkost
  -- strict thread matches above, loose matches on Subject: below --
2015-04-30 19:19 Eduardo Habkost
2015-05-01  1:51 ` Peter Crosthwaite
2015-05-01 12:17   ` Eduardo Habkost
2015-05-04  9:47 ` Igor Mammedov
2015-05-04  9:59   ` Paolo Bonzini
2015-05-04 13:16     ` Igor Mammedov
2015-05-04 13:19       ` Paolo Bonzini
2015-05-04 14:05         ` Eduardo Habkost
2015-05-04 15:53           ` Paolo Bonzini
2015-05-04 18:37             ` Eduardo Habkost
2015-05-04 13:37       ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).