qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts
@ 2012-03-20  8:01 Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 01/12] vga: disable default VGA if appropriate -device is used Paolo Bonzini
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This converts a lot of commonly-used options to QemuOpts.  Most of them
get in -machine, but I don't intend -machine to become a catch-all option.
In fact I refrained from converting those that should go in -display
(like -keyboard) or should be moved to enum device properties.

With the exception of -display, now a more-or-less complete PC machine
can be created from config.  This is unfortunately not true of most
embedded machines which use arrays such as serial_hd to create devices
and do not support using -device instead.

This does not mean that all options can be used.  Only -monitor and
-qmp create a backend/frontend pair in QemuOpts, so things such as
-serial stdio will not work.

Patch 1 is a bugfix, it was already submitted and informally approved
by Blue.

Paolo Bonzini (12):
  vga: disable default VGA if appropriate -device is used
  QemuOpts: use strtosz
  cmdline: implement -m with QemuOpts
  cmdline: implement -S with QemuOpts
  cmdline: implement -bios with QemuOpts
  cmdline: implement -localtime with QemuOpts
  cmdline: make -M a simple alias for -machine type
  cmdline: convert -smp to QemuOpts
  cmdline: reindent numa_add
  cmdline: convert -numa to QemuOpts
  cmdline: implement -nodefaults with qemuopts
  cmdline: convert -no-shutdown and -no-reboot to QemuOpts

 qemu-config.c   |   78 +++++++++++++++
 qemu-option.c   |   41 ++------
 vl.c            |  289 ++++++++++++++++++++++++++-----------------------------
 3 files changed, 225 insertions(+), 183 deletions(-)

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 01/12] vga: disable default VGA if appropriate -device is used
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 02/12] QemuOpts: use strtosz Paolo Bonzini
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This is a partial revert of commits a369da5 (vga: improve VGA logic,
committed 2012-01-22) and c5bd4f3 (vga: fix -nodefaults -device VGA,
2012-01-24) which broke command-line option parsing in different ways.

Since commit a369da5 it has become impossible to specify a VGA device
entirely with QemuOpts-enabled options, i.e. without needing an explicit
"-vga none".

In addition, until commit c5bd4f3 -nodefaults would not disable the device
you specified with the legacy "-vga" option, independent of the order.
Since commit c5bd4f3 QEMU -nodefaults will override a previous -vga
option.

I did not reintroduce machine->no_vga.  Boards can simply ignore the
vga_interface_type variable, and most will indeed do so.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/vl.c b/vl.c
index 65f11f2..fd394c8 100644
--- a/vl.c
+++ b/vl.c
@@ -272,6 +272,7 @@ static int default_monitor = 1;
 static int default_floppy = 1;
 static int default_cdrom = 1;
 static int default_sdcard = 1;
+static int default_vga = 1;
 
 static struct {
     const char *driver;
@@ -287,6 +288,12 @@ static struct {
     { .driver = "virtio-serial-pci",    .flag = &default_virtcon   },
     { .driver = "virtio-serial-s390",   .flag = &default_virtcon   },
     { .driver = "virtio-serial",        .flag = &default_virtcon   },
+    { .driver = "VGA",                  .flag = &default_vga       },
+    { .driver = "isa-vga",              .flag = &default_vga       },
+    { .driver = "cirrus-vga",           .flag = &default_vga       },
+    { .driver = "isa-cirrus-vga",       .flag = &default_vga       },
+    { .driver = "vmware-svga",          .flag = &default_vga       },
+    { .driver = "qxl-vga",              .flag = &default_vga       },
 };
 
 static void res_free(void)
@@ -2269,7 +2276,7 @@ int main(int argc, char **argv, char **envp)
     const char *loadvm = NULL;
     QEMUMachine *machine;
     const char *cpu_model;
-    const char *vga_model = NULL;
+    const char *vga_model = "none";
     const char *pid_file = NULL;
     const char *incoming = NULL;
 #ifdef CONFIG_VNC
@@ -2699,6 +2706,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_vga:
                 vga_model = optarg;
+                default_vga = 0;
                 break;
             case QEMU_OPTION_g:
                 {
@@ -3107,7 +3115,7 @@ int main(int argc, char **argv, char **envp)
                 default_floppy = 0;
                 default_cdrom = 0;
                 default_sdcard = 0;
-                vga_model = "none";
+                default_vga = 0;
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
@@ -3468,14 +3476,13 @@ int main(int argc, char **argv, char **envp)
 
     module_call_init(MODULE_INIT_QOM);
 
-    /* must be after qdev registration but before machine init */
-    if (vga_model) {
-        select_vgahw(vga_model);
-    } else if (cirrus_vga_available()) {
-        select_vgahw("cirrus");
-    } else {
-        select_vgahw("none");
+    /* This must be after qdev registration but before machine init.
+     * If no default VGA is requested, the default is "none".
+     */
+    if (default_vga && cirrus_vga_available()) {
+        vga_model = "cirrus";
     }
+    select_vgahw(vga_model);
 
     if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
         exit(0);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 02/12] QemuOpts: use strtosz
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 01/12] vga: disable default VGA if appropriate -device is used Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 03/12] cmdline: implement -m with QemuOpts Paolo Bonzini
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This will simplify conversion of -numa node,mem=... and -m to QemuOpts.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-option.c |   41 ++++++++++-------------------------------
 1 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/qemu-option.c b/qemu-option.c
