spapr_cpu_core: cleaning up qdev_get_machine() calls
PATCH 1/1 spapr_cpu_core: cleaning up qdev_get_machine() calls
This patch removes the qdev_get_machine() calls that are made in spapr_cpu_core.c in situations where we can get an existing pointer for the MachineState by either passing it as an argument to the function or by using other already available pointers.
Credits to Daniel Henrique Barboza for the idea and the changelog text.
--- hw/ppc/spapr_cpu_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ppc/spapr_cpu_core.c +4 -4
@@ -73,8 +73,8 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr)static void spapr_cpu_reset (void *opaque) { -sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());PowerPCCPU *cpu = opaque; +sPAPRMachineState *spapr =SPAPR_MACHINE (&cpu->vhyp);CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -162,10 +162,10 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)g_free (sc->threads); } -static void spapr_cpu_core_realize_child (Object *child,Error **errp) +static void spapr_cpu_core_realize_child (Object *child, +sPAPRMachineState *spapr,Error **errp) {Error *local_err =NULL ; -sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());CPUState *cs =CPU (child);PowerPCCPU *cpu =POWERPC_CPU (cs);Object *obj;
@@ -254,7 +254,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)for (j =0 ; j < cc->nr_threads; j++) { obj = sc->threads + j * size; -spapr_cpu_core_realize_child (obj, &local_err); +spapr_cpu_core_realize_child (obj, spapr, &local_err);if (local_err) { goto err; }
Quoted 18 lines · On Mon, 11 Sep 2017 22:52:52 +0200 Greg Kurz <[email protected]> wrote:
This patch removes the
qdev_get_machine()calls that are made inspapr_cpu_core.cin situations where we can get an existing pointer for the MachineState by either passing it as an argument to the function or by using other already available pointers.Credits to Daniel Henrique Barboza for the idea and the changelog text.
Signed-off-by Greg Kurz <[email protected]>--- hw/ppc/spapr_cpu_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/ppc/spapr_cpu_core.c +0
-0
hw/ppc/spapr_cpu_core.c void spapr_cpu_parse_features(sPAPRMachineState *spapr) · line 77
Quoted 6 lines
hw/ppc/spapr_cpu_core.c +1
-1@@ -73,8 +73,8 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr)static void spapr_cpu_reset (void *opaque) { -sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());PowerPCCPU *cpu = opaque; +sPAPRMachineState *spapr =SPAPR_MACHINE (&cpu->vhyp);
^
Ouch! :-\I'll send a v2.
Quoted 27 lines
hw/ppc/spapr_cpu_core.c +3
-3CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;@@ -162,10 +162,10 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)g_free (sc->threads); } -static void spapr_cpu_core_realize_child (Object *child,Error **errp) +static void spapr_cpu_core_realize_child (Object *child, +sPAPRMachineState *spapr,Error **errp) {Error *local_err =NULL ; -sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());CPUState *cs =CPU (child);PowerPCCPU *cpu =POWERPC_CPU (cs);Object *obj;@@ -254,7 +254,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)for (j =0 ; j < cc->nr_threads; j++) { obj = sc->threads + j * size; -spapr_cpu_core_realize_child (obj, &local_err); +spapr_cpu_core_realize_child (obj, spapr, &local_err);if (local_err) { goto err; }