Patchwork [v2,08/14] cmdline: implement -nodefaults with qemuopts

login
register
mail settings
Submitter Paolo Bonzini
Date April 11, 2012, 9:34 p.m.
Message ID <1334180081-6172-9-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/151935/
State New
Headers show

Comments

Paolo Bonzini - April 11, 2012, 9:34 p.m.
This becomes -machine default_devices.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-config.c |    4 ++++
 vl.c          |   41 +++++++++++++++++++----------------------
 2 files changed, 23 insertions(+), 22 deletions(-)

Patch

diff --git a/qemu-config.c b/qemu-config.c
index 8f0923e..23d6b03 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -560,6 +560,10 @@  static QemuOptsList qemu_machine_opts = {
             .type = QEMU_OPT_STRING,
             .help = "accelerator list",
         }, {
+            .name = "default_devices",
+            .type = QEMU_OPT_BOOL,
+            .help = "create default devices",
+        }, {
             .name = "autostart",
             .type = QEMU_OPT_BOOL,
             .help = "start machine immediately",
diff --git a/vl.c b/vl.c
index a280c4c..21fd9ce 100644
--- a/vl.c
+++ b/vl.c
@@ -3084,15 +3084,7 @@  int main(int argc, char **argv, char **envp)
                 runstate_set(RUN_STATE_INMIGRATE);
                 break;
             case QEMU_OPTION_nodefaults:
-                default_serial = 0;
-                default_parallel = 0;
-                default_virtcon = 0;
-                default_monitor = 0;
-                default_net = 0;
-                default_floppy = 0;
-                default_cdrom = 0;
-                default_sdcard = 0;
-                vga_model = "none";
+                qemu_opts_set(qemu_find_opts("machine"), 0, "default_devices", "off");
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
@@ -3243,28 +3235,33 @@  int main(int argc, char **argv, char **envp)
     if (machine->default_machine_opts) {
         qemu_opts_set_defaults(qemu_find_opts("machine"),
                                machine->default_machine_opts, 0);
+        machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     }
 
-    qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
-    qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
+    if (qemu_opt_get_bool(machine_opts, "default_devices", true)) {
+        qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
+        qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
+
+        default_serial &= !machine->no_serial;
+        default_parallel &= !machine->no_parallel;
+        default_virtcon &= machine->use_virtcon;
+        default_floppy &= !machine->no_floppy;
+        default_cdrom &= !machine->no_cdrom;
+        default_sdcard &= !machine->no_sdcard;
 
-    if (machine->no_serial) {
+        /* No need for machine->no_vga.  Boards can simply ignore the
+         * vga_interface_type variable (most will, indeed).
+         */
+    } else {
         default_serial = 0;
-    }
-    if (machine->no_parallel) {
         default_parallel = 0;
-    }
-    if (!machine->use_virtcon) {
         default_virtcon = 0;
-    }
-    if (machine->no_floppy) {
+        default_monitor = 0;
+        default_net = 0;
         default_floppy = 0;
-    }
-    if (machine->no_cdrom) {
         default_cdrom = 0;
-    }
-    if (machine->no_sdcard) {
         default_sdcard = 0;
+        vga_model = "none";
     }
 
     if (display_type == DT_NOGRAPHIC) {