mbox series

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

Message ID 20201027182144.3315885-1-pbonzini@redhat.com
Headers show
Series cleanup qemu_init and make sense of command line processing | expand

Message

Paolo Bonzini Oct. 27, 2020, 6:21 p.m. UTC
The main improvements with respect to v1 are:

- further extraction of various phases of command line processing and VM
  creation to separate function;

- removing the preconfig main_loop: the VM is effectively always starting
  as if -preconfig was specified, it just executes automatically if not
  requested.  This enables "-incoming defer" to be specified together
  with "-preconfig".

I have other patches with which I could configure the VM like

  $ qemu -vnc :0 -monitor stdio -preconfig
    ... in theory blockdev-add and other backend creation would go here...
  (qemu) x-create-onboard-devices
  (qemu) device_add virtio-mouse-pci
  (qemu) cont

Here, x-create-onboard-devices creates enough of the machine to make
it possible to issue device_add monitor commands equivalent to
the -device command line.

However, I'm not posting that part because the above is not the
final state of the QMP interface.  The final QMP interface would have
three commands (machine-set, accel-set, machine-set-memory) that
bring the VM through successive phases of initialization corresponding
roughly to qemu_apply_machine_options (-smp, -boot, -M, -cpu?),
configure_accelerators (-accel) and qemu_finish_machine_init (-m, -M memdev);
after these three steps, one of migrate-incoming, cont, loadvm or
finish-machine-init (the latter of which is equivalent to -S on the
command line) leaves preconfig mode.  For more information see
https://wiki.qemu.org/User:Paolo_Bonzini/Machine_init_sequence#Basic_phases.

Based-on: <20201026143028.3034018-1-pbonzini@redhat.com>

Paolo Bonzini (29):
  trace: remove argument from trace_init_file
  semihosting: fix order of initialization functions
  vl: extract validation of -smp to machine.c
  vl: remove bogus check
  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 new functions
  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
  vl: separate qemu_create_machine
  vl: separate qemu_apply_machine_options
  vl: separate qemu_resolve_machine_memdev
  vl: initialize displays before preconfig loop
  vl: move -global check earlier
  migration, vl: start migration via qmp_migrate_incoming
  vl: start VM via qmp_cont
  hmp: introduce cmd_available
  remove preconfig state
  vl: remove separate preconfig main_loop
  vl: allow -incoming defer with -preconfig

 bsd-user/main.c                      |    6 +-
 hw/core/machine-qmp-cmds.c           |    5 +-
 hw/core/machine.c                    |   27 +
 include/hw/boards.h                  |    1 +
 include/hw/qdev-core.h               |    8 -
 include/migration/misc.h             |    1 -
 include/qapi/qmp/dispatch.h          |    1 +
 include/sysemu/runstate.h            |    1 -
 linux-user/main.c                    |    6 +-
 migration/migration.c                |   37 +-
 monitor/hmp.c                        |   23 +-
 monitor/qmp-cmds.c                   |   10 -
 qapi/qmp-dispatch.c                  |    5 +-
 qapi/run-state.json                  |    5 +-
 qemu-img.c                           |    6 +-
 qemu-io.c                            |    6 +-
 qemu-nbd.c                           |    6 +-
 scsi/qemu-pr-helper.c                |    6 +-
 softmmu/qdev-monitor.c               |   18 +-
 softmmu/vl.c                         | 1796 +++++++++++++-------------
 storage-daemon/qemu-storage-daemon.c |    9 +-
 stubs/meson.build                    |    1 +
 stubs/qmp-command-available.c        |    7 +
 trace/control.c                      |   10 +-
 trace/control.h                      |   12 +-
 25 files changed, 1021 insertions(+), 992 deletions(-)
 create mode 100644 stubs/qmp-command-available.c

Comments

Igor Mammedov Nov. 2, 2020, 3:57 p.m. UTC | #1
On Tue, 27 Oct 2020 14:21:15 -0400
Paolo Bonzini <pbonzini@redhat.com> wrote:

