aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-07 13:47:25 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-07 13:47:26 +0100
commit7f8fea8b3d31ca396eb3c88bf97b543a86773774 (patch)
treeda0ba9bdab83d3e2050d5bdfb78d86ca90c228a9 /vl.c
parent951916d02c59cd0eddd57c3d66f87f921931e394 (diff)
parent848696bf353750899832c51005f1bd3540da5c29 (diff)
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
QOM/QTest infrastructure fixes and device conversions * -device / device_add assertion fix * QEMUMachine conversion to MachineClass * Device error handling improvements * QTest cleanups and test cases for some more PCI devices * PortIO memory leak fixes # gpg: Signature made Mon 05 May 2014 19:59:16 BST using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qom-devices-for-peter: PortioList: Store PortioList in device state tests: Add EHCI qtest tests: Add ioh3420 qtest tests: Add intel-hda qtests tests: Add es1370 qtest tests: Add ac97 qtest qtest: Be paranoid about accept() addrlen argument qtest: Add error reporting to socket_accept() qtest: Assure that init_socket()'s listen() does not fail MAINTAINERS: Document QOM arm: Clean up fragile use of error_is_set() in realize() methods qom: Clean up fragile use of error_is_set() in set() methods hw: Consistently name Error ** objects errp, and not err hw: Consistently name Error * objects err, and not errp machine: Remove QEMUMachine indirection from MachineClass machine: Replace QEMUMachine by MachineClass in accelerator configuration vl.c: Replace QEMUMachine with MachineClass in QEMUMachineInitArgs machine: Copy QEMUMachine's fields to MachineClass machine: Remove obsoleted field from QEMUMachine qdev: Fix crash by validating the object type Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c114
1 files changed, 65 insertions, 49 deletions
diff --git a/vl.c b/vl.c
index 236f95efd7..c4505dc8c1 100644
--- a/vl.c
+++ b/vl.c
@@ -1588,8 +1588,29 @@ MachineState *current_machine;
static void machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
-
- mc->qemu_machine = data;
+ QEMUMachine *qm = data;
+
+ mc->name = qm->name;
+ mc->alias = qm->alias;
+ mc->desc = qm->desc;
+ mc->init = qm->init;
+ mc->reset = qm->reset;
+ mc->hot_add_cpu = qm->hot_add_cpu;
+ mc->kvm_type = qm->kvm_type;
+ mc->block_default_type = qm->block_default_type;
+ mc->max_cpus = qm->max_cpus;
+ mc->no_serial = qm->no_serial;
+ mc->no_parallel = qm->no_parallel;
+ mc->use_virtcon = qm->use_virtcon;
+ mc->use_sclp = qm->use_sclp;
+ mc->no_floppy = qm->no_floppy;
+ mc->no_cdrom = qm->no_cdrom;
+ mc->no_sdcard = qm->no_sdcard;
+ mc->is_default = qm->is_default;
+ mc->default_machine_opts = qm->default_machine_opts;
+ mc->default_boot_order = qm->default_boot_order;
+ mc->compat_props = qm->compat_props;
+ mc->hw_version = qm->hw_version;
}
int qemu_register_machine(QEMUMachine *m)
@@ -1616,12 +1637,12 @@ static MachineClass *find_machine(const char *name)
for (el = machines; el; el = el->next) {
MachineClass *temp = el->data;
- if (!strcmp(temp->qemu_machine->name, name)) {
+ if (!strcmp(temp->name, name)) {
mc = temp;
break;
}
- if (temp->qemu_machine->alias &&
- !strcmp(temp->qemu_machine->alias, name)) {
+ if (temp->alias &&
+ !strcmp(temp->alias, name)) {
mc = temp;
break;
}
@@ -1639,7 +1660,7 @@ MachineClass *find_default_machine(void)
for (el = machines; el; el = el->next) {
MachineClass *temp = el->data;
- if (temp->qemu_machine->is_default) {
+ if (temp->is_default) {
mc = temp;
break;
}
@@ -1653,27 +1674,25 @@ MachineInfoList *qmp_query_machines(Error **errp)
{
GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
MachineInfoList *mach_list = NULL;
- QEMUMachine *m;
for (el = machines; el; el = el->next) {
MachineClass *mc = el->data;
MachineInfoList *entry;
MachineInfo *info;
- m = mc->qemu_machine;
info = g_malloc0(sizeof(*info));
- if (m->is_default) {
+ if (mc->is_default) {
info->has_is_default = true;
info->is_default = true;
}
- if (m->alias) {
+ if (mc->alias) {
info->has_alias = true;
- info->alias = g_strdup(m->alias);
+ info->alias = g_strdup(mc->alias);
}
- info->name = g_strdup(m->name);
- info->cpu_max = !m->max_cpus ? 1 : m->max_cpus;
+ info->name = g_strdup(mc->name);
+ info->cpu_max = !mc->max_cpus ? 1 : mc->max_cpus;
entry = g_malloc0(sizeof(*entry));
entry->value = info;
@@ -1879,8 +1898,8 @@ void qemu_system_reset(bool report)
mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
- if (mc && mc->qemu_machine->reset) {
- mc->qemu_machine->reset();
+ if (mc && mc->reset) {
+ mc->reset();
} else {
qemu_devices_reset();
}
@@ -2689,12 +2708,11 @@ static MachineClass *machine_parse(const char *name)
printf("Supported machines are:\n");
for (el = machines; el; el = el->next) {
MachineClass *mc = el->data;
- QEMUMachine *m = 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)" : "");
}
}
@@ -2702,7 +2720,7 @@ static MachineClass *machine_parse(const char *name)
exit(!name || !is_help_option(name));
}
-static int tcg_init(QEMUMachine *machine)
+static int tcg_init(MachineClass *mc)
{
tcg_exec_init(tcg_tb_size * 1024 * 1024);
return 0;
@@ -2712,7 +2730,7 @@ static struct {
const char *opt_name;
const char *name;
int (*available)(void);
- int (*init)(QEMUMachine *);
+ int (*init)(MachineClass *mc);
bool *allowed;
} accel_list[] = {
{ "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed },
@@ -2721,7 +2739,7 @@ static struct {
{ "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed },
};
-static int configure_accelerator(QEMUMachine *machine)
+static int configure_accelerator(MachineClass *mc)
{
const char *p;
char buf[10];
@@ -2748,7 +2766,7 @@ static int configure_accelerator(QEMUMachine *machine)
break;
}
*(accel_list[i].allowed) = true;
- ret = accel_list[i].init(machine);
+ ret = accel_list[i].init(mc);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
@@ -2948,7 +2966,6 @@ int main(int argc, char **argv, char **envp)
const char *optarg;
const char *loadvm = NULL;
MachineClass *machine_class;
- QEMUMachine *machine;
const char *cpu_model;
const char *vga_model = NULL;
const char *qtest_chrdev = NULL;
@@ -3976,9 +3993,8 @@ int main(int argc, char **argv, char **envp)
object_property_add_child(object_get_root(), "machine",
OBJECT(current_machine), &error_abort);
- machine = 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);
}
if (qemu_opts_foreach(qemu_find_opts("object"),
@@ -4038,11 +4054,11 @@ int main(int argc, char **argv, char **envp)
smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
- machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
- if (smp_cpus > machine->max_cpus) {
+ machine_class->max_cpus = 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);
}
@@ -4050,9 +4066,9 @@ int main(int argc, char **argv, char **envp)
* Get the default machine options from the machine if it is not already
* 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);
}
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
@@ -4061,25 +4077,25 @@ int main(int argc, char **argv, char **envp)
if (!vga_model && !default_vga) {
vga_interface_type = VGA_DEVICE;
}
- if (!has_defaults || machine->no_serial) {
+ if (!has_defaults || machine_class->no_serial) {
default_serial = 0;
}
- if (!has_defaults || machine->no_parallel) {
+ if (!has_defaults || machine_class->no_parallel) {
default_parallel = 0;
}
- if (!has_defaults || !machine->use_virtcon) {
+ if (!has_defaults || !machine_class->use_virtcon) {
default_virtcon = 0;
}
- if (!has_defaults || !machine->use_sclp) {
+ if (!has_defaults || !machine_class->use_sclp) {
default_sclp = 0;
}
- if (!has_defaults || machine->no_floppy) {
+ if (!has_defaults || machine_class->no_floppy) {
default_floppy = 0;
}
- if (!has_defaults || machine->no_cdrom) {
+ if (!has_defaults || machine_class->no_cdrom) {
default_cdrom = 0;
}
- if (!has_defaults || machine->no_sdcard) {
+ if (!has_defaults || machine_class->no_sdcard) {
default_sdcard = 0;
}
if (!has_defaults) {
@@ -4199,7 +4215,7 @@ int main(int argc, char **argv, char **envp)
exit(0);
}
- configure_accelerator(machine);
+ configure_accelerator(machine_class);
if (qtest_chrdev) {
Error *local_err = NULL;
@@ -4217,7 +4233,7 @@ int main(int argc, char **argv, char **envp)
kernel_cmdline = qemu_opt_get(machine_opts, "append");
bios_name = qemu_opt_get(machine_opts, "firmware");
- boot_order = machine->default_boot_order;
+ boot_order = machine_class->default_boot_order;
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
if (opts) {
char *normal_boot_order;
@@ -4311,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) != 0) {
+ &machine_class->block_default_type, 1) != 0) {
exit(1);
}
- 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);
@@ -4399,15 +4415,15 @@ int main(int argc, char **argv, char **envp)
exit (i == 1 ? 1 : 0);
}
- 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();
qdev_machine_init();
current_machine->init_args = (QEMUMachineInitArgs) {
- .machine = machine,
+ .machine = machine_class,
.ram_size = ram_size,
.boot_order = boot_order,
.kernel_filename = kernel_filename,
@@ -4415,7 +4431,7 @@ int main(int argc, char **argv, char **envp)
.initrd_filename = initrd_filename,
.cpu_model = cpu_model };
- machine->init(&current_machine->init_args);
+ machine_class->init(&current_machine->init_args);
audio_init();