Skip to contentSkip to conversation

ui: Add a Wayland backend for Qemu UI (v2)

RFC In review Vivek Kasireddy 3 participants 8 messages Sep 13, 2021 – Sep 14, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover ui: Add a Wayland backend for Qemu UI (v2)

Why does Qemu need a new Wayland UI backend?
The main reason why there needs to be a plain and simple Wayland backend for Qemu UI is to eliminate the Blit (aka GPU copy) that happens if using a toolkit like GTK or SDL (because they use EGL). The Blit can be eliminated by sharing the dmabuf fd -- associated with the Guest scanout buffer -- directly with the Host compositor via the linux-dmabuf (unstable) protocol. Once properly integrated, it would be potentially possible to have the scanout buffer created by the Guest compositor be placed directly on a hardware plane on the Host thereby improving performance. Only Guest compositors that use multiple back buffers (at-least 1 front and 1 back) and virtio-gpu would benefit from this work.

v2:
- Add support for handling/forwarding keyboard and mouse events.
- Augment handling of events to ensure that they are not lost in a multi-threaded environment.
- Rebase

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Dongwon Kim <[email protected]>
Cc Tina Zhang <[email protected]>
Cc Satyeshwar Singh <[email protected]>

Vivek Kasireddy (2):
virtio-gpu: Add support for VIRTIO_GPU_F_RELEASE_FENCE
ui: Add a plain Wayland backend for Qemu UI

 configure                                   |   8 +-
 hw/display/virtio-gpu-base.c                |   3 +
 hw/display/virtio-gpu-udmabuf.c             |   4 +-
 hw/display/virtio-gpu.c                     |  54 +-
 include/hw/virtio/virtio-gpu.h              |   6 +
 include/standard-headers/linux/virtio_gpu.h |   2 +
 meson.build                                 |  33 +
 meson_options.txt                           |   2 +
 qapi/ui.json                                |   3 +
 ui/meson.build                              |  52 ++
 ui/wayland.c                                | 628 ++++++++++++++++++++
 11 files changed, 791 insertions(+), 4 deletions(-)
 create mode 100644 ui/wayland.c
Signature · 1 line
2.30.2
#1 lore raw

RFC v2 1/2 virtio-gpu: Add support for VIRTIO_GPU_F_RELEASE_FENCE

To support this feature, we add a new queue named rel_fenceq to enqueue finished set_scanout_blob cmds.

---
 hw/display/virtio-gpu-base.c                |  3 ++
 hw/display/virtio-gpu-udmabuf.c             |  4 +-
 hw/display/virtio-gpu.c                     | 54 ++++++++++++++++++++-
 include/hw/virtio/virtio-gpu.h              |  6 +++
 include/standard-headers/linux/virtio_gpu.h |  2 +
 5 files changed, 66 insertions(+), 3 deletions(-)
hw/display/virtio-gpu-base.c +3 -0
index c8da4806e0..0218a6d3d2 100644
@@ -211,6 +211,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features,
     if (virtio_gpu_blob_enabled(g->conf)) {
         features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB);
     }
+    if (virtio_gpu_relfence_enabled(g->conf)) {
+        features |= (1 << VIRTIO_GPU_F_RELEASE_FENCE);
+    }
 
     return features;
 }
hw/display/virtio-gpu-udmabuf.c +2 -2
index c6f7f58784..adb3fd4e0c 100644
@@ -157,7 +157,7 @@ void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res)
     }
 }
 
-static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDMABuf *dmabuf)
+void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDMABuf *dmabuf)
 {
     struct virtio_gpu_scanout *scanout;
 
@@ -216,7 +216,7 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g,
                         new_primary->buf.height);
     dpy_gl_scanout_dmabuf(scanout->con, &new_primary->buf);
 
-    if (old_primary) {
+    if (old_primary && !virtio_gpu_relfence_enabled(g->parent_obj.conf)) {
         virtio_gpu_free_dmabuf(g, old_primary);
     }
 
hw/display/virtio-gpu.c +53 -1

95 lines not on this page · raw message

include/hw/virtio/virtio-gpu.h +6 -0
index 24c6628944..60dd2b8985 100644
@@ -90,6 +90,7 @@ enum virtio_gpu_base_conf_flags {
     VIRTIO_GPU_FLAG_EDID_ENABLED,
     VIRTIO_GPU_FLAG_DMABUF_ENABLED,
     VIRTIO_GPU_FLAG_BLOB_ENABLED,
+    VIRTIO_GPU_FLAG_RELFENCE_ENABLED,
 };
 
 #define virtio_gpu_virgl_enabled(_cfg) \
@@ -102,6 +103,8 @@ enum virtio_gpu_base_conf_flags {
     (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED))
 #define virtio_gpu_blob_enabled(_cfg) \
     (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED))
+#define virtio_gpu_relfence_enabled(_cfg) \
+    (_cfg.flags & (1 << VIRTIO_GPU_FLAG_RELFENCE_ENABLED))
 
 struct virtio_gpu_base_conf {
     uint32_t max_outputs;
@@ -170,6 +173,7 @@ struct VirtIOGPU {
     QTAILQ_HEAD(, virtio_gpu_simple_resource) reslist;
     QTAILQ_HEAD(, virtio_gpu_ctrl_command) cmdq;
     QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq;
+    QTAILQ_HEAD(, virtio_gpu_ctrl_command) rel_fenceq;
 
     uint64_t hostmem;
 
@@ -274,6 +278,8 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g,
                              uint32_t scanout_id,
                              struct virtio_gpu_simple_resource *res,
                              struct virtio_gpu_framebuffer *fb);
+void virtio_gpu_free_dmabuf(VirtIOGPU *g,
+                            VGPUDMABuf *dmabuf);
 
 /* virtio-gpu-3d.c */
 void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
include/standard-headers/linux/virtio_gpu.h +2 -0
index 1357e4774e..4331f999c4 100644
@@ -60,6 +60,8 @@
  */
 #define VIRTIO_GPU_F_RESOURCE_BLOB       3
 
+#define VIRTIO_GPU_F_RELEASE_FENCE       4
+
 enum virtio_gpu_ctrl_type {
 	VIRTIO_GPU_UNDEFINED = 0,
 
Signature · 1 line
2.30.2
#2 lore raw

RFC v2 2/2 ui: Add a plain Wayland backend for Qemu UI

In reply to Vivek Kasireddy
---
 configure         |   8 +-
 meson.build       |  33 +++
 meson_options.txt |   2 +
 qapi/ui.json      |   3 +
 ui/meson.build    |  52 ++++
 ui/wayland.c      | 628 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 ui/wayland.c
configure +7 -1
index da2501489f..02339681dc 100755
@@ -406,6 +406,7 @@ cfi_debug="false"
 seccomp="auto"
 glusterfs="auto"
 gtk="auto"
+wayland="auto"
 tls_priority="NORMAL"
 gnutls="auto"
 nettle="auto"
@@ -1383,6 +1384,10 @@ for opt do
   ;;
   --enable-gtk) gtk="enabled"
   ;;
+  --disable-wayland) wayland="disabled"
+  ;;
+  --enable-wayland) wayland="enabled"
+  ;;
   --tls-priority=*) tls_priority="$optarg"
   ;;
   --disable-gnutls) gnutls="disabled"
@@ -1868,6 +1873,7 @@ disabled with --disable-FEATURE, default is enabled if available
   sdl             SDL UI
   sdl-image       SDL Image support for icons
   gtk             gtk UI
+  wayland         Wayland UI
   vte             vte support for the gtk UI
   curses          curses UI
   iconv           font glyph conversion support
@@ -5191,7 +5197,7 @@ if test "$skip_meson" = no; then
         -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
         -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
         -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
-        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
+        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dwayland=$wayland -Dsdl_image=$sdl_image \
         -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
         -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
meson.build +33 -0
index 7d7d14a4bc..cda10b7d0f 100644
@@ -927,6 +927,37 @@ if gtkx11.found()
   x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
                    kwargs: static_kwargs)
 endif
