[PATCH v2 00/37] Add D-Bus display backend

marcandre.lureau@redhat.com posted 37 patches 2 years, 6 months ago
Failed in applying to current master (apply log)
docs/conf.py                    |   8 +
docs/interop/dbus-display.rst   |  31 ++
docs/interop/dbus-vmstate.rst   |  52 +--
docs/interop/dbus.rst           |   2 +
docs/interop/index.rst          |   1 +
docs/sphinx/dbusdoc.py          | 166 +++++++
docs/sphinx/dbusdomain.py       | 406 +++++++++++++++++
docs/sphinx/dbusparser.py       | 373 ++++++++++++++++
docs/sphinx/fakedbusdoc.py      |  25 ++
configure                       |  49 +-
meson.build                     |  46 +-
qapi/audio.json                 |   3 +-
qapi/char.json                  |  27 ++
qapi/misc.json                  |   4 +-
qapi/ui.json                    |  34 +-
audio/audio_int.h               |   7 +
audio/audio_template.h          |   2 +
include/chardev/char-socket.h   |  86 ++++
include/qemu/cutils.h           |   5 +
include/qemu/dbus.h             |  24 +
include/qemu/option.h           |   2 +
include/ui/clipboard.h          |  55 ++-
include/ui/console.h            |  70 ++-
include/ui/dbus-display.h       |  17 +
include/ui/dbus-module.h        |  11 +
include/ui/egl-context.h        |   6 +-
include/ui/gtk.h                |  11 +-
include/ui/sdl2.h               |   7 +-
include/ui/spice-display.h      |   5 +-
tests/qtest/libqos/libqtest.h   |  10 +
ui/dbus.h                       | 144 ++++++
audio/audio.c                   |   1 +
audio/dbusaudio.c               | 654 +++++++++++++++++++++++++++
chardev/char-socket.c           |  72 +--
hw/display/qxl.c                |   7 +-
hw/display/vhost-user-gpu.c     |   2 +-
hw/display/virtio-gpu-base.c    |   5 +-
hw/display/virtio-gpu-virgl.c   |   3 +-
hw/display/virtio-vga.c         |  11 -
monitor/qmp-cmds.c              |  13 +
tests/qtest/dbus-display-test.c | 281 ++++++++++++
tests/qtest/libqtest.c          |  19 +
ui/clipboard.c                  |  34 +-
ui/console.c                    | 305 +++++++++----
ui/dbus-chardev.c               | 296 +++++++++++++
ui/dbus-clipboard.c             | 457 +++++++++++++++++++
ui/dbus-console.c               | 497 +++++++++++++++++++++
ui/dbus-error.c                 |  48 ++
ui/dbus-listener.c              | 486 ++++++++++++++++++++
ui/dbus-module.c                |  35 ++
ui/dbus.c                       | 477 ++++++++++++++++++++
ui/egl-context.c                |   6 +-
ui/egl-headless.c               |  20 +-
ui/gtk-clipboard.c              |  23 +-
ui/gtk-egl.c                    |  11 +-
ui/gtk-gl-area.c                |   9 +-
ui/gtk.c                        |  28 +-
ui/sdl2-gl.c                    |  12 +-
ui/sdl2.c                       |  16 +-
ui/spice-core.c                 |  50 ---
ui/spice-display.c              |  27 +-
ui/util.c                       |  75 ++++
ui/vdagent.c                    |  94 +++-
ui/vnc-clipboard.c              |  21 +-
ui/vnc.c                        |   4 +-
MAINTAINERS                     |  10 +-
audio/meson.build               |   8 +-
audio/trace-events              |   5 +
backends/dbus-vmstate1.xml      |  52 +++
chardev/meson.build             |   2 +-
meson_options.txt               |   6 +
qemu-options.hx                 |  20 +
scripts/modinfo-collect.py      |   3 +
tests/qtest/dbus-vmstate1.xml   |  12 -
tests/qtest/meson.build         |  10 +-
ui/cocoa.m                      |  20 +-
ui/dbus-display1.xml            | 761 ++++++++++++++++++++++++++++++++
ui/meson.build                  |  32 +-
ui/trace-events                 |  15 +
79 files changed, 6284 insertions(+), 460 deletions(-)
create mode 100644 docs/interop/dbus-display.rst
create mode 100644 docs/sphinx/dbusdoc.py
create mode 100644 docs/sphinx/dbusdomain.py
create mode 100644 docs/sphinx/dbusparser.py
create mode 100644 docs/sphinx/fakedbusdoc.py
create mode 100644 include/chardev/char-socket.h
create mode 100644 include/ui/dbus-display.h
create mode 100644 include/ui/dbus-module.h
create mode 100644 ui/dbus.h
create mode 100644 audio/dbusaudio.c
create mode 100644 tests/qtest/dbus-display-test.c
create mode 100644 ui/dbus-chardev.c
create mode 100644 ui/dbus-clipboard.c
create mode 100644 ui/dbus-console.c
create mode 100644 ui/dbus-error.c
create mode 100644 ui/dbus-listener.c
create mode 100644 ui/dbus-module.c
create mode 100644 ui/dbus.c
create mode 100644 ui/util.c
create mode 100644 backends/dbus-vmstate1.xml
delete mode 100644 tests/qtest/dbus-vmstate1.xml
create mode 100644 ui/dbus-display1.xml
[PATCH v2 00/37] Add D-Bus display backend
Posted by marcandre.lureau@redhat.com 2 years, 6 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hi,

