qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing
@ 2020-10-21 20:56 Paolo Bonzini
  2020-10-21 20:56 ` [PATCH 01/22] semihosting: fix order of initialization functions Paolo Bonzini
                   ` (21 more replies)
  0 siblings, 22 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

This series cleans up qemu_init, grouping together code that does
a similar function.  In particular:

* generic initialization of various subsystemd is placed in separate
functions

* code that was randomly placed in vl.c is moved to machine.c

* early options that affect the whole program are grouped
together (-sandbox, -name, -trace, -L)

* pure syntactic sugar options (-mem-prealloc, -watchdog)
are grouped together

* the creation of backends is split into an "early" (before -machine)
and a "late" (after -machine) part


The remaining code that I have not split deals mostly with setting
up the machine object; this includes -smp, -boot, -m, -numa.  With
this refactoring, one can (almost) see some clearly delimited phases:

* before the machine is created, only backends can be created
(e.g. early -object processing).  In principle more initialization
could be moved before the machine is created: the machine class is
available and it can be used to decide which default devices to create.

* after the machine is created, the accelerator needs to be established

* after the accelerator is established, board setup can
proceed and devices can be created


Apart from the obvious absence of commands like machine-set and accel-set
(and making chardev-add, blockdev-add etc. available in preconfig mode),
the following complications are the blockers for pure-QMP configuration
of machines:

* as usual, there is no hook into board creation code to communicate
the backends for on-board devices.  This is because serial_hd,
nd_table etc. don't have a QAPI/QMP representation.

* the current "preconfig" loop does not let you configure enough, since it
ends before devices can be created and the regular monitor loop only
starts after qdev_machine_creation_done.  Perhaps x-exit-preconfig would
execute everything up to (and excluding) qdev_machine_creation_done,
while the rest would be deferred to the first "cont" command using a vm
state change notifier.

Paolo

Paolo Bonzini (22):
  semihosting: fix order of initialization functions
  machine: remove deprecated -machine enforce-config-section option
  machine: move UP defaults to class_base_init
  machine: move SMP initialization from vl.c
  vl: extract validation of -smp to machine.c
  vl: remove bogus check
  trace: remove argument from trace_init_file
  vl: split various early command line options to a separate function
  vl: move various initialization routines out of qemu_init
  vl: extract qemu_init_subsystems
  vl: move prelaunch part of qemu_init to a new function
  vl: move bios_name out of softmmu/vl.c
  vl: extract various command line validation snippets to a new function
  vl: preconfig and loadvm are mutually exclusive
  vl: extract various command line desugaring snippets to a new function
  vl: create "-net nic -net user" default earlier
  vl: load plugins as late as possible
  vl: move semihosting command line fallback to qemu_finish_machine_init
  vl: extract default devices to separate functions
  vl: move CHECKPOINT_INIT after preconfig
  vl: separate qemu_create_early_backends
  vl: separate qemu_create_late_backends

 bsd-user/main.c                      |    6 +-
 docs/system/deprecated.rst           |   12 +-
 hw/core/machine.c                    |   68 +-
 include/hw/boards.h                  |    2 +-
 include/hw/qdev-core.h               |    8 -
 include/sysemu/sysemu.h              |    1 +
 linux-user/main.c                    |    6 +-
 migration/migration.c                |   12 +-
 qemu-img.c                           |    6 +-
 qemu-io.c                            |    6 +-
 qemu-nbd.c                           |    6 +-
 qemu-options.hx                      |    8 -
 scsi/qemu-pr-helper.c                |    6 +-
 softmmu/qdev-monitor.c               |    6 -
 softmmu/vl.c                         | 1249 +++++++++++++-------------
 storage-daemon/qemu-storage-daemon.c |    9 +-
 trace/control.c                      |   10 +-
 trace/control.h                      |   12 +-
 18 files changed, 704 insertions(+), 729 deletions(-)

-- 
2.26.2



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

* [PATCH 01/22] semihosting: fix order of initialization functions
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
@ 2020-10-21 20:56 ` Paolo Bonzini
  2020-10-27 11:18   ` Alex Bennée
  2020-10-21 20:56 ` [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option Paolo Bonzini
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

qemu_semihosting_console_init uses semihosting.chardev which is set
by qemu_semihosting_connect_chardevs.  Thus qemu_semihosting_connect_chardevs
has to be called first.

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

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 6f5b000f07..42314e6ff9 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4288,7 +4288,8 @@ void qemu_init(int argc, char **argv, char **envp)
     qemu_opts_foreach(qemu_find_opts("mon"),
                       mon_init_func, NULL, &error_fatal);
 
-    /* connect semihosting console input if requested */
+    /* now chardevs have been created we may have semihosting to connect */
+    qemu_semihosting_connect_chardevs();
     qemu_semihosting_console_init();
 
     if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
@@ -4298,9 +4299,6 @@ void qemu_init(int argc, char **argv, char **envp)
     if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
         exit(1);
 
-    /* now chardevs have been created we may have semihosting to connect */
-    qemu_semihosting_connect_chardevs();
-
     /* If no default VGA is requested, the default is "none".  */
     if (default_vga) {
         vga_model = get_default_vga_model(machine_class);
-- 
2.26.2




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

* [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
  2020-10-21 20:56 ` [PATCH 01/22] semihosting: fix order of initialization functions Paolo Bonzini
