cleanup qemu_init and make sense of command line processing
v2 cover cleanup qemu_init and make sense of command line processing
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) contHere, 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: <[email protected]>
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
Signature · 1 line
2.26.2
PATCH 1/29 trace: remove argument from trace_init_file
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.
--- 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(-)
bsd-user/main.c +2 -4
@@ -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 ));
linux-user/main.c +2 -4
@@ -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 ); }
qemu-img.c +2 -4
@@ -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 */
qemu-io.c +2 -4
@@ -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 */
qemu-nbd.c +2 -4
@@ -578,7 +578,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 ;
@@ -762,8 +761,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;
@@ -810,7 +808,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 ();
scsi/qemu-pr-helper.c +2 -4
@@ -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
softmmu/vl.c +2 -4
@@ -2886,7 +2886,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 ;
@@ -3687,8 +3686,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);
@@ -3938,7 +3936,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. */
storage-daemon/qemu-storage-daemon.c +3 -6
@@ -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" );
trace/control.c +4 -6
@@ -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 )
trace/control.h +3 -9
@@ -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:
Signature · 1 line
2.26.2
PATCH 2/29 semihosting: fix order of initialization functions
In reply to Paolo Bonziniqemu_semihosting_console_init uses semihosting.chardev which is set by qemu_semihosting_connect_chardevs. Thus qemu_semihosting_connect_chardevs has to be called first.
Both have to be called after processing -serial and friends though, so that the semihosting console can connect to a multiplexer as in "-serial mon:stdio -semihosting-config chardev=serial0"
--- softmmu/vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
softmmu/vl.c +1 -3
@@ -4280,9 +4280,6 @@ 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 */ -qemu_semihosting_console_init (); -if (foreach_device_config (DEV_SERIAL , serial_parse) <0 )exit (1 );if (foreach_device_config (DEV_PARALLEL , parallel_parse) <0 )
@@ -4292,6 +4289,7 @@ void qemu_init(int argc, char **argv, char **envp)/* 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) {
Signature · 1 line
2.26.2
PATCH 3/29 vl: extract validation of -smp to machine.c
In reply to Paolo BonziniOnce smp_parse is done, the validation operates on the MachineState. There is no reason for that code to be in vl.c.
--- hw/core/machine.c | 23 +++++++++++++++++++++++ include/hw/boards.h | 1 + softmmu/vl.c | 20 ++------------------ 3 files changed, 26 insertions(+), 18 deletions(-)
hw/core/machine.c +23 -0
@@ -1072,6 +1072,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);
include/hw/boards.h +1 -0
@@ -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);
softmmu/vl.c +2 -18
@@ -3971,24 +3971,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;
Signature · 1 line
2.26.2
Re: [PATCH 03/29] vl: extract validation of -smp to machine.c
Quoted 4 lines · On Tue, 27 Oct 2020 14:21:18 -0400 Paolo Bonzini <[email protected]> wrote:
Once
smp_parseis done, the validation operates on the MachineState. There is no reason for that code to be invl.c.Signed-off-by Paolo Bonzini <[email protected]>
Quoted 83 lines
--- hw/core/machine.c | 23 +++++++++++++++++++++++ include/hw/boards.h | 1 + softmmu/vl.c | 20 ++------------------ 3 files changed, 26 insertions(+), 18 deletions(-)hw/core/machine.c +23
-0@@ -1072,6 +1072,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);include/hw/boards.h +1
-0@@ -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);softmmu/vl.c +2
-18@@ -3971,24 +3971,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;
PATCH 4/29 vl: remove bogus check
In reply to Paolo BonziniThere 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.
--- softmmu/vl.c | 6 ------ 1 file changed, 6 deletions(-)
softmmu/vl.c +0 -6
@@ -4027,12 +4027,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
Signature · 1 line
2.26.2
Re: [PATCH 04/29] vl: remove bogus check
Quoted 3 lines · On Tue, 27 Oct 2020 14:21:19 -0400 Paolo Bonzini <[email protected]> wrote:
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.
it was related to how libvirt starts QEMU but I don't recall why anymore, CCing Daniel
Quoted 23 lines
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 6 ------ 1 file changed, 6 deletions(-)softmmu/vl.c +0
-6@@ -4027,12 +4027,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
Re: [PATCH 04/29] vl: remove bogus check
Quoted 9 lines · Igor Mammedov
Quoted 3 lines · On Tue, 27 Oct 2020 14:21:19 -0400 Paolo Bonzini <[email protected]> wrote:
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.
it was related to how libvirt starts QEMU but I don't recall why anymore, CCing Daniel
Libvirt didn't request this to best of my knowledge.
We don't even use -daemonize, so have no reason to ask to forbid -preconfig with -daemonize.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 6 ------ 1 file changed, 6 deletions(-)softmmu/vl.c +0
-0@@ -4027,12 +4027,6 @@ void qemu_init(int argc, char **argv, char **envp) }
Quoted 11 lines
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4032
Quoted 10 lines
softmmu/vl.c +0
-6if (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
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 04/29] vl: remove bogus check
In reply to Paolo BonziniQuoted 3 lines · On Tue, 27 Oct 2020 14:21:19 -0400 Paolo Bonzini <[email protected]> wrote:
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.
looking some more at the current code, this piece is currently somewhat broken, so it would indeed exit but 'after' fork and output error message to nowhere. It happens since os_daemonize() where moved before it later on, given no one actually complained since then we probably do not care about it.
Quoted 22 lines
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 6 ------ 1 file changed, 6 deletions(-)softmmu/vl.c +0
-6@@ -4027,12 +4027,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
PATCH 5/29 vl: split various early command line options to a separate function
In reply to Paolo BonziniVarious 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.
--- softmmu/vl.c | 202 ++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 89 deletions(-)
softmmu/vl.c +113 -89
@@ -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;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;
@@ -142,6 +143,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 ;
@@ -2862,6 +2866,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;
@@ -2878,21 +2982,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);
@@ -3840,20 +3939,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 ();
@@ -3874,40 +3970,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 );
@@ -3933,44 +3995,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);
Signature · 1 line
2.26.2
Re: [PATCH 05/29] vl: split various early command line options to a separate function
Quoted 10 lines · On Tue, 27 Oct 2020 14:21:20 -0400 Paolo Bonzini <[email protected]> wrote:
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 <[email protected]>--- softmmu/vl.c | 202 ++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 89 deletions(-)softmmu/vl.c +0
-0
[...]
softmmu/vl.c
Quoted 2 lines
softmmu/vl.c +2
-0+ +static void qemu_maybe_daemonize (const char *pid_file)
why it's _maybe_ ?
It looks to me as just deamonize (or die which could be omitted)
Quoted 14 lines
softmmu/vl.c +14
-0+{ +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); +}
[...]
Re: [PATCH 05/29] vl: split various early command line options to a separate function
Quoted 12 lines · Igor Mammedov
Quoted 9 lines · On Tue, 27 Oct 2020 14:21:20 -0400 Paolo Bonzini <[email protected]> wrote:
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 <[email protected]>--- softmmu/vl.c | 202 ++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 89 deletions(-)
Quoted 7 lines
Quoted 1 line
softmmu/vl.c +0
-0[...]
softmmu/vl.c
Quoted 2 lines
softmmu/vl.c +2
-0+ +static void qemu_maybe_daemonize (const char *pid_file)why it's _maybe_ ?
It looks to me as just deamonize (or die which could be omitted)
Because os_daemonize() in turn only daemonize if the corresponding option was set:
void os_daemonize(void)
{
if (daemonize) {
pid_t pid;
int fds[2];
...Paolo
Quoted 16 lines
Quoted 14 lines
softmmu/vl.c +14
-0+{ +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); +}[...]
PATCH 6/29 vl: move various initialization routines out of qemu_init
In reply to Paolo BonziniSome very simple initialization routines can be nested in existing subsystem-level functions, do that to simplify qemu_init.
--- 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(-)
hw/core/machine.c +3 -0
@@ -872,6 +872,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;
include/hw/qdev-core.h +0 -8
@@ -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: *
migration/migration.c +4 -0
@@ -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 )
softmmu/qdev-monitor.c +0 -6
@@ -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" ,
softmmu/vl.c +0 -5
@@ -4275,10 +4275,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);
@@ -4311,7 +4307,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;
Signature · 1 line
2.26.2
Re: [PATCH 06/29] vl: move various initialization routines out of qemu_init
Quoted 4 lines · On Tue, 27 Oct 2020 14:21:21 -0400 Paolo Bonzini <[email protected]> wrote:
Some very simple initialization routines can be nested in existing subsystem-level functions, do that to simplify
qemu_init.Signed-off-by Paolo Bonzini <[email protected]>
Quoted 96 lines
--- 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(-)hw/core/machine.c +3
-0@@ -872,6 +872,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;include/hw/qdev-core.h +0
-8@@ -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: * migration/migration.c +4
-0@@ -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 )softmmu/qdev-monitor.c +0
-6@@ -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" ,softmmu/vl.c +0
-5@@ -4275,10 +4275,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);@@ -4311,7 +4307,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;
PATCH 7/29 vl: extract qemu_init_subsystems
In reply to Paolo BonziniGroup 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.
--- softmmu/vl.c | 94 ++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 51 deletions(-)
softmmu/vl.c +43 -51
@@ -128,7 +128,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,
@@ -1228,7 +1228,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:
@@ -2965,11 +2966,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 ;
@@ -2990,7 +3025,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;
@@ -2998,22 +3032,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);
@@ -3048,27 +3066,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 ;
@@ -3947,13 +3948,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) {
@@ -4132,9 +4130,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);
@@ -4251,9 +4246,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);
Signature · 1 line
2.26.2
Re: [PATCH 07/29] vl: extract qemu_init_subsystems
Quoted 5 lines · On Tue, 27 Oct 2020 14:21:22 -0400 Paolo Bonzini <[email protected]> wrote:
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 <[email protected]>
Quoted 172 lines
--- softmmu/vl.c | 94 ++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 51 deletions(-)softmmu/vl.c +43
-51@@ -128,7 +128,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,@@ -1228,7 +1228,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: @@ -2965,11 +2966,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 ;@@ -2990,7 +3025,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;@@ -2998,22 +3032,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);@@ -3048,27 +3066,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 ;@@ -3947,13 +3948,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) {@@ -4132,9 +4130,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);@@ -4251,9 +4246,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);
PATCH 8/29 vl: move prelaunch part of qemu_init to new functions
In reply to Paolo BonziniThe 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.
--- softmmu/vl.c | 250 +++++++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 115 deletions(-)
softmmu/vl.c +135 -115
@@ -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;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;int display_opengl;const char * keyboard_layout =NULL ;
@@ -3000,6 +3003,135 @@ static void qemu_init_subsystems(void)socket_init (); } +/* +* Called after leaving preconfig state. From here on runstate is +* RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. +*/ +static void qemu_finish_machine_init (void ) +{ +MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); + +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 (); + +if (hax_enabled ()) { +/* FIXME: why isn't cpu_synchronize_all_post_init enough? */ +hax_sync_vcpus (); + } +} + +static void qemu_create_cli_devices (void ) +{ +soundhw_init (); + +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); +rom_reset_order_override (); +} + +static void qemu_machine_creation_done (void ) +{ +DisplayState *ds; + +cpu_synchronize_all_post_init (); + +/* 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;
@@ -3007,9 +3139,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;
@@ -3026,7 +3155,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);
@@ -4346,117 +4474,10 @@ 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 (); +qemu_finish_machine_init (); +qemu_create_cli_devices (); +qemu_machine_creation_done (); -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 ();if (loadvm) {Error *local_err =NULL ;if (load_snapshot (loadvm, &local_err) <0 ) {
@@ -4475,7 +4496,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);
Signature · 1 line
2.26.2
Re: [PATCH 08/29] vl: move prelaunch part of qemu_init to new functions
Quoted 5 lines · On Tue, 27 Oct 2020 14:21:23 -0400 Paolo Bonzini <[email protected]> wrote:
The final part of
qemu_init, starting with the completion of board init, is already relatively clean. Split it out ofqemu_initso thatqemu_initkeeps only the messy parts.Signed-off-by Paolo Bonzini <[email protected]>
Quoted 301 lines
--- softmmu/vl.c | 250 +++++++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 115 deletions(-)softmmu/vl.c +135
-115@@ -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;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;int display_opengl;const char * keyboard_layout =NULL ;@@ -3000,6 +3003,135 @@ static void qemu_init_subsystems(void)socket_init (); } +/* +* Called after leaving preconfig state. From here on runstate is +* RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. +*/ +static void qemu_finish_machine_init (void ) +{ +MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); + +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 (); + +if (hax_enabled ()) { +/* FIXME: why isn't cpu_synchronize_all_post_init enough? */ +hax_sync_vcpus (); + } +} + +static void qemu_create_cli_devices (void ) +{ +soundhw_init (); + +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); +rom_reset_order_override (); +} + +static void qemu_machine_creation_done (void ) +{ +DisplayState *ds; + +cpu_synchronize_all_post_init (); + +/* 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;@@ -3007,9 +3139,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;@@ -3026,7 +3155,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);@@ -4346,117 +4474,10 @@ 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 (); +qemu_finish_machine_init (); +qemu_create_cli_devices (); +qemu_machine_creation_done (); -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 ();if (loadvm) {Error *local_err =NULL ;if (load_snapshot (loadvm, &local_err) <0 ) {@@ -4475,7 +4496,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);
PATCH 9/29 vl: extract various command line validation snippets to a new function
In reply to Paolo Bonzini--- hw/core/machine.c | 1 + softmmu/vl.c | 78 +++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 39 deletions(-)
hw/core/machine.c +1 -0
@@ -878,6 +878,7 @@ static void machine_initfn(Object *obj) ms->dump_guest_core = true; ms->mem_merge = true; ms->enable_graphics = true; + ms->kernel_cmdline =g_strdup ("" );if (mc->nvdimm_supported) {Object *obj =OBJECT (ms);
softmmu/vl.c +39 -39
132 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH 09/29] vl: extract various command line validation snippets to a new function
Quoted 1 line · On Tue, 27 Oct 2020 14:21:24 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 162 lines
--- hw/core/machine.c | 1 + softmmu/vl.c | 78 +++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 39 deletions(-)hw/core/machine.c +1
-0@@ -878,6 +878,7 @@ static void machine_initfn(Object *obj) ms->dump_guest_core = true; ms->mem_merge = true; ms->enable_graphics = true; + ms->kernel_cmdline =g_strdup ("" );if (mc->nvdimm_supported) {Object *obj =OBJECT (ms);softmmu/vl.c +39
-39@@ -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 ;@@ -2870,6 +2871,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;@@ -3136,9 +3170,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;@@ -3147,7 +3178,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 ;@@ -4068,6 +4098,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. */ @@ -4082,12 +4114,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 ();@@ -4191,12 +4217,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) {@@ -4327,11 +4347,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" );@@ -4352,24 +4367,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); }
PATCH 10/29 vl: preconfig and loadvm are mutually exclusive
In reply to Paolo BonziniJust like -incoming.
--- softmmu/vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
softmmu/vl.c +6 -1
@@ -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 ;
@@ -2890,6 +2891,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" );
@@ -3175,7 +3181,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;
Signature · 1 line
2.26.2
Re: [PATCH 10/29] vl: preconfig and loadvm are mutually exclusive
Quoted 3 lines · On Tue, 27 Oct 2020 14:21:25 -0400 Paolo Bonzini <[email protected]> wrote:
Just like -incoming.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 36 lines
--- softmmu/vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)softmmu/vl.c +6
-1@@ -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 ;@@ -2890,6 +2891,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" );@@ -3175,7 +3181,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;
PATCH 11/29 vl: extract various command line desugaring snippets to a new function
In reply to Paolo Bonzini--- softmmu/vl.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
softmmu/vl.c +22 -18
@@ -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 ;
@@ -2910,6 +2911,25 @@ static void qemu_validate_options(void)#endif } +static void qemu_process_sugar_options (void ) +{ +if (mem_prealloc) { +char *val; + + val =g_strdup_printf ("%d" , + (uint32_t )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;
@@ -3174,7 +3194,6 @@ static void qemu_machine_creation_done(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 ;
@@ -3193,7 +3212,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);
@@ -4104,6 +4122,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.
@@ -4155,15 +4174,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.
@@ -4422,12 +4432,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. */
Signature · 1 line
2.26.2
Re: [PATCH 11/29] vl: extract various command line desugaring snippets to a new function
Quoted 10 lines · On Tue, 27 Oct 2020 14:21:26 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)softmmu/vl.c +0
-0
softmmu/vl.c static const char *boot_once; · line 130
Quoted 5 lines
softmmu/vl.c +1
-0@@ -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 */
Is there a reason for it not being static?
Quoted 13 lines
softmmu/vl.c +0
-0int display_opengl;const char * keyboard_layout =NULL ;
ram_addr_tram_size;softmmu/vl.c +1
-1@@ -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 ;
softmmu/vl.c static void qemu_validate_options(void) · line 2920
Quoted 10 lines
softmmu/vl.c +7
-0@@ -2910,6 +2911,25 @@ static void qemu_validate_options(void)#endif } +static void qemu_process_sugar_options (void ) +{ +if (mem_prealloc) { +char *val; + + val =g_strdup_printf ("%d" , + (uint32_t )qemu_opt_get_number (qemu_find_opts_singleton ("smp-opts" ),"cpus" ,1 ));
if -smp isn't present it value used here was mc->default_cpus, which in most cases is 1 modulo some ARM boards and riscv.
But we probably don't care much how this heuristic is picked up for default_cpus, is users really care about how many treads QEMU spawns for preallocating RAM, they should use explicit -object memory-backend-foo,prealloc-threads=X explicitly
Quoted 68 lines
softmmu/vl.c +13
-17+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;@@ -3174,7 +3194,6 @@ static void qemu_machine_creation_done(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 ;@@ -3193,7 +3212,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);@@ -4104,6 +4122,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. @@ -4155,15 +4174,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. @@ -4422,12 +4432,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. */
Re: [PATCH 11/29] vl: extract various command line desugaring snippets to a new function
Il mer 11 nov 2020, 20:57 Igor Mammedov <[email protected]> ha scritto:
Quoted 17 lines
Quoted 13 lines · On Tue, 27 Oct 2020 14:21:26 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)softmmu/vl.c +0
-0@@ -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 ;
Quoted 3 lines
softmmu/vl.c static const char *boot_once; · line 129
Quoted 1 line
softmmu/vl.c +1
-0+int mem_prealloc;/* force preallocation of physical target memory */ Is there a reason for it not being static?
I will check if I am using it later in the series, but I don't think so.
Quoted 16 lines
Quoted 16 lines
softmmu/vl.c +1
-1int 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 ;@@ -2910,6 +2911,25 @@ static void qemu_validate_options(void)#endif }
Quoted 11 lines
softmmu/vl.c static void qemu_validate_options(void)
Quoted 7 lines
softmmu/vl.c +7
-0+static void qemu_process_sugar_options (void ) +{ +if (mem_prealloc) { +char *val; + + val = g_strdup_printf("%d", + (uint32_t)
qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1)); if -smp isn't present it value used here wasmc->default_cpus, which in most cases is 1 modulo some ARM boards and riscv.
Yes, I remember noticing that but decided I would not care. I should have added it to the commit message, though.
Paolo
Igor Mammedov
Reviewed-byRe: [PATCH 11/29] vl: extract various command line desugaring snippets to a new function
Quoted 19 lines · On Wed, 11 Nov 2020 21:04:53 +0100 Paolo Bonzini <[email protected]> wrote:
Il mer 11 nov 2020, 20:57 Igor Mammedov <[email protected]> ha scritto:
Quoted 17 lines
Quoted 13 lines · On Tue, 27 Oct 2020 14:21:26 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)softmmu/vl.c +0
-0@@ -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 ;
Quoted 5 lines
Quoted 3 lines
softmmu/vl.c static const char *boot_once; · line 129
Quoted 1 line
softmmu/vl.c +1
-0+int mem_prealloc;/* force preallocation of physical target memory */ Is there a reason for it not being static?
I will check if I am using it later in the series, but I don't think so.
with it fixed to static
Quoted 34 lines
Quoted 18 lines
Quoted 18 lines
softmmu/vl.c +1
-1int 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 ;@@ -2910,6 +2911,25 @@ static void qemu_validate_options(void)#endif }Quoted 11 lines
softmmu/vl.c static void qemu_validate_options(void)
Quoted 7 lines
softmmu/vl.c +7
-0+static void qemu_process_sugar_options (void ) +{ +if (mem_prealloc) { +char *val; + + val = g_strdup_printf("%d", + (uint32_t)
qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1)); if -smp isn't present it value used here wasmc->default_cpus, which in most cases is 1 modulo some ARM boards and riscv.Yes, I remember noticing that but decided I would not care. I should have added it to the commit message, though.
Paolo
PATCH 12/29 vl: create "-net nic -net user" default earlier
In reply to Paolo BonziniCreate it together with other default backends, even though the processing is done later.
--- softmmu/vl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
softmmu/vl.c +8 -8
@@ -4254,6 +4254,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++;
@@ -4389,14 +4397,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 );
Signature · 1 line
2.26.2
Re: [PATCH 12/29] vl: create "-net nic -net user" default earlier
Quoted 4 lines · On Tue, 27 Oct 2020 14:21:27 -0400 Paolo Bonzini <[email protected]> wrote:
Create it together with other default backends, even though the processing is done later.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 38 lines
--- softmmu/vl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)softmmu/vl.c +8
-8@@ -4254,6 +4254,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++;@@ -4389,14 +4397,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 );
PATCH 13/29 vl: load plugins as late as possible
In reply to Paolo BonziniThere is no need to load plugins in the middle of default device processing, move -plugin handling just before preconfig is entered.
--- softmmu/vl.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
softmmu/vl.c +6 -7
@@ -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;
@@ -3076,7 +3077,11 @@ static void qemu_finish_machine_init(void)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);/*
@@ -3211,7 +3216,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);
@@ -4183,11 +4187,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"),
Signature · 1 line
2.26.2
PATCH 14/29 vl: move semihosting command line fallback to qemu_finish_machine_init
In reply to Paolo BonziniMove more sane parts of the huge qemu_init function out of it.
--- softmmu/vl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
softmmu/vl.c +5 -7
@@ -3072,6 +3072,11 @@ static void qemu_finish_machine_init(void) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); +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);
@@ -4389,13 +4394,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 );
Signature · 1 line
2.26.2
PATCH 15/29 vl: extract default devices to separate functions
In reply to Paolo Bonzini--- softmmu/vl.c | 216 +++++++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 102 deletions(-)
softmmu/vl.c +114 -102
@@ -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 withRTC_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;
@@ -3211,10 +3323,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 ;
@@ -4192,97 +4301,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" );
@@ -4421,14 +4441,6 @@ void qemu_init(int argc, char **argv, char **envp)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); - } -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. */
Signature · 1 line
2.26.2
PATCH 16/29 vl: move CHECKPOINT_INIT after preconfig
In reply to Paolo BonziniMove CHECKPOINT_INIT right before the machine initialization is completed. Everything before is essentially an extension of command line parsing.
--- softmmu/vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
softmmu/vl.c +5 -5
@@ -3199,6 +3199,11 @@ static 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);/*
@@ -4441,11 +4446,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_semihosting_connect_chardevs ();qemu_semihosting_console_init (); -/* 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 */
Signature · 1 line
2.26.2
PATCH 17/29 vl: separate qemu_create_early_backends
In reply to Paolo Bonzini"Early" backends are created before the machine and can be used as machine options.
--- softmmu/vl.c | 123 +++++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 58 deletions(-)
softmmu/vl.c +65 -58
@@ -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 );
@@ -2696,6 +2698,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
@@ -2703,7 +2757,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); }
@@ -3321,7 +3375,6 @@ static void qemu_machine_creation_done(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;
@@ -3334,7 +3387,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);
@@ -4308,52 +4360,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,
Signature · 1 line
2.26.2
Re: [PATCH 17/29] vl: separate qemu_create_early_backends
Quoted 4 lines · On Tue, 27 Oct 2020 14:21:32 -0400 Paolo Bonzini <[email protected]> wrote:
"Early" backends are created before the machine and can be used as machine options.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 195 lines
--- softmmu/vl.c | 123 +++++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 58 deletions(-)softmmu/vl.c +65
-58@@ -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 );@@ -2696,6 +2698,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 @@ -2703,7 +2757,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); }@@ -3321,7 +3375,6 @@ static void qemu_machine_creation_done(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;@@ -3334,7 +3387,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);@@ -4308,52 +4360,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,
PATCH 18/29 vl: separate qemu_create_late_backends
In reply to Paolo Bonzini"Late" backends are created after the machine.
--- softmmu/vl.c | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-)
softmmu/vl.c +32 -32
@@ -2755,11 +2755,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); + +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 ); + +/* now chardevs have been created we may have semihosting to connect */ +qemu_semihosting_connect_chardevs (); +qemu_semihosting_console_init (); +}static bool set_memory_options (uint64_t *ram_slots,ram_addr_t *maxram_size,MachineClass *mc)
@@ -3385,7 +3415,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);
@@ -4402,10 +4431,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" );
@@ -4426,32 +4451,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); - -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 ); - -/* now chardevs have been created we may have semihosting to connect */ -qemu_semihosting_connect_chardevs (); -qemu_semihosting_console_init (); +qemu_create_late_backends (); current_machine->boot_order = boot_order;
Signature · 1 line
2.26.2
Re: [PATCH 18/29] vl: separate qemu_create_late_backends
Quoted 3 lines · On Tue, 27 Oct 2020 14:21:33 -0400 Paolo Bonzini <[email protected]> wrote:
"Late" backends are created after the machine.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 104 lines
--- softmmu/vl.c | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-)softmmu/vl.c +32
-32@@ -2755,11 +2755,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); + +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 ); + +/* now chardevs have been created we may have semihosting to connect */ +qemu_semihosting_connect_chardevs (); +qemu_semihosting_console_init (); +}static bool set_memory_options (uint64_t *ram_slots,ram_addr_t *maxram_size,MachineClass *mc)@@ -3385,7 +3415,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);@@ -4402,10 +4431,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" );@@ -4426,32 +4451,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); - -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 ); - -/* now chardevs have been created we may have semihosting to connect */ -qemu_semihosting_connect_chardevs (); -qemu_semihosting_console_init (); +qemu_create_late_backends (); current_machine->boot_order = boot_order;
PATCH 19/29 vl: separate qemu_create_machine
In reply to Paolo Bonzini--- softmmu/vl.c | 111 +++++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 52 deletions(-)
softmmu/vl.c +59 -52
@@ -133,6 +133,8 @@ static const char *boot_order;static const char *boot_once;static const char *incoming;static const char *loadvm; +static ram_addr_t maxram_size; +static uint64_t ram_slots;static int display_remote;static int snapshot;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);
@@ -2791,8 +2793,13 @@ static void qemu_create_late_backends(void)qemu_semihosting_console_init (); } -static bool set_memory_options (uint64_t *ram_slots,ram_addr_t *maxram_size, -MachineClass *mc) +static bool have_custom_ram_size (void ) +{ +QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +return !!qemu_opt_get (opts,"size" ); +} + +static void set_memory_options (MachineClass *mc) {uint64_t sz;const char *mem_str;
@@ -2842,7 +2849,7 @@ static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); - *maxram_size = ram_size; + maxram_size = ram_size;if (qemu_opt_get (opts,"maxmem" )) {uint64_t slots;
@@ -2863,15 +2870,58 @@ static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,exit (EXIT_FAILURE ); } - *maxram_size = sz; - *ram_slots = slots; + maxram_size = sz; + ram_slots = slots; }else if (qemu_opt_get (opts,"slots" )) {error_report ("invalid -m option value: missing 'maxmem' option" );exit (EXIT_FAILURE ); }loc_pop (&loc); -return !!mem_str; +} + +static void qemu_create_machine (MachineClass *machine_class) +{ +object_set_machine_compat_props (machine_class->compat_props); + +set_memory_options (machine_class); + + current_machine =MACHINE (object_new_with_class (OBJECT_CLASS (machine_class))); +if (machine_help_func (qemu_get_machine_opts (), current_machine)) { +exit (0 ); + } +object_property_add_child (object_get_root (),"machine" , +OBJECT (current_machine)); +object_property_add_child (container_get (OBJECT (current_machine), +"/unattached" ), +"sysbus" ,OBJECT (sysbus_get_default ())); + +if (machine_class->minimum_page_bits) { +if (!set_preferred_target_page_bits (machine_class->minimum_page_bits)) { +/* This would be a board error: specifying a minimum smaller than +* a target's compile-time fixed setting. +*/ +g_assert_not_reached (); + } + } + +cpu_exec_init_all (); + +if (machine_class->hw_version) { +qemu_set_hw_version (machine_class->hw_version); + } + +machine_smp_parse (current_machine, +qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ), &error_fatal); + +/* +* Get the default machine options from the machine if it is not already +* specified either by the configuration file or by the command line. +*/ +if (machine_class->default_machine_opts) { +qemu_opts_set_defaults (qemu_find_opts ("machine" ), + machine_class->default_machine_opts,0 ); + } }static int global_init_func (void *opaque,QemuOpts *opts,Error **errp)
@@ -3412,10 +3462,7 @@ void qemu_init(int argc, char **argv, char **envp)const char *optarg;MachineClass *machine_class;bool userconfig = true; -ram_addr_t maxram_size; -uint64_t ram_slots =0 ;FILE *vmstate_dump_file =NULL ; -bool have_custom_ram_size;qemu_add_opts (&qemu_drive_opts);qemu_add_drive_opts (&qemu_legacy_drive_opts);
@@ -4344,48 +4391,7 @@ void qemu_init(int argc, char **argv, char **envp)configure_rtc (qemu_find_opts_singleton ("rtc" )); - machine_class =select_machine (); -object_set_machine_compat_props (machine_class->compat_props); - - have_custom_ram_size =set_memory_options (&ram_slots, &maxram_size, - machine_class); - - current_machine =MACHINE (object_new_with_class (OBJECT_CLASS (machine_class))); -if (machine_help_func (qemu_get_machine_opts (), current_machine)) { -exit (0 ); - } -object_property_add_child (object_get_root (),"machine" , -OBJECT (current_machine)); -object_property_add_child (container_get (OBJECT (current_machine), -"/unattached" ), -"sysbus" ,OBJECT (sysbus_get_default ())); - -if (machine_class->minimum_page_bits) { -if (!set_preferred_target_page_bits (machine_class->minimum_page_bits)) { -/* This would be a board error: specifying a minimum smaller than -* a target's compile-time fixed setting. -*/ -g_assert_not_reached (); - } - } - -cpu_exec_init_all (); - -if (machine_class->hw_version) { -qemu_set_hw_version (machine_class->hw_version); - } - -machine_smp_parse (current_machine, -qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ), &error_fatal); - -/* -* Get the default machine options from the machine if it is not already -* specified either by the configuration file or by the command line. -*/ -if (machine_class->default_machine_opts) { -qemu_opts_set_defaults (qemu_find_opts ("machine" ), - machine_class->default_machine_opts,0 ); - } +qemu_create_machine (select_machine ());qemu_disable_default_devices ();qemu_create_default_devices ();
@@ -4420,6 +4426,7 @@ void qemu_init(int argc, char **argv, char **envp)* called from configure_accelerator(). */ + machine_class =MACHINE_GET_CLASS (current_machine);if (!qtest_enabled () && machine_class->deprecation_reason) {error_report ("Machine type '%s' is deprecated: %s" , machine_class->name, machine_class->deprecation_reason);
@@ -4473,7 +4480,7 @@ void qemu_init(int argc, char **argv, char **envp)exit (EXIT_FAILURE ); } backend_size =object_property_get_uint (backend,"size" , &error_abort); -if (have_custom_ram_size && backend_size != ram_size) { +if (have_custom_ram_size () && backend_size != ram_size) {error_report ("Size specified by -m option must match size of " "explicitly specified 'memory-backend' property" );exit (EXIT_FAILURE );
Signature · 1 line
2.26.2
Re: [PATCH 19/29] vl: separate qemu_create_machine
Quoted 1 line · On Tue, 27 Oct 2020 14:21:34 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 182 lines
--- softmmu/vl.c | 111 +++++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 52 deletions(-)softmmu/vl.c +59
-52@@ -133,6 +133,8 @@ static const char *boot_order;static const char *boot_once;static const char *incoming;static const char *loadvm; +static ram_addr_t maxram_size; +static uint64_t ram_slots;static int display_remote;static int snapshot;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);@@ -2791,8 +2793,13 @@ static void qemu_create_late_backends(void)qemu_semihosting_console_init (); } -static bool set_memory_options (uint64_t *ram_slots,ram_addr_t *maxram_size, -MachineClass *mc) +static bool have_custom_ram_size (void ) +{ +QemuOpts *opts =qemu_find_opts_singleton ("memory" ); +return !!qemu_opt_get (opts,"size" ); +} + +static void set_memory_options (MachineClass *mc) {uint64_t sz;const char *mem_str;@@ -2842,7 +2849,7 @@ static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,/* store value for the future use */ qemu_opt_set_number (opts,"size" , ram_size, &error_abort); - *maxram_size = ram_size; + maxram_size = ram_size;if (qemu_opt_get (opts,"maxmem" )) {uint64_t slots;@@ -2863,15 +2870,58 @@ static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,exit (EXIT_FAILURE ); } - *maxram_size = sz; - *ram_slots = slots; + maxram_size = sz; + ram_slots = slots; }else if (qemu_opt_get (opts,"slots" )) {error_report ("invalid -m option value: missing 'maxmem' option" );exit (EXIT_FAILURE ); }loc_pop (&loc); -return !!mem_str; +} + +static void qemu_create_machine (MachineClass *machine_class) +{ +object_set_machine_compat_props (machine_class->compat_props); + +set_memory_options (machine_class); + + current_machine =MACHINE (object_new_with_class (OBJECT_CLASS (machine_class))); +if (machine_help_func (qemu_get_machine_opts (), current_machine)) { +exit (0 ); + } +object_property_add_child (object_get_root (),"machine" , +OBJECT (current_machine)); +object_property_add_child (container_get (OBJECT (current_machine), +"/unattached" ), +"sysbus" ,OBJECT (sysbus_get_default ())); + +if (machine_class->minimum_page_bits) { +if (!set_preferred_target_page_bits (machine_class->minimum_page_bits)) { +/* This would be a board error: specifying a minimum smaller than +* a target's compile-time fixed setting. +*/ +g_assert_not_reached (); + } + } + +cpu_exec_init_all (); + +if (machine_class->hw_version) { +qemu_set_hw_version (machine_class->hw_version); + } + +machine_smp_parse (current_machine, +qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ), &error_fatal); + +/* +* Get the default machine options from the machine if it is not already +* specified either by the configuration file or by the command line. +*/ +if (machine_class->default_machine_opts) { +qemu_opts_set_defaults (qemu_find_opts ("machine" ), + machine_class->default_machine_opts,0 ); + } }static int global_init_func (void *opaque,QemuOpts *opts,Error **errp)@@ -3412,10 +3462,7 @@ void qemu_init(int argc, char **argv, char **envp)const char *optarg;MachineClass *machine_class;bool userconfig = true; -ram_addr_t maxram_size; -uint64_t ram_slots =0 ;FILE *vmstate_dump_file =NULL ; -bool have_custom_ram_size;qemu_add_opts (&qemu_drive_opts);qemu_add_drive_opts (&qemu_legacy_drive_opts);@@ -4344,48 +4391,7 @@ void qemu_init(int argc, char **argv, char **envp)configure_rtc (qemu_find_opts_singleton ("rtc" )); - machine_class =select_machine (); -object_set_machine_compat_props (machine_class->compat_props); - - have_custom_ram_size =set_memory_options (&ram_slots, &maxram_size, - machine_class); - - current_machine =MACHINE (object_new_with_class (OBJECT_CLASS (machine_class))); -if (machine_help_func (qemu_get_machine_opts (), current_machine)) { -exit (0 ); - } -object_property_add_child (object_get_root (),"machine" , -OBJECT (current_machine)); -object_property_add_child (container_get (OBJECT (current_machine), -"/unattached" ), -"sysbus" ,OBJECT (sysbus_get_default ())); - -if (machine_class->minimum_page_bits) { -if (!set_preferred_target_page_bits (machine_class->minimum_page_bits)) { -/* This would be a board error: specifying a minimum smaller than -* a target's compile-time fixed setting. -*/ -g_assert_not_reached (); - } - } - -cpu_exec_init_all (); - -if (machine_class->hw_version) { -qemu_set_hw_version (machine_class->hw_version); - } - -machine_smp_parse (current_machine, -qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ), &error_fatal); - -/* -* Get the default machine options from the machine if it is not already -* specified either by the configuration file or by the command line. -*/ -if (machine_class->default_machine_opts) { -qemu_opts_set_defaults (qemu_find_opts ("machine" ), - machine_class->default_machine_opts,0 ); - } +qemu_create_machine (select_machine ());qemu_disable_default_devices ();qemu_create_default_devices ();@@ -4420,6 +4426,7 @@ void qemu_init(int argc, char **argv, char **envp)* called from configure_accelerator(). */ + machine_class =MACHINE_GET_CLASS (current_machine);if (!qtest_enabled () && machine_class->deprecation_reason) {error_report ("Machine type '%s' is deprecated: %s" , machine_class->name, machine_class->deprecation_reason);@@ -4473,7 +4480,7 @@ void qemu_init(int argc, char **argv, char **envp)exit (EXIT_FAILURE ); } backend_size =object_property_get_uint (backend,"size" , &error_abort); -if (have_custom_ram_size && backend_size != ram_size) { +if (have_custom_ram_size () && backend_size != ram_size) {error_report ("Size specified by -m option must match size of " "explicitly specified 'memory-backend' property" );exit (EXIT_FAILURE );
PATCH 20/29 vl: separate qemu_apply_machine_options
In reply to Paolo Bonzini--- softmmu/vl.c | 66 +++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-)
softmmu/vl.c +37 -29
@@ -2700,6 +2700,41 @@ static bool object_create_early(const char *type, QemuOpts *opts)return true; } +static void qemu_apply_machine_options (void ) +{ +MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); +QemuOpts *machine_opts =qemu_get_machine_opts (); +QemuOpts *opts; + +qemu_opt_foreach (machine_opts, machine_set_property, current_machine, + &error_fatal); + current_machine->ram_size = ram_size; + current_machine->maxram_size = maxram_size; + current_machine->ram_slots = ram_slots; + + opts =qemu_opts_find (qemu_find_opts ("boot-opts" ),NULL ); +if (opts) { + boot_order =qemu_opt_get (opts,"order" ); +if (boot_order) { +validate_bootdevices (boot_order, &error_fatal); + } + + boot_once =qemu_opt_get (opts,"once" ); +if (boot_once) { +validate_bootdevices (boot_once, &error_fatal); + } + + boot_menu =qemu_opt_get_bool (opts,"menu" , boot_menu); + boot_strict =qemu_opt_get_bool (opts,"strict" , false); + } + +if (!boot_order) { + boot_order = machine_class->default_boot_order; + } + + current_machine->boot_order = boot_order; +} +static void qemu_create_early_backends (void ) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine);
@@ -3455,7 +3490,7 @@ static void qemu_machine_creation_done(void)void qemu_init (int argc,char **argv,char **envp) { -QemuOpts *opts, *machine_opts; +QemuOpts *opts;QemuOpts *icount_opts =NULL , *accel_opts =NULL ;QemuOptsList *olist;int optind;
@@ -4397,12 +4432,7 @@ void qemu_init(int argc, char **argv, char **envp)qemu_create_default_devices ();qemu_create_early_backends (); - machine_opts =qemu_get_machine_opts (); -qemu_opt_foreach (machine_opts, machine_set_property, current_machine, - &error_fatal); - current_machine->ram_size = ram_size; - current_machine->maxram_size = maxram_size; - current_machine->ram_slots = ram_slots; +qemu_apply_machine_options ();/* * Note: uses machine properties such as kernel-irqchip, must run
@@ -4438,30 +4468,8 @@ void qemu_init(int argc, char **argv, char **envp)*/ migration_object_init (); - opts =qemu_opts_find (qemu_find_opts ("boot-opts" ),NULL ); -if (opts) { - boot_order =qemu_opt_get (opts,"order" ); -if (boot_order) { -validate_bootdevices (boot_order, &error_fatal); - } - - boot_once =qemu_opt_get (opts,"once" ); -if (boot_once) { -validate_bootdevices (boot_once, &error_fatal); - } - - boot_menu =qemu_opt_get_bool (opts,"menu" , boot_menu); - boot_strict =qemu_opt_get_bool (opts,"strict" , false); - } - -if (!boot_order) { - boot_order = machine_class->default_boot_order; - } -qemu_create_late_backends (); - current_machine->boot_order = boot_order; -/* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type;if (cpu_option) {
Signature · 1 line
2.26.2
Re: [PATCH 20/29] vl: separate qemu_apply_machine_options
Quoted 1 line · On Tue, 27 Oct 2020 14:21:35 -0400 Paolo Bonzini <[email protected]> wrote:
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 104 lines
--- softmmu/vl.c | 66 +++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-)softmmu/vl.c +37
-29@@ -2700,6 +2700,41 @@ static bool object_create_early(const char *type, QemuOpts *opts)return true; } +static void qemu_apply_machine_options (void ) +{ +MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); +QemuOpts *machine_opts =qemu_get_machine_opts (); +QemuOpts *opts; + +qemu_opt_foreach (machine_opts, machine_set_property, current_machine, + &error_fatal); + current_machine->ram_size = ram_size; + current_machine->maxram_size = maxram_size; + current_machine->ram_slots = ram_slots; + + opts =qemu_opts_find (qemu_find_opts ("boot-opts" ),NULL ); +if (opts) { + boot_order =qemu_opt_get (opts,"order" ); +if (boot_order) { +validate_bootdevices (boot_order, &error_fatal); + } + + boot_once =qemu_opt_get (opts,"once" ); +if (boot_once) { +validate_bootdevices (boot_once, &error_fatal); + } + + boot_menu =qemu_opt_get_bool (opts,"menu" , boot_menu); + boot_strict =qemu_opt_get_bool (opts,"strict" , false); + } + +if (!boot_order) { + boot_order = machine_class->default_boot_order; + } + + current_machine->boot_order = boot_order; +} +static void qemu_create_early_backends (void ) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine);@@ -3455,7 +3490,7 @@ static void qemu_machine_creation_done(void)void qemu_init (int argc,char **argv,char **envp) { -QemuOpts *opts, *machine_opts; +QemuOpts *opts;QemuOpts *icount_opts =NULL , *accel_opts =NULL ;QemuOptsList *olist;int optind;@@ -4397,12 +4432,7 @@ void qemu_init(int argc, char **argv, char **envp)qemu_create_default_devices ();qemu_create_early_backends (); - machine_opts =qemu_get_machine_opts (); -qemu_opt_foreach (machine_opts, machine_set_property, current_machine, - &error_fatal); - current_machine->ram_size = ram_size; - current_machine->maxram_size = maxram_size; - current_machine->ram_slots = ram_slots; +qemu_apply_machine_options ();/* * Note: uses machine properties such as kernel-irqchip, must run @@ -4438,30 +4468,8 @@ void qemu_init(int argc, char **argv, char **envp)*/ migration_object_init (); - opts =qemu_opts_find (qemu_find_opts ("boot-opts" ),NULL ); -if (opts) { - boot_order =qemu_opt_get (opts,"order" ); -if (boot_order) { -validate_bootdevices (boot_order, &error_fatal); - } - - boot_once =qemu_opt_get (opts,"once" ); -if (boot_once) { -validate_bootdevices (boot_once, &error_fatal); - } - - boot_menu =qemu_opt_get_bool (opts,"menu" , boot_menu); - boot_strict =qemu_opt_get_bool (opts,"strict" , false); - } - -if (!boot_order) { - boot_order = machine_class->default_boot_order; - } -qemu_create_late_backends (); - current_machine->boot_order = boot_order; -/* parse features once if machine provides default cpu_type */ current_machine->cpu_type = machine_class->default_cpu_type;if (cpu_option) {
PATCH 21/29 vl: separate qemu_resolve_machine_memdev
In reply to Paolo BonziniThis is a bit nasty: the machine is storing a string and later resolving it. We probably want to remove the memdev property and instead make this a memory-set command. "-M memdev" can be handled as a legacy option that is special cased by machine_set_property.
--- softmmu/vl.c | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 33 deletions(-)
softmmu/vl.c +37 -33
@@ -2834,6 +2834,42 @@ static bool have_custom_ram_size(void)return !!qemu_opt_get (opts,"size" ); } +static void qemu_resolve_machine_memdev (void ) +{ +if (current_machine->ram_memdev_id) { +Object *backend; +ram_addr_t backend_size; + + backend =object_resolve_path_type (current_machine->ram_memdev_id, +TYPE_MEMORY_BACKEND ,NULL ); +if (!backend) { +error_report ("Memory backend '%s' not found" , + current_machine->ram_memdev_id); +exit (EXIT_FAILURE ); + } + backend_size =object_property_get_uint (backend,"size" , &error_abort); +if (have_custom_ram_size () && backend_size != ram_size) { +error_report ("Size specified by -m option must match size of " +"explicitly specified 'memory-backend' property" ); +exit (EXIT_FAILURE ); + } +if (mem_path) { +error_report ("'-mem-path' can't be used together with" +"'-machine memory-backend'" ); +exit (EXIT_FAILURE ); + } + ram_size = backend_size; + } + +if (!xen_enabled ()) { +/* On 32-bit hosts, QEMU is limited by virtual address space */ +if (ram_size > (2047 <<20 ) &&HOST_LONG_BITS ==32 ) { +error_report ("at most 2047 MB RAM can be simulated" ); +exit (1 ); + } + } +} +static void set_memory_options (MachineClass *mc) {uint64_t sz;
@@ -4476,39 +4512,7 @@ void qemu_init(int argc, char **argv, char **envp) current_machine->cpu_type =parse_cpu_option (cpu_option); } -if (current_machine->ram_memdev_id) { -Object *backend; -ram_addr_t backend_size; - - backend =object_resolve_path_type (current_machine->ram_memdev_id, -TYPE_MEMORY_BACKEND ,NULL ); -if (!backend) { -error_report ("Memory backend '%s' not found" , - current_machine->ram_memdev_id); -exit (EXIT_FAILURE ); - } - backend_size =object_property_get_uint (backend,"size" , &error_abort); -if (have_custom_ram_size () && backend_size != ram_size) { -error_report ("Size specified by -m option must match size of " -"explicitly specified 'memory-backend' property" ); -exit (EXIT_FAILURE ); - } -if (mem_path) { -error_report ("'-mem-path' can't be used together with" -"'-machine memory-backend'" ); -exit (EXIT_FAILURE ); - } - ram_size = backend_size; - } - -if (!xen_enabled ()) { -/* On 32-bit hosts, QEMU is limited by virtual address space */ -if (ram_size > (2047 <<20 ) &&HOST_LONG_BITS ==32 ) { -error_report ("at most 2047 MB RAM can be simulated" ); -exit (1 ); - } - } - +qemu_resolve_machine_memdev ();parse_numa_opts (current_machine);/* do monitor/qmp handling at preconfig state if requested */
Signature · 1 line
2.26.2
Re: [PATCH 21/29] vl: separate qemu_resolve_machine_memdev
Quoted 5 lines · On Tue, 27 Oct 2020 14:21:36 -0400 Paolo Bonzini <[email protected]> wrote:
This is a bit nasty: the machine is storing a string and later resolving it. We probably want to remove the memdev property and instead make this a memory-set command. "-M memdev" can be handled as a legacy option that is special cased by
machine_set_property.
I'd treat this description as topic starter and drop it from this patch in v2. with that,
how memory-set would help or be any better than memdev?
memdev should be a link property, but due to RAM allocation being dependent on used accel we can't create actual backend until accelerator is initialized (i.e. after machine options parsed, which forced me to make memdev a string that refers to a backend created later).
If we can make RAM allocation independent from used accelerator (if I recall right it has TCG dependency) and if we split -m CLI handling and default ram_memdev_id (which is implicit CLI), then we can make -M memdev a link and move RAM backends to qemu_create_early_backends() time.
Which in context of creating machine via QMP would imply that link should be set explicitly via QMP after backend is created.
Flow could look like this:
CLI part:
-m / defaults - preps and 'if not NUMA'
executes QMP
object_add memory-backend-foo,size=X,id=(ram_memdev_id)
in case -M memory-backend is not set explicitly, or fetch id of explicitly provided backend (which would be created by qemu_create_early_backends)
QMP part:
object_add machine_foo,id=my_machine
set (link) my_machine.memory-backend=(ram_memdev_id)
that way we do no need to create a separate memory-set command, we can handle it as a normal property, where all compat stuff is kept in CLI part.
For CLI part handling there are 2 caveats:
* Xen doesn't use memdev at all, it allocates memory region directly. Not sure what we should do in this case
(may be we can create a separate xen-ram backend for it and remove
'mr == &ram_memory' in xen_ram_alloc() hack)
* legacy S390 machine types (<5.0) fixup ram_size before creating backend, if user provided value is not correct 5c30ef937f5 (i.e. not aligned properly).
I guess we are stuck with it, given it's version-ed machine type. The rest of the code was fixed to error-out in the case board doesn't like -m value.
Or we can treat it as user error (which should be corrected by user) and deprecate/remove fixup.
Quoted 93 lines
Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 33 deletions(-)softmmu/vl.c +37
-33@@ -2834,6 +2834,42 @@ static bool have_custom_ram_size(void)return !!qemu_opt_get (opts,"size" ); } +static void qemu_resolve_machine_memdev (void ) +{ +if (current_machine->ram_memdev_id) { +Object *backend; +ram_addr_t backend_size; + + backend =object_resolve_path_type (current_machine->ram_memdev_id, +TYPE_MEMORY_BACKEND ,NULL ); +if (!backend) { +error_report ("Memory backend '%s' not found" , + current_machine->ram_memdev_id); +exit (EXIT_FAILURE ); + } + backend_size =object_property_get_uint (backend,"size" , &error_abort); +if (have_custom_ram_size () && backend_size != ram_size) { +error_report ("Size specified by -m option must match size of " +"explicitly specified 'memory-backend' property" ); +exit (EXIT_FAILURE ); + } +if (mem_path) { +error_report ("'-mem-path' can't be used together with" +"'-machine memory-backend'" ); +exit (EXIT_FAILURE ); + } + ram_size = backend_size; + } + +if (!xen_enabled ()) { +/* On 32-bit hosts, QEMU is limited by virtual address space */ +if (ram_size > (2047 <<20 ) &&HOST_LONG_BITS ==32 ) { +error_report ("at most 2047 MB RAM can be simulated" ); +exit (1 ); + } + } +} +static void set_memory_options (MachineClass *mc) {uint64_t sz;@@ -4476,39 +4512,7 @@ void qemu_init(int argc, char **argv, char **envp) current_machine->cpu_type =parse_cpu_option (cpu_option); } -if (current_machine->ram_memdev_id) { -Object *backend; -ram_addr_t backend_size; - - backend =object_resolve_path_type (current_machine->ram_memdev_id, -TYPE_MEMORY_BACKEND ,NULL ); -if (!backend) { -error_report ("Memory backend '%s' not found" , - current_machine->ram_memdev_id); -exit (EXIT_FAILURE ); - } - backend_size =object_property_get_uint (backend,"size" , &error_abort); -if (have_custom_ram_size () && backend_size != ram_size) { -error_report ("Size specified by -m option must match size of " -"explicitly specified 'memory-backend' property" ); -exit (EXIT_FAILURE ); - } -if (mem_path) { -error_report ("'-mem-path' can't be used together with" -"'-machine memory-backend'" ); -exit (EXIT_FAILURE ); - } - ram_size = backend_size; - } - -if (!xen_enabled ()) { -/* On 32-bit hosts, QEMU is limited by virtual address space */ -if (ram_size > (2047 <<20 ) &&HOST_LONG_BITS ==32 ) { -error_report ("at most 2047 MB RAM can be simulated" ); -exit (1 ); - } - } - +qemu_resolve_machine_memdev ();parse_numa_opts (current_machine);/* do monitor/qmp handling at preconfig state if requested */
PATCH 22/29 vl: initialize displays before preconfig loop
In reply to Paolo BonziniDisplays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to qemu_init_displays will go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will the preconfig_exit_requested variable (that is only preconfig_requested remains).
--- softmmu/vl.c | 58 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-)
softmmu/vl.c +36 -22
@@ -137,6 +137,7 @@ static ram_addr_t maxram_size;static uint64_t ram_slots;static int display_remote;static int snapshot; +static bool preconfig_requested;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);static BlockdevOptionsQueue bdo_queue =QSIMPLEQ_HEAD_INITIALIZER (bdo_queue);static bool nographic = false;
@@ -3210,12 +3211,12 @@ static void qemu_validate_options(void) } } -if (loadvm && !preconfig_exit_requested) { +if (loadvm && preconfig_requested) {error_report ("'preconfig' and 'loadvm' options are " "mutually exclusive" );exit (EXIT_FAILURE ); } -if (incoming && !preconfig_exit_requested) { +if (incoming && preconfig_requested) {error_report ("'preconfig' and 'incoming' options are " "mutually exclusive" );exit (EXIT_FAILURE );
@@ -3381,6 +3382,28 @@ static void qemu_init_subsystems(void)socket_init (); } +static void qemu_init_displays (void ) +{ +DisplayState *ds; + +/* 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 (); + } +} +/* * Called after leaving preconfig state. From here on runstate is * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE.
@@ -3449,8 +3472,6 @@ static void qemu_create_cli_devices(void)static void qemu_machine_creation_done (void ) { -DisplayState *ds; -cpu_synchronize_all_post_init ();/* Did we create any drives that we failed to create a device for? */
@@ -3473,23 +3494,6 @@ static void qemu_machine_creation_done(void)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 ); }
@@ -4094,6 +4098,7 @@ void qemu_init(int argc, char **argv, char **envp)break ;case QEMU_OPTION_preconfig: preconfig_exit_requested = false; + preconfig_requested = true;break ;case QEMU_OPTION_enable_kvm: olist =qemu_find_opts ("machine" );
@@ -4515,11 +4520,20 @@ void qemu_init(int argc, char **argv, char **envp)qemu_resolve_machine_memdev ();parse_numa_opts (current_machine); +if (preconfig_requested) { +qemu_init_displays (); + } +/* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop (); -qemu_finish_machine_init (); +qemu_create_cli_devices (); + +/* initialize displays after all errors have been reported */ +if (!preconfig_requested) { +qemu_init_displays (); + }qemu_machine_creation_done ();if (loadvm) {
Signature · 1 line
2.26.2
Re: [PATCH 22/29] vl: initialize displays before preconfig loop
Quoted 11 lines · On Tue, 27 Oct 2020 14:21:37 -0400 Paolo Bonzini <[email protected]> wrote:
Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to
qemu_init_displayswill go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will thepreconfig_exit_requestedvariable (that is onlypreconfig_requestedremains).Signed-off-by Paolo Bonzini <[email protected]>
Doesn't apply to yer for-6.0 branch
Quoted 123 lines
--- softmmu/vl.c | 58 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-)softmmu/vl.c +36
-22@@ -137,6 +137,7 @@ static ram_addr_t maxram_size;static uint64_t ram_slots;static int display_remote;static int snapshot; +static bool preconfig_requested;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);static BlockdevOptionsQueue bdo_queue =QSIMPLEQ_HEAD_INITIALIZER (bdo_queue);static bool nographic = false;@@ -3210,12 +3211,12 @@ static void qemu_validate_options(void) } } -if (loadvm && !preconfig_exit_requested) { +if (loadvm && preconfig_requested) {error_report ("'preconfig' and 'loadvm' options are " "mutually exclusive" );exit (EXIT_FAILURE ); } -if (incoming && !preconfig_exit_requested) { +if (incoming && preconfig_requested) {error_report ("'preconfig' and 'incoming' options are " "mutually exclusive" );exit (EXIT_FAILURE );@@ -3381,6 +3382,28 @@ static void qemu_init_subsystems(void)socket_init (); } +static void qemu_init_displays (void ) +{ +DisplayState *ds; + +/* 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 (); + } +} +/* * Called after leaving preconfig state. From here on runstate is * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. @@ -3449,8 +3472,6 @@ static void qemu_create_cli_devices(void)static void qemu_machine_creation_done (void ) { -DisplayState *ds; -cpu_synchronize_all_post_init ();/* Did we create any drives that we failed to create a device for? */ @@ -3473,23 +3494,6 @@ static void qemu_machine_creation_done(void)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 ); }@@ -4094,6 +4098,7 @@ void qemu_init(int argc, char **argv, char **envp)break ;case QEMU_OPTION_preconfig: preconfig_exit_requested = false; + preconfig_requested = true;break ;case QEMU_OPTION_enable_kvm: olist =qemu_find_opts ("machine" );@@ -4515,11 +4520,20 @@ void qemu_init(int argc, char **argv, char **envp)qemu_resolve_machine_memdev ();parse_numa_opts (current_machine); +if (preconfig_requested) { +qemu_init_displays (); + } +/* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop (); -qemu_finish_machine_init (); +qemu_create_cli_devices (); + +/* initialize displays after all errors have been reported */ +if (!preconfig_requested) { +qemu_init_displays (); + }qemu_machine_creation_done ();if (loadvm) {
Re: [PATCH 22/29] vl: initialize displays before preconfig loop
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 Oct 2020 14:21:37 -0400 Paolo Bonzini <[email protected]> wrote:
Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to
qemu_init_displayswill go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will thepreconfig_exit_requestedvariable (that is onlypreconfig_requestedremains).
Quoted 3 lines
Quoted 1 line
Signed-off-by Paolo Bonzini <[email protected]>Doesn't apply to yer for-6.0 branch
I updated the branch.
Thanks,
Paolo
Quoted 124 lines
Quoted 123 lines
--- softmmu/vl.c | 58 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-)softmmu/vl.c +36
-22@@ -137,6 +137,7 @@ static ram_addr_t maxram_size;static uint64_t ram_slots;static int display_remote;static int snapshot; +static bool preconfig_requested;static QemuPluginList plugin_list =QTAILQ_HEAD_INITIALIZER (plugin_list);static BlockdevOptionsQueue bdo_queue =QSIMPLEQ_HEAD_INITIALIZER (bdo_queue);static bool nographic = false;@@ -3210,12 +3211,12 @@ static void qemu_validate_options(void) } } -if (loadvm && !preconfig_exit_requested) { +if (loadvm && preconfig_requested) {error_report ("'preconfig' and 'loadvm' options are " "mutually exclusive" );exit (EXIT_FAILURE ); } -if (incoming && !preconfig_exit_requested) { +if (incoming && preconfig_requested) {error_report ("'preconfig' and 'incoming' options are " "mutually exclusive" );exit (EXIT_FAILURE );@@ -3381,6 +3382,28 @@ static void qemu_init_subsystems(void)socket_init (); } +static void qemu_init_displays (void ) +{ +DisplayState *ds; + +/* 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 (); + } +} +/* * Called after leaving preconfig state. From here on runstate is * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. @@ -3449,8 +3472,6 @@ static void qemu_create_cli_devices(void)static void qemu_machine_creation_done (void ) { -DisplayState *ds; -cpu_synchronize_all_post_init ();/* Did we create any drives that we failed to create a device for? */ @@ -3473,23 +3494,6 @@ static void qemu_machine_creation_done(void)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 ); }@@ -4094,6 +4098,7 @@ void qemu_init(int argc, char **argv, char **envp)break ;case QEMU_OPTION_preconfig: preconfig_exit_requested = false; + preconfig_requested = true;break ;case QEMU_OPTION_enable_kvm: olist =qemu_find_opts ("machine" );@@ -4515,11 +4520,20 @@ void qemu_init(int argc, char **argv, char **envp)qemu_resolve_machine_memdev ();parse_numa_opts (current_machine); +if (preconfig_requested) { +qemu_init_displays (); + } +/* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop (); -qemu_finish_machine_init (); +qemu_create_cli_devices (); + +/* initialize displays after all errors have been reported */ +if (!preconfig_requested) { +qemu_init_displays (); + }qemu_machine_creation_done ();if (loadvm) {
Re: [PATCH 22/29] vl: initialize displays before preconfig loop
Quoted 14 lines · On Fri, 20 Nov 2020 16:53:41 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 Oct 2020 14:21:37 -0400 Paolo Bonzini <[email protected]> wrote:
Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to
qemu_init_displayswill go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will thepreconfig_exit_requestedvariable (that is onlypreconfig_requestedremains).
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Paolo Bonzini <[email protected]>Doesn't apply to yer for-6.0 branch
I updated the branch.
it probably won't help,
what I do review/test is drop these patches on branch and reapply them from this thread.
Having v2 on list that applies to master would be better.
Quoted 4 lines
Thanks,
Paolo
[...]
Re: [PATCH 22/29] vl: initialize displays before preconfig loop
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Fri, 20 Nov 2020 16:53:41 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
Quoted 11 lines · On Tue, 27 Oct 2020 14:21:37 -0400 Paolo Bonzini <[email protected]> wrote:
Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to
qemu_init_displayswill go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will thepreconfig_exit_requestedvariable (that is onlypreconfig_requestedremains).Signed-off-by Paolo Bonzini <[email protected]>
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Doesn't apply to yer for-6.0 branch
I updated the branch.
it probably won't help,
what I do review/test is drop these patches on branch and reapply them from this thread.
Having v2 on list that applies to master would be better.
Yes, of course. I meant that the for-6.0 branch already _is_ the v2, I'll send it out as soon as I integrate all your feedback.
Thanks,
Paolo
Re: [PATCH 22/29] vl: initialize displays before preconfig loop
Quoted 24 lines · On Fri, 20 Nov 2020 17:46:14 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 19 lines · On Fri, 20 Nov 2020 16:53:41 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 Oct 2020 14:21:37 -0400 Paolo Bonzini <[email protected]> wrote:
Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself.
This patch is quite ugly, but all this is temporary. The double call to
qemu_init_displayswill go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will thepreconfig_exit_requestedvariable (that is onlypreconfig_requestedremains).Quoted 3 lines
Quoted 1 line
Signed-off-by Paolo Bonzini <[email protected]>Doesn't apply to yer for-6.0 branch
I updated the branch.
Quoted 7 lines
Quoted 4 lines
it probably won't help,
what I do review/test is drop these patches on branch and reapply them from this thread.
Having v2 on list that applies to master would be better.Yes, of course. I meant that the for-6.0 branch already _is_ the v2, I'll send it out as soon as I integrate all your feedback.
Thanks for trying to make hornets nest (vl.c) in something manageable and less scary to touch.
I'll try to review v2 faster (there is not much of it left by now)
Quoted 6 lines
Thanks,
Paolo
PATCH 23/29 vl: move -global check earlier
In reply to Paolo BonziniThe check has no effect after both builtin and user-specified devices have been created.
--- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
softmmu/vl.c +2 -1
@@ -3489,6 +3489,8 @@ static void qemu_machine_creation_done(void)net_check_clients (); } +qdev_prop_check_globals (); +if (boot_once) {qemu_boot_set (boot_once, &error_fatal);qemu_register_reset (restore_boot_order,g_strdup (boot_order));
@@ -4548,7 +4550,6 @@ void qemu_init(int argc, char **argv, char **envp)replay_vmstate_init (); } -qdev_prop_check_globals ();if (vmstate_dump_file) {/* dump and exit */ dump_vmstate_json_to_file (vmstate_dump_file);
Signature · 1 line
2.26.2
Re: [PATCH 23/29] vl: move -global check earlier
Quoted 4 lines · On Tue, 27 Oct 2020 14:21:38 -0400 Paolo Bonzini <[email protected]> wrote:
The check has no effect after both builtin and user-specified devices have been created.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 25 lines
--- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)softmmu/vl.c +2
-1@@ -3489,6 +3489,8 @@ static void qemu_machine_creation_done(void)net_check_clients (); } +qdev_prop_check_globals (); +if (boot_once) {qemu_boot_set (boot_once, &error_fatal);qemu_register_reset (restore_boot_order,g_strdup (boot_order));@@ -4548,7 +4550,6 @@ void qemu_init(int argc, char **argv, char **envp)replay_vmstate_init (); } -qdev_prop_check_globals ();if (vmstate_dump_file) {/* dump and exit */ dump_vmstate_json_to_file (vmstate_dump_file);
PATCH 24/29 migration, vl: start migration via qmp_migrate_incoming
In reply to Paolo BonziniMake qemu_start_incoming_migration local to migration/migration.c. By using the runstate instead of a separate flag, vl need not do anything to setup deferred incoming migration.
qmp_migrate_incoming also does not need the deferred_incoming flag anymore, because "-incoming PROTOCOL" will clear the "once" flag before the main loop starts. Therefore, later invocations of the migrate-incoming command will fail with the existing "The incoming migration has already been started" error message.
--- include/migration/misc.h | 1 - migration/migration.c | 33 ++++++++------------------------- softmmu/vl.c | 11 +++++++---- 3 files changed, 15 insertions(+), 30 deletions(-)
include/migration/misc.h +0 -1
@@ -58,7 +58,6 @@ void dump_vmstate_json_to_file(FILE *out_fp);/* migration/migration.c */ void migration_object_init (void );void migration_shutdown (void ); -void qemu_start_incoming_migration (const char *uri,Error **errp);bool migration_is_idle (void );bool migration_is_active (MigrationState *);void add_migration_state_change_notifier (Notifier *notify);
migration/migration.c +8 -25
@@ -114,8 +114,6 @@static NotifierList migration_state_notifiers =NOTIFIER_LIST_INITIALIZER (migration_state_notifiers); -static bool deferred_incoming; -/* Messages sent on the return path from destination to source */ enum mig_rp_message_type {MIG_RP_MSG_INVALID =0 ,/* Must be 0 */
@@ -257,19 +255,6 @@ static bool migrate_late_block_activate(void) MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; } -/* -* Called on -incoming with a defer: uri. -* The migration can be started later after any parameters have been -* changed. -*/ -static void deferred_incoming_migration (Error **errp) -{ -if (deferred_incoming) { -error_setg (errp,"Incoming migration already deferred" ); - } - deferred_incoming = true; -} -/* * Send a message on the return channel back to the source * of the migration.
@@ -380,16 +365,14 @@ void migrate_add_address(SocketAddress *address) addrs->value =QAPI_CLONE (SocketAddress, address); } -void qemu_start_incoming_migration (const char *uri,Error **errp) +static void qemu_start_incoming_migration (const char *uri,Error **errp) {const char *p =NULL ;qapi_event_send_migration (MIGRATION_STATUS_SETUP ); -if (!strcmp (uri,"defer" )) { -deferred_incoming_migration (errp); - }else if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) { +if (strstart (uri,"tcp:" , &p) || +strstart (uri,"unix:" ,NULL ) || +strstart (uri,"vsock:" ,NULL )) {socket_start_incoming_migration (p ? p : uri, errp); #ifdef CONFIG_RDMA }else if (strstart (uri,"rdma:" , &p)) {
@@ -1926,14 +1909,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp)Error *local_err =NULL ;static bool once = true; -if (!deferred_incoming) { -error_setg (errp,"For use with '-incoming defer'" ); -return ; - }if (!once) {error_setg (errp,"The incoming migration has already been started" );return ; } +if (!runstate_check (RUN_STATE_INMIGRATE )) { +error_setg (errp,"'-incoming' was not specified on the command line" ); +return ; + }qemu_start_incoming_migration (uri, &local_err);
softmmu/vl.c +7 -4
@@ -109,6 +109,7 @@#include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h"
@@ -4557,10 +4558,12 @@ void qemu_init(int argc, char **argv, char **envp) }if (incoming) {Error *local_err =NULL ; -qemu_start_incoming_migration (incoming, &local_err); -if (local_err) { -error_reportf_err (local_err,"-incoming %s: " , incoming); -exit (1 ); +if (strcmp (incoming,"defer" ) !=0 ) { +qmp_migrate_incoming (incoming, &local_err); +if (local_err) { +error_reportf_err (local_err,"-incoming %s: " , incoming); +exit (1 ); + } } }else if (autostart) {vm_start ();
Signature · 1 line
2.26.2
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 67 lines · On Tue, 27 Oct 2020 14:21:39 -0400 Paolo Bonzini <[email protected]> wrote:
Make
qemu_start_incoming_migrationlocal tomigration/migration.c. By using the runstate instead of a separate flag, vl need not do anything to setup deferred incoming migration.
qmp_migrate_incomingalso does not need thedeferred_incomingflag anymore, because "-incoming PROTOCOL" will clear the "once" flag before the main loop starts. Therefore, later invocations of the migrate-incoming command will fail with the existing "The incoming migration has already been started" error message.Signed-off-by Paolo Bonzini <[email protected]>--- include/migration/misc.h | 1 - migration/migration.c | 33 ++++++++------------------------- softmmu/vl.c | 11 +++++++---- 3 files changed, 15 insertions(+), 30 deletions(-)include/migration/misc.h +0
-1@@ -58,7 +58,6 @@ void dump_vmstate_json_to_file(FILE *out_fp);/* migration/migration.c */ void migration_object_init (void );void migration_shutdown (void ); -void qemu_start_incoming_migration (const char *uri,Error **errp);bool migration_is_idle (void );bool migration_is_active (MigrationState *);void add_migration_state_change_notifier (Notifier *notify);migration/migration.c +0
-16@@ -114,8 +114,6 @@static NotifierList migration_state_notifiers =NOTIFIER_LIST_INITIALIZER (migration_state_notifiers); -static bool deferred_incoming; -/* Messages sent on the return path from destination to source */ enum mig_rp_message_type {MIG_RP_MSG_INVALID =0 ,/* Must be 0 */ @@ -257,19 +255,6 @@ static bool migrate_late_block_activate(void) MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; } -/* -* Called on -incoming with a defer: uri. -* The migration can be started later after any parameters have been -* changed. -*/ -static void deferred_incoming_migration (Error **errp) -{ -if (deferred_incoming) { -error_setg (errp,"Incoming migration already deferred" ); - } - deferred_incoming = true; -} -/* * Send a message on the return channel back to the source * of the migration. @@ -380,16 +365,14 @@ void migrate_add_address(SocketAddress *address) addrs->value =QAPI_CLONE (SocketAddress, address); } -void qemu_start_incoming_migration (const char *uri,Error **errp)
migration/migration.c void migrate_add_address(SocketAddress *address) · line 392
Quoted 10 lines
migration/migration.c +1
-5+static void qemu_start_incoming_migration (const char *uri,Error **errp) {const char *p =NULL ;qapi_event_send_migration (MIGRATION_STATUS_SETUP ); -if (!strcmp (uri,"defer" )) { -deferred_incoming_migration (errp); - }else if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) {
considering the last hunk does won't call qmp_migrate_incoming if 'defer' was used, wouldn't we will lose QAPI event here? not sure how important it to users,
Ccing David
Quoted 54 lines
migration/migration.c +7
-4+if (strstart (uri,"tcp:" , &p) || +strstart (uri,"unix:" ,NULL ) || +strstart (uri,"vsock:" ,NULL )) {socket_start_incoming_migration (p ? p : uri, errp); #ifdef CONFIG_RDMA }else if (strstart (uri,"rdma:" , &p)) {@@ -1926,14 +1909,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp)Error *local_err =NULL ;static bool once = true; -if (!deferred_incoming) { -error_setg (errp,"For use with '-incoming defer'" ); -return ; - }if (!once) {error_setg (errp,"The incoming migration has already been started" );return ; } +if (!runstate_check (RUN_STATE_INMIGRATE )) { +error_setg (errp,"'-incoming' was not specified on the command line" ); +return ; + }qemu_start_incoming_migration (uri, &local_err);softmmu/vl.c +7
-4@@ -109,6 +109,7 @@#include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" @@ -4557,10 +4558,12 @@ void qemu_init(int argc, char **argv, char **envp) }if (incoming) {Error *local_err =NULL ; -qemu_start_incoming_migration (incoming, &local_err); -if (local_err) { -error_reportf_err (local_err,"-incoming %s: " , incoming); -exit (1 ); +if (strcmp (incoming,"defer" ) !=0 ) { +qmp_migrate_incoming (incoming, &local_err); +if (local_err) { +error_reportf_err (local_err,"-incoming %s: " , incoming); +exit (1 ); + } } }else if (autostart) {vm_start ();
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 9 lines · Igor Mammedov
migration/migration.c void migrate_add_address(SocketAddress *address) · line 392
Quoted 6 lines
qapi_event_send_migration(MIGRATION_STATUS_SETUP);migration/migration.c +0
-5-if (!strcmp (uri,"defer" )) { -deferred_incoming_migration (errp); - }else if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) {considering the last hunk does won't call
qmp_migrate_incomingif 'defer' was used, wouldn't we will lose QAPI event here? not sure how important it to users,
Hmm yeah that's true. That might even be considered a bugfix (no setup is done until the "real" migrate-incoming command), but I can also add the event manually in qemu_init.
(Libvirt doesn't use the SETUP case of the event but that's of course only part of the story).
Paolo
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 11 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 9 lines · Igor Mammedov
migration/migration.c void migrate_add_address(SocketAddress *address) · line 392
Quoted 6 lines
qapi_event_send_migration(MIGRATION_STATUS_SETUP);migration/migration.c +0
-5-if (!strcmp (uri,"defer" )) { -deferred_incoming_migration (errp); - }else if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) {considering the last hunk does won't call
qmp_migrate_incomingif 'defer' was used, wouldn't we will lose QAPI event here? not sure how important it to users,
Quoted 6 lines
Hmm yeah that's true. That might even be considered a bugfix (no setup is done until the "real" migrate-incoming command), but I can also add the event manually in
qemu_init.(Libvirt doesn't use the SETUP case of the event but that's of course only part of the story).
I'm more worried about how this stops a repeated 'migrate incoming' or a 'migrate_incoming' that's issued following a qemu that's been started with -incoming tcp:... but which a socket hasn't yet connected to.
Dave
Quoted 2 lines
Paolo
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 16 lines · Dr. David Alan Gilbert
Quoted 15 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 9 lines · Igor Mammedov
migration/migration.c void migrate_add_address(SocketAddress *address) · line 392
Quoted 6 lines
qapi_event_send_migration(MIGRATION_STATUS_SETUP);migration/migration.c +0
-5-if (!strcmp (uri,"defer" )) { -deferred_incoming_migration (errp); - }else if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) {considering the last hunk does won't call
qmp_migrate_incomingif 'defer' was used, wouldn't we will lose QAPI event here? not sure how important it to users,Hmm yeah that's true. That might even be considered a bugfix (no setup is done until the "real" migrate-incoming command), but I can also add the event manually in
qemu_init.
Quoted 7 lines
Quoted 2 lines
(Libvirt doesn't use the SETUP case of the event but that's of course only part of the story).
I'm more worried about how this stops a repeated 'migrate incoming' or a '
migrate_incoming' that's issued following a qemu that's been started with -incoming tcp:... but which a socket hasn't yet connected to.
Can someone remind me why we need to have an -incoming arg at all ?
With snapshots, we can just start QEMU normally, using -S if desired, and then invoke "loadvm" to restore from a snapshot at any time.
What is different thet means we can't just run "migrate_incoming" on any QEMU at any time, ignoring -incoming entirely ?
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 7 lines · Daniel P. Berrangé
Can someone remind me why we need to have an -incoming arg at all ?
With snapshots, we can just start QEMU normally, using -S if desired, and then invoke "loadvm" to restore from a snapshot at any time.
What is different thet means we can't just run "
migrate_incoming" on any QEMU at any time, ignoring -incoming entirely ?
There are some parts of QEMU that operate differently based on RUN_STATE_INCOMING. Removing those is one of the things that these patches should enable, though there are also some uses in Xen that I'm more worried about.
Paolo
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
In reply to Dr. David Alan GilbertQuoted 4 lines · Dr. David Alan Gilbert
I'm more worried about how this stops a repeated 'migrate incoming' or a '
migrate_incoming' that's issued following a qemu that's been started with -incoming tcp:... but which a socket hasn't yet connected to.
Good question, fortunately it is simply handled answer:
void qmp_migrate_incoming(const char *uri, Error **errp)
{
Error *local_err = NULL;
static bool once = true;
if (!once) {
error_setg(errp, "The incoming migration has already been
started");
return;
}
if (!runstate_check(RUN_STATE_INMIGRATE)) {
error_setg(errp, "'-incoming' was not specified on the command
line");
return;
}
qemu_start_incoming_migration(uri, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
once = false;
}This patch can simplify things because every incoming migrations (no matter if '-incoming defer' or '-incoming tcp:...') goes through the qmp_migrate_incoming function above.
Paolo
Re: [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming
Quoted 33 lines · * Paolo Bonzini ([email protected]) wrote:
Quoted 4 lines · Dr. David Alan Gilbert
I'm more worried about how this stops a repeated 'migrate incoming' or a '
migrate_incoming' that's issued following a qemu that's been started with -incoming tcp:... but which a socket hasn't yet connected to.Good question, fortunately it is simply handled answer:
void
qmp_migrate_incoming(const char *uri, Error **errp){ Error *local_err = NULL; static bool once = true; if (!once) { error_setg(errp, "The incoming migration has already been started"); return; } if (!runstate_check(RUN_STATE_INMIGRATE)) { error_setg(errp, "'-incoming' was not specified on the command line"); return; } qemu_start_incoming_migration(uri, &local_err); if (local_err) { error_propagate(errp, local_err); return; } once = false; }
Quoted 3 lines
This patch can simplify things because every incoming migrations (no matter if '-incoming defer' or '-incoming tcp:...') goes through the
qmp_migrate_incomingfunction above.
Yeh I think that's OK.
Dave
Quoted 2 lines
Paolo
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 25/29 vl: start VM via qmp_cont
In reply to Paolo BonziniComplement the previous patch by starting the VM with a QMP command. Later, the user will be able to do the same, invoking two commands "finish-machine-init" and "cont" instead of "x-exit-preconfig".
--- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
softmmu/vl.c +2 -1
@@ -110,6 +110,7 @@#include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h"
@@ -4566,7 +4567,7 @@ void qemu_init(int argc, char **argv, char **envp) } } }else if (autostart) { -vm_start (); +qmp_cont (NULL ); }accel_setup_post (current_machine);
Signature · 1 line
2.26.2
Re: [PATCH 25/29] vl: start VM via qmp_cont
Quoted 6 lines · On Tue, 27 Oct 2020 14:21:40 -0400 Paolo Bonzini <[email protected]> wrote:
Complement the previous patch by starting the VM with a QMP command. Later, the user will be able to do the same, invoking two commands "finish-machine-init" and "cont" instead of "x-exit-preconfig".
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 25 lines
--- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)softmmu/vl.c +2
-1@@ -110,6 +110,7 @@#include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" @@ -4566,7 +4567,7 @@ void qemu_init(int argc, char **argv, char **envp) } } }else if (autostart) { -vm_start (); +qmp_cont (NULL ); }accel_setup_post (current_machine);
PATCH 26/29 hmp: introduce cmd_available
In reply to Paolo BonziniCombine the RUN_STATE_PRECONFIG and cmd_can_preconfig checks into a single function, to avoid repeating the same expression (or its negation after applying DeMorgan's rule) over and over again.
--- monitor/hmp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
monitor/hmp.c +10 -8
@@ -213,6 +213,11 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)return strchr (cmd->flags,'p' ); } +static bool cmd_available (const HMPCommand *cmd) +{ +return !runstate_check (RUN_STATE_PRECONFIG ) ||cmd_can_preconfig (cmd); +} + static void help_cmd_dump_one(Monitor *mon, const HMPCommand *cmd, char **prefix_args,
@@ -220,7 +225,7 @@ static void help_cmd_dump_one(Monitor *mon, {int i; -if (runstate_check (RUN_STATE_PRECONFIG ) && !cmd_can_preconfig (cmd)) { +if (!cmd_available (cmd)) {return ; }
@@ -248,8 +253,7 @@ static void help_cmd_dump(Monitor *mon, const HMPCommand *cmds,/* Find one entry to dump */ for (cmd = cmds; cmd->name !=NULL ; cmd++) {if (hmp_compare_cmd (args[arg_index], cmd->name) && - ((!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd)))) { +cmd_available (cmd)) {if (cmd->sub_table) {/* continue with next arg */ help_cmd_dump(mon, cmd->sub_table,
@@ -653,7 +657,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon, (int)(p - cmdp_start), cmdp_start);return NULL ; } -if (runstate_check (RUN_STATE_PRECONFIG ) && !cmd_can_preconfig (cmd)) { +if (!cmd_available (cmd)) {monitor_printf (mon,"Command '%.*s' not available with -preconfig " "until after exit_preconfig.\n" , (int )(p - cmdp_start), cmdp_start);
@@ -1225,8 +1229,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon, }readline_set_completion_index (mon->rs,strlen (cmdname));for (cmd = cmd_table; cmd->name !=NULL ; cmd++) { -if (!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd)) { +if (cmd_available (cmd)) {cmd_completion (mon, cmdname, cmd->name); } }
@@ -1234,8 +1237,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,/* find the command */ for (cmd = cmd_table; cmd->name !=NULL ; cmd++) {if (hmp_compare_cmd (args[0 ], cmd->name) && - (!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd))) { +cmd_available (cmd)) {break ; } }
Signature · 1 line
2.26.2
Re: [PATCH 26/29] hmp: introduce cmd_available
Quoted 6 lines · On Tue, 27 Oct 2020 14:21:41 -0400 Paolo Bonzini <[email protected]> wrote:
Combine the
RUN_STATE_PRECONFIGandcmd_can_preconfigchecks into a single function, to avoid repeating the same expression (or its negation after applying DeMorgan's rule) over and over again.Signed-off-by Paolo Bonzini <[email protected]>
Quoted 68 lines
--- monitor/hmp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)monitor/hmp.c +10
-8@@ -213,6 +213,11 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)return strchr (cmd->flags,'p' ); } +static bool cmd_available (const HMPCommand *cmd) +{ +return !runstate_check (RUN_STATE_PRECONFIG ) ||cmd_can_preconfig (cmd); +} + static void help_cmd_dump_one(Monitor *mon, const HMPCommand *cmd, char **prefix_args,@@ -220,7 +225,7 @@ static void help_cmd_dump_one(Monitor *mon, {int i; -if (runstate_check (RUN_STATE_PRECONFIG ) && !cmd_can_preconfig (cmd)) { +if (!cmd_available (cmd)) {return ; }@@ -248,8 +253,7 @@ static void help_cmd_dump(Monitor *mon, const HMPCommand *cmds,/* Find one entry to dump */ for (cmd = cmds; cmd->name !=NULL ; cmd++) {if (hmp_compare_cmd (args[arg_index], cmd->name) && - ((!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd)))) { +cmd_available (cmd)) {if (cmd->sub_table) {/* continue with next arg */ help_cmd_dump(mon, cmd->sub_table,@@ -653,7 +657,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon, (int)(p - cmdp_start), cmdp_start);return NULL ; } -if (runstate_check (RUN_STATE_PRECONFIG ) && !cmd_can_preconfig (cmd)) { +if (!cmd_available (cmd)) {monitor_printf (mon,"Command '%.*s' not available with -preconfig " "until after exit_preconfig.\n" , (int )(p - cmdp_start), cmdp_start);@@ -1225,8 +1229,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon, }readline_set_completion_index (mon->rs,strlen (cmdname));for (cmd = cmd_table; cmd->name !=NULL ; cmd++) { -if (!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd)) { +if (cmd_available (cmd)) {cmd_completion (mon, cmdname, cmd->name); } }@@ -1234,8 +1237,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,/* find the command */ for (cmd = cmd_table; cmd->name !=NULL ; cmd++) {if (hmp_compare_cmd (args[0 ], cmd->name) && - (!runstate_check (RUN_STATE_PRECONFIG ) || -cmd_can_preconfig (cmd))) { +cmd_available (cmd)) {break ; } }
PATCH 27/29 remove preconfig state
In reply to Paolo BonziniThe preconfig state is only used if -incoming is not specified, which makes the RunState state machine more tricky than it need be. However there is already an equivalent condition which works even with -incoming, namely qdev_hotplug. Use it instead of a separate runstate.
--- hw/core/machine-qmp-cmds.c | 5 ++--- include/qapi/qmp/dispatch.h | 1 + monitor/hmp.c | 7 ++++--- monitor/qmp-cmds.c | 5 ++--- qapi/qmp-dispatch.c | 5 +---- qapi/run-state.json | 5 +---- softmmu/qdev-monitor.c | 12 ++++++++++++ softmmu/vl.c | 13 ++----------- stubs/meson.build | 1 + stubs/qmp-command-available.c | 7 +++++++ 10 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 stubs/qmp-command-available.c
hw/core/machine-qmp-cmds.c +2 -3
@@ -286,9 +286,8 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)void qmp_set_numa_node (NumaOptions *cmd,Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before the machine has been created" );return ; }
include/qapi/qmp/dispatch.h +1 -0
@@ -48,6 +48,7 @@ void qmp_disable_command(QmpCommandList *cmds, const char *name);void qmp_enable_command (QmpCommandList *cmds,const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd); +bool qmp_command_available (const QmpCommand *cmd,Error **errp);const char *qmp_command_name (const QmpCommand *cmd);bool qmp_has_success_response (const QmpCommand *cmd);QDict *qmp_error_response (Error *err);
monitor/hmp.c +4 -3
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include <dirent.h> +#include "hw/qdev-core.h" #include "monitor-internal.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h"
@@ -215,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)static bool cmd_available (const HMPCommand *cmd) { -return !runstate_check (RUN_STATE_PRECONFIG ) ||cmd_can_preconfig (cmd); +return qdev_hotplug ||cmd_can_preconfig (cmd); } static void help_cmd_dump_one(Monitor *mon,
@@ -658,8 +659,8 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,return NULL ; }if (!cmd_available (cmd)) { -monitor_printf (mon,"Command '%.*s' not available with -preconfig " -"until after exit_preconfig.\n" , +monitor_printf (mon,"Command '%.*s' not available " +"until machine initialization has completed.\n" , (int )(p - cmdp_start), cmdp_start);return NULL ; }
monitor/qmp-cmds.c +2 -3
@@ -104,9 +104,8 @@ void qmp_system_powerdown(Error **errp)void qmp_x_exit_preconfig (Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before machine initialization" );return ; }qemu_exit_preconfig_request ();
qapi/qmp-dispatch.c +1 -4
@@ -167,10 +167,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, goto out; } -if (runstate_check (RUN_STATE_PRECONFIG ) && - !(cmd->options &QCO_ALLOW_PRECONFIG )) { -error_setg (&err,"The command '%s' isn't permitted in '%s' state" , - cmd->name,RunState_str (RUN_STATE_PRECONFIG )); +if (!qmp_command_available (cmd, &err)) { goto out; }
qapi/run-state.json +1 -4
@@ -50,15 +50,12 @@ # @colo: guest is paused to save/restore VM state under colo checkpoint, # VM can not get into this state unless colo capability is enabled # for migration. (since 2.8) -# @preconfig: QEMU is paused before board specific init callback is executed. -# The state is reachable only if the --preconfig CLI option is used. -# (Since 3.0) ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', - 'guest-panicked', 'colo', 'preconfig' ] } + 'guest-panicked', 'colo' ] } ## # @ShutdownCause:
softmmu/qdev-monitor.c +12 -0
@@ -25,6 +25,7 @@#include "sysemu/arch_init.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" +#include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/config-file.h"
@@ -997,3 +998,14 @@ int qemu_global_option(const char *str)return 0 ; } + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +if (!qdev_hotplug && + !(cmd->options &QCO_ALLOW_PRECONFIG )) { +error_setg (errp,"The command '%s' is permitted only after machine initialization has completed" , + cmd->name); +return false; + } +return true; +}
softmmu/vl.c +2 -11
@@ -574,7 +574,7 @@ static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)/***********************************************************/ /* QEMU state */ -static RunState current_run_state =RUN_STATE_PRECONFIG ; +static RunState current_run_state =RUN_STATE_PRELAUNCH ;/* We use RUN_STATE__MAX but any invalid value will do */ static RunState vmstop_requested =RUN_STATE__MAX ;
@@ -586,13 +586,7 @@ typedef struct { } RunStateTransition;static const RunStateTransition runstate_transitions_def[] = { -/* from -> to */ - {RUN_STATE_PRECONFIG ,RUN_STATE_PRELAUNCH }, -/* Early switch to inmigrate state to allow -incoming CLI option work -* as it used to. TODO: delay actual switching to inmigrate state to -* the point after machine is built and remove this hack. -*/ - {RUN_STATE_PRECONFIG ,RUN_STATE_INMIGRATE }, + {RUN_STATE_PRELAUNCH ,RUN_STATE_INMIGRATE }, {RUN_STATE_DEBUG ,RUN_STATE_RUNNING }, {RUN_STATE_DEBUG ,RUN_STATE_FINISH_MIGRATE },
@@ -1633,9 +1627,6 @@ static bool main_loop_should_exit(void)ShutdownCause request;if (preconfig_exit_requested) { -if (runstate_check (RUN_STATE_PRECONFIG )) { -runstate_set (RUN_STATE_PRELAUNCH ); - } preconfig_exit_requested = false;return true; }
stubs/meson.build +1 -0
@@ -29,6 +29,7 @@ stub_ss.add(files('pci-bus.c')) stub_ss.add(files('pci-host-piix.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) +stub_ss.add(files('qmp-command-available.c')) stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c'))
stubs/qmp-command-available.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qapi/qmp/dispatch.h" + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +return true; +}
Signature · 1 line
2.26.2
Re: [PATCH 27/29] remove preconfig state
Quoted 6 lines · On Tue, 27 Oct 2020 14:21:42 -0400 Paolo Bonzini <[email protected]> wrote:
The preconfig state is only used if -incoming is not specified, which makes the RunState state machine more tricky than it need be. However there is already an equivalent condition which works even with -incoming, namely
qdev_hotplug. Use it instead of a separate runstate.Signed-off-by Paolo Bonzini <[email protected]>
ERROR:
tests/qtest/qmp-test.c:298:test_qmp_preconfig: assertion failed (qdict_get_try_str(ret, "status") == "preconfig"): ("prelaunch" == "preconfig")
Quoted 217 lines
--- hw/core/machine-qmp-cmds.c | 5 ++--- include/qapi/qmp/dispatch.h | 1 + monitor/hmp.c | 7 ++++--- monitor/qmp-cmds.c | 5 ++--- qapi/qmp-dispatch.c | 5 +---- qapi/run-state.json | 5 +---- softmmu/qdev-monitor.c | 12 ++++++++++++ softmmu/vl.c | 13 ++----------- stubs/meson.build | 1 + stubs/qmp-command-available.c | 7 +++++++ 10 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 stubs/qmp-command-available.chw/core/machine-qmp-cmds.c +2
-3@@ -286,9 +286,8 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)void qmp_set_numa_node (NumaOptions *cmd,Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before the machine has been created" );return ; }include/qapi/qmp/dispatch.h +1
-0@@ -48,6 +48,7 @@ void qmp_disable_command(QmpCommandList *cmds, const char *name);void qmp_enable_command (QmpCommandList *cmds,const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd); +bool qmp_command_available (const QmpCommand *cmd,Error **errp);const char *qmp_command_name (const QmpCommand *cmd);bool qmp_has_success_response (const QmpCommand *cmd);QDict *qmp_error_response (Error *err);monitor/hmp.c +4
-3@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include <dirent.h> +#include "hw/qdev-core.h" #include "monitor-internal.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" @@ -215,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)static bool cmd_available (const HMPCommand *cmd) { -return !runstate_check (RUN_STATE_PRECONFIG ) ||cmd_can_preconfig (cmd); +return qdev_hotplug ||cmd_can_preconfig (cmd); } static void help_cmd_dump_one(Monitor *mon,@@ -658,8 +659,8 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,return NULL ; }if (!cmd_available (cmd)) { -monitor_printf (mon,"Command '%.*s' not available with -preconfig " -"until after exit_preconfig.\n" , +monitor_printf (mon,"Command '%.*s' not available " +"until machine initialization has completed.\n" , (int )(p - cmdp_start), cmdp_start);return NULL ; }monitor/qmp-cmds.c +2
-3@@ -104,9 +104,8 @@ void qmp_system_powerdown(Error **errp)void qmp_x_exit_preconfig (Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before machine initialization" );return ; }qemu_exit_preconfig_request ();qapi/qmp-dispatch.c +1
-4@@ -167,10 +167,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, goto out; } -if (runstate_check (RUN_STATE_PRECONFIG ) && - !(cmd->options &QCO_ALLOW_PRECONFIG )) { -error_setg (&err,"The command '%s' isn't permitted in '%s' state" , - cmd->name,RunState_str (RUN_STATE_PRECONFIG )); +if (!qmp_command_available (cmd, &err)) { goto out; }qapi/run-state.json +1
-4@@ -50,15 +50,12 @@ # @colo: guest is paused to save/restore VM state under colo checkpoint, # VM can not get into this state unless colo capability is enabled # for migration. (since 2.8) -# @preconfig: QEMU is paused before board specific init callback is executed. -# The state is reachable only if the --preconfig CLI option is used. -# (Since 3.0) ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', - 'guest-panicked', 'colo', 'preconfig' ] } + 'guest-panicked', 'colo' ] } ## # @ShutdownCause:softmmu/qdev-monitor.c +12
-0@@ -25,6 +25,7 @@#include "sysemu/arch_init.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" +#include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/config-file.h" @@ -997,3 +998,14 @@ int qemu_global_option(const char *str)return 0 ; } + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +if (!qdev_hotplug && + !(cmd->options &QCO_ALLOW_PRECONFIG )) { +error_setg (errp,"The command '%s' is permitted only after machine initialization has completed" , + cmd->name); +return false; + } +return true; +}softmmu/vl.c +2
-11@@ -574,7 +574,7 @@ static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)/***********************************************************/ /* QEMU state */ -static RunState current_run_state =RUN_STATE_PRECONFIG ; +static RunState current_run_state =RUN_STATE_PRELAUNCH ;/* We use RUN_STATE__MAX but any invalid value will do */ static RunState vmstop_requested =RUN_STATE__MAX ;@@ -586,13 +586,7 @@ typedef struct { } RunStateTransition;static const RunStateTransition runstate_transitions_def[] = { -/* from -> to */ - {RUN_STATE_PRECONFIG ,RUN_STATE_PRELAUNCH }, -/* Early switch to inmigrate state to allow -incoming CLI option work -* as it used to. TODO: delay actual switching to inmigrate state to -* the point after machine is built and remove this hack. -*/ - {RUN_STATE_PRECONFIG ,RUN_STATE_INMIGRATE }, + {RUN_STATE_PRELAUNCH ,RUN_STATE_INMIGRATE }, {RUN_STATE_DEBUG ,RUN_STATE_RUNNING }, {RUN_STATE_DEBUG ,RUN_STATE_FINISH_MIGRATE },@@ -1633,9 +1627,6 @@ static bool main_loop_should_exit(void)ShutdownCause request;if (preconfig_exit_requested) { -if (runstate_check (RUN_STATE_PRECONFIG )) { -runstate_set (RUN_STATE_PRELAUNCH ); - } preconfig_exit_requested = false;return true; }stubs/meson.build +1
-0@@ -29,6 +29,7 @@ stub_ss.add(files('pci-bus.c')) stub_ss.add(files('pci-host-piix.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) +stub_ss.add(files('qmp-command-available.c')) stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c'))stubs/qmp-command-available.c new file +7
-0@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qapi/qmp/dispatch.h" + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +return true; +}
Re: [PATCH 27/29] remove preconfig state
Quoted 8 lines · Igor Mammedov
Quoted 5 lines · On Tue, 27 Oct 2020 14:21:42 -0400 Paolo Bonzini <[email protected]> wrote:
The preconfig state is only used if -incoming is not specified, which makes the RunState state machine more tricky than it need be. However there is already an equivalent condition which works even with -incoming, namely
qdev_hotplug. Use it instead of a separate runstate.
Quoted 4 lines
Quoted 1 line
Signed-off-by Paolo Bonzini <[email protected]>ERROR:
tests/qtest/qmp-test.c:298:test_qmp_preconfig: assertion failed (qdict_get_try_str(ret, "status")== "preconfig"): ("prelaunch" == "preconfig")
Uff, of course. So this would be an incompatible change.
Do you think it's important to keep the runstate? Especially when allowing "-incoming defer" with preconfig things become complicated, because there's code that checks for RUN_STATE_INMIGRATE and it would break if the state is preconfig.
Paolo
Quoted 218 lines
Quoted 217 lines
--- hw/core/machine-qmp-cmds.c | 5 ++--- include/qapi/qmp/dispatch.h | 1 + monitor/hmp.c | 7 ++++--- monitor/qmp-cmds.c | 5 ++--- qapi/qmp-dispatch.c | 5 +---- qapi/run-state.json | 5 +---- softmmu/qdev-monitor.c | 12 ++++++++++++ softmmu/vl.c | 13 ++----------- stubs/meson.build | 1 + stubs/qmp-command-available.c | 7 +++++++ 10 files changed, 33 insertions(+), 28 deletions(-)create mode 100644
stubs/qmp-command-available.chw/core/machine-qmp-cmds.c +2
-3@@ -286,9 +286,8 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)void qmp_set_numa_node (NumaOptions *cmd,Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before the machine has been created" );return ; }include/qapi/qmp/dispatch.h +1
-0@@ -48,6 +48,7 @@ void qmp_disable_command(QmpCommandList *cmds, const char *name);void qmp_enable_command (QmpCommandList *cmds,const char *name);bool qmp_command_is_enabled (const QmpCommand *cmd); +bool qmp_command_available (const QmpCommand *cmd,Error **errp);const char *qmp_command_name (const QmpCommand *cmd);bool qmp_has_success_response (const QmpCommand *cmd);QDict *qmp_error_response (Error *err);monitor/hmp.c +4
-3@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include <dirent.h> +#include "hw/qdev-core.h" #include "monitor-internal.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" @@ -215,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd)static bool cmd_available (const HMPCommand *cmd) { -return !runstate_check (RUN_STATE_PRECONFIG ) ||cmd_can_preconfig (cmd); +return qdev_hotplug ||cmd_can_preconfig (cmd); } static void help_cmd_dump_one(Monitor *mon,@@ -658,8 +659,8 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,return NULL ; }if (!cmd_available (cmd)) { -monitor_printf (mon,"Command '%.*s' not available with -preconfig " -"until after exit_preconfig.\n" , +monitor_printf (mon,"Command '%.*s' not available " +"until machine initialization has completed.\n" , (int )(p - cmdp_start), cmdp_start);return NULL ; }monitor/qmp-cmds.c +2
-3@@ -104,9 +104,8 @@ void qmp_system_powerdown(Error **errp)void qmp_x_exit_preconfig (Error **errp) { -if (!runstate_check (RUN_STATE_PRECONFIG )) { -error_setg (errp,"The command is permitted only in '%s' state" , -RunState_str (RUN_STATE_PRECONFIG )); +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before machine initialization" );return ; }qemu_exit_preconfig_request ();qapi/qmp-dispatch.c +1
-4@@ -167,10 +167,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, goto out; } -if (runstate_check (RUN_STATE_PRECONFIG ) && - !(cmd->options &QCO_ALLOW_PRECONFIG )) { -error_setg (&err,"The command '%s' isn't permitted in '%s' state" , - cmd->name,RunState_str (RUN_STATE_PRECONFIG )); +if (!qmp_command_available (cmd, &err)) { goto out; }qapi/run-state.json +1
-4@@ -50,15 +50,12 @@ # @colo: guest is paused to save/restore VM state under colo checkpoint, # VM can not get into this state unless colo capability is enabled # for migration. (since 2.8) -# @preconfig: QEMU is paused before board specific init callback is executed. -# The state is reachable only if the --preconfig CLI option is used. -# (Since 3.0) ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', - 'guest-panicked', 'colo', 'preconfig' ] } + 'guest-panicked', 'colo' ] } ## # @ShutdownCause:softmmu/qdev-monitor.c +12
-0@@ -25,6 +25,7 @@#include "sysemu/arch_init.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" +#include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/config-file.h" @@ -997,3 +998,14 @@ int qemu_global_option(const char *str)return 0 ; } + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +if (!qdev_hotplug && + !(cmd->options &QCO_ALLOW_PRECONFIG )) { +error_setg (errp,"The command '%s' is permitted only after machine initialization has completed" , + cmd->name); +return false; + } +return true; +}softmmu/vl.c +2
-11@@ -574,7 +574,7 @@ static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)/***********************************************************/ /* QEMU state */ -static RunState current_run_state =RUN_STATE_PRECONFIG ; +static RunState current_run_state =RUN_STATE_PRELAUNCH ;/* We use RUN_STATE__MAX but any invalid value will do */ static RunState vmstop_requested =RUN_STATE__MAX ;@@ -586,13 +586,7 @@ typedef struct { } RunStateTransition;static const RunStateTransition runstate_transitions_def[] = { -/* from -> to */ - {RUN_STATE_PRECONFIG ,RUN_STATE_PRELAUNCH }, -/* Early switch to inmigrate state to allow -incoming CLI option work -* as it used to. TODO: delay actual switching to inmigrate state to -* the point after machine is built and remove this hack. -*/ - {RUN_STATE_PRECONFIG ,RUN_STATE_INMIGRATE }, + {RUN_STATE_PRELAUNCH ,RUN_STATE_INMIGRATE }, {RUN_STATE_DEBUG ,RUN_STATE_RUNNING }, {RUN_STATE_DEBUG ,RUN_STATE_FINISH_MIGRATE },@@ -1633,9 +1627,6 @@ static bool main_loop_should_exit(void)ShutdownCause request;if (preconfig_exit_requested) { -if (runstate_check (RUN_STATE_PRECONFIG )) { -runstate_set (RUN_STATE_PRELAUNCH ); - } preconfig_exit_requested = false;return true; }stubs/meson.build +1
-0@@ -29,6 +29,7 @@ stub_ss.add(files('pci-bus.c')) stub_ss.add(files('pci-host-piix.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) +stub_ss.add(files('qmp-command-available.c')) stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c'))stubs/qmp-command-available.c new file +7
-0@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qapi/qmp/dispatch.h" + +bool qmp_command_available (const QmpCommand *cmd,Error **errp) +{ +return true; +}
PATCH 28/29 vl: remove separate preconfig main_loop
In reply to Paolo BonziniMove post-preconfig initialization to the x-exit-preconfig. If preconfig is not requested, just exit preconfig mode immediately with the QMP command.
As a result, the preconfig loop will run with accel_setup_post and os_setup_post restrictions (xen_restrict, chroot, etc.) already done.
--- include/sysemu/runstate.h | 1 - monitor/qmp-cmds.c | 9 ---- softmmu/vl.c | 94 +++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 63 deletions(-)
include/sysemu/runstate.h +0 -1
@@ -41,7 +41,6 @@ typedef enum WakeupReason {QEMU_WAKEUP_REASON_OTHER , } WakeupReason; -void qemu_exit_preconfig_request (void );void qemu_system_reset_request (ShutdownCause reason);void qemu_system_suspend_request (void );void qemu_register_suspend_notifier (Notifier *notifier);
monitor/qmp-cmds.c +0 -9
@@ -102,15 +102,6 @@ void qmp_system_powerdown(Error **errp)qemu_system_powerdown_request (); } -void qmp_x_exit_preconfig (Error **errp) -{ -if (qdev_hotplug) { -error_setg (errp,"The command is permitted only before machine initialization" ); -return ; - } -qemu_exit_preconfig_request (); -} -void qmp_cont (Error **errp) {BlockBackend *blk;
softmmu/vl.c +41 -53
138 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH 28/29] vl: remove separate preconfig main_loop
Quoted 9 lines · On Tue, 27 Oct 2020 14:21:43 -0400 Paolo Bonzini <[email protected]> wrote:
Move post-preconfig initialization to the x-exit-preconfig. If preconfig is not requested, just exit preconfig mode immediately with the QMP command.
As a result, the preconfig loop will run with
accel_setup_postandos_setup_postrestrictions (xen_restrict, chroot, etc.) already done.Signed-off-by Paolo Bonzini <[email protected]>
This one also doesn't apply,
+ one more comment below
Quoted 126 lines
--- include/sysemu/runstate.h | 1 - monitor/qmp-cmds.c | 9 ---- softmmu/vl.c | 94 +++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 63 deletions(-)include/sysemu/runstate.h +0
-1@@ -41,7 +41,6 @@ typedef enum WakeupReason {QEMU_WAKEUP_REASON_OTHER , } WakeupReason; -void qemu_exit_preconfig_request (void );void qemu_system_reset_request (ShutdownCause reason);void qemu_system_suspend_request (void );void qemu_register_suspend_notifier (Notifier *notifier);monitor/qmp-cmds.c +0
-9@@ -102,15 +102,6 @@ void qmp_system_powerdown(Error **errp)qemu_system_powerdown_request (); } -void qmp_x_exit_preconfig (Error **errp) -{ -if (qdev_hotplug) { -error_setg (errp,"The command is permitted only before machine initialization" ); -return ; - } -qemu_exit_preconfig_request (); -} -void qmp_cont (Error **errp) {BlockBackend *blk;softmmu/vl.c +37
-11@@ -1313,7 +1313,6 @@ static pid_t shutdown_pid;static int powerdown_requested;static int debug_requested;static int suspend_requested; -static bool preconfig_exit_requested = true;static WakeupReason wakeup_reason;static NotifierList powerdown_notifiers =NOTIFIER_LIST_INITIALIZER (powerdown_notifiers);@@ -1400,11 +1399,6 @@ static int qemu_debug_requested(void)return r; } -void qemu_exit_preconfig_request (void ) -{ - preconfig_exit_requested = true; -} -/* * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. */ @@ -1626,10 +1620,6 @@ static bool main_loop_should_exit(void)RunState r;ShutdownCause request; -if (preconfig_exit_requested) { - preconfig_exit_requested = false; -return true; - }if (qemu_debug_requested ()) {vm_stop (RUN_STATE_DEBUG ); }@@ -3523,6 +3513,43 @@ static void qemu_machine_creation_done(void)register_global_state (); } +void qmp_x_exit_preconfig (Error **errp) +{ +if (qdev_hotplug) { +error_setg (errp,"The command is permitted only before machine initialization" ); +return ; + } + +qemu_finish_machine_init (); +qemu_create_cli_devices (); +qemu_machine_creation_done (); + +if (loadvm) { +Error *local_err =NULL ; +if (load_snapshot (loadvm, &local_err) <0 ) { +error_report_err (local_err); + autostart =0 ; +exit (1 ); + } + } +if (replay_mode !=REPLAY_MODE_NONE ) { +replay_vmstate_init (); + } + +if (incoming) { +Error *local_err =NULL ; +if (strcmp (incoming,"defer" ) !=0 ) { +qmp_migrate_incoming (incoming, &local_err); +if (local_err) { +error_reportf_err (local_err,"-incoming %s: " , incoming); +exit (1 ); + } + } + }else if (autostart) { +qmp_cont (NULL ); + } +} +void qemu_init (int argc,char **argv,char **envp) {QemuOpts *opts;@@ -4092,7 +4119,6 @@ void qemu_init(int argc, char **argv, char **envp) }break ;case QEMU_OPTION_preconfig: - preconfig_exit_requested = false; preconfig_requested = true;break ;case QEMU_OPTION_enable_kvm:
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4520
Quoted 6 lines
softmmu/vl.c +0
-3@@ -4515,56 +4541,18 @@ void qemu_init(int argc, char **argv, char **envp)qemu_resolve_machine_memdev ();parse_numa_opts (current_machine); -if (preconfig_requested) { -qemu_init_displays (); - }
^^^
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4531
Quoted 11 lines
softmmu/vl.c +0
-11- -/* do monitor/qmp handling at preconfig state if requested */ -qemu_main_loop (); -qemu_finish_machine_init (); - -qemu_create_cli_devices (); - -/* initialize displays after all errors have been reported */ -if (!preconfig_requested) { -qemu_init_displays (); - }
^^^
[...]
Quoted 1 line
1)
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4553
Quoted 4 lines
softmmu/vl.c +4
-0+if (!preconfig_requested) { +qmp_x_exit_preconfig (&error_fatal); + } +qemu_init_displays ();
given that qemu_init_displays() were called in both cases, shouldn't it be called unconditionally at [1]?
Quoted 7 lines
accel_setup_post(current_machine); os_setup_post();softmmu/vl.c +0
-2- -return ; }void qemu_cleanup (void )
Re: [PATCH 28/29] vl: remove separate preconfig main_loop
Quoted 6 lines · Igor Mammedov
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4553
Quoted 4 lines
softmmu/vl.c +4
-0+if (!preconfig_requested) { +qmp_x_exit_preconfig (&error_fatal); + } +qemu_init_displays ();given that
qemu_init_displays()were called in both cases, shouldn't it be called unconditionally at [1]?
Yes, makes sense. In fact, it would be nicer to also call
accel_setup_post(current_machine);
os_setup_post();before x_exit_preconfig, but it's left for another day.
Paolo
Re: [PATCH 28/29] vl: remove separate preconfig main_loop
In reply to Igor MammedovQuoted 7 lines · Igor Mammedov
softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4553
Quoted 4 lines
softmmu/vl.c +4
-0+if (!preconfig_requested) { +qmp_x_exit_preconfig (&error_fatal); + } +qemu_init_displays ();given that
qemu_init_displays()were called in both cases, shouldn't it be called unconditionally at [1]?
Yes, correct.
Paolo
PATCH 29/29 vl: allow -incoming defer with -preconfig
In reply to Paolo BonziniNow that there is no RUN_STATE_PRECONFIG anymore that can conflict with RUN_STATE_INMIGRATE, we can allow -incoming defer with -preconfig.
--- softmmu/vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
softmmu/vl.c +2 -3
@@ -3199,9 +3199,8 @@ static void qemu_validate_options(void) "mutually exclusive");exit (EXIT_FAILURE ); } -if (incoming && preconfig_requested) { -error_report ("'preconfig' and 'incoming' options are " -"mutually exclusive" ); +if (incoming && preconfig_requested &&strcmp (incoming,"defer" ) !=0 ) { +error_report ("'preconfig' supports '-incoming defer' only" );exit (EXIT_FAILURE ); }
Signature · 1 line
2.26.2
Re: [PATCH 29/29] vl: allow -incoming defer with -preconfig
Quoted 13 lines · On Tue, 27 Oct 2020 14:21:44 -0400 Paolo Bonzini <[email protected]> wrote:
Now that there is no
RUN_STATE_PRECONFIGanymore that can conflict withRUN_STATE_INMIGRATE, we can allow -incoming defer with -preconfig.Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)softmmu/vl.c +0
-0
softmmu/vl.c static void qemu_validate_options(void) · line 3202
Quoted 7 lines
softmmu/vl.c +1
-3@@ -3199,9 +3199,8 @@ static void qemu_validate_options(void) "mutually exclusive");exit (EXIT_FAILURE ); } -if (incoming && preconfig_requested) { -error_report ("'preconfig' and 'incoming' options are " -"mutually exclusive" ); +if (incoming && preconfig_requested &&strcmp (incoming,"defer" ) !=0 ) {
why limit it only to 'defer'?
Quoted 4 lines
softmmu/vl.c +1
-0+error_report ("'preconfig' supports '-incoming defer' only" );exit (EXIT_FAILURE ); }
Re: [PATCH 29/29] vl: allow -incoming defer with -preconfig
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 27 Oct 2020 14:21:44 -0400 Paolo Bonzini <[email protected]> wrote:
Now that there is no
RUN_STATE_PRECONFIGanymore that can conflict withRUN_STATE_INMIGRATE, we can allow -incoming defer with -preconfig.Signed-off-by Paolo Bonzini <[email protected]>--- softmmu/vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 13 lines
softmmu/vl.c static void qemu_validate_options(void) · line 3202
Quoted 12 lines
softmmu/vl.c +1
-3@@ -3199,9 +3199,8 @@ static void qemu_validate_options(void) "mutually exclusive");exit (EXIT_FAILURE ); } -if (incoming && preconfig_requested) { -error_report ("'preconfig' and 'incoming' options are " -"mutually exclusive" ); +if (incoming && preconfig_requested &&strcmp (incoming,"defer" ) !=0 ) {why limit it only to 'defer'?
After these patches, the difference between "-incoming defer" and "-incoming foo" is very small: the latter adds an automatic "migrate-incoming foo" at the tail of x-exit-preconfig, and that's it.
At the time I sent these patches, my plan was to replace x-exit-preconfig with a command "finish-machine-init" that the user would follow with one of "cont", "migrate-incoming" or "loadvm". So it would make sense to have "-incoming defer" only, because without "x-exit-preconfig" there's no command that triggers incoming migration as specified with "-incoming foo".
Then I sent only the minimal (so to speak) beginning of the series, but decided to be consrvative in what to allow on the command line. Since you are interacting with the monitor anyway to exit preconfig, you can use it to send the migrate-incoming command.
Thanks,
Paolo
Quoted 1 line · On Tue, 27 Oct 2020 14:21:15 -0400 Paolo Bonzini <[email protected]> wrote:
The main improvements with respect to v1 are:
series no longer applies to master
what commit if was based on?
Quoted 93 lines
- 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) contHere, x-create-onboard-devices creates enough of the machine to make it possible to issue
device_addmonitor 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) andqemu_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: <[email protected]>
Paolo Bonzini (29):
trace: remove argument fromtrace_init_file
semihosting: fix order of initialization functions
vl: extract validation of -smp tomachine.c
vl: remove bogus check
vl: split various early command line options to a separate function
vl: move various initialization routines out ofqemu_init
vl: extractqemu_init_subsystems
vl: move prelaunch part ofqemu_initto 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 toqemu_finish_machine_init
vl: extract default devices to separate functions
vl: moveCHECKPOINT_INITafter preconfig
vl: separateqemu_create_early_backends
vl: separateqemu_create_late_backends
vl: separateqemu_create_machine
vl: separateqemu_apply_machine_options
vl: separateqemu_resolve_machine_memdev
vl: initialize displays before preconfig loop
vl: move -global check earlier
migration, vl: start migration viaqmp_migrate_incoming
vl: start VM viaqmp_cont
hmp: introducecmd_available
remove preconfig state
vl: remove separate preconfigmain_loop
vl: allow -incoming defer with -preconfigbsd-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
Quoted 4 lines · Igor Mammedov
Quoted 1 line
The main improvements with respect to v1 are:
series no longer applies to master
what commit if was based on?
It's based on [email protected] (which you should be able to get through patchew).
Paolo
Quoted 8 lines · On Mon, 2 Nov 2020 17:34:00 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Quoted 1 line
The main improvements with respect to v1 are:
series no longer applies to master
what commit if was based on?It's based on [email protected] (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?
Quoted 3 lines
Paolo
Quoted 4 lines · Igor Mammedov
Quoted 2 lines
It's based on [email protected] (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
Quoted 8 lines · On Tue, 3 Nov 2020 15:37:13 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Quoted 2 lines
It's based on [email protected] (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)
util/qemu-option.c +1 -0
@@ -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);
Quoted 4 lines
Paolo
Quoted 20 lines · Igor Mammedov
Quoted 8 lines · On Tue, 3 Nov 2020 15:37:13 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
Quoted 2 lines
It's based on [email protected] (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)
util/qemu-option.c +0
-0
util/qemu-option.c static const char *get_opt_name_value(const char *params, · line 782
Quoted 7 lines
util/qemu-option.c +1
-0@@ -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