mbox series

[RFC,00/22] cleanup qemu_init and make sense of command line processing

Message ID 20201021205716.2359430-1-pbonzini@redhat.com (mailing list archive)
Headers show
Series cleanup qemu_init and make sense of command line processing | expand

Message

Paolo Bonzini Oct. 21, 2020, 8:56 p.m. UTC
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(-)