[RFC PATCH 1/1] hw/display/xenfb: always register vfb and allocate console early

Dario Faggioli <[email protected]>
Newsgroups org.xenproject.lists.xen-devel,org.nongnu.qemu-devel
Message-ID <[email protected]>
This commit addresses a black console issues for Xen PV and PVH guests.

In fact, commit 6ece1df966 ("hw/xen: Register framebuffer backend via
xen_backend_init()") introduced a check before registering the vfb
backend. Problem is that the '-vga' agrument may not be present (e.g.,
for PV/PVH guests started with 'xl') and this causes the backend to be
silently ignored.

This commit restores the unconditional registration of the vfb backend.

Furthermore, even with the backend always being registered, the fact
that xenfb allocates the QemuConsole asynchronously in fb_initialise()
looks problematic. In fact, when the UI initializes, it finds 0 active
consoles and it permanently allocates a dummy surface showing the
message "This VM has no graphic display device". And since the removal
of console_select() there's no way to dynamically switch to the xenfb
console, when it is finally up and running.

This commit works around the issue by moving console creation to
fb_init(), so that VNC attaches to it immediately. The surface is then
updated normally via qemu_console_set_surface() once the guest framebuffer
is mapped.

Fixes: 6ece1df966 ("hw/xen: Register framebuffer backend via xen_backend_init()")
Signed-off-by: Dario Faggioli <[email protected]>
---
 hw/display/xenfb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index ae302b217f..3a0cdc0578 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -851,9 +851,14 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
 static int fb_init(struct XenLegacyDevice *xendev)
 {
+    struct XenFB *fb = container_of(xendev, struct XenFB, c.xendev);
+
 #ifdef XENFB_TYPE_RESIZE
     xenstore_write_be_int(xendev, "feature-resize", 1);
 #endif
+
+    fb->con = qemu_graphic_console_create(NULL, 0, &xenfb_ops, fb);
+
     return 0;
 }
 
@@ -882,8 +887,6 @@ static int fb_initialise(struct XenLegacyDevice *xendev)
     if (rc != 0)
         return rc;
 
-    fb->con = qemu_graphic_console_create(NULL, 0, &xenfb_ops, fb);
-
     if (xenstore_read_fe_int(xendev, "feature-update", &fb->feature_update) == -1)
         fb->feature_update = 0;
     if (fb->feature_update)
@@ -973,9 +976,6 @@ static const GraphicHwOps xenfb_ops = {
 static void xen_ui_register_backend(void)
 {
     xen_be_register("vkbd", &xen_kbdmouse_ops);
-
-    if (vga_interface_type == VGA_XENFB) {
-        xen_be_register("vfb", &xen_framebuffer_ops);
-    }
+    xen_be_register("vfb", &xen_framebuffer_ops);
 }
 xen_backend_init(xen_ui_register_backend);
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.