@ 2020-10-21 20:56 ` Paolo Bonzini
  2020-10-22  5:09   ` Thomas Huth
  2020-10-21 20:56 ` [PATCH 03/22] machine: move UP defaults to class_base_init Paolo Bonzini
                   ` (19 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Deprecated since 3.1 and complicates the initialization sequence,
remove it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/system/deprecated.rst | 12 ++++++------
 hw/core/machine.c          | 24 +-----------------------
 include/hw/boards.h        |  1 -
 migration/migration.c      | 10 ----------
 qemu-options.hx            |  8 --------
 5 files changed, 7 insertions(+), 48 deletions(-)

diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 895433c356..0ebce37a19 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -21,12 +21,6 @@ deprecated.
 System emulator command line arguments
 --------------------------------------
 
-``-machine enforce-config-section=on|off`` (since 3.1)
-''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-The ``enforce-config-section`` parameter is replaced by the
-``-global migration.send-configuration={on|off}`` option.
-
 ``-usbdevice`` (since 2.10.0)
 '''''''''''''''''''''''''''''
 
@@ -689,6 +683,12 @@ Support for invalid topologies is removed, the user must ensure
 topologies described with -smp include all possible cpus, i.e.
 *sockets* * *cores* * *threads* = *maxcpus*.
 
+``-machine enforce-config-section=on|off`` (removed 5.2)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The ``enforce-config-section`` property was replaced by the
+``-global migration.send-configuration={on|off}`` option.
+
 Block devices
 -------------
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d740a7e963..80a918895a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -26,6 +26,7 @@
 #include "sysemu/qtest.h"
 #include "hw/pci/pci.h"
 #include "hw/mem/nvdimm.h"
+#include "migration/misc.h"
 #include "migration/vmstate.h"
 
 GlobalProperty hw_compat_5_1[] = {
@@ -411,24 +412,6 @@ static bool machine_get_suppress_vmdesc(Object *obj, Error **errp)
     return ms->suppress_vmdesc;
 }
 
-static void machine_set_enforce_config_section(Object *obj, bool value,
-                                             Error **errp)
-{
-    MachineState *ms = MACHINE(obj);
-
-    warn_report("enforce-config-section is deprecated, please use "
-                "-global migration.send-configuration=on|off instead");
-
-    ms->enforce_config_section = value;
-}
-
-static bool machine_get_enforce_config_section(Object *obj, Error **errp)
-{
-    MachineState *ms = MACHINE(obj);
-
-    return ms->enforce_config_section;
-}
-
 static char *machine_get_memory_encryption(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
@@ -857,11 +840,6 @@ static void machine_class_init(ObjectClass *oc, void *data)
     object_class_property_set_description(oc, "suppress-vmdesc",
         "Set on to disable self-describing migration");
 
-    object_class_property_add_bool(oc, "enforce-config-section",
-        machine_get_enforce_config_section, machine_set_enforce_config_section);
-    object_class_property_set_description(oc, "enforce-config-section",
-        "Set on to enforce configuration section migration");
-
     object_class_property_add_str(oc, "memory-encryption",
         machine_get_memory_encryption, machine_set_memory_encryption);
     object_class_property_set_description(oc, "memory-encryption",
diff --git a/include/hw/boards.h b/include/hw/boards.h
index bf53e8a16e..a49e3a6b44 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -268,7 +268,6 @@ struct MachineState {
     char *firmware;
     bool iommu;
     bool suppress_vmdesc;
-    bool enforce_config_section;
     bool enable_graphics;
     char *memory_encryption;
     char *ram_memdev_id;
diff --git a/migration/migration.c b/migration/migration.c
index 0575ecb379..deb6005b8d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -145,7 +145,6 @@ static void migrate_fd_cancel(MigrationState *s);
 
 void migration_object_init(void)
 {
-    MachineState *ms = MACHINE(qdev_get_machine());
     Error *err = NULL;
 
     /* This can only be called once. */
@@ -170,15 +169,6 @@ void migration_object_init(void)
         error_report_err(err);
         exit(1);
     }
-
-    /*
-     * We cannot really do this in migration_instance_init() since at
-     * that time global properties are not yet applied, then this
-     * value will be definitely replaced by something else.
-     */
-    if (ms->enforce_config_section) {
-        current_migration->send_configuration = true;
-    }
 }
 
 void migration_shutdown(void)
diff --git a/qemu-options.hx b/qemu-options.hx
index 9e1ace04f7..2c83390504 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -34,7 +34,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
     "                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
     "                suppress-vmdesc=on|off disables self-describing migration (default=off)\n"
     "                nvdimm=on|off controls NVDIMM support (default=off)\n"
-    "                enforce-config-section=on|off enforce configuration section migration (default=off)\n"
     "                memory-encryption=@var{} memory encryption object to use (default=none)\n"
     "                hmat=on|off controls ACPI HMAT support (default=off)\n",
     QEMU_ARCH_ALL)
@@ -91,13 +90,6 @@ SRST
     ``nvdimm=on|off``
         Enables or disables NVDIMM support. The default is off.
 
-    ``enforce-config-section=on|off``
-        If ``enforce-config-section`` is set to on, force migration code
-        to send configuration section even if the machine-type sets the
-        ``migration.send-configuration`` property to off. NOTE: this
-        parameter is deprecated. Please use ``-global``
-        ``migration.send-configuration``\ =on\|off instead.
-
     ``memory-encryption=``
         Memory encryption object to use. The default is none.
 
-- 
2.26.2




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

* [PATCH 03/22] machine: move UP defaults to class_base_init
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
  2020-10-21 20:56 ` [PATCH 01/22] semihosting: fix order of initialization functions Paolo Bonzini
  2020-10-21 20:56 ` [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option Paolo Bonzini
@ 2020-10-21 20:56 ` Paolo Bonzini
  2020-10-22  5:11   ` Thomas Huth
  2020-10-21 20:56 ` [PATCH 04/22] machine: move SMP initialization from vl.c Paolo Bonzini
                   ` (18 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Clean up vl.c, default min/max/default_cpus to uniprocessor
directly in the QOM class initialization code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c | 6 +++++-
 softmmu/vl.c      | 5 -----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 80a918895a..d3a8450b1f 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -854,8 +854,12 @@ static void machine_class_init(ObjectClass *oc, void *data)
 
 static void machine_class_base_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+    mc->max_cpus = mc->max_cpus ?: 1;
+    mc->min_cpus = mc->min_cpus ?: 1;
+    mc->default_cpus = mc->default_cpus ?: 1;
+
     if (!object_class_is_abstract(oc)) {
-        MachineClass *mc = MACHINE_CLASS(oc);
         const char *cname = object_class_get_name(oc);
         assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
         mc->name = g_strndup(cname,
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 42314e6ff9..75bc686397 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3966,11 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp)
         exit(0);
     }
 
-    /* machine_class: default to UP */
-    machine_class->max_cpus = machine_class->max_cpus ?: 1;
-    machine_class->min_cpus = machine_class->min_cpus ?: 1;
-    machine_class->default_cpus = machine_class->default_cpus ?: 1;
-
     /* default to machine_class->default_cpus */
     current_machine->smp.cpus = machine_class->default_cpus;
     current_machine->smp.max_cpus = machine_class->default_cpus;
-- 
2.26.2




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

* [PATCH 04/22] machine: move SMP initialization from vl.c
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (2 preceding siblings ...)
  2020-10-21 20:56 ` [PATCH 03/22] machine: move UP defaults to class_base_init Paolo Bonzini
@ 2020-10-21 20:56 ` Paolo Bonzini
  2020-10-22  7:16   ` Philippe Mathieu-Daudé
  2020-10-21 20:56 ` [PATCH 05/22] vl: extract validation of -smp to machine.c Paolo Bonzini
                   ` (17 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Initialize the object's values from the class when the object is
created, no need to have vl.c do it for us.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c | 7 +++++++
 softmmu/vl.c      | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index d3a8450b1f..7efeac03b3 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -908,6 +908,13 @@ static void machine_initfn(Object *obj)
     /* Register notifier when init is done for sysbus sanity checks */
     ms->sysbus_notifier.notify = machine_init_notify;
     qemu_add_machine_init_done_notifier(&ms->sysbus_notifier);
+
+    /* default to mc->default_cpus */
+    ms->smp.cpus = mc->default_cpus;
+    ms->smp.max_cpus = mc->default_cpus;
+    ms->smp.cores = 1;
+    ms->smp.threads = 1;
+    ms->smp.sockets = 1;
 }
 
 static void machine_finalize(Object *obj)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 75bc686397..05422a15ee 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3966,13 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp)
         exit(0);
     }
 
-    /* default to machine_class->default_cpus */
-    current_machine->smp.cpus = machine_class->default_cpus;
-    current_machine->smp.max_cpus = machine_class->default_cpus;
-    current_machine->smp.cores = 1;
-    current_machine->smp.threads = 1;
-    current_machine->smp.sockets = 1;
-
     machine_class->smp_parse(current_machine,
         qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
 
-- 
2.26.2




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

* [PATCH 05/22] vl: extract validation of -smp to machine.c
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (3 preceding siblings ...)
  2020-10-21 20:56 ` [PATCH 04/22] machine: move SMP initialization from vl.c Paolo Bonzini
@ 2020-10-21 20:56 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 06/22] vl: remove bogus check Paolo Bonzini
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Once smp_parse is done, the validation operates on the MachineState.
There is no reason for that code to be in vl.c.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c   | 23 +++++++++++++++++++++++
 include/hw/boards.h |  1 +
 softmmu/vl.c        | 20 ++------------------
 3 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 7efeac03b3..70b1e5e8e8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1073,6 +1073,29 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
     return ret;
 }
 
+bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
+{
+    MachineClass *mc = MACHINE_GET_CLASS(ms);
+
+    mc->smp_parse(ms, opts);
+
+    /* sanity-check smp_cpus and max_cpus against mc */
+    if (ms->smp.cpus < mc->min_cpus) {
+        error_setg(errp, "Invalid SMP CPUs %d. The min CPUs "
+                   "supported by machine '%s' is %d",
+                   ms->smp.cpus,
+                   mc->name, mc->min_cpus);
+        return false;
+    } else if (ms->smp.max_cpus > mc->max_cpus) {
+        error_setg(errp, "Invalid SMP CPUs %d. The max CPUs "
+                   "supported by machine '%s' is %d",
+                   current_machine->smp.max_cpus,
+                   mc->name, mc->max_cpus);
+        return false;
+    }
+    return true;
+}
+
 void machine_run_board_init(MachineState *machine)
 {
     MachineClass *machine_class = MACHINE_GET_CLASS(machine);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index a49e3a6b44..4537cfb5c6 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -26,6 +26,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE)
 extern MachineState *current_machine;
 
 void machine_run_board_init(MachineState *machine);
+bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp);
 bool machine_usb(MachineState *machine);
 int machine_phandle_start(MachineState *machine);
 bool machine_dump_guest_core(MachineState *machine);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 05422a15ee..8a7d11ef05 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3966,24 +3966,8 @@ void qemu_init(int argc, char **argv, char **envp)
         exit(0);
     }
 
-    machine_class->smp_parse(current_machine,
-        qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
-
-    /* sanity-check smp_cpus and max_cpus against machine_class */
-    if (current_machine->smp.cpus < machine_class->min_cpus) {
-        error_report("Invalid SMP CPUs %d. The min CPUs "
-                     "supported by machine '%s' is %d",
-                     current_machine->smp.cpus,
-                     machine_class->name, machine_class->min_cpus);
-        exit(1);
-    }
-    if (current_machine->smp.max_cpus > machine_class->max_cpus) {
-        error_report("Invalid SMP CPUs %d. The max CPUs "
-                     "supported by machine '%s' is %d",
-                     current_machine->smp.max_cpus,
-                     machine_class->name, machine_class->max_cpus);
-        exit(1);
-    }
+    machine_smp_parse(current_machine,
+        qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal);
 
     if (mem_prealloc) {
         char *val;
-- 
2.26.2




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

* [PATCH 06/22] vl: remove bogus check
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (4 preceding siblings ...)
  2020-10-21 20:56 ` [PATCH 05/22] vl: extract validation of -smp to machine.c Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 07/22] trace: remove argument from trace_init_file Paolo Bonzini
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

There is no reason to prevent -preconfig -daemonize.  Of course if
no monitor is defined there will be no way to start the VM,
but that is a user error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 8a7d11ef05..3def5f3688 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4022,12 +4022,6 @@ void qemu_init(int argc, char **argv, char **envp)
     }
 
     if (is_daemonized()) {
-        if (!preconfig_exit_requested) {
-            error_report("'preconfig' and 'daemonize' options are "
-                         "mutually exclusive");
-            exit(EXIT_FAILURE);
-        }
-
         /* According to documentation and historically, -nographic redirects
          * serial port, parallel port and monitor to stdio, which does not work
          * with -daemonize.  We can redirect these to null instead, but since
-- 
2.26.2




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

* [PATCH 07/22] trace: remove argument from trace_init_file
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (5 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 06/22] vl: remove bogus check Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 08/22] vl: split various early command line options to a separate function Paolo Bonzini
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

It is not needed, all the callers are just saving what was
retrieved from -trace and trace_init_file can retrieve it
on its own.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 bsd-user/main.c                      |  6 ++----
 linux-user/main.c                    |  6 ++----
 qemu-img.c                           |  6 ++----
 qemu-io.c                            |  6 ++----
 qemu-nbd.c                           |  6 ++----
 scsi/qemu-pr-helper.c                |  6 ++----
 softmmu/vl.c                         |  6 ++----
 storage-daemon/qemu-storage-daemon.c |  9 +++------
 trace/control.c                      | 10 ++++------
 trace/control.h                      | 12 +++---------
 10 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index ac40d79bfa..0a918e8f74 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -745,7 +745,6 @@ int main(int argc, char **argv)
     const char *gdbstub = NULL;
     char **target_environ, **wrk;
     envlist_t *envlist = NULL;
-    char *trace_file = NULL;
     bsd_type = target_openbsd;
 
     if (argc <= 1)
@@ -851,8 +850,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "strace")) {
             do_strace = 1;
         } else if (!strcmp(r, "trace")) {
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
         } else {
             usage();
         }
@@ -880,7 +878,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
 
     /* Zero out regs */
     memset(regs, 0, sizeof(struct target_pt_regs));
diff --git a/linux-user/main.c b/linux-user/main.c
index 75c9785157..24d1eb73ad 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -386,11 +386,9 @@ static void handle_arg_version(const char *arg)
     exit(EXIT_SUCCESS);
 }
 
-static char *trace_file;
 static void handle_arg_trace(const char *arg)
 {
-    g_free(trace_file);
-    trace_file = trace_opt_parse(arg);
+    trace_opt_parse(arg);
 }
 
 #if defined(TARGET_XTENSA)
@@ -672,7 +670,7 @@ int main(int argc, char **argv, char **envp)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     if (qemu_plugin_load_list(&plugins)) {
         exit(1);
     }
diff --git a/qemu-img.c b/qemu-img.c
index 2103507936..ccfdf1f48d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -5434,7 +5434,6 @@ int main(int argc, char **argv)
     const img_cmd_t *cmd;
     const char *cmdname;
     Error *local_error = NULL;
-    char *trace_file = NULL;
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
@@ -5484,8 +5483,7 @@ int main(int argc, char **argv)
             printf(QEMU_IMG_VERSION);
             return 0;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         }
     }
@@ -5503,7 +5501,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     /* find the command */
diff --git a/qemu-io.c b/qemu-io.c
index 7cc832b3d6..ac88d8bd40 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -536,7 +536,6 @@ int main(int argc, char **argv)
     Error *local_error = NULL;
     QDict *opts = NULL;
     const char *format = NULL;
-    char *trace_file = NULL;
     bool force_share = false;
 
 #ifdef CONFIG_POSIX
@@ -601,8 +600,7 @@ int main(int argc, char **argv)
             }
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case 'V':
             printf("%s version " QEMU_FULL_VERSION "\n"
@@ -653,7 +651,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     /* initialize commands */
diff --git a/qemu-nbd.c b/qemu-nbd.c
index bc644a0670..37adeb0596 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -573,7 +573,6 @@ int main(int argc, char **argv)
     const char *tlscredsid = NULL;
     bool imageOpts = false;
     bool writethrough = true;
-    char *trace_file = NULL;
     bool fork_process = false;
     bool list = false;
     int old_stderr = -1;
@@ -767,8 +766,7 @@ int main(int argc, char **argv)
             imageOpts = true;
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case QEMU_NBD_OPT_TLSAUTHZ:
             tlsauthz = optarg;
@@ -815,7 +813,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     socket_activation = check_socket_activation();
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index d26faaf91e..2733d92f2d 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -884,7 +884,6 @@ int main(int argc, char **argv)
     int quiet = 0;
     int ch;
     Error *local_err = NULL;
-    char *trace_file = NULL;
     bool daemonize = false;
     bool pidfile_specified = false;
     bool socket_path_specified = false;
@@ -968,8 +967,7 @@ int main(int argc, char **argv)
             ++loglevel;
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case 'V':
             version(argv[0]);
@@ -992,7 +990,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(EXIT_FAILURE);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
 #ifdef CONFIG_MPATH
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3def5f3688..05e661abb8 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2883,7 +2883,6 @@ void qemu_init(int argc, char **argv, char **envp)
     int display_remote = 0;
     const char *log_mask = NULL;
     const char *log_file = NULL;
-    char *trace_file = NULL;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
@@ -3684,8 +3683,7 @@ void qemu_init(int argc, char **argv, char **envp)
                 xen_domid_restrict = true;
                 break;
             case QEMU_OPTION_trace:
-                g_free(trace_file);
-                trace_file = trace_opt_parse(optarg);
+                trace_opt_parse(optarg);
                 break;
             case QEMU_OPTION_plugin:
                 qemu_plugin_opt_parse(optarg, &plugin_list);
@@ -3931,7 +3929,7 @@ void qemu_init(int argc, char **argv, char **envp)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
 
     /* Open the logfile at this point and set the log mask if necessary.
      */
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index e419ba9f19..7c914b0dc1 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -180,12 +180,9 @@ static void process_options(int argc, char *argv[])
             help();
             exit(EXIT_SUCCESS);
         case 'T':
-            {
-                char *trace_file = trace_opt_parse(optarg);
-                trace_init_file(trace_file);
-                g_free(trace_file);
-                break;
-            }
+            trace_opt_parse(optarg);
+            trace_init_file();
+            break;
         case 'V':
             printf("qemu-storage-daemon version "
                    QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
diff --git a/trace/control.c b/trace/control.c
index b35e512dce..7a57fa7dd5 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -221,8 +221,10 @@ static void trace_init_events(const char *fname)
     loc_pop(&loc);
 }
 
-void trace_init_file(const char *file)
+void trace_init_file(void)
 {
+    QemuOpts *opts = qemu_find_opts_singleton("trace");
+    const char *file = qemu_opt_get(opts, "file");
 #ifdef CONFIG_TRACE_SIMPLE
     st_set_trace_file(file);
     st_set_trace_file_enabled(true);
@@ -286,9 +288,8 @@ bool trace_init_backends(void)
     return true;
 }
 
-char *trace_opt_parse(const char *optarg)
+void trace_opt_parse(const char *optarg)
 {
-    char *trace_file;
     QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
                                              optarg, true);
     if (!opts) {
@@ -298,10 +299,7 @@ char *trace_opt_parse(const char *optarg)
         trace_enable_events(qemu_opt_get(opts, "enable"));
     }
     trace_init_events(qemu_opt_get(opts, "events"));
-    trace_file = g_strdup(qemu_opt_get(opts, "file"));
     qemu_opts_del(opts);
-
-    return trace_file;
 }
 
 uint32_t trace_get_vcpu_event_count(void)
diff --git a/trace/control.h b/trace/control.h
index 1f81c491b6..05b95ea453 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -167,8 +167,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
 
 /**
  * trace_init_backends:
- * @file:   Name of trace output file; may be NULL.
- *          Corresponds to commandline option "--trace file=...".
  *
  * Initialize the tracing backend.
  *
@@ -178,14 +176,12 @@ bool trace_init_backends(void);
 
 /**
  * trace_init_file:
- * @file:   Name of trace output file; may be NULL.
- *          Corresponds to commandline option "--trace file=...".
  *
  * Record the name of the output file for the tracing backend.
  * Exits if no selected backend does not support specifying the
- * output file, and a non-NULL file was passed.
+ * output file, and a file was specified with "-trace file=...".
  */
-void trace_init_file(const char *file);
+void trace_init_file(void);
 
 /**
  * trace_init_vcpu:
@@ -229,10 +225,8 @@ extern QemuOptsList qemu_trace_opts;
  * @optarg: A string argument of --trace command line argument
  *
  * Initialize tracing subsystem.
- *
- * Returns the filename to save trace to.  It must be freed with g_free().
  */
-char *trace_opt_parse(const char *optarg);
+void trace_opt_parse(const char *optarg);
 
 /**
  * trace_get_vcpu_event_count:
-- 
2.26.2




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

* [PATCH 08/22] vl: split various early command line options to a separate function
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (6 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 07/22] trace: remove argument from trace_init_file Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 09/22] vl: move various initialization routines out of qemu_init Paolo Bonzini
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Various options affect the global state of QEMU including the rest of
qemu_init, and they need to be called very early.  Group them together
in a function that is called at the beginning.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 202 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 113 insertions(+), 89 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 05e661abb8..2e1714d7a4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -117,6 +117,7 @@
 
 #define MAX_VIRTIO_CONSOLES 1
 
+static const char *cpu_option;
 static const char *data_dir[16];
 static int data_dir_idx;
 const char *bios_name = NULL;
@@ -143,6 +144,9 @@ int vga_interface_type = VGA_NONE;
 static DisplayOptions dpy;
 static int num_serial_hds;
 static Chardev **serial_hds;
+static const char *log_mask = NULL;
+static const char *log_file = NULL;
+static bool list_data_dirs = false;
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 int win2k_install_hack = 0;
 int singlestep = 0;
@@ -2859,6 +2863,106 @@ static char *find_datadir(void)
     return get_relocated_path(CONFIG_QEMU_DATADIR);
 }
 
+static void qemu_process_early_options(void)
+{
+    char **dirs;
+    int i;
+
+#ifdef CONFIG_SECCOMP
+    QemuOptsList *olist = qemu_find_opts_err("sandbox", NULL);
+    if (olist) {
+        qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal);
+    }
+#endif
+
+    qemu_opts_foreach(qemu_find_opts("name"),
+                      parse_name, NULL, &error_fatal);
+
+#ifndef _WIN32
+    qemu_opts_foreach(qemu_find_opts("add-fd"),
+                      parse_add_fd, NULL, &error_fatal);
+
+    qemu_opts_foreach(qemu_find_opts("add-fd"),
+                      cleanup_add_fd, NULL, &error_fatal);
+#endif
+
+    if (!trace_init_backends()) {
+        exit(1);
+    }
+    trace_init_file();
+
+    /* Open the logfile at this point and set the log mask if necessary.
+     */
+    qemu_set_log_filename(log_file, &error_fatal);
+    if (log_mask) {
+        int mask;
+        mask = qemu_str_to_log_mask(log_mask);
+        if (!mask) {
+            qemu_print_log_usage(stdout);
+            exit(1);
+        }
+        qemu_set_log(mask);
+    } else {
+        qemu_set_log(0);
+    }
+
+    /* add configured firmware directories */
+    dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
+    for (i = 0; dirs[i] != NULL; i++) {
+        qemu_add_data_dir(get_relocated_path(dirs[i]));
+    }
+    g_strfreev(dirs);
+
+    /* try to find datadir relative to the executable path */
+    qemu_add_data_dir(find_datadir());
+}
+
+static void qemu_process_help_options(void)
+{
+    int i;
+
+    /*
+     * Check for -cpu help and -device help before we call select_machine(),
+     * which will return an error if the architecture has no default machine
+     * type and the user did not specify one, so that the user doesn't need
+     * to say '-cpu help -machine something'.
+     */
+    if (cpu_option && is_help_option(cpu_option)) {
+        list_cpus(cpu_option);
+        exit(0);
+    }
+
+    if (qemu_opts_foreach(qemu_find_opts("device"),
+                          device_help_func, NULL, NULL)) {
+        exit(0);
+    }
+
+    /* -L help lists the data directories and exits. */
+    if (list_data_dirs) {
+        for (i = 0; i < data_dir_idx; i++) {
+            printf("%s\n", data_dir[i]);
+        }
+        exit(0);
+    }
+}
+
+static void qemu_maybe_daemonize(const char *pid_file)
+{
+    Error *err;
+
+    os_daemonize();
+    rcu_disable_atfork();
+
+    if (pid_file && !qemu_write_pidfile(pid_file, &err)) {
+        error_reportf_err(err, "cannot create PID file: ");
+        exit(1);
+    }
+
+    qemu_unlink_pidfile_notifier.notify = qemu_unlink_pidfile;
+    qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier);
+}
+
+
 void qemu_init(int argc, char **argv, char **envp)
 {
     int i;
@@ -2875,21 +2979,16 @@ void qemu_init(int argc, char **argv, char **envp)
     const char *optarg;
     const char *loadvm = NULL;
     MachineClass *machine_class;
-    const char *cpu_option;
     const char *vga_model = NULL;
     const char *incoming = NULL;
     bool userconfig = true;
     bool nographic = false;
     int display_remote = 0;
-    const char *log_mask = NULL;
-    const char *log_file = NULL;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
     Error *main_loop_err = NULL;
     Error *err = NULL;
-    bool list_data_dirs = false;
-    char **dirs;
     const char *mem_path = NULL;
     bool have_custom_ram_size;
     BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
@@ -3833,20 +3932,17 @@ void qemu_init(int argc, char **argv, char **envp)
      */
     loc_set_none();
 
-    /*
-     * Check for -cpu help and -device help before we call select_machine(),
-     * which will return an error if the architecture has no default machine
-     * type and the user did not specify one, so that the user doesn't need
-     * to say '-cpu help -machine something'.
+    /* These options affect everything else and should be processed
+     * before daemonizing.
      */
-    if (cpu_option && is_help_option(cpu_option)) {
-        list_cpus(cpu_option);
-        exit(0);
-    }
+    qemu_process_early_options();
 
-    if (qemu_opts_foreach(qemu_find_opts("device"),
-                          device_help_func, NULL, NULL)) {
-        exit(0);
+    qemu_process_help_options();
+    qemu_maybe_daemonize(pid_file);
+
+    if (qemu_init_main_loop(&main_loop_err)) {
+        error_report_err(main_loop_err);
+        exit(1);
     }
 
     user_register_global_props();
@@ -3867,40 +3963,6 @@ void qemu_init(int argc, char **argv, char **envp)
     have_custom_ram_size = set_memory_options(&ram_slots, &maxram_size,
                                               machine_class);
 
-    os_daemonize();
-    rcu_disable_atfork();
-
-    if (pid_file && !qemu_write_pidfile(pid_file, &err)) {
-        error_reportf_err(err, "cannot create PID file: ");
-        exit(1);
-    }
-
-    qemu_unlink_pidfile_notifier.notify = qemu_unlink_pidfile;
-    qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier);
-
-    if (qemu_init_main_loop(&main_loop_err)) {
-        error_report_err(main_loop_err);
-        exit(1);
-    }
-
-#ifdef CONFIG_SECCOMP
-    olist = qemu_find_opts_err("sandbox", NULL);
-    if (olist) {
-        qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal);
-    }
-#endif
-
-    qemu_opts_foreach(qemu_find_opts("name"),
-                      parse_name, NULL, &error_fatal);
-
-#ifndef _WIN32
-    qemu_opts_foreach(qemu_find_opts("add-fd"),
-                      parse_add_fd, NULL, &error_fatal);
-
-    qemu_opts_foreach(qemu_find_opts("add-fd"),
-                      cleanup_add_fd, NULL, &error_fatal);
-#endif
-
     current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class)));
     if (machine_help_func(qemu_get_machine_opts(), current_machine)) {
         exit(0);
@@ -3926,44 +3988,6 @@ void qemu_init(int argc, char **argv, char **envp)
         qemu_set_hw_version(machine_class->hw_version);
     }
 
-    if (!trace_init_backends()) {
-        exit(1);
-    }
-    trace_init_file();
-
-    /* Open the logfile at this point and set the log mask if necessary.
-     */
-    qemu_set_log_filename(log_file, &error_fatal);
-    if (log_mask) {
-        int mask;
-        mask = qemu_str_to_log_mask(log_mask);
-        if (!mask) {
-            qemu_print_log_usage(stdout);
-            exit(1);
-        }
-        qemu_set_log(mask);
-    } else {
-        qemu_set_log(0);
-    }
-
-    /* add configured firmware directories */
-    dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
-    for (i = 0; dirs[i] != NULL; i++) {
-        qemu_add_data_dir(get_relocated_path(dirs[i]));
-    }
-    g_strfreev(dirs);
-
-    /* try to find datadir relative to the executable path */
-    qemu_add_data_dir(find_datadir());
-
-    /* -L help lists the data directories and exits. */
-    if (list_data_dirs) {
-        for (i = 0; i < data_dir_idx; i++) {
-            printf("%s\n", data_dir[i]);
-        }
-        exit(0);
-    }
-
     machine_smp_parse(current_machine,
         qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal);
 
-- 
2.26.2




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

* [PATCH 09/22] vl: move various initialization routines out of qemu_init
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (7 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 08/22] vl: split various early command line options to a separate function Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 10/22] vl: extract qemu_init_subsystems Paolo Bonzini
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Some very simple initialization routines can be nested in existing
subsystem-level functions, do that to simplify qemu_init.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c      | 3 +++
 include/hw/qdev-core.h | 8 --------
 migration/migration.c  | 4 ++++
 softmmu/qdev-monitor.c | 6 ------
 softmmu/vl.c           | 5 -----
 5 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 70b1e5e8e8..3c674bb05e 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -873,6 +873,9 @@ static void machine_initfn(Object *obj)
     MachineState *ms = MACHINE(obj);
     MachineClass *mc = MACHINE_GET_CLASS(obj);
 
+    container_get(obj, "/peripheral");
+    container_get(obj, "/peripheral-anon");
+
     ms->dump_guest_core = true;
     ms->mem_merge = true;
     ms->enable_graphics = true;
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 868973319e..56ce7f2d7f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -769,14 +769,6 @@ BusState *sysbus_get_default(void);
 char *qdev_get_fw_dev_path(DeviceState *dev);
 char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
 
-/**
- * @qdev_machine_init
- *
- * Initialize platform devices before machine init.  This is a hack until full
- * support for composition is added.
- */
-void qdev_machine_init(void);
-
 /**
  * device_legacy_reset:
  *
diff --git a/migration/migration.c b/migration/migration.c
index deb6005b8d..f48b03cac2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -169,6 +169,10 @@ void migration_object_init(void)
         error_report_err(err);
         exit(1);
     }
+
+    blk_mig_init();
+    ram_mig_init();
+    dirty_bitmap_mig_init();
 }
 
 void migration_shutdown(void)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index bcfb90a08f..bcfcbac181 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -943,12 +943,6 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
     return blk;
 }
 
-void qdev_machine_init(void)
-{
-    qdev_get_peripheral_anon();
-    qdev_get_peripheral();
-}
-
 QemuOptsList qemu_device_opts = {
     .name = "device",
     .implied_opt_name = "driver",
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 2e1714d7a4..a9f69a7d11 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4269,10 +4269,6 @@ void qemu_init(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    blk_mig_init();
-    ram_mig_init();
-    dirty_bitmap_mig_init();
-
     qemu_opts_foreach(qemu_find_opts("mon"),
                       mon_init_func, NULL, &error_fatal);
 
@@ -4305,7 +4301,6 @@ void qemu_init(int argc, char **argv, char **envp)
        reading from the other reads, because timer polling functions query
        clock values from the log. */
     replay_checkpoint(CHECKPOINT_INIT);
-    qdev_machine_init();
 
     current_machine->boot_order = boot_order;
 
-- 
2.26.2




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

* [PATCH 10/22] vl: extract qemu_init_subsystems
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (8 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 09/22] vl: move various initialization routines out of qemu_init Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 11/22] vl: move prelaunch part of qemu_init to a new function Paolo Bonzini
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Group a bunch of subsystem initializations that can be done right
after command line parsing.  Remove initializations that can be done
simply as global variable initializers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 94 ++++++++++++++++++++++++----------------------------
 1 file changed, 43 insertions(+), 51 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index a9f69a7d11..e731d754ec 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -129,7 +129,7 @@ bool enable_mlock = false;
 bool enable_cpu_pm = false;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
-int autostart;
+int autostart = 1;
 static enum {
     RTC_BASE_UTC,
     RTC_BASE_LOCALTIME,
@@ -1229,7 +1229,8 @@ struct VMChangeStateEntry {
     int priority;
 };
 
-static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head;
+static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head =
+    QTAILQ_HEAD_INITIALIZER(vm_change_state_head);
 
 /**
  * qemu_add_vm_change_state_handler_prio:
@@ -2962,11 +2963,45 @@ static void qemu_maybe_daemonize(const char *pid_file)
     qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier);
 }
 
+static void qemu_init_subsystems(void)
+{
+    Error *err;
+
+    os_set_line_buffering();
+
+    module_call_init(MODULE_INIT_TRACE);
+
+    qemu_init_cpu_list();
+    qemu_init_cpu_loop();
+    qemu_mutex_lock_iothread();
+
+    atexit(qemu_run_exit_notifiers);
+
+    module_call_init(MODULE_INIT_QOM);
+    module_call_init(MODULE_INIT_MIGRATION);
+
+    runstate_init();
+    precopy_infrastructure_init();
+    postcopy_infrastructure_init();
+    monitor_init_globals();
+
+    if (qcrypto_init(&err) < 0) {
+        error_reportf_err(err, "cannot initialize crypto: ");
+        exit(1);
+    }
+
+    os_setup_early_signal_handling();
+
+    bdrv_init_with_whitelist();
+    page_size_init();
+    socket_init();
+}
 
 void qemu_init(int argc, char **argv, char **envp)
 {
     int i;
-    int snapshot, linux_boot;
+    int snapshot = 0;
+    int linux_boot;
     const char *initrd_filename;
     const char *kernel_filename, *kernel_cmdline;
     const char *boot_order = NULL;
@@ -2987,7 +3022,6 @@ void qemu_init(int argc, char **argv, char **envp)
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
-    Error *main_loop_err = NULL;
     Error *err = NULL;
     const char *mem_path = NULL;
     bool have_custom_ram_size;
@@ -2995,22 +3029,6 @@ void qemu_init(int argc, char **argv, char **envp)
     QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
     int mem_prealloc = 0; /* force preallocation of physical target memory */
 
-    os_set_line_buffering();
-
-    error_init(argv[0]);
-    module_call_init(MODULE_INIT_TRACE);
-
-    qemu_init_cpu_list();
-    qemu_init_cpu_loop();
-
-    qemu_mutex_lock_iothread();
-
-    atexit(qemu_run_exit_notifiers);
-    qemu_init_exec_dir(argv[0]);
-
-    module_call_init(MODULE_INIT_QOM);
-    module_call_init(MODULE_INIT_MIGRATION);
-
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
     qemu_add_drive_opts(&qemu_common_drive_opts);
@@ -3045,27 +3063,10 @@ void qemu_init(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_fw_cfg_opts);
     module_call_init(MODULE_INIT_OPTS);
 
-    runstate_init();
-    precopy_infrastructure_init();
-    postcopy_infrastructure_init();
-    monitor_init_globals();
-
-    if (qcrypto_init(&err) < 0) {
-        error_reportf_err(err, "cannot initialize crypto: ");
-        exit(1);
-    }
-
-    QTAILQ_INIT(&vm_change_state_head);
-    os_setup_early_signal_handling();
-
-    cpu_option = NULL;
-    snapshot = 0;
-
-    nb_nics = 0;
-
-    bdrv_init_with_whitelist();
+    error_init(argv[0]);
+    qemu_init_exec_dir(argv[0]);
 
-    autostart = 1;
+    qemu_init_subsystems();
 
     /* first pass of option parsing */
     optind = 1;
@@ -3940,13 +3941,10 @@ void qemu_init(int argc, char **argv, char **envp)
     qemu_process_help_options();
     qemu_maybe_daemonize(pid_file);
 
-    if (qemu_init_main_loop(&main_loop_err)) {
-        error_report_err(main_loop_err);
-        exit(1);
-    }
+    qemu_init_main_loop(&error_fatal);
+    cpu_timers_init();
 
     user_register_global_props();
-
     replay_configure(icount_opts);
 
     if (incoming && !preconfig_exit_requested) {
@@ -4125,9 +4123,6 @@ void qemu_init(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    page_size_init();
-    socket_init();
-
     qemu_opts_foreach(qemu_find_opts("object"),
                       user_creatable_add_opts_foreach,
                       object_create_initial, &error_fatal);
@@ -4245,9 +4240,6 @@ void qemu_init(int argc, char **argv, char **envp)
         semihosting_arg_fallback(kernel_filename, kernel_cmdline);
     }
 
-    /* initialize cpu timers and VCPU throttle modules */
-    cpu_timers_init();
-
     if (default_net) {
         QemuOptsList *net = qemu_find_opts("net");
         qemu_opts_set(net, NULL, "type", "nic", &error_abort);
-- 
2.26.2




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

* [PATCH 11/22] vl: move prelaunch part of qemu_init to a new function
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (9 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 10/22] vl: extract qemu_init_subsystems Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 12/22] vl: move bios_name out of softmmu/vl.c Paolo Bonzini
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

The final part of qemu_init, starting with the completion of
board init, is already relatively clean.  Split it out of
qemu_init so that qemu_init keeps only the messy parts.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/sysemu/sysemu.h |   1 +
 softmmu/vl.c            | 238 +++++++++++++++++++++-------------------
 2 files changed, 124 insertions(+), 115 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 817ff4cf75..9f47b2a354 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -112,6 +112,7 @@ QemuOpts *qemu_get_machine_opts(void);
 bool defaults_enabled(void);
 
 void qemu_init(int argc, char **argv, char **envp);
+void qemu_finish_machine_init(void);
 void qemu_main_loop(void);
 void qemu_cleanup(void);
 
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e731d754ec..52e7d317d7 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -120,6 +120,9 @@
 static const char *cpu_option;
 static const char *data_dir[16];
 static int data_dir_idx;
+static const char *mem_path;
+static const char *boot_order;
+static const char *boot_once;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
@@ -2997,6 +3000,125 @@ static void qemu_init_subsystems(void)
     socket_init();
 }
 
+/* Called after leaving preconfig state.  */
+void qemu_finish_machine_init(void)
+{
+    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+    DisplayState *ds;
+
+    if (machine_class->default_ram_id && current_machine->ram_size &&
+        numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
+        create_default_memdev(current_machine, mem_path);
+    }
+
+    /* from here on runstate is RUN_STATE_PRELAUNCH */
+    machine_run_board_init(current_machine);
+
+    /*
+     * TODO To drop support for deprecated bogus if=..., move
+     * drive_check_orphaned() here, replacing this call.  Also drop
+     * its deprecation warning, along with DriveInfo member
+     * @claimed_by_board.
+     */
+    drive_mark_claimed_by_board();
+
+    realtime_init();
+
+    soundhw_init();
+
+    if (hax_enabled()) {
+        hax_sync_vcpus();
+    }
+
+    qemu_opts_foreach(qemu_find_opts("fw_cfg"),
+                      parse_fw_cfg, fw_cfg_find(), &error_fatal);
+
+    /* init USB devices */
+    if (machine_usb(current_machine)) {
+        if (foreach_device_config(DEV_USB, usb_parse) < 0)
+            exit(1);
+    }
+
+    /* init generic devices */
+    rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
+    qemu_opts_foreach(qemu_find_opts("device"),
+                      device_init_func, NULL, &error_fatal);
+
+    cpu_synchronize_all_post_init();
+
+    rom_reset_order_override();
+
+    /* Did we create any drives that we failed to create a device for? */
+    drive_check_orphaned();
+
+    /* Don't warn about the default network setup that you get if
+     * no command line -net or -netdev options are specified. There
+     * are two cases that we would otherwise complain about:
+     * (1) board doesn't support a NIC but the implicit "-net nic"
+     * requested one
+     * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic"
+     * sets up a nic that isn't connected to anything.
+     */
+    if (!default_net && (!qtest_enabled() || has_defaults)) {
+        net_check_clients();
+    }
+
+    if (boot_once) {
+        qemu_boot_set(boot_once, &error_fatal);
+        qemu_register_reset(restore_boot_order, g_strdup(boot_order));
+    }
+
+    /* init local displays */
+    ds = init_displaystate();
+    qemu_display_init(ds, &dpy);
+
+    /* must be after terminal init, SDL library changes signal handlers */
+    os_setup_signal_handling();
+
+    /* init remote displays */
+#ifdef CONFIG_VNC
+    qemu_opts_foreach(qemu_find_opts("vnc"),
+                      vnc_init_func, NULL, &error_fatal);
+#endif
+
+    if (using_spice) {
+        qemu_spice_display_init();
+    }
+
+    if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
+        exit(1);
+    }
+
+    qdev_machine_creation_done();
+
+    /* TODO: once all bus devices are qdevified, this should be done
+     * when bus is created by qdev.c */
+    /*
+     * TODO: If we had a main 'reset container' that the whole system
+     * lived in, we could reset that using the multi-phase reset
+     * APIs. For the moment, we just reset the sysbus, which will cause
+     * all devices hanging off it (and all their child buses, recursively)
+     * to be reset. Note that this will *not* reset any Device objects
+     * which are not attached to some part of the qbus tree!
+     */
+    qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
+    qemu_run_machine_init_done_notifiers();
+
+    if (rom_check_and_register_reset() != 0) {
+        error_report("rom check and register reset failed");
+        exit(1);
+    }
+
+    replay_start();
+
+    /* This checkpoint is required by replay to separate prior clock
+       reading from the other reads, because timer polling functions query
+       clock values from the log. */
+    replay_checkpoint(CHECKPOINT_RESET);
+    qemu_system_reset(SHUTDOWN_CAUSE_NONE);
+    register_global_state();
+}
+
 void qemu_init(int argc, char **argv, char **envp)
 {
     int i;
@@ -3004,9 +3126,6 @@ void qemu_init(int argc, char **argv, char **envp)
     int linux_boot;
     const char *initrd_filename;
     const char *kernel_filename, *kernel_cmdline;
-    const char *boot_order = NULL;
-    const char *boot_once = NULL;
-    DisplayState *ds;
     QemuOpts *opts, *machine_opts;
     QemuOpts *icount_opts = NULL, *accel_opts = NULL;
     QemuOptsList *olist;
@@ -3023,7 +3142,6 @@ void qemu_init(int argc, char **argv, char **envp)
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
     Error *err = NULL;
-    const char *mem_path = NULL;
     bool have_custom_ram_size;
     BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
     QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
@@ -4340,117 +4458,8 @@ void qemu_init(int argc, char **argv, char **envp)
     /* do monitor/qmp handling at preconfig state if requested */
     qemu_main_loop();
 
-    if (machine_class->default_ram_id && current_machine->ram_size &&
-        numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
-        create_default_memdev(current_machine, mem_path);
-    }
-
-    /* from here on runstate is RUN_STATE_PRELAUNCH */
-    machine_run_board_init(current_machine);
-
-    /*
-     * TODO To drop support for deprecated bogus if=..., move
-     * drive_check_orphaned() here, replacing this call.  Also drop
-     * its deprecation warning, along with DriveInfo member
-     * @claimed_by_board.
-     */
-    drive_mark_claimed_by_board();
-
-    realtime_init();
-
-    soundhw_init();
-
-    if (hax_enabled()) {
-        hax_sync_vcpus();
-    }
-
-    qemu_opts_foreach(qemu_find_opts("fw_cfg"),
-                      parse_fw_cfg, fw_cfg_find(), &error_fatal);
-
-    /* init USB devices */
-    if (machine_usb(current_machine)) {
-        if (foreach_device_config(DEV_USB, usb_parse) < 0)
-            exit(1);
-    }
-
-    /* init generic devices */
-    rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
-    qemu_opts_foreach(qemu_find_opts("device"),
-                      device_init_func, NULL, &error_fatal);
-
-    cpu_synchronize_all_post_init();
-
-    rom_reset_order_override();
-
-    /* Did we create any drives that we failed to create a device for? */
-    drive_check_orphaned();
-
-    /* Don't warn about the default network setup that you get if
-     * no command line -net or -netdev options are specified. There
-     * are two cases that we would otherwise complain about:
-     * (1) board doesn't support a NIC but the implicit "-net nic"
-     * requested one
-     * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic"
-     * sets up a nic that isn't connected to anything.
-     */
-    if (!default_net && (!qtest_enabled() || has_defaults)) {
-        net_check_clients();
-    }
-
-    if (boot_once) {
-        qemu_boot_set(boot_once, &error_fatal);
-        qemu_register_reset(restore_boot_order, g_strdup(boot_order));
-    }
+    qemu_finish_machine_init();
 
-    /* init local displays */
-    ds = init_displaystate();
-    qemu_display_init(ds, &dpy);
-
-    /* must be after terminal init, SDL library changes signal handlers */
-    os_setup_signal_handling();
-
-    /* init remote displays */
-#ifdef CONFIG_VNC
-    qemu_opts_foreach(qemu_find_opts("vnc"),
-                      vnc_init_func, NULL, &error_fatal);
-#endif
-
-    if (using_spice) {
-        qemu_spice_display_init();
-    }
-
-    if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
-        exit(1);
-    }
-
-    qdev_machine_creation_done();
-
-    /* TODO: once all bus devices are qdevified, this should be done
-     * when bus is created by qdev.c */
-    /*
-     * TODO: If we had a main 'reset container' that the whole system
-     * lived in, we could reset that using the multi-phase reset
-     * APIs. For the moment, we just reset the sysbus, which will cause
-     * all devices hanging off it (and all their child buses, recursively)
-     * to be reset. Note that this will *not* reset any Device objects
-     * which are not attached to some part of the qbus tree!
-     */
-    qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
-    qemu_run_machine_init_done_notifiers();
-
-    if (rom_check_and_register_reset() != 0) {
-        error_report("rom check and register reset failed");
-        exit(1);
-    }
-
-    replay_start();
-
-    /* This checkpoint is required by replay to separate prior clock
-       reading from the other reads, because timer polling functions query
-       clock values from the log. */
-    replay_checkpoint(CHECKPOINT_RESET);
-    qemu_system_reset(SHUTDOWN_CAUSE_NONE);
-    register_global_state();
     if (loadvm) {
         Error *local_err = NULL;
         if (load_snapshot(loadvm, &local_err) < 0) {
@@ -4469,7 +4478,6 @@ void qemu_init(int argc, char **argv, char **envp)
         dump_vmstate_json_to_file(vmstate_dump_file);
         exit(0);
     }
-
     if (incoming) {
         Error *local_err = NULL;
         qemu_start_incoming_migration(incoming, &local_err);
-- 
2.26.2




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

* [PATCH 12/22] vl: move bios_name out of softmmu/vl.c
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (10 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 11/22] vl: move prelaunch part of qemu_init to a new function Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-22  7:22   ` Philippe Mathieu-Daudé
  2020-10-21 20:57 ` [PATCH 13/22] vl: extract various command line validation snippets to a new function Paolo Bonzini
                   ` (9 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

bios_name is a legacy variable used by machine code.  Hide it
from softmmu/vl.c.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c | 5 +++++
 softmmu/vl.c      | 2 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 3c674bb05e..e4dac350d4 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -212,6 +212,8 @@ GlobalProperty hw_compat_2_1[] = {
 };
 const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1);
 
+const char *bios_name = NULL;
+
 static char *machine_get_kernel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
@@ -396,6 +398,9 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
 
     g_free(ms->firmware);
     ms->firmware = g_strdup(value);
+
+    /* HACK */
+    bios_name = ms->firmware;
 }
 
 static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 52e7d317d7..e32e209a82 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -123,7 +123,6 @@ static int data_dir_idx;
 static const char *mem_path;
 static const char *boot_order;
 static const char *boot_once;
-const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
 const char* keyboard_layout = NULL;
@@ -4314,7 +4313,6 @@ void qemu_init(int argc, char **argv, char **envp)
     kernel_filename = qemu_opt_get(machine_opts, "kernel");
     initrd_filename = qemu_opt_get(machine_opts, "initrd");
     kernel_cmdline = qemu_opt_get(machine_opts, "append");
-    bios_name = qemu_opt_get(machine_opts, "firmware");
 
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
-- 
2.26.2




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

* [PATCH 13/22] vl: extract various command line validation snippets to a new function
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (11 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 12/22] vl: move bios_name out of softmmu/vl.c Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 14/22] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 78 ++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index e32e209a82..f8b1ffb46e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -123,6 +123,7 @@ static int data_dir_idx;
 static const char *mem_path;
 static const char *boot_order;
 static const char *boot_once;
+static const char *incoming;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
 const char* keyboard_layout = NULL;
@@ -2866,6 +2867,39 @@ static char *find_datadir(void)
     return get_relocated_path(CONFIG_QEMU_DATADIR);
 }
 
+static void qemu_validate_options(void)
+{
+    QemuOpts *machine_opts = qemu_get_machine_opts();
+    const char *kernel_filename = qemu_opt_get(machine_opts, "kernel");
+    const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
+    const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
+
+    if (kernel_filename == NULL) {
+         if (kernel_cmdline != NULL) {
+              error_report("-append only allowed with -kernel option");
+              exit(1);
+          }
+
+          if (initrd_filename != NULL) {
+              error_report("-initrd only allowed with -kernel option");
+              exit(1);
+          }
+    }
+
+    if (incoming && !preconfig_exit_requested) {
+        error_report("'preconfig' and 'incoming' options are "
+                     "mutually exclusive");
+        exit(EXIT_FAILURE);
+    }
+
+#ifdef CONFIG_CURSES
+    if (is_daemonized() && dpy.type == DISPLAY_TYPE_CURSES) {
+        error_report("curses display cannot be used with -daemonize");
+        exit(1);
+    }
+#endif
+}
+
 static void qemu_process_early_options(void)
 {
     char **dirs;
@@ -3122,9 +3156,6 @@ void qemu_init(int argc, char **argv, char **envp)
 {
     int i;
     int snapshot = 0;
-    int linux_boot;
-    const char *initrd_filename;
-    const char *kernel_filename, *kernel_cmdline;
     QemuOpts *opts, *machine_opts;
     QemuOpts *icount_opts = NULL, *accel_opts = NULL;
     QemuOptsList *olist;
@@ -3133,7 +3164,6 @@ void qemu_init(int argc, char **argv, char **envp)
     const char *loadvm = NULL;
     MachineClass *machine_class;
     const char *vga_model = NULL;
-    const char *incoming = NULL;
     bool userconfig = true;
     bool nographic = false;
     int display_remote = 0;
@@ -4050,6 +4080,8 @@ void qemu_init(int argc, char **argv, char **envp)
      */
     loc_set_none();
 
+    qemu_validate_options();
+
     /* These options affect everything else and should be processed
      * before daemonizing.
      */
@@ -4064,12 +4096,6 @@ void qemu_init(int argc, char **argv, char **envp)
     user_register_global_props();
     replay_configure(icount_opts);
 
-    if (incoming && !preconfig_exit_requested) {
-        error_report("'preconfig' and 'incoming' options are "
-                     "mutually exclusive");
-        exit(EXIT_FAILURE);
-    }
-
     configure_rtc(qemu_find_opts_singleton("rtc"));
 
     machine_class = select_machine();
@@ -4173,12 +4199,6 @@ void qemu_init(int argc, char **argv, char **envp)
             error_report("-nographic cannot be used with -daemonize");
             exit(1);
         }
-#ifdef CONFIG_CURSES
-        if (dpy.type == DISPLAY_TYPE_CURSES) {
-            error_report("curses display cannot be used with -daemonize");
-            exit(1);
-        }
-#endif
     }
 
     if (nographic) {
@@ -4309,11 +4329,6 @@ void qemu_init(int argc, char **argv, char **envp)
         qtest_server_init(qtest_chrdev, qtest_log, &error_fatal);
     }
 
-    machine_opts = qemu_get_machine_opts();
-    kernel_filename = qemu_opt_get(machine_opts, "kernel");
-    initrd_filename = qemu_opt_get(machine_opts, "initrd");
-    kernel_cmdline = qemu_opt_get(machine_opts, "append");
-
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
         boot_order = qemu_opt_get(opts, "order");
@@ -4334,24 +4349,9 @@ void qemu_init(int argc, char **argv, char **envp)
         boot_order = machine_class->default_boot_order;
     }
 
-    if (!kernel_cmdline) {
-        kernel_cmdline = "";
-        current_machine->kernel_cmdline = (char *)kernel_cmdline;
-    }
-
-    linux_boot = (kernel_filename != NULL);
-
-    if (!linux_boot && *kernel_cmdline != '\0') {
-        error_report("-append only allowed with -kernel option");
-        exit(1);
-    }
-
-    if (!linux_boot && initrd_filename != NULL) {
-        error_report("-initrd only allowed with -kernel option");
-        exit(1);
-    }
-
-    if (semihosting_enabled() && !semihosting_get_argc() && kernel_filename) {
+    if (semihosting_enabled() && !semihosting_get_argc()) {
+        const char *kernel_filename = qemu_opt_get(machine_opts, "kernel");
+        const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
         /* fall back to the -kernel/-append */
         semihosting_arg_fallback(kernel_filename, kernel_cmdline);
     }
-- 
2.26.2




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

* [PATCH 14/22] vl: preconfig and loadvm are mutually exclusive
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (12 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 13/22] vl: extract various command line validation snippets to a new function Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 15/22] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Just like -incoming.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index f8b1ffb46e..3607cd4357 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -124,6 +124,7 @@ static const char *mem_path;
 static const char *boot_order;
 static const char *boot_once;
 static const char *incoming;
+static const char *loadvm;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
 const char* keyboard_layout = NULL;
@@ -2886,6 +2887,11 @@ static void qemu_validate_options(void)
           }
     }
 
+    if (loadvm && !preconfig_exit_requested) {
+        error_report("'preconfig' and 'loadvm' options are "
+                     "mutually exclusive");
+        exit(EXIT_FAILURE);
+    }
     if (incoming && !preconfig_exit_requested) {
         error_report("'preconfig' and 'incoming' options are "
                      "mutually exclusive");
@@ -3161,7 +3167,6 @@ void qemu_init(int argc, char **argv, char **envp)
     QemuOptsList *olist;
     int optind;
     const char *optarg;
-    const char *loadvm = NULL;
     MachineClass *machine_class;
     const char *vga_model = NULL;
     bool userconfig = true;
-- 
2.26.2




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

* [PATCH 15/22] vl: extract various command line desugaring snippets to a new function
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (13 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 14/22] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 16/22] vl: create "-net nic -net user" default earlier Paolo Bonzini
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3607cd4357..122bf1821b 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -126,6 +126,7 @@ static const char *boot_once;
 static const char *incoming;
 static const char *loadvm;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
+int mem_prealloc; /* force preallocation of physical target memory */
 int display_opengl;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
@@ -159,7 +160,7 @@ int fd_bootchk = 1;
 static int no_reboot;
 int no_shutdown = 0;
 int graphic_rotate = 0;
-const char *watchdog;
+static const char *watchdog;
 QEMUOptionRom option_rom[MAX_OPTION_ROMS];
 int nb_option_roms;
 int old_param = 0;
@@ -2906,6 +2907,24 @@ static void qemu_validate_options(void)
 #endif
 }
 
+static void qemu_process_sugar_options(void)
+{
+    if (mem_prealloc) {
+        char *val;
+
+        val = g_strdup_printf("%ld", qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1));
+        object_register_sugar_prop("memory-backend", "prealloc-threads", val);
+        g_free(val);
+        object_register_sugar_prop("memory-backend", "prealloc", "on");
+    }
+
+    if (watchdog) {
+        int i = select_watchdog(watchdog);
+        if (i > 0)
+            exit (i == 1 ? 1 : 0);
+    }
+}
+
 static void qemu_process_early_options(void)
 {
     char **dirs;
@@ -3160,7 +3179,6 @@ void qemu_finish_machine_init(void)
 
 void qemu_init(int argc, char **argv, char **envp)
 {
-    int i;
     int snapshot = 0;
     QemuOpts *opts, *machine_opts;
     QemuOpts *icount_opts = NULL, *accel_opts = NULL;
@@ -3179,7 +3197,6 @@ void qemu_init(int argc, char **argv, char **envp)
     bool have_custom_ram_size;
     BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
     QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
-    int mem_prealloc = 0; /* force preallocation of physical target memory */
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
@@ -4086,6 +4103,7 @@ void qemu_init(int argc, char **argv, char **envp)
     loc_set_none();
 
     qemu_validate_options();
+    qemu_process_sugar_options();
 
     /* These options affect everything else and should be processed
      * before daemonizing.
@@ -4137,15 +4155,6 @@ void qemu_init(int argc, char **argv, char **envp)
     machine_smp_parse(current_machine,
         qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal);
 
-    if (mem_prealloc) {
-        char *val;
-
-        val = g_strdup_printf("%d", current_machine->smp.cpus);
-        object_register_sugar_prop("memory-backend", "prealloc-threads", val);
-        g_free(val);
-        object_register_sugar_prop("memory-backend", "prealloc", "on");
-    }
-
     /*
      * Get the default machine options from the machine if it is not already
      * specified either by the configuration file or by the command line.
@@ -4404,12 +4413,6 @@ void qemu_init(int argc, char **argv, char **envp)
         select_vgahw(machine_class, vga_model);
     }
 
-    if (watchdog) {
-        i = select_watchdog(watchdog);
-        if (i > 0)
-            exit (i == 1 ? 1 : 0);
-    }
-
     /* This checkpoint is required by replay to separate prior clock
        reading from the other reads, because timer polling functions query
        clock values from the log. */
-- 
2.26.2




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

* [PATCH 16/22] vl: create "-net nic -net user" default earlier
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (14 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 15/22] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 17/22] vl: load plugins as late as possible Paolo Bonzini
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Create it together with other default backends, even though the processing is
done later.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 122bf1821b..8577667b8f 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4235,6 +4235,14 @@ void qemu_init(int argc, char **argv, char **envp)
             monitor_parse("vc:80Cx24C", "readline", false);
     }
 
+    if (default_net) {
+        QemuOptsList *net = qemu_find_opts("net");
+        qemu_opts_set(net, NULL, "type", "nic", &error_abort);
+#ifdef CONFIG_SLIRP
+        qemu_opts_set(net, NULL, "type", "user", &error_abort);
+#endif
+    }
+
 #if defined(CONFIG_VNC)
     if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) {
         display_remote++;
@@ -4370,14 +4378,6 @@ void qemu_init(int argc, char **argv, char **envp)
         semihosting_arg_fallback(kernel_filename, kernel_cmdline);
     }
 
-    if (default_net) {
-        QemuOptsList *net = qemu_find_opts("net");
-        qemu_opts_set(net, NULL, "type", "nic", &error_abort);
-#ifdef CONFIG_SLIRP
-        qemu_opts_set(net, NULL, "type", "user", &error_abort);
-#endif
-    }
-
     if (net_init_clients(&err) < 0) {
         error_report_err(err);
         exit(1);
-- 
2.26.2




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

* [PATCH 17/22] vl: load plugins as late as possible
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (15 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 16/22] vl: create "-net nic -net user" default earlier Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-22  7:28   ` Philippe Mathieu-Daudé
  2020-10-21 20:57 ` [PATCH 18/22] vl: move semihosting command line fallback to qemu_finish_machine_init Paolo Bonzini
                   ` (4 subsequent siblings)
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

There is no need to load plugins in the middle of default device processing,
move -plugin handling just before preconfig is entered.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 8577667b8f..75e57133ad 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -125,6 +125,7 @@ static const char *boot_order;
 static const char *boot_once;
 static const char *incoming;
 static const char *loadvm;
+static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int mem_prealloc; /* force preallocation of physical target memory */
 int display_opengl;
@@ -3064,12 +3065,18 @@ void qemu_finish_machine_init(void)
     MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
     DisplayState *ds;
 
+    /* from here on runstate is RUN_STATE_PRELAUNCH */
+
     if (machine_class->default_ram_id && current_machine->ram_size &&
         numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
         create_default_memdev(current_machine, mem_path);
     }
 
-    /* from here on runstate is RUN_STATE_PRELAUNCH */
+    /* process plugin before CPUs are created, but once -smp has been parsed */
+    if (qemu_plugin_load_list(&plugin_list)) {
+        exit(1);
+    }
+
     machine_run_board_init(current_machine);
 
     /*
@@ -3196,7 +3203,6 @@ void qemu_init(int argc, char **argv, char **envp)
     Error *err = NULL;
     bool have_custom_ram_size;
     BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
-    QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
@@ -4164,11 +4170,6 @@ void qemu_init(int argc, char **argv, char **envp)
                                machine_class->default_machine_opts, 0);
     }
 
-    /* process plugin before CPUs are created, but once -smp has been parsed */
-    if (qemu_plugin_load_list(&plugin_list)) {
-        exit(1);
-    }
-
     qemu_opts_foreach(qemu_find_opts("device"),
                       default_driver_check, NULL, NULL);
     qemu_opts_foreach(qemu_find_opts("global"),
-- 
2.26.2




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

* [PATCH 18/22] vl: move semihosting command line fallback to qemu_finish_machine_init
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (16 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 17/22] vl: load plugins as late as possible Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 19/22] vl: extract default devices to separate functions Paolo Bonzini
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Move more sane parts of the huge qemu_init function out of it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 75e57133ad..e58572dbd8 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3067,6 +3067,11 @@ void qemu_finish_machine_init(void)
 
     /* from here on runstate is RUN_STATE_PRELAUNCH */
 
+    if (semihosting_enabled() && !semihosting_get_argc() && current_machine->kernel_filename) {
+        /* fall back to the -kernel/-append */
+        semihosting_arg_fallback(current_machine->kernel_filename, current_machine->kernel_cmdline);
+    }
+
     if (machine_class->default_ram_id && current_machine->ram_size &&
         numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
         create_default_memdev(current_machine, mem_path);
@@ -4372,13 +4377,6 @@ void qemu_init(int argc, char **argv, char **envp)
         boot_order = machine_class->default_boot_order;
     }
 
-    if (semihosting_enabled() && !semihosting_get_argc()) {
-        const char *kernel_filename = qemu_opt_get(machine_opts, "kernel");
-        const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
-        /* fall back to the -kernel/-append */
-        semihosting_arg_fallback(kernel_filename, kernel_cmdline);
-    }
-
     if (net_init_clients(&err) < 0) {
         error_report_err(err);
         exit(1);
-- 
2.26.2




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

* [PATCH 19/22] vl: extract default devices to separate functions
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (17 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 18/22] vl: move semihosting command line fallback to qemu_finish_machine_init Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 216 +++++++++++++++++++++++++++------------------------
 1 file changed, 114 insertions(+), 102 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index e58572dbd8..0a6f47e7d6 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -125,7 +125,9 @@ static const char *boot_order;
 static const char *boot_once;
 static const char *incoming;
 static const char *loadvm;
+static int display_remote;
 static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
+static bool nographic = false;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int mem_prealloc; /* force preallocation of physical target memory */
 int display_opengl;
@@ -147,6 +149,7 @@ static int rtc_host_datetime_offset = -1; /* valid & used only with
                                              RTC_BASE_DATETIME */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
+static const char *vga_model = NULL;
 static DisplayOptions dpy;
 static int num_serial_hds;
 static Chardev **serial_hds;
@@ -2224,6 +2227,115 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
     return 0;
 }
 
+static void qemu_disable_default_devices(void)
+{
+    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
+    qemu_opts_foreach(qemu_find_opts("device"),
+                      default_driver_check, NULL, NULL);
+    qemu_opts_foreach(qemu_find_opts("global"),
+                      default_driver_check, NULL, NULL);
+
+    if (!vga_model && !default_vga) {
+        vga_interface_type = VGA_DEVICE;
+    }
+    if (!has_defaults || machine_class->no_serial) {
+        default_serial = 0;
+    }
+    if (!has_defaults || machine_class->no_parallel) {
+        default_parallel = 0;
+    }
+    if (!has_defaults || machine_class->no_floppy) {
+        default_floppy = 0;
+    }
+    if (!has_defaults || machine_class->no_cdrom) {
+        default_cdrom = 0;
+    }
+    if (!has_defaults || machine_class->no_sdcard) {
+        default_sdcard = 0;
+    }
+    if (!has_defaults) {
+        default_monitor = 0;
+        default_net = 0;
+        default_vga = 0;
+    }
+}
+
+static void qemu_create_default_devices(void)
+{
+    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
+    if (is_daemonized()) {
+        /* According to documentation and historically, -nographic redirects
+         * serial port, parallel port and monitor to stdio, which does not work
+         * with -daemonize.  We can redirect these to null instead, but since
+         * -nographic is legacy, let's just error out.
+         * We disallow -nographic only if all other ports are not redirected
+         * explicitly, to not break existing legacy setups which uses
+         * -nographic _and_ redirects all ports explicitly - this is valid
+         * usage, -nographic is just a no-op in this case.
+         */
+        if (nographic
+            && (default_parallel || default_serial || default_monitor)) {
+            error_report("-nographic cannot be used with -daemonize");
+            exit(1);
+        }
+    }
+
+    if (nographic) {
+        if (default_parallel)
+            add_device_config(DEV_PARALLEL, "null");
+        if (default_serial && default_monitor) {
+            add_device_config(DEV_SERIAL, "mon:stdio");
+        } else {
+            if (default_serial)
+                add_device_config(DEV_SERIAL, "stdio");
+            if (default_monitor)
+                monitor_parse("stdio", "readline", false);
+        }
+    } else {
+        if (default_serial)
+            add_device_config(DEV_SERIAL, "vc:80Cx24C");
+        if (default_parallel)
+            add_device_config(DEV_PARALLEL, "vc:80Cx24C");
+        if (default_monitor)
+            monitor_parse("vc:80Cx24C", "readline", false);
+    }
+
+    if (default_net) {
+        QemuOptsList *net = qemu_find_opts("net");
+        qemu_opts_set(net, NULL, "type", "nic", &error_abort);
+#ifdef CONFIG_SLIRP
+        qemu_opts_set(net, NULL, "type", "user", &error_abort);
+#endif
+    }
+
+#if defined(CONFIG_VNC)
+    if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) {
+        display_remote++;
+    }
+#endif
+    if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
+        if (!qemu_display_find_default(&dpy)) {
+            dpy.type = DISPLAY_TYPE_NONE;
+#if defined(CONFIG_VNC)
+            vnc_parse("localhost:0,to=99,id=default", &error_abort);
+#endif
+        }
+    }
+    if (dpy.type == DISPLAY_TYPE_DEFAULT) {
+        dpy.type = DISPLAY_TYPE_NONE;
+    }
+
+    /* If no default VGA is requested, the default is "none".  */
+    if (default_vga) {
+        vga_model = get_default_vga_model(machine_class);
+    }
+    if (vga_model) {
+        select_vgahw(machine_class, vga_model);
+    }
+}
+
 static int serial_parse(const char *devname)
 {
     int index = num_serial_hds;
@@ -3198,10 +3310,7 @@ void qemu_init(int argc, char **argv, char **envp)
     int optind;
     const char *optarg;
     MachineClass *machine_class;
-    const char *vga_model = NULL;
     bool userconfig = true;
-    bool nographic = false;
-    int display_remote = 0;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
@@ -4175,97 +4284,8 @@ void qemu_init(int argc, char **argv, char **envp)
                                machine_class->default_machine_opts, 0);
     }
 
-    qemu_opts_foreach(qemu_find_opts("device"),
-                      default_driver_check, NULL, NULL);
-    qemu_opts_foreach(qemu_find_opts("global"),
-                      default_driver_check, NULL, NULL);
-
-    if (!vga_model && !default_vga) {
-        vga_interface_type = VGA_DEVICE;
-    }
-    if (!has_defaults || machine_class->no_serial) {
-        default_serial = 0;
-    }
-    if (!has_defaults || machine_class->no_parallel) {
-        default_parallel = 0;
-    }
-    if (!has_defaults || machine_class->no_floppy) {
-        default_floppy = 0;
-    }
-    if (!has_defaults || machine_class->no_cdrom) {
-        default_cdrom = 0;
-    }
-    if (!has_defaults || machine_class->no_sdcard) {
-        default_sdcard = 0;
-    }
-    if (!has_defaults) {
-        default_monitor = 0;
-        default_net = 0;
-        default_vga = 0;
-    }
-
-    if (is_daemonized()) {
-        /* According to documentation and historically, -nographic redirects
-         * serial port, parallel port and monitor to stdio, which does not work
-         * with -daemonize.  We can redirect these to null instead, but since
-         * -nographic is legacy, let's just error out.
-         * We disallow -nographic only if all other ports are not redirected
-         * explicitly, to not break existing legacy setups which uses
-         * -nographic _and_ redirects all ports explicitly - this is valid
-         * usage, -nographic is just a no-op in this case.
-         */
-        if (nographic
-            && (default_parallel || default_serial || default_monitor)) {
-            error_report("-nographic cannot be used with -daemonize");
-            exit(1);
-        }
-    }
-
-    if (nographic) {
-        if (default_parallel)
-            add_device_config(DEV_PARALLEL, "null");
-        if (default_serial && default_monitor) {
-            add_device_config(DEV_SERIAL, "mon:stdio");
-        } else {
-            if (default_serial)
-                add_device_config(DEV_SERIAL, "stdio");
-            if (default_monitor)
-                monitor_parse("stdio", "readline", false);
-        }
-    } else {
-        if (default_serial)
-            add_device_config(DEV_SERIAL, "vc:80Cx24C");
-        if (default_parallel)
-            add_device_config(DEV_PARALLEL, "vc:80Cx24C");
-        if (default_monitor)
-            monitor_parse("vc:80Cx24C", "readline", false);
-    }
-
-    if (default_net) {
-        QemuOptsList *net = qemu_find_opts("net");
-        qemu_opts_set(net, NULL, "type", "nic", &error_abort);
-#ifdef CONFIG_SLIRP
-        qemu_opts_set(net, NULL, "type", "user", &error_abort);
-#endif
-    }
-
-#if defined(CONFIG_VNC)
-    if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) {
-        display_remote++;
-    }
-#endif
-    if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
-        if (!qemu_display_find_default(&dpy)) {
-            dpy.type = DISPLAY_TYPE_NONE;
-#if defined(CONFIG_VNC)
-            vnc_parse("localhost:0,to=99,id=default", &error_abort);
-#endif
-        }
-    }
-    if (dpy.type == DISPLAY_TYPE_DEFAULT) {
-        dpy.type = DISPLAY_TYPE_NONE;
-    }
-
+    qemu_disable_default_devices();
+    qemu_create_default_devices();
     if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
         error_report("-alt-grab and -ctrl-grab are only valid "
                      "for SDL, ignoring option");
@@ -4404,14 +4424,6 @@ void qemu_init(int argc, char **argv, char **envp)
     if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
         exit(1);
 
-    /* If no default VGA is requested, the default is "none".  */
-    if (default_vga) {
-        vga_model = get_default_vga_model(machine_class);
-    }
-    if (vga_model) {
-        select_vgahw(machine_class, vga_model);
-    }
-
     /* This checkpoint is required by replay to separate prior clock
        reading from the other reads, because timer polling functions query
        clock values from the log. */
-- 
2.26.2




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

* [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (18 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 19/22] vl: extract default devices to separate functions Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-22  7:29   ` Philippe Mathieu-Daudé
  2020-10-21 20:57 ` [PATCH 21/22] vl: separate qemu_create_early_backends Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 22/22] vl: separate qemu_create_late_backends Paolo Bonzini
  21 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

Move CHECKPOINT_INIT right before the machine initialization is
completed.  Everything before is essentially an extension of
command line parsing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 0a6f47e7d6..e9391929f6 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3194,6 +3194,11 @@ void qemu_finish_machine_init(void)
         exit(1);
     }
 
+    /* This checkpoint is required by replay to separate prior clock
+       reading from the other reads, because timer polling functions query
+       clock values from the log. */
+    replay_checkpoint(CHECKPOINT_INIT);
+
     machine_run_board_init(current_machine);
 
     /*
@@ -4424,11 +4429,6 @@ void qemu_init(int argc, char **argv, char **envp)
     if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
         exit(1);
 
-    /* This checkpoint is required by replay to separate prior clock
-       reading from the other reads, because timer polling functions query
-       clock values from the log. */
-    replay_checkpoint(CHECKPOINT_INIT);
-
     current_machine->boot_order = boot_order;
 
     /* parse features once if machine provides default cpu_type */
-- 
2.26.2




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

* [PATCH 21/22] vl: separate qemu_create_early_backends
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (19 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  2020-10-21 20:57 ` [PATCH 22/22] vl: separate qemu_create_late_backends Paolo Bonzini
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

"Early" backends are created before the machine and can be used as
machine options.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 123 +++++++++++++++++++++++++++------------------------
 1 file changed, 65 insertions(+), 58 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index e9391929f6..866df5bb7c 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -117,6 +117,14 @@
 
 #define MAX_VIRTIO_CONSOLES 1
 
+typedef struct BlockdevOptionsQueueEntry {
+    BlockdevOptions *bdo;
+    Location loc;
+    QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry) entry;
+} BlockdevOptionsQueueEntry;
+
+typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
+
 static const char *cpu_option;
 static const char *data_dir[16];
 static int data_dir_idx;
@@ -126,7 +134,9 @@ static const char *boot_once;
 static const char *incoming;
 static const char *loadvm;
 static int display_remote;
+static int snapshot;
 static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
+static BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
 static bool nographic = false;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int mem_prealloc; /* force preallocation of physical target memory */
@@ -1043,14 +1053,6 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,
 
 }
 
-typedef struct BlockdevOptionsQueueEntry {
-    BlockdevOptions *bdo;
-    Location loc;
-    QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry) entry;
-} BlockdevOptionsQueueEntry;
-
-typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
-
 static void configure_blockdev(BlockdevOptionsQueue *bdo_queue,
                                MachineClass *machine_class, int snapshot)
 {
@@ -2640,7 +2642,7 @@ static int machine_set_property(void *opaque,
  * cannot be created here, as it depends on the chardev
  * already existing.
  */
-static bool object_create_initial(const char *type, QemuOpts *opts)
+static bool object_create_early(const char *type, QemuOpts *opts)
 {
     if (user_creatable_print_help(type, opts)) {
         exit(0);
@@ -2692,6 +2694,58 @@ static bool object_create_initial(const char *type, QemuOpts *opts)
     return true;
 }
 
+static void qemu_create_early_backends(void)
+{
+    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
+    if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
+        error_report("-alt-grab and -ctrl-grab are only valid "
+                     "for SDL, ignoring option");
+    }
+    if (dpy.has_window_close &&
+        (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) {
+        error_report("-no-quit is only valid for GTK and SDL, "
+                     "ignoring option");
+    }
+
+    qemu_display_early_init(&dpy);
+    qemu_console_early_init();
+
+    if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) {
+#if defined(CONFIG_OPENGL)
+        error_report("OpenGL is not supported by the display");
+#else
+        error_report("OpenGL support is disabled");
+#endif
+        exit(1);
+    }
+
+    qemu_opts_foreach(qemu_find_opts("object"),
+                      user_creatable_add_opts_foreach,
+                      object_create_early, &error_fatal);
+
+    /* spice needs the timers to be initialized by this point */
+    /* spice must initialize before audio as it changes the default auiodev */
+    /* spice must initialize before chardevs (for spicevmc and spiceport) */
+    qemu_spice_init();
+
+    qemu_opts_foreach(qemu_find_opts("chardev"),
+                      chardev_init_func, NULL, &error_fatal);
+
+#ifdef CONFIG_VIRTFS
+    qemu_opts_foreach(qemu_find_opts("fsdev"),
+                      fsdev_init_func, NULL, &error_fatal);
+#endif
+
+    /*
+     * Note: we need to create audio and block backends before
+     * machine_set_property(), so machine properties can refer to
+     * them.
+     */
+    configure_blockdev(&bdo_queue, machine_class, snapshot);
+    audio_init_audiodevs();
+}
+
 
 /*
  * The remainder of object creation happens after the
@@ -2699,7 +2753,7 @@ static bool object_create_initial(const char *type, QemuOpts *opts)
  */
 static bool object_create_delayed(const char *type, QemuOpts *opts)
 {
-    return !object_create_initial(type, opts);
+    return !object_create_early(type, opts);
 }
 
 
@@ -3308,7 +3362,6 @@ void qemu_finish_machine_init(void)
 
 void qemu_init(int argc, char **argv, char **envp)
 {
-    int snapshot = 0;
     QemuOpts *opts, *machine_opts;
     QemuOpts *icount_opts = NULL, *accel_opts = NULL;
     QemuOptsList *olist;
@@ -3321,7 +3374,6 @@ void qemu_init(int argc, char **argv, char **envp)
     FILE *vmstate_dump_file = NULL;
     Error *err = NULL;
     bool have_custom_ram_size;
-    BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
@@ -4291,52 +4343,7 @@ void qemu_init(int argc, char **argv, char **envp)
 
     qemu_disable_default_devices();
     qemu_create_default_devices();
-    if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
-        error_report("-alt-grab and -ctrl-grab are only valid "
-                     "for SDL, ignoring option");
-    }
-    if (dpy.has_window_close &&
-        (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) {
-        error_report("-no-quit is only valid for GTK and SDL, "
-                     "ignoring option");
-    }
-
-    qemu_display_early_init(&dpy);
-    qemu_console_early_init();
-
-    if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) {
-#if defined(CONFIG_OPENGL)
-        error_report("OpenGL is not supported by the display");
-#else
-        error_report("OpenGL support is disabled");
-#endif
-        exit(1);
-    }
-
-    qemu_opts_foreach(qemu_find_opts("object"),
-                      user_creatable_add_opts_foreach,
-                      object_create_initial, &error_fatal);
-
-    /* spice needs the timers to be initialized by this point */
-    /* spice must initialize before audio as it changes the default auiodev */
-    /* spice must initialize before chardevs (for spicevmc and spiceport) */
-    qemu_spice_init();
-
-    qemu_opts_foreach(qemu_find_opts("chardev"),
-                      chardev_init_func, NULL, &error_fatal);
-
-#ifdef CONFIG_VIRTFS
-    qemu_opts_foreach(qemu_find_opts("fsdev"),
-                      fsdev_init_func, NULL, &error_fatal);
-#endif
-
-    /*
-     * Note: we need to create audio and block backends before
-     * machine_set_property(), so machine properties can refer to
-     * them.
-     */
-    configure_blockdev(&bdo_queue, machine_class, snapshot);
-    audio_init_audiodevs();
+    qemu_create_early_backends();
 
     machine_opts = qemu_get_machine_opts();
     qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
-- 
2.26.2




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

* [PATCH 22/22] vl: separate qemu_create_late_backends
  2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
                   ` (20 preceding siblings ...)
  2020-10-21 20:57 ` [PATCH 21/22] vl: separate qemu_create_early_backends Paolo Bonzini
@ 2020-10-21 20:57 ` Paolo Bonzini
  21 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-21 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, berrange, ehabkost, imammedo

"Late" backends are created after the machine.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 64 ++++++++++++++++++++++++++--------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 866df5bb7c..f36ec16cad 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2751,11 +2751,41 @@ static void qemu_create_early_backends(void)
  * The remainder of object creation happens after the
  * creation of chardev, fsdev, net clients and device data types.
  */
-static bool object_create_delayed(const char *type, QemuOpts *opts)
+static bool object_create_late(const char *type, QemuOpts *opts)
 {
     return !object_create_early(type, opts);
 }
 
+static void qemu_create_late_backends(void)
+{
+    if (qtest_chrdev) {
+        qtest_server_init(qtest_chrdev, qtest_log, &error_fatal);
+    }
+
+    net_init_clients(&error_fatal);
+
+    qemu_opts_foreach(qemu_find_opts("object"),
+                      user_creatable_add_opts_foreach,
+                      object_create_late, &error_fatal);
+
+    if (tpm_init() < 0) {
+        exit(1);
+    }
+
+    qemu_opts_foreach(qemu_find_opts("mon"),
+                      mon_init_func, NULL, &error_fatal);
+
+    /* now chardevs have been created we may have semihosting to connect */
+    qemu_semihosting_connect_chardevs();
+    qemu_semihosting_console_init();
+
+    if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
+        exit(1);
+    if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
+        exit(1);
+    if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
+        exit(1);
+}
 
 static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
                                MachineClass *mc)
@@ -3372,7 +3402,6 @@ void qemu_init(int argc, char **argv, char **envp)
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
-    Error *err = NULL;
     bool have_custom_ram_size;
 
     qemu_add_opts(&qemu_drive_opts);
@@ -4385,10 +4414,6 @@ void qemu_init(int argc, char **argv, char **envp)
      */
     migration_object_init();
 
-    if (qtest_chrdev) {
-        qtest_server_init(qtest_chrdev, qtest_log, &error_fatal);
-    }
-
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
         boot_order = qemu_opt_get(opts, "order");
@@ -4409,32 +4434,7 @@ void qemu_init(int argc, char **argv, char **envp)
         boot_order = machine_class->default_boot_order;
     }
 
-    if (net_init_clients(&err) < 0) {
-        error_report_err(err);
-        exit(1);
-    }
-
-    qemu_opts_foreach(qemu_find_opts("object"),
-                      user_creatable_add_opts_foreach,
-                      object_create_delayed, &error_fatal);
-
-    if (tpm_init() < 0) {
-        exit(1);
-    }
-
-    qemu_opts_foreach(qemu_find_opts("mon"),
-                      mon_init_func, NULL, &error_fatal);
-
-    /* now chardevs have been created we may have semihosting to connect */
-    qemu_semihosting_connect_chardevs();
-    qemu_semihosting_console_init();
-
-    if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
-        exit(1);
-    if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
-        exit(1);
-    if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
-        exit(1);
+    qemu_create_late_backends();
 
     current_machine->boot_order = boot_order;
 
-- 
2.26.2



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

* Re: [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option
  2020-10-21 20:56 ` [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option Paolo Bonzini
@ 2020-10-22  5:09   ` Thomas Huth
  2020-10-22  6:54     ` Paolo Bonzini
  0 siblings, 1 reply; 32+ messages in thread
From: Thomas Huth @ 2020-10-22  5:09 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 21/10/2020 22.56, Paolo Bonzini wrote:
> Deprecated since 3.1 and complicates the initialization sequence,
> remove it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  docs/system/deprecated.rst | 12 ++++++------
>  hw/core/machine.c          | 24 +-----------------------
>  include/hw/boards.h        |  1 -
>  migration/migration.c      | 10 ----------
>  qemu-options.hx            |  8 --------
>  5 files changed, 7 insertions(+), 48 deletions(-)
> 
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index 895433c356..0ebce37a19 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -21,12 +21,6 @@ deprecated.
>  System emulator command line arguments
>  --------------------------------------
>  
> -``-machine enforce-config-section=on|off`` (since 3.1)
> -''''''''''''''''''''''''''''''''''''''''''''''''''''''
> -
> -The ``enforce-config-section`` parameter is replaced by the
> -``-global migration.send-configuration={on|off}`` option.
> -
>  ``-usbdevice`` (since 2.10.0)
>  '''''''''''''''''''''''''''''
>  
> @@ -689,6 +683,12 @@ Support for invalid topologies is removed, the user must ensure
>  topologies described with -smp include all possible cpus, i.e.
>  *sockets* * *cores* * *threads* = *maxcpus*.
>  
> +``-machine enforce-config-section=on|off`` (removed 5.2)
> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> +
> +The ``enforce-config-section`` property was replaced by the
> +``-global migration.send-configuration={on|off}`` option.
> +
>  Block devices
>  -------------
>  
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index d740a7e963..80a918895a 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -26,6 +26,7 @@
>  #include "sysemu/qtest.h"
>  #include "hw/pci/pci.h"
>  #include "hw/mem/nvdimm.h"
> +#include "migration/misc.h"

This new include does not make much sense to me, if all you did was removing
code from this file. Why did you add this here?

With this hunk removed:
Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 03/22] machine: move UP defaults to class_base_init
  2020-10-21 20:56 ` [PATCH 03/22] machine: move UP defaults to class_base_init Paolo Bonzini
@ 2020-10-22  5:11   ` Thomas Huth
  0 siblings, 0 replies; 32+ messages in thread
