diff mbox

[arm-devs,v1,3/6] arm/highbank: Use object_new() rather than cpu_arm_init()

Message ID d45f1dc7faada34cc38091bd68f660fdafc3e0e5.1385542228.git.peter.crosthwaite@xilinx.com
State New
Headers show

Commit Message

Peter Crosthwaite Nov. 27, 2013, 9:02 a.m. UTC
To allow the machine model to set device properties before CPU
realization.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/arm/highbank.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Peter Maydell Nov. 27, 2013, 9:10 a.m. UTC | #1
On 27 November 2013 09:02, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> To allow the machine model to set device properties before CPU
> realization.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
>  hw/arm/highbank.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
> index fe98ef1..70831ba 100644
> --- a/hw/arm/highbank.c
> +++ b/hw/arm/highbank.c
> @@ -228,11 +228,18 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
>          }
>      }
>
> +    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
> +

Please use cpu_class_by_name() rather than hand-constructing
the classname. (see also the hw/arm/virt.c code I posted the other
day, which needs to set a property for other reasons.)

>      for (n = 0; n < smp_cpus; n++) {
>          ARMCPU *cpu;
> -        cpu = cpu_arm_init(cpu_model);
> -        if (cpu == NULL) {
> -            fprintf(stderr, "Unable to find CPU definition\n");
> +        Error *err = NULL;
> +
> +        cpu = ARM_CPU(object_new(cpu_model));
> +        g_free((void *)cpu_model);
> +
> +        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
> +        if (err) {
> +            fprintf(stderr, "%s\n", error_get_pretty(err));
>              exit(1);
>          }

thanks
-- PMM
Andreas Färber Nov. 27, 2013, 9:52 a.m. UTC | #2
Am 27.11.2013 10:10, schrieb Peter Maydell:
> On 27 November 2013 09:02, Peter Crosthwaite
> <peter.crosthwaite@xilinx.com> wrote:
>> To allow the machine model to set device properties before CPU
>> realization.
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>>
>>  hw/arm/highbank.c | 13 ++++++++++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
>> index fe98ef1..70831ba 100644
>> --- a/hw/arm/highbank.c
>> +++ b/hw/arm/highbank.c
>> @@ -228,11 +228,18 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
>>          }
>>      }
>>
>> +    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
>> +
> 
> Please use cpu_class_by_name() rather than hand-constructing
> the classname. (see also the hw/arm/virt.c code I posted the other
> day, which needs to set a property for other reasons.)
> 
>>      for (n = 0; n < smp_cpus; n++) {
>>          ARMCPU *cpu;
>> -        cpu = cpu_arm_init(cpu_model);
>> -        if (cpu == NULL) {
>> -            fprintf(stderr, "Unable to find CPU definition\n");
>> +        Error *err = NULL;
>> +
>> +        cpu = ARM_CPU(object_new(cpu_model));
>> +        g_free((void *)cpu_model);
>> +
>> +        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
>> +        if (err) {
>> +            fprintf(stderr, "%s\n", error_get_pretty(err));

And use of error_report() (without \n) will be appreciated. :)

Cheers,
Andreas

>>              exit(1);
>>          }
> 
> thanks
> -- PMM
diff mbox

Patch

diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index fe98ef1..70831ba 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -228,11 +228,18 @@  static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
         }
     }
 
+    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
+
     for (n = 0; n < smp_cpus; n++) {
         ARMCPU *cpu;
-        cpu = cpu_arm_init(cpu_model);
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition\n");
+        Error *err = NULL;
+
+        cpu = ARM_CPU(object_new(cpu_model));
+        g_free((void *)cpu_model);
+
+        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+        if (err) {
+            fprintf(stderr, "%s\n", error_get_pretty(err));
             exit(1);
         }