Signed-off-by: Anthony Liguori <aligu...@us.ibm.com>
diff --git a/hw/boards.h b/hw/boards.h
index c3f4f68..728908b 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -25,6 +25,7 @@ struct QEMUMachine {
no_sdcard:1;
int is_default;
GlobalProperty *compat_props;
+ QemuOptDesc *opts_desc;
struct QEMUMachine *next;
};
@@ -32,4 +33,29 @@ int qemu_register_machine(QEMUMachine *m);
extern QEMUMachine *current_machine;
+#define COMMON_MACHINE_OPTS() \
+ { \
+ .name = "ram_size", \
+ .type = QEMU_OPT_SIZE, \
+ },{ \
+ .name = "kernel", \
+ .type = QEMU_OPT_STRING, \
+ }, \
+ { \
+ .name = "cmdline", \
+ .type = QEMU_OPT_STRING, \
+ }, \
+ { \
+ .name = "initrd", \
+ .type = QEMU_OPT_STRING, \
+ }, \
+ { \
+ .name = "boot_device", \
+ .type = QEMU_OPT_STRING, \
+ }, \
+ { \
+ .name = "cpu", \
+ .type = QEMU_OPT_STRING, \
+ }
+
#endif
diff --git a/hw/pc.h b/hw/pc.h
index 0e52933..1ae61e0 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -110,7 +110,6 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg);
void cpu_smm_register(cpu_set_smm_t callback, void *arg);
/* acpi.c */
-extern int acpi_enabled;
extern char *acpi_tables;
extern size_t acpi_tables_len;
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index c58cd42..1830aca 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -40,14 +40,14 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376
};
static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
/* PC hardware initialisation */
-static void pc_init1(ram_addr_t ram_size,
- const char *boot_device,
- const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename,
- const char *cpu_model,
- int pci_enabled)
+static void pc_init1(QemuOpts *opts, int pci_enabled)
{
+ ram_addr_t ram_size = qemu_opt_get_size(opts, "ram_size", 0);
+ const char *boot_device = qemu_opt_get(opts, "boot_device");
+ const char *kernel_filename = qemu_opt_get(opts, "kernel");
+ const char *kernel_cmdline = qemu_opt_get(opts, "cmdline");
+ const char *initrd_filename = qemu_opt_get(opts, "initrd");
+ const char *cpu_model = qemu_opt_get(opts, "cpu");
int i;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
@@ -133,7 +133,7 @@ static void pc_init1(ram_addr_t ram_size,
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
- if (pci_enabled && acpi_enabled) {
+ if (pci_enabled && qemu_opt_get_bool(opts, "acpi", 1)) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this
persistent */
i2c_bus *smbus;
@@ -163,32 +163,27 @@ static void pc_init1(ram_addr_t ram_size,
static void pc_init_pci(QemuOpts *opts)
{
- ram_addr_t ram_size = qemu_opt_get_size(opts, "ram_size", 0);
- const char *boot_device = qemu_opt_get(opts, "boot_device");
- const char *kernel_filename = qemu_opt_get(opts, "kernel");
- const char *kernel_cmdline = qemu_opt_get(opts, "cmdline");
- const char *initrd_filename = qemu_opt_get(opts, "initrd");
- const char *cpu_model = qemu_opt_get(opts, "cpu");
- pc_init1(ram_size, boot_device,
- kernel_filename, kernel_cmdline,
- initrd_filename, cpu_model, 1);
+ pc_init1(opts, 1);
}
static void pc_init_isa(QemuOpts *opts)
{
- ram_addr_t ram_size = qemu_opt_get_size(opts, "ram_size", 0);
- const char *boot_device = qemu_opt_get(opts, "boot_device");
- const char *kernel_filename = qemu_opt_get(opts, "kernel");
- const char *kernel_cmdline = qemu_opt_get(opts, "cmdline");
- const char *initrd_filename = qemu_opt_get(opts, "initrd");
- const char *cpu_model = qemu_opt_get(opts, "cpu");
- if (cpu_model == NULL)
- cpu_model = "486";
- pc_init1(ram_size, boot_device,
- kernel_filename, kernel_cmdline,
- initrd_filename, cpu_model, 0);
+ if (!qemu_opt_get(opts, "cpu")) {
+ qemu_opt_set(opts, "cpu", "486");
+ }
+
+ pc_init1(opts, 0);
}
+static QemuOptDesc pc_opts_desc[] = {
+ COMMON_MACHINE_OPTS(),
+ {
+ .name = "acpi",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end of list */ },
+};
+
static QEMUMachine pc_machine = {
.name = "pc-0.13",
.alias = "pc",
@@ -196,6 +191,7 @@ static QEMUMachine pc_machine = {
.init = pc_init_pci,
.max_cpus = 255,
.is_default = 1,
+ .opts_desc = pc_opts_desc,
};
static QEMUMachine pc_machine_v0_12 = {
@@ -203,6 +199,7 @@ static QEMUMachine pc_machine_v0_12 = {
.desc = "Standard PC",
.init = pc_init_pci,
.max_cpus = 255,
+ .opts_desc = pc_opts_desc,
.compat_props = (GlobalProperty[]) {
{
.driver = "virtio-serial-pci",
@@ -222,6 +219,7 @@ static QEMUMachine pc_machine_v0_11 = {
.desc = "Standard PC, qemu 0.11",
.init = pc_init_pci,
.max_cpus = 255,
+ .opts_desc = pc_opts_desc,
.compat_props = (GlobalProperty[]) {
{
.driver = "virtio-blk-pci",
@@ -257,6 +255,7 @@ static QEMUMachine pc_machine_v0_10 = {
.desc = "Standard PC, qemu 0.10",
.init = pc_init_pci,
.max_cpus = 255,
+ .opts_desc = pc_opts_desc,
.compat_props = (GlobalProperty[]) {
{
.driver = "virtio-blk-pci",
diff --git a/vl.c b/vl.c
index 87009eb..4fc4c20 100644
--- a/vl.c
+++ b/vl.c
@@ -209,7 +209,7 @@ int max_cpus = 0;
int smp_cores = 1;
int smp_threads = 1;
const char *vnc_display;
-int acpi_enabled = 1;
+static int acpi_enabled = 1;
int no_hpet = 0;
int fd_bootchk = 1;
int no_reboot = 0;
@@ -2550,32 +2550,8 @@ static const QEMUOption *lookup_opt(int argc, char
**argv,
return popt;
}
-/* TEMP: until we have proper -machine support */
static QemuOptDesc common_machine_opts[] = {
- {
- .name = "ram_size",
- .type = QEMU_OPT_SIZE,
- },
- {
- .name = "kernel",
- .type = QEMU_OPT_STRING,
- },
- {
- .name = "cmdline",
- .type = QEMU_OPT_STRING,
- },
- {
- .name = "initrd",
- .type = QEMU_OPT_STRING,
- },
- {
- .name = "boot_device",
- .type = QEMU_OPT_STRING,
- },
- {
- .name = "cpu",
- .type = QEMU_OPT_STRING,
- },
+ COMMON_MACHINE_OPTS(),
{ /* end of list */ },
};
@@ -3771,8 +3747,18 @@ int main(int argc, char **argv, char **envp)
qemu_opt_set(opts, "ram_size", buffer);
}
- if (qemu_opts_validate(opts, common_machine_opts) < 0) {
- exit(1);
+ if (acpi_enabled == 0) {
+ qemu_opt_set(opts, "acpi", "off");
+ }
+
+ if (machine->opts_desc) {
+ if (qemu_opts_validate(opts, machine->opts_desc) < 0) {
+ exit(1);
+ }
+ } else {
+ if (qemu_opts_validate(opts, common_machine_opts) < 0) {
+ exit(1);
+ }
}
machine->init(opts);
--
1.7.0.4