From: Thomas Huth @ 2020-10-22  5:11 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 21/10/2020 22.56, Paolo Bonzini wrote:
> Clean up vl.c, default min/max/default_cpus to uniprocessor
> directly in the QOM class initialization code.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/core/machine.c | 6 +++++-
>  softmmu/vl.c      | 5 -----
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 80a918895a..d3a8450b1f 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -854,8 +854,12 @@ static void machine_class_init(ObjectClass *oc, void *data)
>  
>  static void machine_class_base_init(ObjectClass *oc, void *data)
>  {
> +    MachineClass *mc = MACHINE_CLASS(oc);
> +    mc->max_cpus = mc->max_cpus ?: 1;
> +    mc->min_cpus = mc->min_cpus ?: 1;
> +    mc->default_cpus = mc->default_cpus ?: 1;
> +
>      if (!object_class_is_abstract(oc)) {
> -        MachineClass *mc = MACHINE_CLASS(oc);
>          const char *cname = object_class_get_name(oc);
>          assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
>          mc->name = g_strndup(cname,
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 42314e6ff9..75bc686397 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -3966,11 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp)
>          exit(0);
>      }
>  
> -    /* machine_class: default to UP */
> -    machine_class->max_cpus = machine_class->max_cpus ?: 1;
> -    machine_class->min_cpus = machine_class->min_cpus ?: 1;
> -    machine_class->default_cpus = machine_class->default_cpus ?: 1;
> -
>      /* default to machine_class->default_cpus */
>      current_machine->smp.cpus = machine_class->default_cpus;
>      current_machine->smp.max_cpus = machine_class->default_cpus;
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option
  2020-10-22  5:09   ` Thomas Huth
@ 2020-10-22  6:54     ` Paolo Bonzini
  0 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-22  6:54 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 22/10/20 07:09, Thomas Huth wrote:
>> +#include "migration/misc.h"
> This new include does not make much sense to me, if all you did was removing
> code from this file. Why did you add this here?

Yeah, it's not needed anymore.  It's part of a different patch that I
threw away when I noticed the deprecation.

Paolo

> With this hunk removed:
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 



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

* Re: [PATCH 04/22] machine: move SMP initialization from vl.c
  2020-10-21 20:56 ` [PATCH 04/22] machine: move SMP initialization from vl.c Paolo Bonzini
@ 2020-10-22  7:16   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-22  7:16 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 10/21/20 10:56 PM, Paolo Bonzini wrote:
> Initialize the object's values from the class when the object is
> created, no need to have vl.c do it for us.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/core/machine.c | 7 +++++++
>   softmmu/vl.c      | 7 -------
>   2 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



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

* Re: [PATCH 12/22] vl: move bios_name out of softmmu/vl.c
  2020-10-21 20:57 ` [PATCH 12/22] vl: move bios_name out of softmmu/vl.c Paolo Bonzini
@ 2020-10-22  7:22   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-22  7:22 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 10/21/20 10:57 PM, Paolo Bonzini wrote:
> bios_name is a legacy variable used by machine code.  Hide it
> from softmmu/vl.c.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/core/machine.c | 5 +++++
>   softmmu/vl.c      | 2 --
>   2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 3c674bb05e..e4dac350d4 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -212,6 +212,8 @@ GlobalProperty hw_compat_2_1[] = {
>   };
>   const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1);
>   
> +const char *bios_name = NULL;