Both Spice and VNC are relatively complex and inefficient for local-only
display/console export.

The goal of this display backend is to export over D-Bus an interface close to
the QEMU internal APIs. Any -display or -audio backend should be possible to
implement externally that way. It will allow third-parties to maintain their own
backends (UI toolkits, servers etc), and eventually reduce the responsability on
QEMU.

D-Bus is the protocol of choice for the desktop, it has many convenient bindings
for various languages and tools. Data blob transfer is more efficient than QMP
too. Backends can come and go as needed: you can have several display opened
(say Boxes & virt-manager), while exporting the display over VNC for example
from a different process. It works best on Unix, but there is some Windows
support too (even Windows has some AF_UNIX nowadays, and the WSL2 situation may
change the future of QEMU on Windows anyway).

Using it only requires "-display dbus" on any reasonable Linux desktop with a
D-Bus session bus. Then you use can use busctl, d-feet or gdbus, ex:
$ gdbus introspect --session -r -d org.qemu -o /

See the different patches and documentation for further options. The p2p=on mode
should also allow users running bus-less (on MacOS for ex). We can also add TCP
socket if needed (although more work would be needed in this case to replace
the FD-passing with some extra TCP listening socket).

A WIP Rust/Gtk4 client and VNC server is: https://gitlab.com/marcandre.lureau/qemu-display/
(check README.md for details, then `cargo run` should connect to QEMU)

The Sphinx build support works best with "[PATCH 0/6] Some Sphinx improvements",
where module dependency tracking is improved.

I can resend the first set of preliminary patches after some feedback.

Thanks

v2:
 - rebased
 - drop for the vhost-user-gpu work for now
 - add documentation, including D-Bus Sphinx directive
 - add bus-less option (p2p=on)
 - add some basic tests for the Console/Keyboard interfaces
 - add clipboard sharing support
 - add chardev redirection support (allowing USB redirection, monitors,
   serials...)
 - register a VC handler to export default serial/monitors
 - probably a few bug fixes here and there too

