From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 064/113] vl: extract default devices to separate functions
Date: Wed, 2 Dec 2020 03:08:00 -0500 [thread overview]
Message-ID: <20201202080849.4125477-65-pbonzini@redhat.com> (raw)
In-Reply-To: <20201202080849.4125477-1-pbonzini@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
softmmu/vl.c | 216 +++++++++++++++++++++++++++------------------------
1 file changed, 114 insertions(+), 102 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index cb4b870f09..1a80a9a68d 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -125,7 +125,9 @@ static const char *boot_order;
static const char *boot_once;
static const char *incoming;
static const char *loadvm;
+static int display_remote;
static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
+static bool nographic = false;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
static int mem_prealloc; /* force preallocation of physical target memory */
int display_opengl;
@@ -147,6 +149,7 @@ static int rtc_host_datetime_offset = -1; /* valid & used only with
RTC_BASE_DATETIME */
QEMUClockType rtc_clock;
int vga_interface_type = VGA_NONE;
+static const char *vga_model = NULL;
static DisplayOptions dpy;
static int num_serial_hds;
static Chardev **serial_hds;
@@ -2224,6 +2227,115 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
return 0;
}
+static void qemu_disable_default_devices(void)
+{
+ MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
+ qemu_opts_foreach(qemu_find_opts("device"),
+ default_driver_check, NULL, NULL);
+ qemu_opts_foreach(qemu_find_opts("global"),
+ default_driver_check, NULL, NULL);
+
+ if (!vga_model && !default_vga) {
+ vga_interface_type = VGA_DEVICE;
+ }
+ if (!has_defaults || machine_class->no_serial) {
+ default_serial = 0;
+ }
+ if (!has_defaults || machine_class->no_parallel) {
+ default_parallel = 0;
+ }
+ if (!has_defaults || machine_class->no_floppy) {
+ default_floppy = 0;
+ }
+ if (!has_defaults || machine_class->no_cdrom) {
+ default_cdrom = 0;
+ }
+ if (!has_defaults || machine_class->no_sdcard) {
+ default_sdcard = 0;
+ }
+ if (!has_defaults) {
+ default_monitor = 0;
+ default_net = 0;
+ default_vga = 0;
+ }
+}
+
+static void qemu_create_default_devices(void)
+{
+ MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
+ if (is_daemonized()) {
+ /* According to documentation and historically, -nographic redirects
+ * serial port, parallel port and monitor to stdio, which does not work
+ * with -daemonize. We can redirect these to null instead, but since
+ * -nographic is legacy, let's just error out.
+ * We disallow -nographic only if all other ports are not redirected
+ * explicitly, to not break existing legacy setups which uses
+ * -nographic _and_ redirects all ports explicitly - this is valid
+ * usage, -nographic is just a no-op in this case.
+ */
+ if (nographic
+ && (default_parallel || default_serial || default_monitor)) {
+ error_report("-nographic cannot be used with -daemonize");
+ exit(1);
+ }
+ }
+
+ if (nographic) {
+ if (default_parallel)
+ add_device_config(DEV_PARALLEL, "null");
+ if (default_serial && default_monitor) {
+ add_device_config(DEV_SERIAL, "mon:stdio");
+ } else {
+ if (default_serial)
+ add_device_config(DEV_SERIAL, "stdio");
+ if (default_monitor)
+ monitor_parse("stdio", "readline", false);
+ }
+ } else {
+ if (default_serial)
+ add_device_config(DEV_SERIAL, "vc:80Cx24C");
+ if (default_parallel)
+ add_device_config(DEV_PARALLEL, "vc:80Cx24C");
+ if (default_monitor)
+ monitor_parse("vc:80Cx24C", "readline", false);
+ }
+
+ if (default_net) {
+ QemuOptsList *net = qemu_find_opts("net");
+ qemu_opts_parse(net, "nic", true, &error_abort);
+#ifdef CONFIG_SLIRP
+ qemu_opts_parse(net, "user", true, &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;
@@ -3208,10 +3320,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;
@@ -4187,97 +4296,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_parse(net, "nic", true, &error_abort);
-#ifdef CONFIG_SLIRP
- qemu_opts_parse(net, "user", true, &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");
@@ -4423,14 +4443,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. */
--
2.26.2
next prev parent reply other threads:[~2020-12-02 9:02 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 8:06 [PULL 000/113] First batch of misc (i386, kernel-doc, memory, vl.c) changes for QEMU 6.0 Paolo Bonzini
2020-12-02 8:06 ` [PULL 001/113] target/i386: fix operand order for PDEP and PEXT Paolo Bonzini
2020-12-02 8:06 ` [PULL 002/113] target/i386: Support up to 32768 CPUs without IRQ remapping Paolo Bonzini
2020-12-02 8:06 ` [PULL 003/113] target/i386: seg_helper: Correct segement selector nullification in the RET/IRET helper Paolo Bonzini
2020-12-02 8:07 ` [PULL 004/113] WHPX: support for the kernel-irqchip on/off Paolo Bonzini
2020-12-02 8:07 ` [PULL 005/113] docs/devel/loads-stores: Add regexp for DMA functions Paolo Bonzini
2020-12-02 8:07 ` [PULL 006/113] qom: eliminate identical functions Paolo Bonzini
2020-12-02 8:07 ` [PULL 007/113] dma: Document address_space_map/address_space_unmap() prototypes Paolo Bonzini
2020-12-02 8:07 ` [PULL 008/113] dma: Let dma_memory_set() propagate MemTxResult Paolo Bonzini
2020-12-02 8:07 ` [PULL 009/113] dma: Let dma_memory_rw() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 010/113] dma: Let dma_memory_read() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 011/113] dma: Let dma_memory_write() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 012/113] pci: Let pci_dma_rw() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 013/113] pci: Let pci_dma_read() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 014/113] pci: Let pci_dma_write() " Paolo Bonzini
2020-12-02 8:07 ` [PULL 015/113] hw/ssi/aspeed_smc: Rename 'max_slaves' variable as 'max_peripherals' Paolo Bonzini
2020-12-02 8:07 ` [PULL 016/113] hw/ssi: Update coding style to make checkpatch.pl happy Paolo Bonzini
2020-12-02 8:07 ` [PULL 017/113] hw/ssi: Rename SSI 'slave' as 'peripheral' Paolo Bonzini
2020-12-02 8:07 ` [PULL 018/113] hw/core/stream: Rename StreamSlave as StreamSink Paolo Bonzini
2020-12-02 8:07 ` [PULL 019/113] hw/dma/xilinx_axidma: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 020/113] hw/net/xilinx_axienet: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 021/113] alpha: remove bios_name Paolo Bonzini
2020-12-02 8:07 ` [PULL 022/113] arm: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 023/113] hppa: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 024/113] i386: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 025/113] lm32: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 026/113] m68k: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 027/113] mips: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 028/113] moxie: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 029/113] ppc: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 030/113] rx: move BIOS load from MCU to board Paolo Bonzini
2020-12-02 8:07 ` [PULL 031/113] s390: remove bios_name Paolo Bonzini
2020-12-02 8:07 ` [PULL 032/113] sh4: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 033/113] sparc: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 034/113] digic: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 035/113] vl: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 036/113] arm: do not use ram_size global Paolo Bonzini
2020-12-02 8:07 ` [PULL 037/113] cris: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 038/113] hppa: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 039/113] i386: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 040/113] m68k: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 041/113] microblaze: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 042/113] mips: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 043/113] moxie: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 044/113] nios2: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 045/113] ppc: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 046/113] riscv: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 047/113] s390x: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 048/113] sparc64: " Paolo Bonzini
2020-12-02 8:07 ` [PULL 049/113] make ram_size local to vl.c Paolo Bonzini
2020-12-02 8:07 ` [PULL 050/113] hw/char/serial: Clean up unnecessary code Paolo Bonzini
2020-12-02 8:07 ` [PULL 051/113] treewide: do not use short-form boolean options Paolo Bonzini
2020-12-02 8:07 ` [PULL 052/113] vl: extract validation of -smp to machine.c Paolo Bonzini
2020-12-02 8:07 ` [PULL 053/113] vl: remove bogus check Paolo Bonzini
2020-12-02 8:07 ` [PULL 054/113] vl: split various early command line options to a separate function Paolo Bonzini
2020-12-02 8:07 ` [PULL 055/113] vl: move various initialization routines out of qemu_init Paolo Bonzini
2020-12-02 8:07 ` [PULL 056/113] vl: extract qemu_init_subsystems Paolo Bonzini
2020-12-02 8:07 ` [PULL 057/113] vl: move prelaunch part of qemu_init to new functions Paolo Bonzini
2020-12-02 8:07 ` [PULL 058/113] vl: extract various command line validation snippets to a new function Paolo Bonzini
2020-12-02 8:07 ` [PULL 059/113] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
2020-12-02 8:07 ` [PULL 060/113] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
2020-12-02 8:07 ` [PULL 061/113] qemu-option: restrict qemu_opts_set to merge-lists QemuOpts Paolo Bonzini
2020-12-02 8:07 ` [PULL 062/113] vl: create "-net nic -net user" default earlier Paolo Bonzini
2020-12-02 8:07 ` [PULL 063/113] vl: load plugins as late as possible Paolo Bonzini
2020-12-02 8:08 ` Paolo Bonzini [this message]
2020-12-02 8:08 ` [PULL 065/113] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
2020-12-02 8:08 ` [PULL 066/113] vl: separate qemu_create_early_backends Paolo Bonzini
2020-12-02 8:08 ` [PULL 067/113] vl: separate qemu_create_late_backends Paolo Bonzini
2020-12-02 8:08 ` [PULL 068/113] vl: separate qemu_create_machine Paolo Bonzini
2020-12-02 8:08 ` [PULL 069/113] vl: separate qemu_apply_machine_options Paolo Bonzini
2020-12-02 8:08 ` [PULL 070/113] vl: separate qemu_resolve_machine_memdev Paolo Bonzini
2020-12-02 8:08 ` [PULL 071/113] vl: initialize displays before preconfig loop Paolo Bonzini
2020-12-02 8:08 ` [PULL 072/113] vl: move -global check earlier Paolo Bonzini
2020-12-02 8:08 ` [PULL 073/113] migration, vl: start migration via qmp_migrate_incoming Paolo Bonzini
2020-12-02 8:08 ` [PULL 074/113] vl: start VM via qmp_cont Paolo Bonzini
2020-12-02 8:08 ` [PULL 075/113] hmp: introduce cmd_available Paolo Bonzini
2020-12-02 8:08 ` [PULL 076/113] vl: extract softmmu/datadir.c Paolo Bonzini
2020-12-02 8:08 ` [PULL 077/113] vl: extract machine done notifiers Paolo Bonzini
2020-12-02 8:08 ` [PULL 078/113] vl: extract softmmu/rtc.c Paolo Bonzini
2020-12-02 8:08 ` [PULL 079/113] vl: remove serial_max_hds Paolo Bonzini
2020-12-02 8:08 ` [PULL 080/113] vl: clean up -boot variables Paolo Bonzini
2020-12-02 8:08 ` [PULL 081/113] config-file: move -set implementation to vl.c Paolo Bonzini
2020-12-02 8:08 ` [PULL 082/113] docs: temporarily disable the kernel-doc extension Paolo Bonzini
2020-12-02 8:08 ` [PULL 083/113] kernel-doc: fix processing nested structs with attributes Paolo Bonzini
2020-12-02 8:08 ` [PULL 084/113] kernel-doc: add support for ____cacheline_aligned_in_smp attribute Paolo Bonzini
2020-12-02 8:08 ` [PULL 085/113] scripts/kernel-doc: Add support for named variable macro arguments Paolo Bonzini
2020-12-02 8:08 ` [PULL 086/113] scripts: kernel-doc: proper handle @foo->bar() Paolo Bonzini
2020-12-02 8:08 ` [PULL 087/113] scripts: kernel-doc: accept negation like !@var Paolo Bonzini
2020-12-02 8:08 ` [PULL 088/113] scripts: kernel-doc: accept blank lines on parameter description Paolo Bonzini
2020-12-02 8:08 ` [PULL 089/113] Replace HTTP links with HTTPS ones: documentation Paolo Bonzini
2020-12-02 8:08 ` [PULL 090/113] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK Paolo Bonzini
2020-12-02 8:08 ` [PULL 091/113] scripts/kernel-doc: handle function pointer prototypes Paolo Bonzini
2020-12-02 8:08 ` [PULL 092/113] scripts/kernel-doc: optionally treat warnings as errors Paolo Bonzini
2020-12-02 8:08 ` [PULL 093/113] kernel-doc: include line numbers for function prototypes Paolo Bonzini
2020-12-02 8:08 ` [PULL 094/113] kernel-doc: add support for ____cacheline_aligned attribute Paolo Bonzini
2020-12-02 8:08 ` [PULL 095/113] scripts: kernel-doc: add support for typedef enum Paolo Bonzini
2020-12-02 8:08 ` [PULL 096/113] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments" Paolo Bonzini
2020-12-02 8:08 ` [PULL 097/113] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later" Paolo Bonzini
2020-12-02 8:08 ` [PULL 098/113] scripts: kernel-doc: make it more compatible with Sphinx 3.x Paolo Bonzini
2020-12-02 8:08 ` [PULL 099/113] scripts: kernel-doc: use a less pedantic markup for funcs on " Paolo Bonzini
2020-12-02 8:08 ` [PULL 100/113] scripts: kernel-doc: fix troubles with line counts Paolo Bonzini
2020-12-02 8:08 ` [PULL 101/113] scripts: kernel-doc: reimplement -nofunction argument Paolo Bonzini
2020-12-02 8:08 ` [PULL 102/113] scripts: kernel-doc: fix typedef identification Paolo Bonzini
2020-12-02 8:08 ` [PULL 103/113] scripts: kernel-doc: don't mangle with parameter list Paolo Bonzini
2020-12-02 8:08 ` [PULL 104/113] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Paolo Bonzini
2020-12-02 8:08 ` [PULL 105/113] scripts: kernel-doc: fix line number handling Paolo Bonzini
2020-12-02 8:08 ` [PULL 106/113] scripts: kernel-doc: try to use c:function if possible Paolo Bonzini
2020-12-02 8:08 ` [PULL 107/113] Revert "kernel-doc: Handle function typedefs without asterisks" Paolo Bonzini
2020-12-02 8:08 ` [PULL 108/113] Revert "kernel-doc: Handle function typedefs that return pointers" Paolo Bonzini
2020-12-02 8:08 ` [PULL 109/113] scripts: kernel-doc: fix typedef parsing Paolo Bonzini
2020-12-02 8:08 ` [PULL 110/113] scripts: kernel-doc: split typedef complex regex Paolo Bonzini
2020-12-02 8:08 ` [PULL 111/113] scripts: kernel-doc: use :c:union when needed Paolo Bonzini
2020-12-02 8:08 ` [PULL 112/113] Revert "docs: temporarily disable the kernel-doc extension" Paolo Bonzini
2020-12-02 8:08 ` [PULL 113/113] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
2020-12-02 11:52 ` [PULL 000/113] First batch of misc (i386, kernel-doc, memory, vl.c) changes for QEMU 6.0 no-reply
2020-12-09 14:16 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201202080849.4125477-65-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).