+
+wayland = not_found
+if not get_option('wayland').auto()
+  wlclientdep = dependency('wayland-client', version: '>= 1.18.90',
+                           method: 'pkg-config',
+                           required: get_option('wayland'),
+                           kwargs: static_kwargs)
+  wlprotocolsdep = dependency('wayland-protocols', version: '>= 1.14.91',
+                              method: 'pkg-config',
+                              required: get_option('wayland'),
+                              kwargs: static_kwargs)
+
+  if not wlprotocolsdep.found()
+    wlproto_dir = subproject('wayland-protocols').get_variable('wayland_protocols_srcdir')
+  else
+    wlproto_dir = wlprotocolsdep.get_pkgconfig_variable('pkgdatadir')
+  endif
+
+  wayland = declare_dependency(dependencies: [wlclientdep, wlprotocolsdep])
+endif
+
+if wayland.found() and get_option('sdl').enabled()
+  error('Wayland and SDL cannot be enabled at the same time')
+endif
+if wayland.found() and get_option('gtk').enabled()
+  error('Wayland and GTK+ cannot be enabled at the same time')
+endif
+if wayland.found() and get_option('cocoa').enabled()
+  error('Wayland and Cocoa cannot be enabled at the same time')
+endif
+
 vnc = not_found
 png = not_found
 jpeg = not_found
@@ -1256,6 +1287,7 @@ if glusterfs.found()
   config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
 endif
 config_host_data.set('CONFIG_GTK', gtk.found())
+config_host_data.set('CONFIG_WAYLAND', wayland.found())
 config_host_data.set('CONFIG_VTE', vte.found())
 config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
 config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
@@ -3052,6 +3084,7 @@ summary_info += {'SDL support':       sdl.found()}
 summary_info += {'SDL image support': sdl_image.found()}
 # TODO: add back version
 summary_info += {'GTK support':       gtk.found()}
+summary_info += {'Wayland support':   wayland.found()}
 summary_info += {'pixman':            pixman.found()}
 # TODO: add back version
 summary_info += {'VTE support':       vte.found()}
meson_options.txt +2 -0
index a9a9b8f4c6..6c0e27e83b 100644
@@ -104,6 +104,8 @@ option('rbd', type : 'feature', value : 'auto',
        description: 'Ceph block device driver')
 option('gtk', type : 'feature', value : 'auto',
        description: 'GTK+ user interface')