> The main improvements with respect to v1 are:


series no longer applies to master
what commit if was based on?

> 

> - further extraction of various phases of command line processing and VM

>   creation to separate function;

> 

> - removing the preconfig main_loop: the VM is effectively always starting

>   as if -preconfig was specified, it just executes automatically if not

>   requested.  This enables "-incoming defer" to be specified together

>   with "-preconfig".

> 

> I have other patches with which I could configure the VM like

> 

>   $ qemu -vnc :0 -monitor stdio -preconfig

>     ... in theory blockdev-add and other backend creation would go here...

>   (qemu) x-create-onboard-devices

>   (qemu) device_add virtio-mouse-pci

>   (qemu) cont

> 

> Here, x-create-onboard-devices creates enough of the machine to make

> it possible to issue device_add monitor commands equivalent to

> the -device command line.

> 

> However, I'm not posting that part because the above is not the

> final state of the QMP interface.  The final QMP interface would have

> three commands (machine-set, accel-set, machine-set-memory) that

> bring the VM through successive phases of initialization corresponding

> roughly to qemu_apply_machine_options (-smp, -boot, -M, -cpu?),

> configure_accelerators (-accel) and qemu_finish_machine_init (-m, -M memdev);

> after these three steps, one of migrate-incoming, cont, loadvm or

> finish-machine-init (the latter of which is equivalent to -S on the

> command line) leaves preconfig mode.  For more information see

> https://wiki.qemu.org/User:Paolo_Bonzini/Machine_init_sequence#Basic_phases.

> 

> Based-on: <20201026143028.3034018-1-pbonzini@redhat.com>

> 

> Paolo Bonzini (29):

>   trace: remove argument from trace_init_file

>   semihosting: fix order of initialization functions

>   vl: extract validation of -smp to machine.c

>   vl: remove bogus check

>   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 new functions

>   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

>   vl: separate qemu_create_machine

>   vl: separate qemu_apply_machine_options

>   vl: separate qemu_resolve_machine_memdev

>   vl: initialize displays before preconfig loop

>   vl: move -global check earlier

>   migration, vl: start migration via qmp_migrate_incoming

>   vl: start VM via qmp_cont

>   hmp: introduce cmd_available

>   remove preconfig state

>   vl: remove separate preconfig main_loop

>   vl: allow -incoming defer with -preconfig

> 

>  bsd-user/main.c                      |    6 +-

>  hw/core/machine-qmp-cmds.c           |    5 +-

>  hw/core/machine.c                    |   27 +

>  include/hw/boards.h                  |    1 +

>  include/hw/qdev-core.h               |    8 -

>  include/migration/misc.h             |    1 -

>  include/qapi/qmp/dispatch.h          |    1 +

>  include/sysemu/runstate.h            |    1 -

>  linux-user/main.c                    |    6 +-

>  migration/migration.c                |   37 +-

>  monitor/hmp.c                        |   23 +-

>  monitor/qmp-cmds.c                   |   10 -

>  qapi/qmp-dispatch.c                  |    5 +-

>  qapi/run-state.json                  |    5 +-

>  qemu-img.c                           |    6 +-

>  qemu-io.c                            |    6 +-

>  qemu-nbd.c                           |    6 +-

>  scsi/qemu-pr-helper.c                |    6 +-

>  softmmu/qdev-monitor.c               |   18 +-

>  softmmu/vl.c                         | 1796 +++++++++++++-------------

>  storage-daemon/qemu-storage-daemon.c |    9 +-

>  stubs/meson.build                    |    1 +

>  stubs/qmp-command-available.c        |    7 +

>  trace/control.c                      |   10 +-

>  trace/control.h                      |   12 +-

>  25 files changed, 1021 insertions(+), 992 deletions(-)

>  create mode 100644 stubs/qmp-command-available.c

