From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [Qemu-devel] [PULL 10/14] vnc: deal with surface NULL pointers
Date: Mon, 12 Mar 2018 10:14:01 +0100 [thread overview]
Message-ID: <20180312091405.19610-11-kraxel@redhat.com> (raw)
In-Reply-To: <20180312091405.19610-1-kraxel@redhat.com>
Secondary displays in multihead setups are allowed to have a NULL
DisplaySurface. Typically user interfaces handle this by hiding the
window which shows the display in question.
This isn't an option for vnc though because it simply hasn't a concept
of windows or outputs. So handle the situation by showing a placeholder
DisplaySurface instead. Also check in console_select whenever a surface
is preset in the first place before requesting an update.
This fixes a segfault which can be triggered by switching to an unused
display (via vtrl-alt-<nr>) in a multihead setup, for example using
-device virtio-vga,max_outputs=2.
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 20180308161803.6152-1-kraxel@redhat.com
---
include/ui/console.h | 2 ++
ui/console.c | 10 ++++++----
ui/vnc.c | 10 ++++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index aae9e44cb3..5fca9afcbc 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -260,6 +260,8 @@ DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height,
pixman_format_code_t format,
int linesize,
uint64_t addr);
+DisplaySurface *qemu_create_message_surface(int w, int h,
+ const char *msg);
PixelFormat qemu_default_pixelformat(int bpp);
DisplaySurface *qemu_create_displaysurface(int width, int height);
diff --git a/ui/console.c b/ui/console.c
index 6ab4ff3baf..348610dd43 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1039,8 +1039,10 @@ void console_select(unsigned int index)
dcl->ops->dpy_gfx_switch(dcl, s->surface);
}
}
- dpy_gfx_update(s, 0, 0, surface_width(s->surface),
- surface_height(s->surface));
+ if (s->surface) {
+ dpy_gfx_update(s, 0, 0, surface_width(s->surface),
+ surface_height(s->surface));
+ }
}
if (ds->have_text) {
dpy_text_resize(s, s->width, s->height);
@@ -1370,8 +1372,8 @@ DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height,
return surface;
}
-static DisplaySurface *qemu_create_message_surface(int w, int h,
- const char *msg)
+DisplaySurface *qemu_create_message_surface(int w, int h,
+ const char *msg)
{
DisplaySurface *surface = qemu_create_displaysurface(w, h);
pixman_color_t bg = color_table_rgb[0][QEMU_COLOR_BLACK];
diff --git a/ui/vnc.c b/ui/vnc.c
index 13c28cabb0..e164eb798c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -746,9 +746,19 @@ static void vnc_update_server_surface(VncDisplay *vd)
static void vnc_dpy_switch(DisplayChangeListener *dcl,
DisplaySurface *surface)
{
+ static const char placeholder_msg[] =
+ "Display output is not active.";
+ static DisplaySurface *placeholder;
VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
VncState *vs;
+ if (surface == NULL) {
+ if (placeholder == NULL) {
+ placeholder = qemu_create_message_surface(640, 480, placeholder_msg);
+ }
+ surface = placeholder;
+ }
+
vnc_abort_display_jobs(vd);
vd->ds = surface;
--
2.9.3
next prev parent reply other threads:[~2018-03-12 9:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 9:13 [Qemu-devel] [PULL 00/14] Ui 20180312 patches Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 01/14] build: try improve handling of clang warnings Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 02/14] make: switch language file build to be gtk module aware Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 03/14] sdl: workaround bug in sdl 2.0.8 headers Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 04/14] ui/gtk: make GtkGlArea usage a runtime option Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 05/14] ui/gtk: group gtk.mo declarations in Makefile Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 06/14] ui/opengl: Makefile cleanup Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 07/14] ui/gtk: use GtkGlArea on wayland only Gerd Hoffmann
2018-03-12 9:13 ` [Qemu-devel] [PULL 08/14] ui/gtk-egl: add scanout_dmabuf support Gerd Hoffmann
2018-03-12 9:14 ` [Qemu-devel] [PULL 09/14] ui/gtk-egl: add cursor_dmabuf support Gerd Hoffmann
2018-03-12 9:14 ` Gerd Hoffmann [this message]
2018-03-12 9:14 ` [Qemu-devel] [PULL 11/14] spice: drop dprint() debug logging Gerd Hoffmann
2018-03-12 9:14 ` [Qemu-devel] [PULL 12/14] spice: add scanout_dmabuf support Gerd Hoffmann
2018-03-12 9:14 ` [Qemu-devel] [PULL 13/14] spice: add cursor_dmabuf support Gerd Hoffmann
2018-04-27 13:12 ` Peter Maydell
2018-04-27 13:16 ` Peter Maydell
2018-07-06 11:54 ` Peter Maydell
2018-07-19 10:54 ` Peter Maydell
2018-03-12 9:14 ` [Qemu-devel] [PULL 14/14] qapi: Add device ID and head parameters to screendump Gerd Hoffmann
2018-03-12 16:14 ` [Qemu-devel] [PULL 00/14] Ui 20180312 patches 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=20180312091405.19610-11-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).