From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSG6k-0005Za-6b for qemu-devel@nongnu.org; Wed, 09 May 2012 19:15:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSG6h-00053S-RH for qemu-devel@nongnu.org; Wed, 09 May 2012 19:15:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:32802 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSG6h-00053K-Hb for qemu-devel@nongnu.org; Wed, 09 May 2012 19:15:43 -0400 Message-ID: <4FAAFA99.7000902@suse.de> Date: Thu, 10 May 2012 01:15:37 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <72a3d008-2d67-47e8-b5f2-927ff5cf2166@zmail16.collab.prod.int.phx2.redhat.com> In-Reply-To: <72a3d008-2d67-47e8-b5f2-927ff5cf2166@zmail16.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC 6/6] target-i386: make cpus childs of /machine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: jan kiszka , aliguori@us.ibm.com, qemu-devel@nongnu.org, Paolo Bonzini Am 17.04.2012 12:28, schrieb Igor Mammedov: > ----- Original Message ----- >> From: "Andreas F=C3=A4rber" >> To: "Paolo Bonzini" , "Igor Mammedov" >> Cc: qemu-devel@nongnu.org, aliguori@us.ibm.com, "jan kiszka" >> Sent: Tuesday, April 17, 2012 10:46:14 AM >> Subject: Re: [PATCH RFC 6/6] target-i386: make cpus childs of /machine >> >> Am 17.04.2012 09:19, schrieb Paolo Bonzini: >>> Il 17/04/2012 01:37, Igor Mammedov ha scritto: >>>> From: Igor Mammedov >>>> >>>> Signed-off-by: Igor Mammedov >>>> --- >>>> target-i386/helper.c | 4 ++++ >>>> 1 files changed, 4 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/target-i386/helper.c b/target-i386/helper.c >>>> index de7637c..1996b97 100644 >>>> --- a/target-i386/helper.c >>>> +++ b/target-i386/helper.c >>>> @@ -1134,6 +1134,7 @@ CPUX86State *cpu_x86_init(const char >>>> *cpu_model) >>>> X86CPU *cpu; >>>> CPUX86State *env; >>>> Error *errp =3D NULL; >>>> + char cpuname[8]; >>>> =20 >>>> cpu =3D X86_CPU(object_new(TYPE_X86_CPU)); >>>> env =3D &cpu->env; >>>> @@ -1146,6 +1147,9 @@ CPUX86State *cpu_x86_init(const char >>>> *cpu_model) >>>> } >>>> } >>>> =20 >>>> + snprintf(cpuname, sizeof(cpuname), "cpu%d", >>>> env->cpuid_apic_id); >>>> + object_property_add_child(container_get("/machine"), cpuname, >>>> OBJECT(cpu), NULL); >>>> + >>>> object_property_set_bool(OBJECT(cpu), true, "realized", >>>> &errp); >>>> if (errp) { >>>> object_delete(OBJECT(cpu)); >>> >>> I think the right name would be /machine/cpu[%d]/cpu. The local >>> APIC >>> for example should reside under /machine/cpu[%d]/apic. >> >> Depends on how we model the CPU, I was kinda waiting for feedback on >> that. >> >> I would prefer /machine/cpu[%d], with the APIC being a child >> .../apic, >> if possible. That however depends on how the device'ification of the >> CPU > Ok, I'll change /machine/cpu%d to /machine/cpu[%d]. Note that I needed a similar patch recently in my quest to move fields from CPU_COMMON into CPUState: https://github.com/afaerber/qemu-cpu/commits/qom-cpu (WIP) current state: https://github.com/afaerber/qemu-cpu/commit/1318ad13cda52e694caea5cc72293= c5879db3f9f I chose to do it in pc.c instead because for other architectures the placement will be a machine-specific decision. I've used cpu_index, but it seems cpuid_apic_id is assigned only once, from cpu_index, so it should be identical. What's the difference? Comparing our code I see that I do an unnecessary NUL termination after snprintf(), whereas your buffer should probably be 9 chars to account for a maximum of 255 CPUs (3 letters, 2 square brackets, 3 digits, NUL). In particular I needed /machine/cpu[n] to pass the X86CPU to the APIC in a sensible way - next commit on that branch, currently: https://github.com/afaerber/qemu-cpu/commit/1134efc143aa1629f8961ef058416= e1acfa50f8e Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg