Message ID | 20231025190818.3278423-10-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Make Pixman an optional dependency | expand |
On 25/10/2023 21.08, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > If a display is backed by a specialized VC, allow to override the > default "vc:80Cx24C". For that, set the dpy.type just before creating > the default serial/parallel/monitor. > > As suggested by Paolo, if the display doesn't implement a VC (get_vc() > returns NULL), use a fallback that will use a muxed console on stdio. > > This changes the behaviour of "qemu -display none", to create a muxed > serial/monitor by default. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- Reviewed-by: Thomas Huth <thuth@redhat.com>
On Wed, Oct 25, 2023 at 11:08:03PM +0400, marcandre.lureau@redhat.com wrote: > If a display is backed by a specialized VC, allow to override the > default "vc:80Cx24C". For that, set the dpy.type just before creating > the default serial/parallel/monitor. > > As suggested by Paolo, if the display doesn't implement a VC (get_vc() > returns NULL), use a fallback that will use a muxed console on stdio. > > This changes the behaviour of "qemu -display none", to create a muxed > serial/monitor by default. Have you verified that this doesn't break libvirt? We use '-display none' for every single VM we run.
On Fri, Oct 27, 2023 at 05:53:19AM -0700, Andrea Bolognani wrote: > On Wed, Oct 25, 2023 at 11:08:03PM +0400, marcandre.lureau@redhat.com wrote: > > If a display is backed by a specialized VC, allow to override the > > default "vc:80Cx24C". For that, set the dpy.type just before creating > > the default serial/parallel/monitor. > > > > As suggested by Paolo, if the display doesn't implement a VC (get_vc() > > returns NULL), use a fallback that will use a muxed console on stdio. > > > > This changes the behaviour of "qemu -display none", to create a muxed > > serial/monitor by default. > > Have you verified that this doesn't break libvirt? We use '-display > none' for every single VM we run. IIUC we're ok as this logic appears to be skipped when -nodefaults is set. With regards, Daniel
diff --git a/include/ui/console.h b/include/ui/console.h index acb61a7f15..a4a49ffc64 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -462,12 +462,14 @@ struct QemuDisplay { DisplayType type; void (*early_init)(DisplayOptions *opts); void (*init)(DisplayState *ds, DisplayOptions *opts); + const char *vc; }; void qemu_display_register(QemuDisplay *ui); bool qemu_display_find_default(DisplayOptions *opts); void qemu_display_early_init(DisplayOptions *opts); void qemu_display_init(DisplayState *ds, DisplayOptions *opts); +const char *qemu_display_get_vc(DisplayOptions *opts); void qemu_display_help(void); /* vnc.c */ diff --git a/system/vl.c b/system/vl.c index db4d5ee79a..86dd2dce28 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1372,6 +1372,7 @@ static void qemu_setup_display(void) static void qemu_create_default_devices(void) { MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); + const char *vc = qemu_display_get_vc(&dpy); if (is_daemonized()) { /* According to documentation and historically, -nographic redirects @@ -1390,24 +1391,30 @@ static void qemu_create_default_devices(void) } } - if (nographic) { - if (default_parallel) + if (nographic || (!vc && !is_daemonized() && isatty(STDOUT_FILENO))) { + 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) + if (default_serial) { add_device_config(DEV_SERIAL, "stdio"); - if (default_monitor) + } + 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_serial) { + add_device_config(DEV_SERIAL, vc ?: "null"); + } + if (default_parallel) { + add_device_config(DEV_PARALLEL, vc ?: "null"); + } + if (default_monitor && vc) { + monitor_parse(vc, "readline", false); + } } if (default_net) { diff --git a/ui/console.c b/ui/console.c index 8ee66d10c5..a758ed62ad 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1675,6 +1675,20 @@ void qemu_display_init(DisplayState *ds, DisplayOptions *opts) dpys[opts->type]->init(ds, opts); } +const char *qemu_display_get_vc(DisplayOptions *opts) +{ + assert(opts->type < DISPLAY_TYPE__MAX); + if (opts->type == DISPLAY_TYPE_NONE) { + return NULL; + } + assert(dpys[opts->type] != NULL); + if (dpys[opts->type]->vc) { + return dpys[opts->type]->vc; + } else { + return "vc:80Cx24C"; + } +} + void qemu_display_help(void) { int idx;