[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/2] cpu: Register QOM links at /machine/cpus[<in
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v2 2/2] cpu: Register QOM links at /machine/cpus[<index>] |
Date: |
Fri, 1 May 2015 11:09:07 -0300 |
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 <address@hidden>
---
Changes v1 -> v2:
* Use object_property_add_const_link()
* Use "/machine/cpus[<index>]" instead of "/machine/cpus/<index>"
* Grab reference to object before adding link
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.
References to previous discussions:
Date: Thu, 23 Apr 2015 10:17:36 -0300
From: Eduardo Habkost <address@hidden>
Subject: Re: [Qemu-devel] cpu modelling and hotplug (was: [PATCH RFC 0/4]
target-i386: PC socket/core/thread modeling, part 1)
Message-ID: <address@hidden>
Date: Tue, 31 Mar 2015 10:16:23 -0300
From: Eduardo Habkost <address@hidden>
Subject: Re: [Qemu-devel] [PATCH v4 11/15] target-s390x: New QMP command
query-cpu-model
Message-ID: <address@hidden>
Date: Fri, 16 May 2014 12:16:41 -0300
From: Eduardo Habkost <address@hidden>
Subject: Re: [Qemu-devel] [RFC 0/5] Allow object-add on X86CPU subclasses,
for CPU model probing
Message-ID: <address@hidden>
---
exec.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/exec.c b/exec.c
index ae37b98..a68f0af 100644
--- a/exec.c
+++ b/exec.c
@@ -519,6 +519,19 @@ 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 *obj = OBJECT(cpu);
+ char *path = g_strdup_printf("cpus[%d]", cpu->cpu_index);
+
+ object_ref(obj);
+ object_property_add_const_link(OBJECT(current_machine), path, TYPE_CPU,
+ obj, 0, &error_abort);
+ g_free(path);
+#endif
+}
+
void cpu_exec_init(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
@@ -558,6 +571,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)
--
2.1.0