+option('wayland', type : 'feature', value : 'auto',
+       description: 'Wayland user interface')
 option('sdl', type : 'feature', value : 'auto',
        description: 'SDL user interface')
 option('sdl_image', type : 'feature', value : 'auto',
qapi/ui.json +3 -0
index b2cf7a6759..8da0baa0bd 100644
@@ -1112,6 +1112,8 @@
 #                DRI device. Graphical display need to be paired with
 #                VNC or Spice. (Since 3.1)
 #
+# @wayland: The Wayland user interface.
+#
 # @curses: Display video output via curses.  For graphics device
 #          models which support a text mode, QEMU can display this
 #          output using a curses/ncurses interface. Nothing is
@@ -1135,6 +1137,7 @@
     { 'name': 'none' },
     { 'name': 'gtk', 'if': 'CONFIG_GTK' },
     { 'name': 'sdl', 'if': 'CONFIG_SDL' },
+    { 'name': 'wayland', 'if': 'CONFIG_WAYLAND' },
     { 'name': 'egl-headless',
               'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
     { 'name': 'curses', 'if': 'CONFIG_CURSES' },
ui/meson.build +52 -0

58 lines not on this page · raw message

ui/wayland.c new file +628 -0

628 lines not on this page · raw message

Signature · 1 line
2.30.2
#3 lore raw

Re: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

Quoted 11 lines · Vivek Kasireddy
---
 configure         |   8 +-
 meson.build       |  33 +++
 meson_options.txt |   2 +
 qapi/ui.json      |   3 +
 ui/meson.build    |  52 ++++
 ui/wayland.c      | 628 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 ui/wayland.c

UI review:

qapi/ui.json line 1115

Quoted 6 lines

+++ b/qapi/ui.json

qapi/ui.json +1 -0
@@ -1112,6 +1112,8 @@
 #                DRI device. Graphical display need to be paired with
 #                VNC or Spice. (Since 3.1)
 #
+# @wayland: The Wayland user interface.

Missing a '(since 6.2)' tag.

Quoted 12 lines
qapi/ui.json +2 -0
+#
 # @curses: Display video output via curses.  For graphics device
 #          models which support a text mode, QEMU can display this
 #          output using a curses/ncurses interface. Nothing is
@@ -1135,6 +1137,7 @@
     { 'name': 'none' },
     { 'name': 'gtk', 'if': 'CONFIG_GTK' },
     { 'name': 'sdl', 'if': 'CONFIG_SDL' },
+    { 'name': 'wayland', 'if': 'CONFIG_WAYLAND' },
     { 'name': 'egl-headless',
               'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
     { 'name': 'curses', 'if': 'CONFIG_CURSES' },
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw

Re: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

In reply to Vivek Kasireddy
Quoted 62 lines · Vivek Kasireddy
---
 configure         |   8 +-
 meson.build       |  33 +++
 meson_options.txt |   2 +
 qapi/ui.json      |   3 +
 ui/meson.build    |  52 ++++
 ui/wayland.c      | 628 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 ui/wayland.c
ui/meson.build +41 -0
index a73beb0e54..86fc324c82 100644
@@ -64,6 +64,58 @@ if config_host.has_key('CONFIG_OPENGL') and gbm.found()
   ui_modules += {'egl-headless' : egl_headless_ss}
 endif
 
+wayland_scanner = find_program('wayland-scanner')
+proto_sources = [
+  ['xdg-shell', 'stable', ],
+  ['fullscreen-shell', 'unstable', 'v1', ],
+  ['linux-dmabuf', 'unstable', 'v1', ],
+]
+wayland_headers = []
+wayland_proto_sources = []
+
+if wayland.found()
+  foreach p: proto_sources
+    proto_name = p.get(0)
+    proto_stability = p.get(1)
+
+    if proto_stability == 'stable'
+      output_base = proto_name
+      input = files(join_paths(wlproto_dir, '@0@/@1@/@[email protected]'.format(proto_stability, proto_name, output_base)))
+    else
+      proto_version = p.get(2)
+      output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
+      input = files(join_paths(wlproto_dir, '@0@/@1@/@[email protected]'.format(proto_stability, proto_name, output_base)))
+    endif
+
+    wayland_headers += custom_target('@0@ client header'.format(output_base),
+      input: input,
+      output: '@[email protected]'.format(output_base),
+      command: [
+        wayland_scanner,
+        'client-header',
+        '@INPUT@', '@OUTPUT@',
+      ], build_by_default: true
+    )
+
+    wayland_proto_sources += custom_target('@0@ source'.format(output_base),
+      input: input,
+      output: '@[email protected]'.format(output_base),
+      command: [
+        wayland_scanner,
+        'private-code',
+        '@INPUT@', '@OUTPUT@',
+      ], build_by_default: true

ui/meson.build if config_host.has_key('CONFIG_OPENGL') and gbm.found() · line 117

Quoted 10 lines
ui/meson.build +10 -0
+    )
+  endforeach
+endif
+
+if wayland.found()
+  wayland_ss = ss.source_set()
+  wayland_ss.add(when: wayland, if_true: files('wayland.c', 'xdg-shell-protocol.c', 'fullscreen-shell-unstable-v1-protocol.c','linux-dmabuf-unstable-v1-protocol.c'))
+  #wayland_ss.add(when: wayland, if_true: files('wayland.c'), [wayland_proto_sources])
+  ui_modules += {'wayland' : wayland_ss}
+endif

Configure fails on this

Program wayland-scanner found: YES (/usr/bin/wayland-scanner)

../ui/meson.build:114:13: ERROR: File xdg-shell-protocol.c does not exist.

the code a few lines above generates xdg-shell-protocol.c, but that isn't run until you type "make", so when meson is resolving the source files they don't exist.

The alternative line you have commented out looks more like what we would need, but it doesn't work either as its syntax is invalid.

How did you actually compile this series ?

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 :|
#5 lore raw

RE: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

Hi Daniel,

Quoted 80 lines · Vivek Kasireddy
Quoted 24 lines
---
 configure         |   8 +-
 meson.build       |  33 +++
 meson_options.txt |   2 +
 qapi/ui.json      |   3 +
 ui/meson.build    |  52 ++++
 ui/wayland.c      | 628 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 725 insertions(+), 1 deletion(-)  create mode 100644

ui/wayland.c

ui/meson.build index renamed from ui/meson.build +0 -0

a73beb0e54..86fc324c82 100644

ui/meson.build +4 -0
@@ -64,6 +64,58 @@ if config_host.has_key('CONFIG_OPENGL') and gbm.found()
   ui_modules += {'egl-headless' : egl_headless_ss}  endif
 
+wayland_scanner = find_program('wayland-scanner') proto_sources = [
+  ['xdg-shell', 'stable', ],
+  ['fullscreen-shell', 'unstable', 'v1', ],
+  ['linux-dmabuf', 'unstable', 'v1', ], ] wayland_headers = []

ui/meson.build if config_host.has_key('CONFIG_OPENGL') and gbm.found() · line 79

Quoted 10 lines
ui/meson.build +10 -0
+wayland_proto_sources = []
+
+if wayland.found()
+  foreach p: proto_sources
+    proto_name = p.get(0)
+    proto_stability = p.get(1)
+
+    if proto_stability == 'stable'
+      output_base = proto_name
+      input = files(join_paths(wlproto_dir,

'@0@/@1@/@[email protected]'.format(proto_stability, proto_name, output_base)))

ui/meson.build if config_host.has_key('CONFIG_OPENGL') and gbm.found()

Quoted 3 lines
ui/meson.build +3 -0
+    else
+      proto_version = p.get(2)
+      output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability,

proto_version)

ui/meson.build if config_host.has_key('CONFIG_OPENGL') and gbm.found() · line 83

Quoted 1 line
ui/meson.build +1 -0
+      input = files(join_paths(wlproto_dir,

'@0@/@1@/@[email protected]'.format(proto_stability, proto_name, output_base)))

Quoted 23 lines
ui/meson.build +23 -0
+    endif
+
+    wayland_headers += custom_target('@0@ client header'.format(output_base),
+      input: input,
+      output: '@[email protected]'.format(output_base),
+      command: [
+        wayland_scanner,
+        'client-header',
+        '@INPUT@', '@OUTPUT@',
+      ], build_by_default: true
+    )
+
+    wayland_proto_sources += custom_target('@0@ source'.format(output_base),
+      input: input,
+      output: '@[email protected]'.format(output_base),
+      command: [
+        wayland_scanner,
+        'private-code',
+        '@INPUT@', '@OUTPUT@',
+      ], build_by_default: true
+    )
+  endforeach
+endif

ui/meson.build if config_host.has_key('CONFIG_OPENGL') and gbm.found()

Quoted 10 lines
ui/meson.build +10 -0
+
+if wayland.found()
+  wayland_ss = ss.source_set()
+  wayland_ss.add(when: wayland, if_true: files('wayland.c',
+'xdg-shell-protocol.c',
+'fullscreen-shell-unstable-v1-protocol.c','linux-dmabuf-unstable-v1-p
+rotocol.c'))
+  #wayland_ss.add(when: wayland, if_true: files('wayland.c'),
+[wayland_proto_sources])
+  ui_modules += {'wayland' : wayland_ss} endif

Configure fails on this

Program wayland-scanner found: YES (/usr/bin/wayland-scanner)

Quoted 8 lines

../ui/meson.build:114:13: ERROR: File xdg-shell-protocol.c does not exist.

the code a few lines above generates xdg-shell-protocol.c, but that isn't run until you type "make", so when meson is resolving the source files they don't exist.

The alternative line you have commented out looks more like what we would need, but it doesn't work either as its syntax is invalid.

[Kasireddy, Vivek] Right, the commented line is the one we'd need but despite exhaustively trying various different combinations, I couldn't get Meson to include the auto-generated protocol sources. If it is not too much trouble, could you please point me to an example where this is done elsewhere in Qemu source that I can look at?

Quoted 2 lines

How did you actually compile this series ?

[Kasireddy, Vivek] Oh, as a workaround, I just manually added the protocol sources. I am sorry I did not realize that this code would be compiled/tested; I mainly posted these RFC/WIP patches to provide additional context to the discussion associated with the DRM/ Virtio-gpu kernel patches.

Thanks,
Vivek

Quoted 8 lines

Regards,
Daniel
--

|: 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 :|
#6 lore raw
In reply to Vivek Kasireddy
Quoted 11 lines · Vivek Kasireddy

Why does Qemu need a new Wayland UI backend?
The main reason why there needs to be a plain and simple Wayland backend for Qemu UI is to eliminate the Blit (aka GPU copy) that happens if using a toolkit like GTK or SDL (because they use EGL). The Blit can be eliminated by sharing the dmabuf fd -- associated with the Guest scanout buffer -- directly with the Host compositor via the linux-dmabuf (unstable) protocol. Once properly integrated, it would be potentially possible to have the scanout buffer created by the Guest compositor be placed directly on a hardware plane on the Host thereby improving performance. Only Guest compositors that use multiple back buffers (at-least 1 front and 1 back) and virtio-gpu would benefit from this work.

IME, QEMU already suffers from having too many barely maintained UI implementations and iti s confusing to users. Using a toolkit like GTK is generally a good thing, even if they don't enable the maximum theoretical performance, because they reduce the long term maint burden.

I'm far from convinced that we should take on the maint of yet another UI in QEMU, even if it does have some performance benefit, especially if implemented using a very low level API like Wayland, that won't let us easily add rich UI features.

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 :|
#7 lore raw

Hi Daniel,

Quoted 13 lines · Vivek Kasireddy
Quoted 11 lines

Why does Qemu need a new Wayland UI backend?
The main reason why there needs to be a plain and simple Wayland backend for Qemu UI is to eliminate the Blit (aka GPU copy) that happens if using a toolkit like GTK or SDL (because they use EGL). The Blit can be eliminated by sharing the dmabuf fd -- associated with the Guest scanout buffer -- directly with the Host compositor via the linux-dmabuf (unstable) protocol. Once properly integrated, it would be potentially possible to have the scanout buffer created by the Guest compositor be placed directly on a hardware plane on the Host thereby improving performance. Only Guest compositors that use multiple back buffers (at-least 1 front and 1 back) and virtio-gpu would benefit from this work.

Quoted 4 lines

IME, QEMU already suffers from having too many barely maintained UI implementations and iti s confusing to users. Using a toolkit like GTK is generally a good thing, even if they don't enable the maximum theoretical performance, because they reduce the long term maint burden.

[Kasireddy, Vivek] The Wayland UI is ~600 lines of code and more than half of that is just boilerplate; it is also fairly standalone. We don't have any major complaints against GTK UI (which is ~3000 lines of code, just the Qemu piece excluding libgtk) except that there is no way to dissociate EGL from it. And, to keep the UI codebase up-to-date and leverage latest features from GTK (for example GTK4 and beyond) it would require non-trivial amount of work. Therefore, I think it'd not be too onerous to maintain something lightweight like the Wayland UI module.

Quoted 3 lines

I'm far from convinced that we should take on the maint of yet another UI in QEMU, even if it does have some performance benefit, especially

[Kasireddy, Vivek] There are novel use-cases coming up particularly with the arrival of technologies like SRIOV where the Guest is expected to do all the rendering and share the fully composited buffer with the Host whose job is to just present it on the screen. And, in this scenario, if we were to use GTK UI, the (fullscreen sized) Blits incurred would quickly add up if there are 4-6 Guests running and presenting content at the same time locally on multiple monitors. Wayland UI helps in this situation as it does not do any additional rendering on the Host (no Blit) as it just merely forwards the Guest composited buffer to the Host compositor.

Quoted 2 lines

if implemented using a very low level API like Wayland, that won't let us easily add rich UI features.

[Kasireddy, Vivek] Yes, it is a drawback of Wayland UI that it'd not be possible to do window decorations/rich UI features but there are users/customers that do not care for them. I think it should be possible to have both Wayland and GTK UI co-exist where users can choose GTK UI for fancy features and Wayland UI for performance.

Thanks,
Vivek

Quoted 7 lines

Regards,
Daniel
--

|: 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 :|