>
Paolo Bonzini Nov. 2, 2020, 4:34 p.m. UTC | #2
On 02/11/20 16:57, Igor Mammedov wrote:
>> The main improvements with respect to v1 are:

> series no longer applies to master

> what commit if was based on?

> 


It's based on 20201026143028.3034018-1-pbonzini@redhat.com (which you
should be able to get through patchew).

Paolo
Igor Mammedov Nov. 3, 2020, 12:57 p.m. UTC | #3
On Mon, 2 Nov 2020 17:34:00 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On 02/11/20 16:57, Igor Mammedov wrote:
> >> The main improvements with respect to v1 are:  
> > series no longer applies to master
> > what commit if was based on?
> >   
> 
> It's based on 20201026143028.3034018-1-pbonzini@redhat.com (which you
> should be able to get through patchew).

Not sure what you mean and how to do that.
Is it possible to share v2 as a git tree somewhere?

> 
> Paolo
>
Paolo Bonzini Nov. 3, 2020, 2:37 p.m. UTC | #4
On 03/11/20 13:57, Igor Mammedov wrote:
>> It's based on 20201026143028.3034018-1-pbonzini@redhat.com (which you

>> should be able to get through patchew).

> Not sure what you mean and how to do that.

> Is it possible to share v2 as a git tree somewhere?


I pushed it to for-6.0 on my gitlab repo.  There's a lot more stuff in
the branch, but these patches are at the top.

Paolo
Igor Mammedov Nov. 20, 2020, 4:19 p.m. UTC | #5
On Tue, 3 Nov 2020 15:37:13 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On 03/11/20 13:57, Igor Mammedov wrote:

> >> It's based on 20201026143028.3034018-1-pbonzini@redhat.com (which you

> >> should be able to get through patchew).  

> > Not sure what you mean and how to do that.

> > Is it possible to share v2 as a git tree somewhere?  

> 

> I pushed it to for-6.0 on my gitlab repo.  There's a lot more stuff in

> the branch, but these patches are at the top.


had to use temporary fixup, to make build pass and fix '-device help' crash
with your branch. (upstream master doesn't have this problem)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index 858860377b..78f3397736 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -776,6 +776,7 @@ static const char *get_opt_name_value(const char *params,
         /* found "foo,more" */
         if (help_wanted && starts_with_help_option(params) == len) {
             *help_wanted = true;
+            return NULL;
         } else if (firstname) {
             /* implicitly named first option */
             *name = g_strdup(firstname);

> 

> Paolo

> 

>
Paolo Bonzini Nov. 20, 2020, 4:27 p.m. UTC | #6
On 20/11/20 17:19, Igor Mammedov wrote:
> On Tue, 3 Nov 2020 15:37:13 +0100

> Paolo Bonzini <pbonzini@redhat.com> wrote:

> 

>> On 03/11/20 13:57, Igor Mammedov wrote:

>>>> It's based on 20201026143028.3034018-1-pbonzini@redhat.com (which you

>>>> should be able to get through patchew).

>>> Not sure what you mean and how to do that.

>>> Is it possible to share v2 as a git tree somewhere?

>>

>> I pushed it to for-6.0 on my gitlab repo.  There's a lot more stuff in

>> the branch, but these patches are at the top.

> 

> had to use temporary fixup, to make build pass and fix '-device help' crash

> with your branch. (upstream master doesn't have this problem)

> 

> diff --git a/util/qemu-option.c b/util/qemu-option.c

> index 858860377b..78f3397736 100644

> --- a/util/qemu-option.c

> +++ b/util/qemu-option.c

> @@ -776,6 +776,7 @@ static const char *get_opt_name_value(const char *params,

>           /* found "foo,more" */

>           if (help_wanted && starts_with_help_option(params) == len) {

>               *help_wanted = true;

> +            return NULL;

>           } else if (firstname) {

>               /* implicitly named first option */

>               *name = g_strdup(firstname);


Thanks!  I'll integrate this in the right place of the series.

Paolo