Marc-André Lureau (37):
  build-sys: move Spice configure handling to meson
  ui/vdagent: add CHECK_SPICE_PROTOCOL_VERSION
  ui/vdagent: replace #if 0 with protocol version check
  ui: generalize clipboard notifier
  ui/vdagent: add serial capability support
  ui/clipboard: add qemu_clipboard_check_serial()
  ui/clipboard: add a clipboard reset serial event
  hw/display: report an error if virgl initialization failed
  virtio-gpu: use VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP
  ui: do not delay further remote resize
  ui: factor out qemu_console_set_display_gl_ctx()
  ui: associate GL context outside of display listener registration
  ui: make gl_block use a counter
  ui: add a gl-unblock warning timer
  ui: simplify gl unblock & flush
  ui: dispatch GL events to all listeners
  ui: split the GL context in a different object
  ui: move qemu_spice_fill_device_address to ui/util.c
  console: save current scanout details
  scripts: teach modinfo to skip non-C sources
  docs/sphinx: add sphinx modules to include D-Bus documentation
  backends: move dbus-vmstate1.xml to backends/
  docs: move D-Bus VMState documentation to source XML
  docs: add dbus-display documentation
  build-sys: set glib dependency version
  ui: add a D-Bus display backend
  ui/dbus: add p2p=on/off option
  tests/qtests: add qtest_qmp_add_client()
  tests: start dbus-display-test
  audio: add "dbus" audio backend
  ui/dbus: add clipboard interface
  chardev: teach socket to accept no addresses
  chardev: make socket derivable
  option: add g_auto for QemuOpts
  ui/dbus: add chardev backend & interface
  ui/dbus: register D-Bus VC handler
  MAINTAINERS: update D-Bus section

 docs/conf.py                    |   8 +
 docs/interop/dbus-display.rst   |  31 ++
 docs/interop/dbus-vmstate.rst   |  52 +--
 docs/interop/dbus.rst           |   2 +
 docs/interop/index.rst          |   1 +
 docs/sphinx/dbusdoc.py          | 166 +++++++
 docs/sphinx/dbusdomain.py       | 406 +++++++++++++++++
 docs/sphinx/dbusparser.py       | 373 ++++++++++++++++
 docs/sphinx/fakedbusdoc.py      |  25 ++
 configure                       |  49 +-
 meson.build                     |  46 +-
 qapi/audio.json                 |   3 +-
 qapi/char.json                  |  27 ++
 qapi/misc.json                  |   4 +-
 qapi/ui.json                    |  34 +-
 audio/audio_int.h               |   7 +
 audio/audio_template.h          |   2 +
 include/chardev/char-socket.h   |  86 ++++
 include/qemu/cutils.h           |   5 +
 include/qemu/dbus.h             |  24 +
 include/qemu/option.h           |   2 +
 include/ui/clipboard.h          |  55 ++-
 include/ui/console.h            |  70 ++-
 include/ui/dbus-display.h       |  17 +
 include/ui/dbus-module.h        |  11 +
 include/ui/egl-context.h        |   6 +-
 include/ui/gtk.h                |  11 +-
 include/ui/sdl2.h               |   7 +-
 include/ui/spice-display.h      |   5 +-
 tests/qtest/libqos/libqtest.h   |  10 +
 ui/dbus.h                       | 144 ++++++
 audio/audio.c                   |   1 +
 audio/dbusaudio.c               | 654 +++++++++++++++++++++++++++
 chardev/char-socket.c           |  72 +--
 hw/display/qxl.c                |   7 +-
 hw/display/vhost-user-gpu.c     |   2 +-
 hw/display/virtio-gpu-base.c    |   5 +-
 hw/display/virtio-gpu-virgl.c   |   3 +-
 hw/display/virtio-vga.c         |  11 -
 monitor/qmp-cmds.c              |  13 +
 tests/qtest/dbus-display-test.c | 281 ++++++++++++
 tests/qtest/libqtest.c          |  19 +
 ui/clipboard.c                  |  34 +-
 ui/console.c                    | 305 +++++++++----
 ui/dbus-chardev.c               | 296 +++++++++++++
 ui/dbus-clipboard.c             | 457 +++++++++++++++++++
 ui/dbus-console.c               | 497 +++++++++++++++++++++
 ui/dbus-error.c                 |  48 ++
 ui/dbus-listener.c              | 486 ++++++++++++++++++++
 ui/dbus-module.c                |  35 ++
 ui/dbus.c                       | 477 ++++++++++++++++++++
 ui/egl-context.c                |   6 +-
 ui/egl-headless.c               |  20 +-
 ui/gtk-clipboard.c              |  23 +-
 ui/gtk-egl.c                    |  11 +-
 ui/gtk-gl-area.c                |   9 +-
 ui/gtk.c                        |  28 +-
 ui/sdl2-gl.c                    |  12 +-
 ui/sdl2.c                       |  16 +-
 ui/spice-core.c                 |  50 ---
 ui/spice-display.c              |  27 +-
 ui/util.c                       |  75 ++++
 ui/vdagent.c                    |  94 +++-
 ui/vnc-clipboard.c              |  21 +-
 ui/vnc.c                        |   4 +-
 MAINTAINERS                     |  10 +-
 audio/meson.build               |   8 +-
 audio/trace-events              |   5 +
 backends/dbus-vmstate1.xml      |  52 +++
 chardev/meson.build             |   2 +-
 meson_options.txt               |   6 +
 qemu-options.hx                 |  20 +
 scripts/modinfo-collect.py      |   3 +
 tests/qtest/dbus-vmstate1.xml   |  12 -
 tests/qtest/meson.build         |  10 +-
 ui/cocoa.m                      |  20 +-
 ui/dbus-display1.xml            | 761 ++++++++++++++++++++++++++++++++
 ui/meson.build                  |  32 +-
 ui/trace-events                 |  15 +
 79 files changed, 6284 insertions(+), 460 deletions(-)
 create mode 100644 docs/interop/dbus-display.rst
 create mode 100644 docs/sphinx/dbusdoc.py
 create mode 100644 docs/sphinx/dbusdomain.py
 create mode 100644 docs/sphinx/dbusparser.py
 create mode 100644 docs/sphinx/fakedbusdoc.py
 create mode 100644 include/chardev/char-socket.h
 create mode 100644 include/ui/dbus-display.h
 create mode 100644 include/ui/dbus-module.h
 create mode 100644 ui/dbus.h
 create mode 100644 audio/dbusaudio.c
 create mode 100644 tests/qtest/dbus-display-test.c
 create mode 100644 ui/dbus-chardev.c
 create mode 100644 ui/dbus-clipboard.c
 create mode 100644 ui/dbus-console.c
 create mode 100644 ui/dbus-error.c
 create mode 100644 ui/dbus-listener.c
 create mode 100644 ui/dbus-module.c
 create mode 100644 ui/dbus.c
 create mode 100644 ui/util.c
 create mode 100644 backends/dbus-vmstate1.xml
 delete mode 100644 tests/qtest/dbus-vmstate1.xml
 create mode 100644 ui/dbus-display1.xml

