diff mbox

[qom-cpu,for-1.4] target-unicore32: Rename CPU subtypes

Message ID 1359327047-30747-1-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Jan. 27, 2013, 10:50 p.m. UTC
In the initial conversion of CPU models to QOM types, model names were
mapped 1:1 to type names. As a side effect this gained us a type "any",
which is now a device.

To avoid "-device any" silliness and to pave the way for compiling
multiple targets into one executable, adopt a <name>-<arch>-cpu scheme.

No functional changes for -cpu arguments.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-unicore32/cpu.c |    8 ++++++--
 1 Datei geändert, 6 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

Comments

Andreas Färber Jan. 28, 2013, 3:47 p.m. UTC | #1
Am 27.01.2013 23:50, schrieb Andreas Färber:
> In the initial conversion of CPU models to QOM types, model names were
> mapped 1:1 to type names. As a side effect this gained us a type "any",
> which is now a device.
> 
> To avoid "-device any" silliness and to pave the way for compiling
> multiple targets into one executable, adopt a <name>-<arch>-cpu scheme.
> 
> No functional changes for -cpu arguments.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Patch breaks linux-user due to forgetting to update cpu_model_str.
I'll double-check the other targets.

Andreas
Guan Xuetao Jan. 29, 2013, 9:25 a.m. UTC | #2
> -----邮件原件-----
> 发件人: Andreas Färber [mailto:afaerber@suse.de]
> 发送时间: Monday, January 28, 2013 23:47
> 收件人: qemu-devel@nongnu.org
> 抄送: Guan Xuetao
> 主题: Re: [Qemu-devel] [PATCH qom-cpu for-1.4] target-unicore32: Rename
> CPU subtypes
> 
> Am 27.01.2013 23:50, schrieb Andreas Färber:
> > In the initial conversion of CPU models to QOM types, model names were
> > mapped 1:1 to type names. As a side effect this gained us a type
> > "any", which is now a device.
> >
> > To avoid "-device any" silliness and to pave the way for compiling
> > multiple targets into one executable, adopt a <name>-<arch>-cpu scheme.
> >
> > No functional changes for -cpu arguments.
> >
> > Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> Patch breaks linux-user due to forgetting to update cpu_model_str.
> I'll double-check the other targets.
> 
> Andreas
After this patch was applied, I saw the following error when running:
	qemu: hardware error: Unable to find CPU definition

Thanks
Guan Xuetao

> 
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Andreas Färber Jan. 29, 2013, 10:12 a.m. UTC | #3
嗨,

Am 29.01.2013 10:25, schrieb Guan Xuetao:
>> -----邮件原件-----
>> 发件人: Andreas Färber [mailto:afaerber@suse.de]
>> 发送时间: Monday, January 28, 2013 23:47
>> 收件人: qemu-devel@nongnu.org
>> 抄送: Guan Xuetao
>> 主题: Re: [Qemu-devel] [PATCH qom-cpu for-1.4] target-unicore32: Rename
>> CPU subtypes
>>
>> Am 27.01.2013 23:50, schrieb Andreas Färber:
>>> In the initial conversion of CPU models to QOM types, model names were
>>> mapped 1:1 to type names. As a side effect this gained us a type
>>> "any", which is now a device.
>>>
>>> To avoid "-device any" silliness and to pave the way for compiling
>>> multiple targets into one executable, adopt a <name>-<arch>-cpu scheme.
>>>
>>> No functional changes for -cpu arguments.
>>>
>>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>>
>> Patch breaks linux-user due to forgetting to update cpu_model_str.
>> I'll double-check the other targets.
>>
> After this patch was applied, I saw the following error when running:
> 	qemu: hardware error: Unable to find CPU definition

As indicated above, this patch has a bug, sorry. I will send a v2.
Forking in linux-user will be broken (cpu_copy()), everything else
should work though, no?

Can you please test qemu.git master and confirm that it is not broken
without this patch?

I do not have any unicore32 image for testing. I therefore tested
"./unicore32-softmmu/qemu-system-unicore32 -cpu ?" (which did not seem
implemented) and "./unicore32-softmmu/qemu-system-unicore32" without
parameters, which ran into a kernel_filename assertion IIRC.
Can you upload a test image and static linux-user binaries somewhere? Or
provide me with instructions how to build a toolchain and kernel?

Thanks,
Andreas

P.S. FYI a hw/uc32/ directory has been created in the meantime. If you
still wish to move your puv3 files out of hw/, please feel invited to
send a patch.
Guan Xuetao Feb. 11, 2013, 7:28 a.m. UTC | #4
>
> As indicated above, this patch has a bug, sorry. I will send a v2.
> Forking in linux-user will be broken (cpu_copy()), everything else
> should work though, no?
>
> Can you please test qemu.git master and confirm that it is not broken
> without this patch?
>
> I do not have any unicore32 image for testing. I therefore tested
> "./unicore32-softmmu/qemu-system-unicore32 -cpu ?" (which did not seem
> implemented) and "./unicore32-softmmu/qemu-system-unicore32" without
> parameters, which ran into a kernel_filename assertion IIRC.
> Can you upload a test image and static linux-user binaries somewhere? Or
> provide me with instructions how to build a toolchain and kernel?

Sorry for replying so late. Since it's chinese spring festival, I can't
access my linux server recently.
My suggestion is that you can apply your patches on unicore32 to qemu.git
freely, and when I rebase my repo on qemu.git, I will review and adjust my
codes.

Happy Chinese New Year!
Xuetao

>
> Thanks,
> Andreas
>
> P.S. FYI a hw/uc32/ directory has been created in the meantime. If you
> still wish to move your puv3 files out of hw/, please feel invited to
> send a patch.
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N眉rnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imend枚rffer; HRB 16746 AG N眉rnberg
>
diff mbox

Patch

diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
index c120440..28c2fa0 100644
--- a/target-unicore32/cpu.c
+++ b/target-unicore32/cpu.c
@@ -25,12 +25,15 @@  static inline void set_feature(CPUUniCore32State *env, int feature)
 static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model)
 {
     ObjectClass *oc;
+    char *typename;
 
     if (cpu_model == NULL) {
         return NULL;
     }
 
-    oc = object_class_by_name(cpu_model);
+    typename = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, cpu_model);
+    oc = object_class_by_name(typename);
+    g_free(typename);
     if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_UNICORE32_CPU) ||
                        object_class_is_abstract(oc))) {
         oc = NULL;
@@ -106,12 +109,13 @@  static void uc32_cpu_class_init(ObjectClass *oc, void *data)
 static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
 {
     TypeInfo type_info = {
-        .name = info->name,
         .parent = TYPE_UNICORE32_CPU,
         .instance_init = info->instance_init,
     };
 
+    type_info.name = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, info->name);
     type_register(&type_info);
+    g_free((void *)type_info.name);
 }
 
 static const TypeInfo uc32_cpu_type_info = {