diff mbox

[13/22] machine: get rid of global default QEMUMachine members

Message ID 1275954730-8196-14-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori June 7, 2010, 11:52 p.m. UTC
Right now, we have a lot of default device type options in the QEMUMachine
structure.  This is used by code within vl.c to determine whether it should
add classes of devices (like serial).

Really, vl.c has no business adding devices but all we need to do to support
this is create common machine options to describe whether there are default
devices of each class.  vl.c can then use that to determine whether to add
said devices.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff mbox

Patch

diff --git a/hw/boards.h b/hw/boards.h
index e05637b..f33c44b 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -16,13 +16,6 @@  struct QEMUMachine {
     QEMUMachineInitFunc *init;
     int use_scsi;
     int max_cpus;
-    unsigned int no_serial:1,
-        no_parallel:1,
-        use_virtcon:1,
-        no_vga:1,
-        no_floppy:1,
-        no_cdrom:1,
-        no_sdcard:1;
     int is_default;
     QemuOptDesc *opts_desc;
     QemuOptValue *opts_default;
@@ -43,29 +36,46 @@  extern QEMUMachine *current_machine;
     {                                   \
         .name = "driver",               \
         .type = QEMU_OPT_STRING,        \
-    },                                  \
-    {                                   \
+    },{                                 \
         .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,        \
+    },{                                 \
+        .name = "serial",               \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "parallel",             \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "virtcon",              \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "vga",                  \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "floppy",               \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "cdrom",                \
+        .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "sdcard",               \
+        .type = QEMU_OPT_BOOL,          \
     }
 
+
 #endif
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 70b88df..e4d6ecd 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -273,9 +273,13 @@  static QEMUMachine s390_machine = {
     .alias = "s390",
     .desc = "VirtIO based S390 machine",
     .init = s390_init,
-    .no_serial = 1,
-    .no_parallel = 1,
-    .use_virtcon = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("serial", "off"),
+        QOPT_VALUE("parallel", "off"),
+        QOPT_VALUE("virtcon", "on"),
+        QOPT_VALUE("vga", "off"),
+        { /* end of list */ }
+    },
     .no_vga = 1,
     .max_cpus = 255,
     .is_default = 1,
diff --git a/vl.c b/vl.c
index 0a31a45..553da4d 100644
--- a/vl.c
+++ b/vl.c
@@ -3505,25 +3505,25 @@  int main(int argc, char **argv, char **envp)
     qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
     qemu_opts_foreach(&qemu_global_opts, default_driver_check, NULL, 0);
 
-    if (machine->no_serial) {
+    if (!qemu_opt_get_bool(machine_opts, "serial", 1)) {
         default_serial = 0;
     }
-    if (machine->no_parallel) {
+    if (!qemu_opt_get_bool(machine_opts, "parallel", 1)) {
         default_parallel = 0;
     }
-    if (!machine->use_virtcon) {
+    if (!qemu_opt_get_bool(machine_opts, "virtcon", 0)) {
         default_virtcon = 0;
     }
-    if (machine->no_vga) {
+    if (!qemu_opt_get_bool(machine_opts, "vga", 1)) {
         default_vga = 0;
     }
-    if (machine->no_floppy) {
+    if (!qemu_opt_get_bool(machine_opts, "floppy", 1)) {
         default_floppy = 0;
     }
-    if (machine->no_cdrom) {
+    if (!qemu_opt_get_bool(machine_opts, "cdrom", 1)) {
         default_cdrom = 0;
     }
-    if (machine->no_sdcard) {
+    if (!qemu_opt_get_bool(machine_opts, "sdcard", 1)) {
         default_sdcard = 0;
     }