diff mbox

[v2,3/4] spapr: Improve device tree CPU node for -cpu host with unknown OF name

Message ID 1376606111-3518-4-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Aug. 15, 2013, 10:35 p.m. UTC
Whenever DeviceClass::fw_name is not available, derive it from the CPU's
type name, resorting to the parent's type in case of -cpu host, and fill
it in for that class in a PAPR-compliant way with "PowerPC," prefix.

Reported-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/ppc/spapr.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andreas Färber Aug. 15, 2013, 10:40 p.m. UTC | #1
Am 16.08.2013 00:35, schrieb Andreas Färber:
> Whenever DeviceClass::fw_name is not available, derive it from the CPU's
> type name, resorting to the parent's type in case of -cpu host, and fill
> it in for that class in a PAPR-compliant way with "PowerPC," prefix.

Ugh, obviously forgot to edit the commit message after splitting this
off from the preceding patch... ;)

Andreas

> 
> Reported-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  hw/ppc/spapr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6d984dc..0e9be32 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -344,6 +344,10 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
>              const char *typename;
>  
>              typename = object_class_get_name(oc);
> +            if (kvm_enabled() &&
> +                strcmp(typename, "host-" TYPE_POWERPC_CPU) == 0) {
> +                typename = object_class_get_name(object_class_get_parent(oc));
> +            }
>              nodename = g_strndup(typename,
>                                   strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
>              dc->fw_name = g_strdup_printf("PowerPC,%s", nodename);
>
Alexey Kardashevskiy Aug. 29, 2013, 4:33 a.m. UTC | #2
On 08/16/2013 08:35 AM, Andreas Färber wrote:
> Whenever DeviceClass::fw_name is not available, derive it from the CPU's
> type name, resorting to the parent's type in case of -cpu host, and fill
> it in for that class in a PAPR-compliant way with "PowerPC," prefix.
> 
> Reported-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  hw/ppc/spapr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6d984dc..0e9be32 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -344,6 +344,10 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
>              const char *typename;
>  
>              typename = object_class_get_name(oc);
> +            if (kvm_enabled() &&
> +                strcmp(typename, "host-" TYPE_POWERPC_CPU) == 0) {
> +                typename = object_class_get_name(object_class_get_parent(oc));
> +            }
>              nodename = g_strndup(typename,
>                                   strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
>              dc->fw_name = g_strdup_printf("PowerPC,%s", nodename);
> 

You could use dc->desc of a parent, would be simpler, no?
Andreas Färber Aug. 29, 2013, 5:30 a.m. UTC | #3
Am 29.08.2013 06:33, schrieb Alexey Kardashevskiy:
> On 08/16/2013 08:35 AM, Andreas Färber wrote:
>> Whenever DeviceClass::fw_name is not available, derive it from the CPU's
>> type name, resorting to the parent's type in case of -cpu host, and fill
>> it in for that class in a PAPR-compliant way with "PowerPC," prefix.
>>
>> Reported-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>>  hw/ppc/spapr.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 6d984dc..0e9be32 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -344,6 +344,10 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
>>              const char *typename;
>>  
>>              typename = object_class_get_name(oc);
>> +            if (kvm_enabled() &&
>> +                strcmp(typename, "host-" TYPE_POWERPC_CPU) == 0) {
>> +                typename = object_class_get_name(object_class_get_parent(oc));
>> +            }
>>              nodename = g_strndup(typename,
>>                                   strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
>>              dc->fw_name = g_strdup_printf("PowerPC,%s", nodename);
>>
> 
> You could use dc->desc of a parent, would be simpler, no?

Answered on 2/4.

Andreas
diff mbox

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 6d984dc..0e9be32 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -344,6 +344,10 @@  static void *spapr_create_fdt_skel(hwaddr initrd_base,
             const char *typename;
 
             typename = object_class_get_name(oc);
+            if (kvm_enabled() &&
+                strcmp(typename, "host-" TYPE_POWERPC_CPU) == 0) {
+                typename = object_class_get_name(object_class_get_parent(oc));
+            }
             nodename = g_strndup(typename,
                                  strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
             dc->fw_name = g_strdup_printf("PowerPC,%s", nodename);