index 35cd609..55cbee8 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -204,41 +204,20 @@ static int parse_option_number(const char *name, const char *value, uint64_t *re
     return 0;
 }
 
-static int parse_option_size(const char *name, const char *value, uint64_t *ret)
+static int parse_option_size(const char *name, const char *value,
+                             const char default_suffix, uint64_t *ret)
 {
     char *postfix;
-    double sizef;
+    int64_t size;
 
-    if (value != NULL) {
-        sizef = strtod(value, &postfix);
-        switch (*postfix) {
-        case 'T':
-            sizef *= 1024;
-            /* fall through */
-        case 'G':
-            sizef *= 1024;
-            /* fall through */
-        case 'M':
-            sizef *= 1024;
-            /* fall through */
-        case 'K':
-        case 'k':
-            sizef *= 1024;
-            /* fall through */
-        case 'b':
-        case '\0':
-            *ret = (uint64_t) sizef;
-            break;
-        default:
-            qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size");
-            error_printf_unless_qmp("You may use k, M, G or T suffixes for "
-                    "kilobytes, megabytes, gigabytes and terabytes.\n");
-            return -1;
-        }
-    } else {
+    size = strtosz_suffix(value, &postfix, default_suffix);
+    if (size < 0 || *postfix) {
         qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size");
+        error_printf_unless_qmp("You may use k, M, G or T suffixes for "
+                    "kilobytes, megabytes, gigabytes and terabytes.\n");
         return -1;
     }
+    *ret = size;
     return 0;
 }
 
@@ -289,7 +268,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
         break;
 
     case OPT_SIZE:
-        if (parse_option_size(name, value, &list->value.n) == -1)
+        if (parse_option_size(name, value, 'B', &list->value.n) == -1)
             return -1;
         break;
 
@@ -589,7 +568,7 @@ static int qemu_opt_parse(QemuOpt *opt)
     case QEMU_OPT_NUMBER:
         return parse_option_number(opt->name, opt->str, &opt->value.uint);
     case QEMU_OPT_SIZE:
-        return parse_option_size(opt->name, opt->str, &opt->value.uint);
+        return parse_option_size(opt->name, opt->str, 'M', &opt->value.uint);
     default:
         abort();
     }
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 03/12] cmdline: implement -m with QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 01/12] vga: disable default VGA if appropriate -device is used Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 02/12] QemuOpts: use strtosz Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 04/12] cmdline: implement -S " Paolo Bonzini
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This becomes -machine ram_size.

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

diff --git a/qemu-config.c b/qemu-config.c
index be84a03..6569acd 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -582,6 +582,10 @@ static QemuOptsList qemu_machine_opts = {
             .name = "dtb",
             .type = QEMU_OPT_STRING,
             .help = "Linux kernel device tree file",
+        }, {
+            .name = "ram_size",
+            .type = QEMU_OPT_SIZE,
+            .help = "RAM size",
         },
         { /* End of list */ }
     },
diff --git a/vl.c b/vl.c
index fd394c8..70c22dc 100644
--- a/vl.c
+++ b/vl.c
@@ -2650,20 +2650,7 @@ int main(int argc, char **argv, char **envp)
                 exit(0);
                 break;
             case QEMU_OPTION_m: {
-                int64_t value;
-                char *end;
-
-                value = strtosz(optarg, &end);
-                if (value < 0 || *end) {
-                    fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
-                    exit(1);
-                }
-
-                if (value != (uint64_t)(ram_addr_t)value) {
-                    fprintf(stderr, "qemu: ram size too large\n");
-                    exit(1);
-                }
-                ram_size = value;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "ram_size", optarg);
                 break;
             }
             case QEMU_OPTION_mempath:
@@ -3325,26 +3312,14 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    /* init the memory */
-    if (ram_size == 0) {
-        ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
-    }
-
-    configure_accelerator();
-
-    qemu_init_cpu_loop();
-    if (qemu_init_main_loop()) {
-        fprintf(stderr, "qemu_init_main_loop failed\n");
-        exit(1);
-    }
-
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+    kernel_filename = initrd_filename = kernel_cmdline = NULL;
+    ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     if (machine_opts) {
+        ram_size = qemu_opt_get_size(machine_opts, "ram_size", ram_size);
         kernel_filename = qemu_opt_get(machine_opts, "kernel");
         initrd_filename = qemu_opt_get(machine_opts, "initrd");
         kernel_cmdline = qemu_opt_get(machine_opts, "append");
-    } else {
-        kernel_filename = initrd_filename = kernel_cmdline = NULL;
     }
 
     if (!kernel_cmdline) {
@@ -3368,6 +3343,14 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+    configure_accelerator();
+
+    qemu_init_cpu_loop();
+    if (qemu_init_main_loop()) {
+        fprintf(stderr, "qemu_init_main_loop failed\n");
+        exit(1);
+    }
+
     os_set_line_buffering();
 
     if (init_timer_alarm() < 0) {
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 04/12] cmdline: implement -S with QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (2 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 03/12] cmdline: implement -m with QemuOpts Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 05/12] cmdline: implement -bios " Paolo Bonzini
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This becomes -machine autostart.

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

diff --git a/qemu-config.c b/qemu-config.c
index 6569acd..3a313de 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -559,6 +559,10 @@ static QemuOptsList qemu_machine_opts = {
             .type = QEMU_OPT_STRING,
             .help = "accelerator list",
         }, {
+            .name = "autostart",
+            .type = QEMU_OPT_BOOL,
+            .help = "start machine immediately",
+        }, {
             .name = "kernel_irqchip",
             .type = QEMU_OPT_BOOL,
             .help = "use KVM in-kernel irqchip",
diff --git a/vl.c b/vl.c
index 70c22dc..52a0ea6 100644
--- a/vl.c
+++ b/vl.c
@@ -2683,7 +2683,7 @@ int main(int argc, char **argv, char **envp)
                 singlestep = 1;
                 break;
             case QEMU_OPTION_S:
-                autostart = 0;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "autostart", "off");
                 break;
 	    case QEMU_OPTION_k:
 		keyboard_layout = optarg;
@@ -3316,6 +3316,7 @@ int main(int argc, char **argv, char **envp)
     kernel_filename = initrd_filename = kernel_cmdline = NULL;
     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     if (machine_opts) {
+        autostart = qemu_opt_get_bool(machine_opts, "autostart", true);
         ram_size = qemu_opt_get_size(machine_opts, "ram_size", ram_size);
         kernel_filename = qemu_opt_get(machine_opts, "kernel");
         initrd_filename = qemu_opt_get(machine_opts, "initrd");
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 05/12] cmdline: implement -bios with QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (3 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 04/12] cmdline: implement -S " Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 06/12] cmdline: implement -localtime " Paolo Bonzini
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This becomes -machine bios.

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

diff --git a/qemu-config.c b/qemu-config.c
index 3a313de..89706df 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -563,6 +563,10 @@ static QemuOptsList qemu_machine_opts = {
             .type = QEMU_OPT_BOOL,
             .help = "start machine immediately",
         }, {
+            .name = "bios",
+            .type = QEMU_OPT_STRING,
+            .help = "BIOS/firmware file",
+        }, {
             .name = "kernel_irqchip",
             .type = QEMU_OPT_BOOL,
             .help = "use KVM in-kernel irqchip",
diff --git a/vl.c b/vl.c
index 52a0ea6..54c5d79 100644
--- a/vl.c
+++ b/vl.c
@@ -2677,7 +2677,7 @@ int main(int argc, char **argv, char **envp)
                 data_dir = optarg;
                 break;
             case QEMU_OPTION_bios:
-                bios_name = optarg;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "bios", optarg);
                 break;
             case QEMU_OPTION_singlestep:
                 singlestep = 1;
@@ -3313,10 +3313,12 @@ int main(int argc, char **argv, char **envp)
     }
 
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+    bios_name = NULL;
     kernel_filename = initrd_filename = kernel_cmdline = NULL;
     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     if (machine_opts) {
         autostart = qemu_opt_get_bool(machine_opts, "autostart", true);
+        bios_name = qemu_opt_get(machine_opts, "bios");
         ram_size = qemu_opt_get_size(machine_opts, "ram_size", ram_size);
         kernel_filename = qemu_opt_get(machine_opts, "kernel");
         initrd_filename = qemu_opt_get(machine_opts, "initrd");
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 06/12] cmdline: implement -localtime with QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (4 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 05/12] cmdline: implement -bios " Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 07/12] cmdline: make -M a simple alias for -machine type Paolo Bonzini
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