-- 
2.33.0.721.g106298f7f9



Re: [PATCH v2 00/37] Add D-Bus display backend
Posted by Gerd Hoffmann 2 years, 6 months ago
On Sun, Oct 10, 2021 at 01:08:01AM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Hi,
> 
> Both Spice and VNC are relatively complex and inefficient for local-only
> display/console export.
> 
> The goal of this display backend is to export over D-Bus an interface close to
> the QEMU internal APIs. Any -display or -audio backend should be possible to
> implement externally that way. It will allow third-parties to maintain their own
> backends (UI toolkits, servers etc), and eventually reduce the responsability on
> QEMU.
> 
> D-Bus is the protocol of choice for the desktop, it has many convenient bindings
> for various languages and tools. Data blob transfer is more efficient than QMP
> too. Backends can come and go as needed: you can have several display opened
> (say Boxes & virt-manager), while exporting the display over VNC for example
> from a different process. It works best on Unix, but there is some Windows
> support too (even Windows has some AF_UNIX nowadays, and the WSL2 situation may
> change the future of QEMU on Windows anyway).
> 
> Using it only requires "-display dbus" on any reasonable Linux desktop with a
> D-Bus session bus. Then you use can use busctl, d-feet or gdbus, ex:
> $ gdbus introspect --session -r -d org.qemu -o /
> 
> See the different patches and documentation for further options. The p2p=on mode
> should also allow users running bus-less (on MacOS for ex). We can also add TCP
> socket if needed (although more work would be needed in this case to replace
> the FD-passing with some extra TCP listening socket).

Wow.  That series got a lot of fine tuning.  The patches look all good
to me.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

> A WIP Rust/Gtk4 client and VNC server is: https://gitlab.com/marcandre.lureau/qemu-display/
> (check README.md for details, then `cargo run` should connect to QEMU)

Hmm, that wants rather cutting edge versions, stock Fedora 34 isn't new
enough to build it.  And I don't feel like updating to Fedora 35 beta
for that.  So unfortunately I couldn't easily test it, but I'd love to
see that live in action.

Is it possible to keep the client running while starting and stopping
qemu (comparable to "virt-viewer --wait --reconnect" behaviour)?