I expect checkpatch.pl to complain "do not zero-initialize global".

> +
>   static char *machine_get_kernel(Object *obj, Error **errp)
>   {
>       MachineState *ms = MACHINE(obj);
> @@ -396,6 +398,9 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
>   
>       g_free(ms->firmware);
>       ms->firmware = g_strdup(value);
> +
> +    /* HACK */

With a slightly better rationale explanation:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +    bios_name = ms->firmware;
>   }
>   
>   static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 52e7d317d7..e32e209a82 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -123,7 +123,6 @@ static int data_dir_idx;
>   static const char *mem_path;
>   static const char *boot_order;
>   static const char *boot_once;
> -const char *bios_name = NULL;
>   enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>   int display_opengl;
>   const char* keyboard_layout = NULL;
> @@ -4314,7 +4313,6 @@ void qemu_init(int argc, char **argv, char **envp)
>       kernel_filename = qemu_opt_get(machine_opts, "kernel");
>       initrd_filename = qemu_opt_get(machine_opts, "initrd");
>       kernel_cmdline = qemu_opt_get(machine_opts, "append");
> -    bios_name = qemu_opt_get(machine_opts, "firmware");
>   
>       opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
>       if (opts) {
> 



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

* Re: [PATCH 17/22] vl: load plugins as late as possible
  2020-10-21 20:57 ` [PATCH 17/22] vl: load plugins as late as possible Paolo Bonzini
@ 2020-10-22  7:28   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-22  7:28 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: berrange, jsnow, ehabkost, imammedo

On 10/21/20 10:57 PM, Paolo Bonzini wrote:
> There is no need to load plugins in the middle of default device processing,
> move -plugin handling just before preconfig is entered.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   softmmu/vl.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 8577667b8f..75e57133ad 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -125,6 +125,7 @@ static const char *boot_order;
>   static const char *boot_once;
>   static const char *incoming;
>   static const char *loadvm;
> +static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
>   enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>   int mem_prealloc; /* force preallocation of physical target memory */
>   int display_opengl;
> @@ -3064,12 +3065,18 @@ void qemu_finish_machine_init(void)
>       MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
>       DisplayState *ds;
>   
> +    /* from here on runstate is RUN_STATE_PRELAUNCH */
> +

Please move this comment in your patch #11:
"vl: move prelaunch part of qemu_init to a new function"

Then:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>       if (machine_class->default_ram_id && current_machine->ram_size &&
>           numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
>           create_default_memdev(current_machine, mem_path);
>       }
>   
> -    /* from here on runstate is RUN_STATE_PRELAUNCH */
> +    /* process plugin before CPUs are created, but once -smp has been parsed */
> +    if (qemu_plugin_load_list(&plugin_list)) {
> +        exit(1);
> +    }
> +
>       machine_run_board_init(current_machine);
>   
>       /*
> @@ -3196,7 +3203,6 @@ void qemu_init(int argc, char **argv, char **envp)
>       Error *err = NULL;
>       bool have_custom_ram_size;
>       BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
> -    QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
>   
>       qemu_add_opts(&qemu_drive_opts);
>       qemu_add_drive_opts(&qemu_legacy_drive_opts);
> @@ -4164,11 +4170,6 @@ void qemu_init(int argc, char **argv, char **envp)
>                                  machine_class->default_machine_opts, 0);
>       }
>   
> -    /* process plugin before CPUs are created, but once -smp has been parsed */
> -    if (qemu_plugin_load_list(&plugin_list)) {
> -        exit(1);
> -    }
> -
>       qemu_opts_foreach(qemu_find_opts("device"),
>                         default_driver_check, NULL, NULL);
>       qemu_opts_foreach(qemu_find_opts("global"),
> 



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

* Re: [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig
  2020-10-21 20:57 ` [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
@ 2020-10-22  7:29   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 32+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-22  7:29 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel, Pavel Dovgalyuk
  Cc: berrange, jsnow, ehabkost, imammedo

On 10/21/20 10:57 PM, Paolo Bonzini wrote:
> Move CHECKPOINT_INIT right before the machine initialization is
> completed.  Everything before is essentially an extension of
> command line parsing.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   softmmu/vl.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 0a6f47e7d6..e9391929f6 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -3194,6 +3194,11 @@ void qemu_finish_machine_init(void)
>           exit(1);
>       }
>   
> +    /* This checkpoint is required by replay to separate prior clock
> +       reading from the other reads, because timer polling functions query
> +       clock values from the log. */
> +    replay_checkpoint(CHECKPOINT_INIT);
> +
>       machine_run_board_init(current_machine);
>   
>       /*
> @@ -4424,11 +4429,6 @@ void qemu_init(int argc, char **argv, char **envp)
>       if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
>           exit(1);
>   
> -    /* This checkpoint is required by replay to separate prior clock
> -       reading from the other reads, because timer polling functions query
> -       clock values from the log. */
> -    replay_checkpoint(CHECKPOINT_INIT);
> -
>       current_machine->boot_order = boot_order;
>   
>       /* parse features once if machine provides default cpu_type */
> 



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

* Re: [PATCH 01/22] semihosting: fix order of initialization functions
  2020-10-21 20:56 ` [PATCH 01/22] semihosting: fix order of initialization functions Paolo Bonzini
@ 2020-10-27 11:18   ` Alex Bennée
  2020-10-27 13:32     ` Paolo Bonzini
  0 siblings, 1 reply; 32+ messages in thread
From: Alex Bennée @ 2020-10-27 11:18 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, berrange, jsnow, ehabkost, imammedo


Paolo Bonzini <pbonzini@redhat.com> writes:

> qemu_semihosting_console_init uses semihosting.chardev which is set
> by qemu_semihosting_connect_chardevs.  Thus qemu_semihosting_connect_chardevs
> has to be called first.

It looks like this is reverting 619985e9 ("semihosting: defer
connect_chardevs a little more to use serialx"). Looking back at the
history it seems the two calls had different results:

  Right - can confirm the difference between:

    ./aarch64-softmmu/qemu-system-aarch64 -cpu max -serial mon:stdio -M virt -display none -semihosting -kernel ./tests/tcg/aarch64-softmmu/memory

  and

    ./aarch64-softmmu/qemu-system-aarch64 -cpu max -serial mon:stdio -M virt -display none -semihosting-config chardev=serial0 -kernel ./tests/tcg/aarch64-softmmu/memory

With this patch applied it breaks the later invocation:

  ./aarch64-softmmu/qemu-system-aarch64  -cpu max -serial mon:stdio -M virt -display none -semihosting-config chardev=serial0 -kernel ./tests/tcg/aarch64-softmmu/memory
  qemu-system-aarch64: semihosting chardev 'serial0' not found

>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  softmmu/vl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 6f5b000f07..42314e6ff9 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -4288,7 +4288,8 @@ void qemu_init(int argc, char **argv, char **envp)
>      qemu_opts_foreach(qemu_find_opts("mon"),
>                        mon_init_func, NULL, &error_fatal);
>  
> -    /* connect semihosting console input if requested */
> +    /* now chardevs have been created we may have semihosting to connect */
> +    qemu_semihosting_connect_chardevs();
>      qemu_semihosting_console_init();

Maybe instead of this we should:

>  
>      if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
> @@ -4298,9 +4299,6 @@ void qemu_init(int argc, char **argv, char **envp)
>      if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
>          exit(1);
>  
> -    /* now chardevs have been created we may have semihosting to connect */
> -    qemu_semihosting_connect_chardevs();
> -

Move both here:

    if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
        exit(1);

    /* now chardevs have been created we may have semihosting to connect */
    qemu_semihosting_connect_chardevs();
    qemu_semihosting_console_init();


>      /* If no default VGA is requested, the default is "none".  */
>      if (default_vga) {
>          vga_model = get_default_vga_model(machine_class);


-- 
Alex Bennée


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

* Re: [PATCH 01/22] semihosting: fix order of initialization functions
  2020-10-27 11:18   ` Alex Bennée
@ 2020-10-27 13:32     ` Paolo Bonzini
  0 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2020-10-27 13:32 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, berrange, jsnow, ehabkost, imammedo

On 27/10/20 12:18, Alex Bennée wrote:
>>  
>> -    /* now chardevs have been created we may have semihosting to connect */
>> -    qemu_semihosting_connect_chardevs();
>> -
> Move both here:
> 
>     if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
>         exit(1);
> 
>     /* now chardevs have been created we may have semihosting to connect */
>     qemu_semihosting_connect_chardevs();
>     qemu_semihosting_console_init();
> 
> 

Sounds good, thanks!

Paolo



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

end of thread, other threads:[~2020-10-27 13:44 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 20:56 [RFC PATCH 00/22] cleanup qemu_init and make sense of command line processing Paolo Bonzini
2020-10-21 20:56 ` [PATCH 01/22] semihosting: fix order of initialization functions Paolo Bonzini
2020-10-27 11:18   ` Alex Bennée
2020-10-27 13:32     ` Paolo Bonzini
2020-10-21 20:56 ` [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option Paolo Bonzini
2020-10-22  5:09   ` Thomas Huth
2020-10-22  6:54     ` Paolo Bonzini
2020-10-21 20:56 ` [PATCH 03/22] machine: move UP defaults to class_base_init Paolo Bonzini
2020-10-22  5:11   ` Thomas Huth
2020-10-21 20:56 ` [PATCH 04/22] machine: move SMP initialization from vl.c Paolo Bonzini
2020-10-22  7:16   ` Philippe Mathieu-Daudé
2020-10-21 20:56 ` [PATCH 05/22] vl: extract validation of -smp to machine.c Paolo Bonzini
2020-10-21 20:57 ` [PATCH 06/22] vl: remove bogus check Paolo Bonzini
2020-10-21 20:57 ` [PATCH 07/22] trace: remove argument from trace_init_file Paolo Bonzini
2020-10-21 20:57 ` [PATCH 08/22] vl: split various early command line options to a separate function Paolo Bonzini
2020-10-21 20:57 ` [PATCH 09/22] vl: move various initialization routines out of qemu_init Paolo Bonzini
2020-10-21 20:57 ` [PATCH 10/22] vl: extract qemu_init_subsystems Paolo Bonzini
2020-10-21 20:57 ` [PATCH 11/22] vl: move prelaunch part of qemu_init to a new function Paolo Bonzini
2020-10-21 20:57 ` [PATCH 12/22] vl: move bios_name out of softmmu/vl.c Paolo Bonzini
2020-10-22  7:22   ` Philippe Mathieu-Daudé
2020-10-21 20:57 ` [PATCH 13/22] vl: extract various command line validation snippets to a new function Paolo Bonzini
2020-10-21 20:57 ` [PATCH 14/22] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
2020-10-21 20:57 ` [PATCH 15/22] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
2020-10-21 20:57 ` [PATCH 16/22] vl: create "-net nic -net user" default earlier Paolo Bonzini
2020-10-21 20:57 ` [PATCH 17/22] vl: load plugins as late as possible Paolo Bonzini
2020-10-22  7:28   ` Philippe Mathieu-Daudé
2020-10-21 20:57 ` [PATCH 18/22] vl: move semihosting command line fallback to qemu_finish_machine_init Paolo Bonzini
2020-10-21 20:57 ` [PATCH 19/22] vl: extract default devices to separate functions Paolo Bonzini
2020-10-21 20:57 ` [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
2020-10-22  7:29   ` Philippe Mathieu-Daudé
2020-10-21 20:57 ` [PATCH 21/22] vl: separate qemu_create_early_backends Paolo Bonzini
2020-10-21 20:57 ` [PATCH 22/22] vl: separate qemu_create_late_backends 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).