The -localtime option already has a QemuOpts equivalent.  Setting
the merge_lists option on the -rtc list makes it simple to use it.

This includes a small change in behavior for -rtc.  For example, "-rtc
base=localtime -rtc driftfix=slew" will actually combine the option
rather than override them.  These are actually nicer semantics than
what was there so far.

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

diff --git a/qemu-config.c b/qemu-config.c
index 89706df..8f0923e 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -327,6 +327,7 @@ static QemuOptsList qemu_net_opts = {
 
 static QemuOptsList qemu_rtc_opts = {
     .name = "rtc",
+    .merge_lists = true,
     .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
     .desc = {
         {
diff --git a/vl.c b/vl.c
index 54c5d79..3b9ff31 100644
--- a/vl.c
+++ b/vl.c
@@ -2689,7 +2689,7 @@ int main(int argc, char **argv, char **envp)
 		keyboard_layout = optarg;
 		break;
             case QEMU_OPTION_localtime:
-                rtc_utc = 0;
+                qemu_opts_parse(qemu_find_opts("rtc"), "base=localtime", 0);
                 break;
             case QEMU_OPTION_vga:
                 vga_model = optarg;
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 07/12] cmdline: make -M a simple alias for -machine type
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (5 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 06/12] cmdline: implement -localtime " Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 08/12] cmdline: convert -smp to QemuOpts Paolo Bonzini
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

machine_parse is still being called from the -M handler.  Remove this,
and just call machine_parse based on the "-machine type" value.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/vl.c b/vl.c
index 3b9ff31..1fc5044 100644
--- a/vl.c
+++ b/vl.c
@@ -2274,7 +2274,7 @@ int main(int argc, char **argv, char **envp)
     int optind;
     const char *optarg;
     const char *loadvm = NULL;
-    QEMUMachine *machine;
+    QEMUMachine *machine = NULL;
     const char *cpu_model;
     const char *vga_model = "none";
     const char *pid_file = NULL;
@@ -2317,7 +2317,6 @@ int main(int argc, char **argv, char **envp)
     os_setup_early_signal_handling();
 
     module_call_init(MODULE_INIT_MACHINE);
-    machine = find_default_machine();
     cpu_model = NULL;
     ram_size = 0;
     snapshot = 0;
@@ -2384,7 +2383,7 @@ int main(int argc, char **argv, char **envp)
             }
             switch(popt->index) {
             case QEMU_OPTION_M:
-                machine = machine_parse(optarg);
+                qemu_opts_set(qemu_find_opts("machine"), 0, "type", optarg);
                 break;
             case QEMU_OPTION_cpu:
                 /* hw initialization will check this */
@@ -2954,10 +2953,6 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "parse error: %s\n", optarg);
                     exit(1);
                 }
-                optarg = qemu_opt_get(opts, "type");
-                if (optarg) {
-                    machine = machine_parse(optarg);
-                }
                 break;
             case QEMU_OPTION_usb:
                 usb_enabled = 1;
@@ -3218,11 +3213,19 @@ int main(int argc, char **argv, char **envp)
         data_dir = CONFIG_QEMU_DATADIR;
     }
 
-    if (machine == NULL) {
-        fprintf(stderr, "No machine found.\n");
-        exit(1);
+    machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+    if (machine_opts) {
+        optarg = qemu_opt_get(machine_opts, "type");
+        if (optarg) {
+            machine = machine_parse(optarg);
+        }
+    }
+    if (!machine) {
+        machine = find_default_machine();
     }
 
+    current_machine = machine;
+
     /*
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
@@ -3312,7 +3315,7 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+    /* Initialize machine options */
     bios_name = NULL;
     kernel_filename = initrd_filename = kernel_cmdline = NULL;
     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
@@ -3493,8 +3496,6 @@ int main(int argc, char **argv, char **envp)
 
     set_numa_modes();
 
-    current_machine = machine;
-
     /* init USB devices */
     if (usb_enabled) {
         if (foreach_device_config(DEV_USB, usb_parse) < 0)
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 08/12] cmdline: convert -smp to QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (6 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 07/12] cmdline: make -M a simple alias for -machine type Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 09/12] cmdline: reindent numa_add Paolo Bonzini
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This introduces a new option group, but it is mostly trivial.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-config.c |   31 +++++++++++++++++++++++++++++
 vl.c          |   61 +++++++++++++++++++++++++-------------------------------
 2 files changed, 58 insertions(+), 34 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index 8f0923e..c1a4642 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -600,6 +600,36 @@ static QemuOptsList qemu_machine_opts = {
     },
 };
 
