vhost-user-bridge housekeeping and test
v4 cover vhost-user-bridge housekeeping and test
Hi,
The existence check of the vhost-user-bridge file checks for None when it should check for False to determine whether the test should be skipped; a trivial fix.
Changes since v3:
--------------------
- Fix is_readable_executable_file() check of vubr for skipping test
Link to v3:
-----------
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks,
Yodel
Cover letter from v3:
=====================
This series (1) moves vhost-user-bridge (vubr) from tests/ to contrib/vhost-user-bridge/, (2) introduces a basic functional test of vubr, and (3) adds UDP receive packet logging to vubr:
Patch 1: Moving vhost-user-bridge
---------------------------------
After the introduction of vhost-user-bridge and libvhost-user, new vhost-user backend daemons were placed in dedicated subdirectories of contrib/. An F: line under the vhost section in MAINTAINERS grants these daemons coverage; in tests/, however, vhost-user-bridge lacks coverage and appears orphaned there. So, let's give it a home with the rest of the vhost-user backend family.
As part of the move, vhost-user-bridge also gains a section in the vhost-user-contrib document. More can be said about vubr there, like its client mode feature added in aef8486ede8b by Marc-André, but for now a short description and usage example will help folks interested in using the daemon to expand vhost-user support in QEMU.
Lastly, Patch 1 makes the necessary changes to the meson build files in tests/ and root, and the new one in contrib/vhost-user-bridge/.
Patch 2: Introducing a functional test
--------------------------------------
This test was inspired by discussions with Cédric regarding build errors from recent glibc const changes and was the subject of the first RFC.
The functional test introduced in the second patch starts vubr as a subprocess, then launches a single QEMU instance that provides a slirp stack and serves as the frontend of the vhost-user protocol, much like the testing setup described in vhost-user-bridge's initial commit in 3595e2eb0a23.
For additional details about the test, please see Patch 2's commit message and/or the test's header; in short: the host serves a file to the guest via tftp, then the guest serves a file to the host via http.
The guest's kernel image was built with Buildroot in a Containerfile that is based on a snapshot Debian container image, so that the kernel image remains bit-for-bit reproducible indefinitely. For the image and its build files, please see:
https://github.com/yodel/vhost-user-bridge-test
The repo will be placed in archive (read-only) mode if/when the series is pulled.
Patch 3: Adding UDP RX logging
------------------------------
An existing transmit hexdump of UDP packets provides valuable data; adding a receive hexdump to complement TX doubles the fun (read:
visibility). Like TX, the RX hexdump is gated behind a currently hardcoded-on macro. Another new debug print separates transmit blocks from receives.
Changes since RFCv2:
--------------------
- Promoted to PATCH
- Collect R-b's (thanks to Marc-André and Thomas)
- Add test to .../x86_64/meson.build thorough suite (Marc-André)
- Add encoding= args to open() (Thomas)
- Add pylint disable=unbalanced-tuple-unpacking on find_free_ports()
- Minor commit message rewording
Changes since RFCv1:
--------------------
- Remove external host dependency (Marc-André)
- Use user netdev tftp feature (Thomas)
- Use check_http_download (Thomas)
- Remove wget
- Inherit from LinuxKernelTest instead of QemuSystemTest
- Use hardcoded UUIDs in files on the guest and host for data transfer
- Use a Popen context manager to terminate and wait on vubr
- Add test to MAINTAINERS under the vhost section (Michael)
- New patch to move from tests/ to contrib/vhost-user-bridge/ and add docs section
- New patch to add RX debug logging in vhost-user-bridge.c
Links
-----
RFCv2:
https://lore.kernel.org/qemu-devel/[email protected]/
RFCv1:
https://lore.kernel.org/qemu-devel/[email protected]/
Yodel Eldar (3):
tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/ tests/functional/x86_64: Add vhost-user-bridge test contrib/vhost-user-bridge: Add UDP receive hexdump
MAINTAINERS | 1 +
contrib/vhost-user-bridge/meson.build | 4 +
.../vhost-user-bridge}/vhost-user-bridge.c | 7 +
.../devices/virtio/vhost-user-contrib.rst | 39 +++++
meson.build | 1 +
tests/functional/x86_64/meson.build | 1 +
.../x86_64/test_vhost_user_bridge.py | 147 ++++++++++++++++++
tests/meson.build | 6 -
8 files changed, 200 insertions(+), 6 deletions(-)
create mode 100644 contrib/vhost-user-bridge/meson.build
rename {tests => contrib/vhost-user-bridge}/vhost-user-bridge.c (98%)
create mode 100755 tests/functional/x86_64/test_vhost_user_bridge.pySignature · 1 line
2.52.0
PATCH v4 1/3 tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/
After the introduction of vhost-user-bridge and libvhost-user, we formed the convention of placing vhost-user daemons in eponymous subdirs of contrib/. Follow this convention.
Create a contrib/vhost-user-bridge/ directory and move vhost-user-bridge into it. Extract its build target definition from tests/meson.build into the new directory, and include its subdir in the root-level meson.build.
Add a section about it in the "vhost-user daemons in contrib" document.
---
contrib/vhost-user-bridge/meson.build | 4 ++
.../vhost-user-bridge}/vhost-user-bridge.c | 0
.../devices/virtio/vhost-user-contrib.rst | 39 +++++++++++++++++++
meson.build | 1 +
tests/meson.build | 6 ---
5 files changed, 44 insertions(+), 6 deletions(-)
create mode 100644 contrib/vhost-user-bridge/meson.build
rename {tests => contrib/vhost-user-bridge}/vhost-user-bridge.c (100%)contrib/vhost-user-bridge/meson.build new file +4 -0
@@ -0,0 +1,4 @@ +if have_tools and have_vhost_user and host_os == 'linux' + executable('vhost-user-bridge', files('vhost-user-bridge.c'), + dependencies: [qemuutil, vhost_user], install: false) +endif
contrib/vhost-user-bridge/vhost-user-bridge.c renamed from tests/vhost-user-bridge.c +0 -0
docs/system/devices/virtio/vhost-user-contrib.rst +39 -0
@@ -85,3 +85,42 @@ vhost-user-scsi - SCSI controller The vhost-user-scsi daemon can proxy iSCSI devices onto a virtualized SCSI controller. + +.. _vhost_user_bridge: + +vhost-user-bridge - Network bridge +================================== + +The vhost-user-bridge daemon serves as a development tool for testing real +internet traffic by providing a networking backend, i.e. server, for the +vhost-user protocol. + +Example +------- +For a single QEMU instance that both runs the user-mode net stack (slirp) and +serves as a vhost-user protocol frontend, i.e. client, simultaneously: + +First, start vhost-user-bridge: + +:: + + $ vhost-user-bridge -u /tmp/vubr.sock \ + -l 127.0.0.1:4444 \ + -r 127.0.0.1:5555 + +Then, invoke QEMU: + +:: + + $ qemu-system-x86_64 \ + -m 4G \ + -object memory-backend-memfd,id=mem0,size=4G,share=on,prealloc=on \ + -numa node,memdev=mem0 \ + -chardev socket,id=char0,path=/tmp/vubr.sock \ + -netdev vhost-user,id=vhost0,chardev=char0,vhostforce=on \ + -device virtio-net-pci,netdev=vhost0 \ + -netdev socket,id=udp0,udp=localhost:4444,localaddr=localhost:5555 \ + -netdev user,id=user0 \ + -netdev hubport,id=hub0,hubid=0,netdev=udp0 \ + -netdev hubport,id=hub1,hubid=0,netdev=user0 \ + ...
meson.build +1 -0
@@ -4494,6 +4494,7 @@ if have_tools if have_vhost_user subdir('contrib/vhost-user-blk') + subdir('contrib/vhost-user-bridge') subdir('contrib/vhost-user-gpu') subdir('contrib/vhost-user-input') subdir('contrib/vhost-user-scsi')
tests/meson.build +0 -6
@@ -70,12 +70,6 @@ test_deps = { 'test-qht-par': qht_bench, } -if have_tools and have_vhost_user and host_os == 'linux' - executable('vhost-user-bridge', - sources: files('vhost-user-bridge.c'), - dependencies: [qemuutil, vhost_user]) -endif - subdir('decode') if 'CONFIG_TCG' in config_all_accel
Signature · 1 line
2.52.0
PATCH v4 2/3 tests/functional/x86_64: Add vhost-user-bridge test
In reply to Yodel EldarIntroduce a functional test of vhost-user-bridge and enter it into MAINTAINERS under the vhost section.
The test runs vhost-user-bridge as a subprocess, then launches a guest with four backends: a unix domain socket for vhost-user, a UDP socket, a user-mode net, and a hubport to hub the UDP and user backends; only the vhost-user backend is exposed, the rest are deviceless. This configuration mimics the testing setup described in the initial commit of vhost-user-bridge in 3595e2eb0a23.
The test creates a scratch file containing a hardcoded UUID on the host and exposes it to the the guest via the tftp parameter of the user netdev. After the guest invokes tftp to request the file, the test verifies the transfer by hashsum.
Similarly, the test creates a file with another hardcoded UUID in the guest. A call to check_http_download() serves the file to the host via http, whereupon a check of the file hashsum occurs on the host.
Lastly, add the test to the thorough tests suite in meson.build.
--- MAINTAINERS | 1 + tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vhost_user_bridge.py | 147 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100755 tests/functional/x86_64/test_vhost_user_bridge.py
MAINTAINERS +1 -0
@@ -2395,6 +2395,7 @@ F: subprojects/libvhost-user/ F: block/export/vhost-user* F: util/vhost-user-server.c F: net/vhost* +F: tests/functional/x86_64/test_vhost_user_bridge.py vhost-shadow-virtqueue R: Eugenio Pérez <[email protected]>
tests/functional/x86_64/meson.build +1 -0
@@ -34,6 +34,7 @@ tests_x86_64_system_thorough = [ 'reverse_debug', 'tuxrun', 'vfio_user_client', + 'vhost_user_bridge', 'virtio_balloon', 'virtio_gpu', ]
tests/functional/x86_64/test_vhost_user_bridge.py new file +147 -0
147 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v4 3/3 contrib/vhost-user-bridge: Add UDP receive hexdump
In reply to Yodel Eldarvhost-user-bridge debug prints UDP TX hexdumps in its transmit handler, but does not for receives, even though they are beneficial for testing. Add an RX hexdump in the receive callback.
To delineate between transmits and receives, also add a debug print indicating that the program is in the transmit handler.
--- contrib/vhost-user-bridge/vhost-user-bridge.c | 7 +++++++ 1 file changed, 7 insertions(+)
contrib/vhost-user-bridge/vhost-user-bridge.c +7 -0
@@ -179,6 +179,9 @@ vubr_handle_tx(VuDev *dev, int qidx)assert (qidx %2 ); +DPRINT ("\n\n *** IN UDP TRANSMIT HANDLER ***\n\n" ); +DPRINT (" hdrlen = %d\n" , hdrlen); +for (;;) {ssize_t ret;unsigned int out_num;
@@ -333,6 +336,10 @@ vubr_backend_recv_cb(int sock, void *ctx) }; ret =RETRY_ON_EINTR (recvmsg (vubr->backend_udp_sock, &msg,0 )); +if (ret >0 &&VHOST_USER_BRIDGE_DEBUG ) { +iov_hexdump (sg, num, stderr,"RX:" , ret); + } +if (i ==0 ) {iov_restore_front (elem->in_sg, sg, hdrlen); }
Signature · 1 line
2.52.0
Hi,
Quoted 117 lines · Yodel Eldar
Hi,
The existence check of the vhost-user-bridge file checks for None when it should check for False to determine whether the test should be skipped; a trivial fix.
Changes since v3:
--------------------
- Fixis_readable_executable_file()check of vubr for skipping testLink to v3:
-----------
https://lore.kernel.org/qemu-devel/[email protected]/Thanks,
YodelCover letter from v3:
=====================This series (1) moves vhost-user-bridge (vubr) from tests/ to contrib/vhost-user-bridge/, (2) introduces a basic functional test of vubr, and (3) adds UDP receive packet logging to vubr:
Patch 1: Moving vhost-user-bridge
---------------------------------
After the introduction of vhost-user-bridge and libvhost-user, new vhost-user backend daemons were placed in dedicated subdirectories of contrib/. An F: line under the vhost section inMAINTAINERSgrants these daemons coverage; in tests/, however, vhost-user-bridge lacks coverage and appears orphaned there. So, let's give it a home with the rest of the vhost-user backend family.As part of the move, vhost-user-bridge also gains a section in the vhost-user-contrib document. More can be said about vubr there, like its client mode feature added in
aef8486ede8bby Marc-André, but for now a short description and usage example will help folks interested in using the daemon to expand vhost-user support in QEMU.Lastly, Patch 1 makes the necessary changes to the meson build files in tests/ and root, and the new one in contrib/vhost-user-bridge/.
Patch 2: Introducing a functional test
--------------------------------------
This test was inspired by discussions with Cédric regarding build errors from recent glibc const changes and was the subject of the first RFC.The functional test introduced in the second patch starts vubr as a subprocess, then launches a single QEMU instance that provides a slirp stack and serves as the frontend of the vhost-user protocol, much like the testing setup described in vhost-user-bridge's initial commit in
3595e2eb0a23.For additional details about the test, please see Patch 2's commit message and/or the test's header; in short: the host serves a file to the guest via tftp, then the guest serves a file to the host via http.
The guest's kernel image was built with Buildroot in a Containerfile that is based on a snapshot Debian container image, so that the kernel image remains bit-for-bit reproducible indefinitely. For the image and its build files, please see:
https://github.com/yodel/vhost-user-bridge-test
The repo will be placed in archive (read-only) mode if/when the series is pulled.Patch 3: Adding UDP RX logging
------------------------------
An existing transmit hexdump of UDP packets provides valuable data; adding a receive hexdump to complement TX doubles the fun (read:
visibility). Like TX, the RX hexdump is gated behind a currently hardcoded-on macro. Another new debug print separates transmit blocks from receives.Changes since RFCv2:
--------------------
- Promoted to PATCH
- Collect R-b's (thanks to Marc-André and Thomas)
- Add test to .../x86_64/meson.build thorough suite (Marc-André)
- Add encoding= args toopen()(Thomas)
- Add pylint disable=unbalanced-tuple-unpacking onfind_free_ports()
- Minor commit message rewordingChanges since RFCv1:
--------------------
- Remove external host dependency (Marc-André)
- Use user netdev tftp feature (Thomas)
- Usecheck_http_download(Thomas)
- Remove wget
- Inherit from LinuxKernelTest instead of QemuSystemTest
- Use hardcoded UUIDs in files on the guest and host for data transfer
- Use a Popen context manager to terminate and wait on vubr
- Add test toMAINTAINERSunder the vhost section (Michael)
- New patch to move from tests/ to contrib/vhost-user-bridge/ and add docs section
- New patch to add RX debug logging invhost-user-bridge.cLinks
-----
RFCv2:
https://lore.kernel.org/qemu-devel/[email protected]/
RFCv1:
https://lore.kernel.org/qemu-devel/[email protected]/Yodel Eldar (3):
tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/ tests/functional/x86_64: Add vhost-user-bridge test contrib/vhost-user-bridge: Add UDP receive hexdumpMAINTAINERS | 1 + contrib/vhost-user-bridge/meson.build | 4 + .../vhost-user-bridge}/vhost-user-bridge.c | 7 + .../devices/virtio/vhost-user-contrib.rst | 39 +++++ meson.build | 1 + tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vhost_user_bridge.py | 147 ++++++++++++++++++ tests/meson.build | 6 - 8 files changed, 200 insertions(+), 6 deletions(-)
Quoted 4 lines
create mode 100644 contrib/vhost-user-bridge/meson.build rename {tests =>
contrib/vhost-user-bridge}/vhost-user-bridge.c(98%) create mode 100755tests/functional/x86_64/test_vhost_user_bridge.py
Ping?
Note: All patches have been reviewed.
Link to v4:
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks,
Yodel
Hi,
Quoted 3 lines · Yodel Eldar
Hi,
On 29/01/2026 07:30, Yodel Eldar wrote:
...skipping...
Quoted 7 lines
Quoted 7 lines
Changes since v3:
--------------------
- Fixis_readable_executable_file()check of vubr for skipping testLink to v3:
-----------
https://lore.kernel.org/qemu-devel/20260120215021.30711-1- [email protected]/
...skipping...
Quoted 50 lines
Quoted 44 lines
Changes since RFCv2:
--------------------
- Promoted to PATCH
- Collect R-b's (thanks to Marc-André and Thomas)
- Add test to .../x86_64/meson.build thorough suite (Marc-André)
- Add encoding= args toopen()(Thomas)
- Add pylint disable=unbalanced-tuple-unpacking onfind_free_ports()
- Minor commit message rewordingChanges since RFCv1:
--------------------
- Remove external host dependency (Marc-André)
- Use user netdev tftp feature (Thomas)
- Usecheck_http_download(Thomas)
- Remove wget
- Inherit from LinuxKernelTest instead of QemuSystemTest
- Use hardcoded UUIDs in files on the guest and host for data transfer
- Use a Popen context manager to terminate and wait on vubr
- Add test toMAINTAINERSunder the vhost section (Michael)
- New patch to move from tests/ to contrib/vhost-user-bridge/ and add docs section
- New patch to add RX debug logging invhost-user-bridge.cLinks
-----
RFCv2:
https://lore.kernel.org/qemu-devel/20260112230127.99125-1- [email protected]/ RFCv1:
https://lore.kernel.org/qemu-devel/20251230002604.113632-1- [email protected]/Yodel Eldar (3):
tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/ tests/functional/x86_64: Add vhost-user-bridge test contrib/vhost-user-bridge: Add UDP receive hexdumpMAINTAINERS | 1 + contrib/vhost-user-bridge/meson.build | 4 + .../vhost-user-bridge}/vhost-user-bridge.c | 7 + .../devices/virtio/vhost-user-contrib.rst | 39 +++++ meson.build | 1 + tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vhost_user_bridge.py | 147 ++++++++++++++++++ tests/meson.build | 6 -
Quoted 5 lines
8 files changed, 200 insertions(+), 6 deletions(-)create mode 100644 contrib/vhost-user-bridge/meson.build rename {tests =>
contrib/vhost-user-bridge}/vhost-user-bridge.c(98%) create mode 100755tests/functional/x86_64/test_vhost_user_bridge.py
Quoted 7 lines
Ping?
Note: All patches have been reviewed.
Link to v4:
https://lore.kernel.org/qemu-devel/20260129133049.119829-1- [email protected]/
Ping?
Quoted 3 lines
Thanks,
Yodel
Quoted 74 lines · Yodel Eldar
Hi,
Quoted 3 lines · Yodel Eldar
Hi,
On 29/01/2026 07:30, Yodel Eldar wrote:
...skipping...
Quoted 8 lines
Quoted 8 lines
Changes since v3:
--------------------
- Fixis_readable_executable_file()check of vubr for skipping testLink to v3:
-----------
https://lore.kernel.org/qemu-devel/20260120215021.30711-1-
[email protected]/...skipping...
Quoted 54 lines
Quoted 46 lines
Changes since RFCv2:
--------------------
- Promoted to PATCH
- Collect R-b's (thanks to Marc-André and Thomas)
- Add test to .../x86_64/meson.build thorough suite (Marc-André)
- Add encoding= args toopen()(Thomas)
- Add pylint disable=unbalanced-tuple-unpacking onfind_free_ports()
- Minor commit message rewordingChanges since RFCv1:
--------------------
- Remove external host dependency (Marc-André)
- Use user netdev tftp feature (Thomas)
- Usecheck_http_download(Thomas)
- Remove wget
- Inherit from LinuxKernelTest instead of QemuSystemTest
- Use hardcoded UUIDs in files on the guest and host for data transfer
- Use a Popen context manager to terminate and wait on vubr
- Add test toMAINTAINERSunder the vhost section (Michael)
- New patch to move from tests/ to contrib/vhost-user-bridge/ and add docs section
- New patch to add RX debug logging invhost-user-bridge.cLinks
-----
RFCv2:
https://lore.kernel.org/qemu-devel/20260112230127.99125-1-
[email protected]/
RFCv1:
https://lore.kernel.org/qemu-devel/20251230002604.113632-1-
[email protected]/Yodel Eldar (3):
tests/vhost-user-bridge: Move to contrib/vhost-user-bridge/ tests/functional/x86_64: Add vhost-user-bridge test contrib/vhost-user-bridge: Add UDP receive hexdumpMAINTAINERS | 1 + contrib/vhost-user-bridge/meson.build | 4 + .../vhost-user-bridge}/vhost-user-bridge.c | 7 + .../devices/virtio/vhost-user-contrib.rst | 39 +++++ meson.build | 1 + tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vhost_user_bridge.py | 147 ++++++++++++++++++ tests/meson.build | 6 -
Quoted 5 lines
8 files changed, 200 insertions(+), 6 deletions(-)create mode 100644 contrib/vhost-user-bridge/meson.build rename {tests =>
contrib/vhost-user-bridge}/vhost-user-bridge.c(98%) create mode 100755tests/functional/x86_64/test_vhost_user_bridge.pyPing?
Quoted 12 lines
Quoted 6 lines
Note: All patches have been reviewed.
Link to v4:
https://lore.kernel.org/qemu-devel/20260129133049.119829-1-
[email protected]/Ping?
Quoted 3 lines
Thanks,
Yodel
i will queue this shortly.
Hi, Michael
Quoted 1 line · Michael S. Tsirkin
On Tue, Feb 17, 2026 at 08:56:12AM -0600, Yodel Eldar wrote:
...skipping...
Quoted 4 lines
i will queue this shortly.
Thanks for picking up my series and for agreeing to shelter the functional test under your umbrella.
Regards,
Yodel