take care,
  Gerd


Re: [PATCH v2 00/37] Add D-Bus display backend
Posted by Marc-André Lureau 2 years, 4 months ago
Hi

On Wed, Oct 13, 2021 at 9:23 AM Gerd Hoffmann <kraxel@redhat.com> wrote:

> On Sun, Oct 10, 2021 at 01:08:01AM +0400, marcandre.lureau@redhat.com
> wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Hi,
> >
> > Both Spice and VNC are relatively complex and inefficient for local-only
> > display/console export.
> >
> > The goal of this display backend is to export over D-Bus an interface
> close to
> > the QEMU internal APIs. Any -display or -audio backend should be
> possible to
> > implement externally that way. It will allow third-parties to maintain
> their own
> > backends (UI toolkits, servers etc), and eventually reduce the
> responsability on
> > QEMU.
> >
> > D-Bus is the protocol of choice for the desktop, it has many convenient
> bindings
> > for various languages and tools. Data blob transfer is more efficient
> than QMP
> > too. Backends can come and go as needed: you can have several display
> opened
> > (say Boxes & virt-manager), while exporting the display over VNC for
> example
> > from a different process. It works best on Unix, but there is some
> Windows
> > support too (even Windows has some AF_UNIX nowadays, and the WSL2
> situation may
> > change the future of QEMU on Windows anyway).
> >
> > Using it only requires "-display dbus" on any reasonable Linux desktop
> with a
> > D-Bus session bus. Then you use can use busctl, d-feet or gdbus, ex:
> > $ gdbus introspect --session -r -d org.qemu -o /
> >
> > See the different patches and documentation for further options. The
> p2p=on mode
> > should also allow users running bus-less (on MacOS for ex). We can also
> add TCP
> > socket if needed (although more work would be needed in this case to
> replace
> > the FD-passing with some extra TCP listening socket).
>
> Wow.  That series got a lot of fine tuning.  The patches look all good
> to me.
>
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
>

I have rebased the series and added your acked-by (
https://gitlab.com/marcandre.lureau/qemu/-/tree/dbus)

The client side is still in development. However, the libvirt series is in
shape (
https://patchew.org/Libvirt/20211202142411.1718032-1-marcandre.lureau@redhat.com/),
waiting for QEMU side to land.

Should I make a PR or ask for more reviews? Since this is fairly long to
review but quite independent from existing code, I think sending a PR is
reasonable wdyt?


> > A WIP Rust/Gtk4 client and VNC server is:
> https://gitlab.com/marcandre.lureau/qemu-display/
> > (check README.md for details, then `cargo run` should connect to QEMU)
>
> Hmm, that wants rather cutting edge versions, stock Fedora 34 isn't new
> enough to build it.  And I don't feel like updating to Fedora 35 beta
> for that.  So unfortunately I couldn't easily test it, but I'd love to
> see that live in action.
>
> Is it possible to keep the client running while starting and stopping
> qemu (comparable to "virt-viewer --wait --reconnect" behaviour)?
>
>
That's doable. I just added a --wait option to the demo client.

For reconnect to work, we would need a better way to track name ownership
changes (connection and disconnections) in zbus. I am working on it.

thanks

-- 
Marc-André Lureau
Re: [PATCH v2 00/37] Add D-Bus display backend
Posted by Gerd Hoffmann 2 years, 4 months ago
  Hi,

> I have rebased the series and added your acked-by (
> https://gitlab.com/marcandre.lureau/qemu/-/tree/dbus)
> 
> The client side is still in development. However, the libvirt series is in
> shape (
> https://patchew.org/Libvirt/20211202142411.1718032-1-marcandre.lureau@redhat.com/),
> waiting for QEMU side to land.
> 
> Should I make a PR or ask for more reviews? Since this is fairly long to
> review but quite independent from existing code, I think sending a PR is
> reasonable wdyt?

No objections.  Unlikely to break something, also we are early
in the devel cycle so plenty of time to find & fix bugs before
this lands in a release.

> For reconnect to work, we would need a better way to track name ownership
> changes (connection and disconnections) in zbus. I am working on it.

zbus == compressed dbus ?

take care,
  Gerd