+QemuOptsList qemu_smp_opts = {
+    .name = "smp",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
+    .implied_opt_name = "cpus",
+    .desc = {
+        {
+            .name = "cpus",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Number of CPUs",
+        }, {
+            .name = "sockets",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Number of sockets",
+        }, {
+            .name = "cores",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Number of cores per socket",
+        }, {
+            .name = "threads",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Number of simultaneous threads per core",
+        }, {
+            .name = "maxcpus",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Maximum number of pluggable CPUs",
+        },
+        { /*End of list */ }
+    },
+};
+
 QemuOptsList qemu_boot_opts = {
     .name = "boot-opts",
     .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
@@ -639,6 +669,7 @@ static QemuOptsList *vm_config_groups[32] = {
     &qemu_trace_opts,
     &qemu_option_rom_opts,
     &qemu_machine_opts,
+    &qemu_smp_opts,
     &qemu_boot_opts,
     &qemu_iscsi_opts,
     NULL,
diff --git a/vl.c b/vl.c
index 1fc5044..ce55468 100644
--- a/vl.c
+++ b/vl.c
@@ -995,26 +995,15 @@ static void numa_add(const char *optarg)
     return;
 }
 
-static void smp_parse(const char *optarg)
+static int smp_init_func(QemuOpts *opts, void *opaque)
 {
     int smp, sockets = 0, threads = 0, cores = 0;
-    char *endptr;
-    char option[128];
 
-    smp = strtoul(optarg, &endptr, 10);
-    if (endptr != optarg) {
-        if (*endptr == ',') {
-            endptr++;
-        }
-    }
-    if (get_param_value(option, 128, "sockets", endptr) != 0)
-        sockets = strtoull(option, NULL, 10);
-    if (get_param_value(option, 128, "cores", endptr) != 0)
-        cores = strtoull(option, NULL, 10);
-    if (get_param_value(option, 128, "threads", endptr) != 0)
-        threads = strtoull(option, NULL, 10);
-    if (get_param_value(option, 128, "maxcpus", endptr) != 0)
-        max_cpus = strtoull(option, NULL, 10);
+    smp = qemu_opt_get_number(opts, "cpus", 0);
+    sockets = qemu_opt_get_number(opts, "sockets", 0);
+    cores = qemu_opt_get_number(opts, "cores", 0);
+    threads = qemu_opt_get_number(opts, "threads", 0);
+    max_cpus = qemu_opt_get_number(opts, "maxcpus", 0);
 
     /* compute missing values, prefer sockets over cores over threads */
     if (smp == 0 || sockets == 0) {
@@ -1035,8 +1024,22 @@ static void smp_parse(const char *optarg)
     smp_cpus = smp;
     smp_cores = cores > 0 ? cores : 1;
     smp_threads = threads > 0 ? threads : 1;
-    if (max_cpus == 0)
+    if (max_cpus == 0) {
         max_cpus = smp_cpus;
+    }
+    if (smp_cpus < 1) {
+        fprintf(stderr, "Invalid number of CPUs\n");
+        return 1;
+    }
+    if (max_cpus < smp_cpus) {
+        fprintf(stderr, "maxcpus must be equal to or greater than cpus\n");
+        return 1;
+    }
+    if (max_cpus > 255) {
+        fprintf(stderr, "Unsupported number of maxcpus\n");
+        return 1;
+    }
+    return 0;
 }
 
 /***********************************************************/
@@ -2967,20 +2970,7 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_smp:
-                smp_parse(optarg);
-                if (smp_cpus < 1) {
-                    fprintf(stderr, "Invalid number of CPUs\n");
-                    exit(1);
-                }
-                if (max_cpus < smp_cpus) {
-                    fprintf(stderr, "maxcpus must be equal to or greater than "
-                            "smp\n");
-                    exit(1);
-                }
-                if (max_cpus > 255) {
-                    fprintf(stderr, "Unsupported number of maxcpus\n");
-                    exit(1);
-                }
+                qemu_opts_parse(qemu_find_opts("smp"), optarg, 1);
                 break;
 	    case QEMU_OPTION_vnc:
 #ifdef CONFIG_VNC
@@ -3230,9 +3220,12 @@ int main(int argc, char **argv, char **envp)
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
      */
-    if (!max_cpus)
+    if (qemu_opts_foreach(qemu_find_opts("smp"), smp_init_func, NULL, 1) != 0) {
+        exit(1);
+    }
+    if (!max_cpus) {
         max_cpus = smp_cpus;
-
+    }
     machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
     if (smp_cpus > machine->max_cpus) {
         fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 09/12] cmdline: reindent numa_add
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (7 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 08/12] cmdline: convert -smp to QemuOpts Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 10/12] cmdline: convert -numa to QemuOpts Paolo Bonzini
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c |   72 +++++++++++++++++++++++++++++++++---------------------------------
 1 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/vl.c b/vl.c
index ce55468..d9a9cac 100644
--- a/vl.c
+++ b/vl.c
@@ -950,49 +950,49 @@ static void numa_add(const char *optarg)
     int nodenr;
 
     optarg = get_opt_name(option, 128, optarg, ',') + 1;
-    if (!strcmp(option, "node")) {
-        if (get_param_value(option, 128, "nodeid", optarg) == 0) {
-            nodenr = nb_numa_nodes;
-        } else {
-            nodenr = strtoull(option, NULL, 10);
-        }
+    if (strcmp(option, "node")) {
+        return;
+    }
+    if (get_param_value(option, 128, "nodeid", optarg) == 0) {
+        nodenr = nb_numa_nodes;
+    } else {
+        nodenr = strtoull(option, NULL, 10);
+    }
 
-        if (get_param_value(option, 128, "mem", optarg) == 0) {
-            node_mem[nodenr] = 0;
-        } else {
-            int64_t sval;
-            sval = strtosz(option, &endptr);
-            if (sval < 0 || *endptr) {
-                fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
-                exit(1);
-            }
-            node_mem[nodenr] = sval;
+    if (get_param_value(option, 128, "mem", optarg) == 0) {
+        node_mem[nodenr] = 0;
+    } else {
+        int64_t sval;
+        sval = strtosz(option, &endptr);
+        if (sval < 0 || *endptr) {
+            fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
+            exit(1);
         }
-        if (get_param_value(option, 128, "cpus", optarg) == 0) {
-            node_cpumask[nodenr] = 0;
+        node_mem[nodenr] = sval;
+    }
+    if (get_param_value(option, 128, "cpus", optarg) == 0) {
+        node_cpumask[nodenr] = 0;
+    } else {
+        value = strtoull(option, &endptr, 10);
+        if (value >= 64) {
+            value = 63;
+            fprintf(stderr, "only 64 CPUs in NUMA mode supported.\n");
         } else {
-            value = strtoull(option, &endptr, 10);
-            if (value >= 64) {
-                value = 63;
-                fprintf(stderr, "only 64 CPUs in NUMA mode supported.\n");
-            } else {
-                if (*endptr == '-') {
-                    endvalue = strtoull(endptr+1, &endptr, 10);
-                    if (endvalue >= 63) {
-                        endvalue = 62;
-                        fprintf(stderr,
-                            "only 63 CPUs in NUMA mode supported.\n");
-                    }
-                    value = (2ULL << endvalue) - (1ULL << value);
-                } else {
-                    value = 1ULL << value;
+            if (*endptr == '-') {
+                endvalue = strtoull(endptr+1, &endptr, 10);
+                if (endvalue >= 63) {
+                    endvalue = 62;
+                    fprintf(stderr,
+                        "only 63 CPUs in NUMA mode supported.\n");
                 }
+                value = (2ULL << endvalue) - (1ULL << value);
+            } else {
+                value = 1ULL << value;
             }
-            node_cpumask[nodenr] = value;
         }
-        nb_numa_nodes++;
+        node_cpumask[nodenr] = value;
     }
-    return;
+    nb_numa_nodes++;
 }
 
 static int smp_init_func(QemuOpts *opts, void *opaque)
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 10/12] cmdline: convert -numa to QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (8 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 09/12] cmdline: reindent numa_add Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 11/12] cmdline: implement -nodefaults with qemuopts Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts Paolo Bonzini
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This requires some special casing to skip the fake "node" option and
to handle the automatic "-numa node" syntax.  Besides this, the option
parsing maps easily to QemuOpts.

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

diff --git a/qemu-config.c b/qemu-config.c
index c1a4642..f5cf56b 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -630,6 +630,27 @@ QemuOptsList qemu_smp_opts = {
     },
 };
 
+QemuOptsList qemu_numa_opts = {
+    .name = "numa",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_numa_opts.head),
+    .desc = {
+        {
+            .name = "nodeid",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Numeric identifier for the node",
+        }, {
+            .name = "mem",
+            .type = QEMU_OPT_SIZE,
+            .help = "Amount of memory for this node",
+        }, {
+            .name = "cpus",
+            .type = QEMU_OPT_STRING,
+            .help = "Identifier or range of identifiers for CPUs in this node",
+        },
+        { /*End of list */ }
+    },
+};
+
 QemuOptsList qemu_boot_opts = {
     .name = "boot-opts",
     .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
@@ -670,6 +691,7 @@ static QemuOptsList *vm_config_groups[32] = {
     &qemu_option_rom_opts,
     &qemu_machine_opts,
     &qemu_smp_opts,
+    &qemu_numa_opts,
     &qemu_boot_opts,
     &qemu_iscsi_opts,
     NULL,
diff --git a/vl.c b/vl.c
index d9a9cac..b485f4c 100644
--- a/vl.c
+++ b/vl.c
@@ -942,41 +942,29 @@ char *get_boot_devices_list(uint32_t *size)
     return list;
 }
 
-static void numa_add(const char *optarg)
+static int numa_add(QemuOpts *opts, void *opaque)
 {
-    char option[128];
+    const char *option;
     char *endptr;
     unsigned long long value, endvalue;
     int nodenr;
 
-    optarg = get_opt_name(option, 128, optarg, ',') + 1;
-    if (strcmp(option, "node")) {
-        return;
-    }
-    if (get_param_value(option, 128, "nodeid", optarg) == 0) {
-        nodenr = nb_numa_nodes;
-    } else {
-        nodenr = strtoull(option, NULL, 10);
+    nodenr = qemu_opt_get_number(opts, "nodeid", nb_numa_nodes);
+    if (nodenr >= MAX_NODES) {
+        fprintf(stderr, "only %d NUMA nodes supported.\n", MAX_NODES);
+        return 1;
     }
 
-    if (get_param_value(option, 128, "mem", optarg) == 0) {
-        node_mem[nodenr] = 0;
-    } else {
-        int64_t sval;
-        sval = strtosz(option, &endptr);
-        if (sval < 0 || *endptr) {
-            fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
-            exit(1);
-        }
-        node_mem[nodenr] = sval;
-    }
-    if (get_param_value(option, 128, "cpus", optarg) == 0) {
-        node_cpumask[nodenr] = 0;
-    } else {
+    node_mem[nodenr] = qemu_opt_get_size(opts, "mem", 0);
+    node_cpumask[nodenr] = 0;
+
+    option = qemu_opt_get(opts, "cpus");
+    if (option) {
         value = strtoull(option, &endptr, 10);
         if (value >= 64) {
             value = 63;
             fprintf(stderr, "only 64 CPUs in NUMA mode supported.\n");
+            return 1;
         } else {
             if (*endptr == '-') {
                 endvalue = strtoull(endptr+1, &endptr, 10);
@@ -984,6 +972,7 @@ static void numa_add(const char *optarg)
                     endvalue = 62;
                     fprintf(stderr,
                         "only 63 CPUs in NUMA mode supported.\n");
+                    return 1;
                 }
                 value = (2ULL << endvalue) - (1ULL << value);
             } else {
@@ -993,6 +982,7 @@ static void numa_add(const char *optarg)
         node_cpumask[nodenr] = value;
     }
     nb_numa_nodes++;
+    return 0;
 }
 
 static int smp_init_func(QemuOpts *opts, void *opaque)
@@ -2493,7 +2483,13 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "qemu: too many NUMA nodes\n");
                     exit(1);
                 }
-                numa_add(optarg);
+                if (strcmp(optarg, "node") == 0) {
+                    qemu_opts_create(qemu_find_opts("numa"), NULL, 0);
+                } else if (memcmp(optarg, "node,", 5) == 0) {
+                    qemu_opts_parse(qemu_find_opts("numa"), optarg + 5, 0);
+                } else {
+                    fprintf(stderr, "qemu: expected 'node', -numa ignored\n");
+                }
                 break;
             case QEMU_OPTION_display:
                 display_type = select_display(optarg);
@@ -3234,6 +3230,10 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+    if (qemu_opts_foreach(qemu_find_opts("numa"), numa_add, NULL, 1) != 0) {
+        exit(1);
+    }
+
     /*
      * Get the default machine options from the machine if it is not already
      * specified either by the configuration file or by the command line.
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 11/12] cmdline: implement -nodefaults with qemuopts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (9 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 10/12] cmdline: convert -numa to QemuOpts Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts Paolo Bonzini
  11 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

This becomes -machine default_devices.

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

diff --git a/qemu-config.c b/qemu-config.c
index f5cf56b..6e97ff6 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 b485f4c..aa324ed 100644
--- a/vl.c
+++ b/vl.c
@@ -3075,15 +3075,7 @@ int main(int argc, char **argv, char **envp)
                 incoming = optarg;
                 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;
-                default_vga = 0;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "default_devices", "off");
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
@@ -3243,26 +3235,30 @@ int main(int argc, char **argv, char **envp)
                                machine->default_machine_opts, 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;
+        default_vga = 0;
     }
 
     if (display_type == DT_NOGRAPHIC) {
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts
  2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
                   ` (10 preceding siblings ...)
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 11/12] cmdline: implement -nodefaults with qemuopts Paolo Bonzini
@ 2012-03-20  8:01 ` Paolo Bonzini
  2012-03-20  9:04   ` Peter Maydell
  11 siblings, 1 reply; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  8:01 UTC (permalink / raw)
  To: qemu-devel

They are also moved inside -machine.

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

diff --git a/qemu-config.c b/qemu-config.c
index 6e97ff6..e901826 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -568,6 +568,14 @@ static QemuOptsList qemu_machine_opts = {
             .type = QEMU_OPT_BOOL,
             .help = "start machine immediately",
         }, {
+            .name = "no_reboot",
+            .type = QEMU_OPT_BOOL,
+            .help = "exit instead of rebooting",
+        }, {
+            .name = "no_shutdown",
+            .type = QEMU_OPT_BOOL,
+            .help = "stop before shutdown",
+        }, {
             .name = "bios",
             .type = QEMU_OPT_STRING,
             .help = "BIOS/firmware file",
diff --git a/vl.c b/vl.c
index aa324ed..b2a69a5 100644
--- a/vl.c
+++ b/vl.c
@@ -2990,10 +2990,10 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_no_reboot:
-                no_reboot = 1;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "no_reboot", "on");
                 break;
             case QEMU_OPTION_no_shutdown:
-                no_shutdown = 1;
+                qemu_opts_set(qemu_find_opts("machine"), 0, "no_shutdown", "on");
                 break;
             case QEMU_OPTION_show_cursor:
                 cursor_hide = 0;
@@ -3309,6 +3309,8 @@ int main(int argc, char **argv, char **envp)
     kernel_filename = initrd_filename = kernel_cmdline = NULL;
     ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
     if (machine_opts) {
+        no_reboot = qemu_opt_get_bool(machine_opts, "no_reboot", false);
+        no_shutdown = qemu_opt_get_bool(machine_opts, "no_shutdown", false);
         autostart = qemu_opt_get_bool(machine_opts, "autostart", true);
         bios_name = qemu_opt_get(machine_opts, "bios");
         ram_size = qemu_opt_get_size(machine_opts, "ram_size", ram_size);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts
  2012-03-20  8:01 ` [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts Paolo Bonzini
@ 2012-03-20  9:04   ` Peter Maydell
  2012-03-20  9:15     ` Paolo Bonzini
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2012-03-20  9:04 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On 20 March 2012 08:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
> They are also moved inside -machine.

So why "no_reboot" and "no_shutdown" but "autostart" rather than
"no_autostart"?

-- PMM

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts
  2012-03-20  9:04   ` Peter Maydell
@ 2012-03-20  9:15     ` Paolo Bonzini
  0 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2012-03-20  9:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

Il 20/03/2012 10:04, Peter Maydell ha scritto:
>> > They are also moved inside -machine.
> So why "no_reboot" and "no_shutdown" but "autostart" rather than
> "no_autostart"?

Because. :)

Seriously, perhaps we want two enum options on_reboot/on_shutdown with
items reboot/stop/quit?

Paolo

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-03-20  9:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-20  8:01 [Qemu-devel] [PATCH 00/12] convert many options to QemuOpts Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 01/12] vga: disable default VGA if appropriate -device is used Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 02/12] QemuOpts: use strtosz Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 03/12] cmdline: implement -m with QemuOpts Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 04/12] cmdline: implement -S " Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 05/12] cmdline: implement -bios " Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 06/12] cmdline: implement -localtime " Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 07/12] cmdline: make -M a simple alias for -machine type Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 08/12] cmdline: convert -smp to QemuOpts Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 09/12] cmdline: reindent numa_add Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 10/12] cmdline: convert -numa to QemuOpts Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 11/12] cmdline: implement -nodefaults with qemuopts Paolo Bonzini
2012-03-20  8:01 ` [Qemu-devel] [PATCH 12/12] cmdline: convert -no-shutdown and -no-reboot to QemuOpts Paolo Bonzini
2012-03-20  9:04   ` Peter Maydell
2012-03-20  9:15     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).