From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhOBY-0008Dx-U8 for qemu-devel@nongnu.org; Mon, 05 May 2014 15:04:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhOBN-0004z9-3I for qemu-devel@nongnu.org; Mon, 05 May 2014 15:04:20 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 5 May 2014 21:03:50 +0200 Message-Id: <1399316644-20700-7-git-send-email-afaerber@suse.de> In-Reply-To: <1399316644-20700-1-git-send-email-afaerber@suse.de> References: <1399316644-20700-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 06/20] machine: Remove QEMUMachine indirection from MachineClass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Alexander Graf , Luiz Capitulino , "open list:sPAPR" , Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Marcel Apfelbaum No need to go through qemu_machine field. Use MachineClass fields directly. Signed-off-by: Marcel Apfelbaum Signed-off-by: Andreas F=C3=A4rber --- device-hotplug.c | 2 +- hw/ppc/spapr.c | 50 ++++++++------------------------- include/hw/boards.h | 2 -- qmp.c | 4 +-- vl.c | 79 ++++++++++++++++++++++++-----------------------= ------ 5 files changed, 50 insertions(+), 87 deletions(-) diff --git a/device-hotplug.c b/device-hotplug.c index ebfa6b1..eecb08e 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -40,7 +40,7 @@ DriveInfo *add_init_drive(const char *optstr) return NULL; =20 mc =3D MACHINE_GET_CLASS(current_machine); - dinfo =3D drive_init(opts, mc->qemu_machine->block_default_type); + dinfo =3D drive_init(opts, mc->block_default_type); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5192702..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); } =20 -static QEMUMachine spapr_machine =3D { - .name =3D "pseries", - .desc =3D "pSeries Logical Partition (PAPR compliant)", - .is_default =3D 1, - .init =3D ppc_spapr_init, - .reset =3D ppc_spapr_reset, - .block_default_type =3D IF_SCSI, - .max_cpus =3D MAX_CPUS, - .no_parallel =3D 1, - .default_boot_order =3D NULL, - .kvm_type =3D spapr_kvm_type, -}; - /* * Implementation of an interface to adjust firmware patch * for the bootindex property handling. @@ -1493,31 +1480,17 @@ static void spapr_machine_class_init(ObjectClass = *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); FWPathProviderClass *fwc =3D FW_PATH_PROVIDER_CLASS(oc); - QEMUMachine *qm =3D data; - - mc->qemu_machine =3D data; - - mc->name =3D qm->name; - mc->alias =3D qm->alias; - mc->desc =3D qm->desc; - mc->init =3D qm->init; - mc->reset =3D qm->reset; - mc->hot_add_cpu =3D qm->hot_add_cpu; - mc->kvm_type =3D qm->kvm_type; - mc->block_default_type =3D qm->block_default_type; - mc->max_cpus =3D qm->max_cpus; - mc->no_serial =3D qm->no_serial; - mc->no_parallel =3D qm->no_parallel; - mc->use_virtcon =3D qm->use_virtcon; - mc->use_sclp =3D qm->use_sclp; - mc->no_floppy =3D qm->no_floppy; - mc->no_cdrom =3D qm->no_cdrom; - mc->no_sdcard =3D qm->no_sdcard; - mc->is_default =3D qm->is_default; - mc->default_machine_opts =3D qm->default_machine_opts; - mc->default_boot_order =3D qm->default_boot_order; - mc->compat_props =3D qm->compat_props; - mc->hw_version =3D qm->hw_version; + + mc->name =3D "pseries"; + mc->desc =3D "pSeries Logical Partition (PAPR compliant)"; + mc->is_default =3D 1; + mc->init =3D ppc_spapr_init; + mc->reset =3D ppc_spapr_reset; + mc->block_default_type =3D IF_SCSI; + mc->max_cpus =3D MAX_CPUS; + mc->no_parallel =3D 1; + mc->default_boot_order =3D NULL; + mc->kvm_type =3D spapr_kvm_type; =20 fwc->get_dev_path =3D spapr_get_fw_dev_path; } @@ -1526,7 +1499,6 @@ static const TypeInfo spapr_machine_info =3D { .name =3D TYPE_SPAPR_MACHINE, .parent =3D TYPE_MACHINE, .class_init =3D spapr_machine_class_init, - .class_data =3D &spapr_machine, .interfaces =3D (InterfaceInfo[]) { { TYPE_FW_PATH_PROVIDER }, { } diff --git a/include/hw/boards.h b/include/hw/boards.h index 8f53334..4345bd0 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -76,8 +76,6 @@ struct MachineClass { ObjectClass parent_class; /*< public >*/ =20 - QEMUMachine *qemu_machine; - const char *name; const char *alias; const char *desc; diff --git a/qmp.c b/qmp.c index 74107be..c4836df 100644 --- a/qmp.c +++ b/qmp.c @@ -117,8 +117,8 @@ void qmp_cpu_add(int64_t id, Error **errp) MachineClass *mc; =20 mc =3D MACHINE_GET_CLASS(current_machine); - if (mc->qemu_machine->hot_add_cpu) { - mc->qemu_machine->hot_add_cpu(id, errp); + if (mc->hot_add_cpu) { + mc->hot_add_cpu(id, errp); } else { error_setg(errp, "Not supported"); } diff --git a/vl.c b/vl.c index f423b2e..c4505dc 100644 --- a/vl.c +++ b/vl.c @@ -1590,8 +1590,6 @@ static void machine_class_init(ObjectClass *oc, voi= d *data) MachineClass *mc =3D MACHINE_CLASS(oc); QEMUMachine *qm =3D data; =20 - mc->qemu_machine =3D data; - mc->name =3D qm->name; mc->alias =3D qm->alias; mc->desc =3D qm->desc; @@ -1639,12 +1637,12 @@ static MachineClass *find_machine(const char *nam= e) for (el =3D machines; el; el =3D el->next) { MachineClass *temp =3D el->data; =20 - if (!strcmp(temp->qemu_machine->name, name)) { + if (!strcmp(temp->name, name)) { mc =3D temp; break; } - if (temp->qemu_machine->alias && - !strcmp(temp->qemu_machine->alias, name)) { + if (temp->alias && + !strcmp(temp->alias, name)) { mc =3D temp; break; } @@ -1662,7 +1660,7 @@ MachineClass *find_default_machine(void) for (el =3D machines; el; el =3D el->next) { MachineClass *temp =3D el->data; =20 - if (temp->qemu_machine->is_default) { + if (temp->is_default) { mc =3D temp; break; } @@ -1676,27 +1674,25 @@ MachineInfoList *qmp_query_machines(Error **errp) { GSList *el, *machines =3D object_class_get_list(TYPE_MACHINE, false)= ; MachineInfoList *mach_list =3D NULL; - QEMUMachine *m; =20 for (el =3D machines; el; el =3D el->next) { MachineClass *mc =3D el->data; MachineInfoList *entry; MachineInfo *info; =20 - m =3D mc->qemu_machine; info =3D g_malloc0(sizeof(*info)); - if (m->is_default) { + if (mc->is_default) { info->has_is_default =3D true; info->is_default =3D true; } =20 - if (m->alias) { + if (mc->alias) { info->has_alias =3D true; - info->alias =3D g_strdup(m->alias); + info->alias =3D g_strdup(mc->alias); } =20 - info->name =3D g_strdup(m->name); - info->cpu_max =3D !m->max_cpus ? 1 : m->max_cpus; + info->name =3D g_strdup(mc->name); + info->cpu_max =3D !mc->max_cpus ? 1 : mc->max_cpus; =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; @@ -1902,8 +1898,8 @@ void qemu_system_reset(bool report) =20 mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; =20 - if (mc && mc->qemu_machine->reset) { - mc->qemu_machine->reset(); + if (mc && mc->reset) { + mc->reset(); } else { qemu_devices_reset(); } @@ -2712,12 +2708,11 @@ static MachineClass *machine_parse(const char *na= me) printf("Supported machines are:\n"); for (el =3D machines; el; el =3D el->next) { MachineClass *mc =3D el->data; - QEMUMachine *m =3D mc->qemu_machine; - if (m->alias) { - printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m-= >name); + if (mc->alias) { + printf("%-20s %s (alias of %s)\n", mc->alias, mc->desc, = mc->name); } - printf("%-20s %s%s\n", m->name, m->desc, - m->is_default ? " (default)" : ""); + printf("%-20s %s%s\n", mc->name, mc->desc, + mc->is_default ? " (default)" : ""); } } =20 @@ -2971,7 +2966,6 @@ int main(int argc, char **argv, char **envp) const char *optarg; const char *loadvm =3D NULL; MachineClass *machine_class; - QEMUMachine *machine; const char *cpu_model; const char *vga_model =3D NULL; const char *qtest_chrdev =3D NULL; @@ -3999,9 +3993,8 @@ int main(int argc, char **argv, char **envp) object_property_add_child(object_get_root(), "machine", OBJECT(current_machine), &error_abort); =20 - machine =3D machine_class->qemu_machine; - if (machine->hw_version) { - qemu_set_version(machine->hw_version); + if (machine_class->hw_version) { + qemu_set_version(machine_class->hw_version); } =20 if (qemu_opts_foreach(qemu_find_opts("object"), @@ -4061,11 +4054,11 @@ int main(int argc, char **argv, char **envp) =20 smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); =20 - machine->max_cpus =3D machine->max_cpus ?: 1; /* Default to UP */ - if (smp_cpus > machine->max_cpus) { + machine_class->max_cpus =3D machine_class->max_cpus ?: 1; /* Default= to UP */ + if (smp_cpus > machine_class->max_cpus) { fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max = cpus " - "supported by machine `%s' (%d)\n", smp_cpus, machine->= name, - machine->max_cpus); + "supported by machine `%s' (%d)\n", smp_cpus, + machine_class->name, machine_class->max_cpus); exit(1); } =20 @@ -4073,9 +4066,9 @@ int main(int argc, char **argv, char **envp) * Get the default machine options from the machine if it is not alr= eady * specified either by the configuration file or by the command line= . */ - if (machine->default_machine_opts) { + if (machine_class->default_machine_opts) { qemu_opts_set_defaults(qemu_find_opts("machine"), - machine->default_machine_opts, 0); + machine_class->default_machine_opts, 0); } =20 qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NU= LL, 0); @@ -4084,25 +4077,25 @@ int main(int argc, char **argv, char **envp) if (!vga_model && !default_vga) { vga_interface_type =3D VGA_DEVICE; } - if (!has_defaults || machine->no_serial) { + if (!has_defaults || machine_class->no_serial) { default_serial =3D 0; } - if (!has_defaults || machine->no_parallel) { + if (!has_defaults || machine_class->no_parallel) { default_parallel =3D 0; } - if (!has_defaults || !machine->use_virtcon) { + if (!has_defaults || !machine_class->use_virtcon) { default_virtcon =3D 0; } - if (!has_defaults || !machine->use_sclp) { + if (!has_defaults || !machine_class->use_sclp) { default_sclp =3D 0; } - if (!has_defaults || machine->no_floppy) { + if (!has_defaults || machine_class->no_floppy) { default_floppy =3D 0; } - if (!has_defaults || machine->no_cdrom) { + if (!has_defaults || machine_class->no_cdrom) { default_cdrom =3D 0; } - if (!has_defaults || machine->no_sdcard) { + if (!has_defaults || machine_class->no_sdcard) { default_sdcard =3D 0; } if (!has_defaults) { @@ -4240,7 +4233,7 @@ int main(int argc, char **argv, char **envp) kernel_cmdline =3D qemu_opt_get(machine_opts, "append"); bios_name =3D qemu_opt_get(machine_opts, "firmware"); =20 - boot_order =3D machine->default_boot_order; + boot_order =3D machine_class->default_boot_order; opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { char *normal_boot_order; @@ -4334,11 +4327,11 @@ int main(int argc, char **argv, char **envp) if (snapshot) qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot= , NULL, 0); if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, - &machine->block_default_type, 1) !=3D 0) { + &machine_class->block_default_type, 1) !=3D 0)= { exit(1); } =20 - default_drive(default_cdrom, snapshot, machine->block_default_type, = 2, + default_drive(default_cdrom, snapshot, machine_class->block_default_= type, 2, CDROM_OPTS); default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); @@ -4422,8 +4415,8 @@ int main(int argc, char **argv, char **envp) exit (i =3D=3D 1 ? 1 : 0); } =20 - if (machine->compat_props) { - qdev_prop_register_global_list(machine->compat_props); + if (machine_class->compat_props) { + qdev_prop_register_global_list(machine_class->compat_props); } qemu_add_globals(); =20 @@ -4438,7 +4431,7 @@ int main(int argc, char **argv, char **envp) .initrd_filename =3D initrd_filename, .cpu_model =3D cpu_model }; =20 - machine->init(¤t_machine->init_args); + machine_class->init(¤t_machine->init_args); =20 audio_init(); =20 --=20 1.8.4.5