diff mbox

[V2,4/5] hw/ppc: remove QEMUMachine indirection

Message ID 1396257993-4036-5-git-send-email-marcel.a@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum March 31, 2014, 9:26 a.m. UTC
No need for QEMUMachine anymore because
its fields are passed to MachineClass.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/ppc/spapr.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Comments

Andreas Färber April 3, 2014, 5:25 p.m. UTC | #1
Am 31.03.2014 11:26, schrieb Marcel Apfelbaum:
> No need for QEMUMachine anymore because
> its fields are passed to MachineClass.

QEMUMachineInitArgs still has a QEMUMachine field that now becomes NULL?

Andreas
Marcel Apfelbaum April 3, 2014, 5:46 p.m. UTC | #2
On Thu, 2014-04-03 at 19:25 +0200, Andreas Färber wrote:
> Am 31.03.2014 11:26, schrieb Marcel Apfelbaum:
> > No need for QEMUMachine anymore because
> > its fields are passed to MachineClass.
> 
> QEMUMachineInitArgs still has a QEMUMachine field that now becomes NULL?
No... 
It is properly initiated right before the machine init: (No changes made)


   QEMUMachineInitArgs args = { .machine = machine, 
                                .ram_size = ram_size, 
                                .boot_order = boot_order, 
                                .kernel_filename = kernel_filename, 
                                .kernel_cmdline = kernel_cmdline, 
                                .initrd_filename = initrd_filename, 
                                .cpu_model = cpu_model }; 
   
   current_machine->init_args = args; 
   machine->init(&current_machine->init_args);

I plan to get rid of this too, but it touches a lot of files,
I am looking for a clean way to get rid of it.

Thanks,
Marcel

> 
> Andreas
>
Andreas Färber April 3, 2014, 5:57 p.m. UTC | #3
Am 03.04.2014 19:46, schrieb Marcel Apfelbaum:
> On Thu, 2014-04-03 at 19:25 +0200, Andreas Färber wrote:
>> Am 31.03.2014 11:26, schrieb Marcel Apfelbaum:
>>> No need for QEMUMachine anymore because
>>> its fields are passed to MachineClass.
>>
>> QEMUMachineInitArgs still has a QEMUMachine field that now becomes NULL?
> No... 
> It is properly initiated right before the machine init: (No changes made)
> 
> 
>    QEMUMachineInitArgs args = { .machine = machine, 
>                                 .ram_size = ram_size, 
>                                 .boot_order = boot_order, 
>                                 .kernel_filename = kernel_filename, 
>                                 .kernel_cmdline = kernel_cmdline, 
>                                 .initrd_filename = initrd_filename, 
>                                 .cpu_model = cpu_model }; 
>    
>    current_machine->init_args = args; 
>    machine->init(&current_machine->init_args);

You're dropping pseries QEMUMachine in this patch,
=> mc->qemu_machine = NULL
=> machine = NULL
=> .machine = NULL

Therefore my suggestion to start using MachineClass for .machine early
(because machine_class != NULL) and to do the ->qemu_machine and mc->
changes in one go (so that ->qemu_machine != NULL as long as it exists).

Regards,
Andreas
Marcel Apfelbaum April 3, 2014, 6:08 p.m. UTC | #4
On Thu, 2014-04-03 at 19:57 +0200, Andreas Färber wrote:
> Am 03.04.2014 19:46, schrieb Marcel Apfelbaum:
> > On Thu, 2014-04-03 at 19:25 +0200, Andreas Färber wrote:
> >> Am 31.03.2014 11:26, schrieb Marcel Apfelbaum:
> >>> No need for QEMUMachine anymore because
> >>> its fields are passed to MachineClass.
> >>
> >> QEMUMachineInitArgs still has a QEMUMachine field that now becomes NULL?
> > No... 
> > It is properly initiated right before the machine init: (No changes made)
> > 
> > 
> >    QEMUMachineInitArgs args = { .machine = machine, 
> >                                 .ram_size = ram_size, 
> >                                 .boot_order = boot_order, 
> >                                 .kernel_filename = kernel_filename, 
> >                                 .kernel_cmdline = kernel_cmdline, 
> >                                 .initrd_filename = initrd_filename, 
> >                                 .cpu_model = cpu_model }; 
> >    
> >    current_machine->init_args = args; 
> >    machine->init(&current_machine->init_args);
> 
> You're dropping pseries QEMUMachine in this patch,
> => mc->qemu_machine = NULL
> => machine = NULL
> => .machine = NULL
Right! My bad :(

> 
> Therefore my suggestion to start using MachineClass for .machine early
> (because machine_class != NULL) and to do the ->qemu_machine and mc->
> changes in one go (so that ->qemu_machine != NULL as long as it exists).
Going for it,

Thanks,
Marcel
> 
> Regards,
> Andreas
>
diff mbox

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index a11e121..b4ce950 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1419,19 +1419,6 @@  static int spapr_kvm_type(const char *vm_type)
     exit(1);
 }
 
-static QEMUMachine spapr_machine = {
-    .name = "pseries",
-    .desc = "pSeries Logical Partition (PAPR compliant)",
-    .is_default = 1,
-    .init = ppc_spapr_init,
-    .reset = ppc_spapr_reset,
-    .block_default_type = IF_SCSI,
-    .max_cpus = MAX_CPUS,
-    .no_parallel = 1,
-    .default_boot_order = NULL,
-    .kvm_type = spapr_kvm_type,
-};
-
 /*
  * Implementation of an interface to adjust firmware patch
  * for the bootindex property handling.
@@ -1494,7 +1481,17 @@  static void spapr_machine_class_init(ObjectClass *oc, void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
 
-    mc->qemu_machine = data;
+    mc->name = "pseries";
+    mc->desc = "pSeries Logical Partition (PAPR compliant)";
+    mc->is_default = 1;
+    mc->init = ppc_spapr_init;
+    mc->reset = ppc_spapr_reset;
+    mc->block_default_type = IF_SCSI;
+    mc->max_cpus = MAX_CPUS;
+    mc->no_parallel = 1;
+    mc->default_boot_order = NULL;
+    mc->kvm_type = spapr_kvm_type;
+
     fwc->get_dev_path = spapr_get_fw_dev_path;
 }
 
@@ -1502,7 +1499,6 @@  static const TypeInfo spapr_machine_info = {
     .name          = TYPE_SPAPR_MACHINE,
     .parent        = TYPE_MACHINE,
     .class_init    = spapr_machine_class_init,
-    .class_data    = &spapr_machine,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_FW_PATH_PROVIDER },
         { }