From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpCyQ-0004VY-9M for qemu-devel@nongnu.org; Mon, 04 May 2015 05:47:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpCyN-0005R1-24 for qemu-devel@nongnu.org; Mon, 04 May 2015 05:47:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpCyM-0005Qx-So for qemu-devel@nongnu.org; Mon, 04 May 2015 05:47:34 -0400 Date: Mon, 4 May 2015 11:47:28 +0200 From: Igor Mammedov Message-ID: <20150504114728.0dd227dd@nial.brq.redhat.com> In-Reply-To: <1430421547-18278-1-git-send-email-ehabkost@redhat.com> References: <1430421547-18278-1-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] cpu: Register QOM links at /machine/cpus/ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: peter.maydell@linaro.org, mimu@linux.vnet.ibm.com, agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, bharata@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, Paolo Bonzini , Andreas =?UTF-8?B?RsOkcmJlcg==?= , david@gibson.dropbear.id.au On Thu, 30 Apr 2015 16:19:07 -0300 Eduardo Habkost wrote: > 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. provided the way cpu_index is generated, path won't be predictable/stable with CPU unplug. I'd rather use DEVICE->id instead of cpu_index. > > Signed-off-by: Eduardo Habkost > --- > 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 > 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/ link */ > + Object *self; > + > int nr_cores; > int nr_threads; > int numa_node;