All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] virtio: two fixes
@ 2026-09-22 21:32 Vladimir Sementsov-Ogievskiy
  2026-09-22 21:32 ` [PATCH 1/3] tests/funtional: add test_virtio_status.py Vladimir Sementsov-Ogievskiy
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-09-22 21:32 UTC (permalink / raw)
  To: mst
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, vsementsov, qemu-stable

Hi all! There two fixes for my old patches. I apologize if
this affected anyone.

Vladimir Sementsov-Ogievskiy (3):
  tests/funtional: add test_virtio_status.py
  qapi/virtio: Restore backend features in x-query-virtio-status
  qapi/monitor: Handle missing vhost-user protocol features

 MAINTAINERS                                   |  1 +
 hw/virtio/virtio-hmp-cmds.c                   |  6 +-
 hw/virtio/virtio-qmp.c                        |  2 +
 qapi/virtio.json                              |  5 +-
 tests/functional/qemu_test/testcase.py        |  9 +-
 tests/functional/x86_64/meson.build           |  2 +
 tests/functional/x86_64/test_virtio_status.py | 95 +++++++++++++++++++
 7 files changed, 112 insertions(+), 8 deletions(-)
 create mode 100755 tests/functional/x86_64/test_virtio_status.py

-- 
2.43.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] tests/funtional: add test_virtio_status.py
  2026-09-22 21:32 [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
@ 2026-09-22 21:32 ` Vladimir Sementsov-Ogievskiy
  2026-10-28 16:21   ` Michael S. Tsirkin
  2026-09-22 21:32 ` [PATCH 2/3] qapi/virtio: Restore backend features in x-query-virtio-status Vladimir Sementsov-Ogievskiy
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-09-22 21:32 UTC (permalink / raw)
  To: mst
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, vsementsov, qemu-stable

Add test that run x-query-virtio-status QMP command, and its
HMP analog.

Now QEMU crashes in these scenarios due to bugs, so the test-cases
are skipped. You may run them by setting QEMU_FAILING_TESTS
environment variable.

Following commits will fix bug and enable the test-cases.

Wrap QEMU run by "unshare" to access vhost-net without sudo.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 MAINTAINERS                                   |  1 +
 tests/functional/qemu_test/testcase.py        |  9 +-
 tests/functional/x86_64/meson.build           |  2 +
 tests/functional/x86_64/test_virtio_status.py | 97 +++++++++++++++++++
 4 files changed, 105 insertions(+), 4 deletions(-)
 create mode 100755 tests/functional/x86_64/test_virtio_status.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 6be9c5725b9..8bd7c8472d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2535,6 +2535,7 @@ F: include/hw/virtio/
 F: docs/devel/virtio*
 F: docs/devel/migration/virtio.rst
 F: tests/functional/x86_64/test_virtio_version.py
+F: tests/functional/x86_64/test_virtio_status.py
 
 virtio-balloon
 M: Michael S. Tsirkin <mst@redhat.com>
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index bf2dc1dc101..d719b79eb1e 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -387,12 +387,13 @@ def require_device(self, devicename):
         if helptxt.find(devicename) < 0:
             self.skipTest('no support for device ' + devicename)
 
-    def _new_vm(self, name, monitor_address):
+    def _new_vm(self, name, monitor_address, wrapper):
         vm = QEMUMachine(self.qemu_bin,
                          name=name,
                          base_temp_dir=self.workdir,
                          log_dir=self.log_file(),
-                         monitor_address=monitor_address)
+                         monitor_address=monitor_address,
+                         wrapper=wrapper)
         self.log.debug('QEMUMachine "%s" created', name)
         self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
 
@@ -407,11 +408,11 @@ def _new_vm(self, name, monitor_address):
     def vm(self):
         return self.get_vm(name='default')
 
-    def get_vm(self, name=None, monitor_address=None):
+    def get_vm(self, name=None, monitor_address=None, wrapper=()):
         if not name:
             name = str(uuid.uuid4())
         if self._vms.get(name) is None:
-            self._vms[name] = self._new_vm(name, monitor_address)
+            self._vms[name] = self._new_vm(name, monitor_address, wrapper)
             if self.cpu is not None:
                 self._vms[name].add_args('-cpu', self.cpu)
             if self.machine is not None:
diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
index 0353b2af8e1..62dedb2e203 100644
--- a/tests/functional/x86_64/meson.build
+++ b/tests/functional/x86_64/meson.build
@@ -7,6 +7,7 @@ test_x86_64_timeouts = {
   'netdev_ethtool' : 180,
   'replay' : 480,
   'virtio_balloon': 120,
+  'virtio_status': 120,
 }
 
 tests_x86_64_system_quick = [
@@ -50,5 +51,6 @@ tests_x86_64_system_thorough = [
   'vhost_user_bridge',
   'virtio_balloon',
   'virtio_gpu',
+  'virtio_status',
   'rebuild_vmfd',
 ]
diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
new file mode 100755
index 00000000000..c8cbdf7c42e
--- /dev/null
+++ b/tests/functional/x86_64/test_virtio_status.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: MIT
+
+import os
+import subprocess
+
+from qemu_test import (
+    Asset,
+    LinuxKernelTest,
+    skipIfMissingCommands,
+    skipIfMissingEnv,
+)
+
+
+class VirtioStatus(LinuxKernelTest):
+    ASSET_KERNEL = Asset(
+        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
+        "netboot-3.24.2/vmlinuz-virt",
+        "be8ae7782de532d1a791c97fbf9ddc955b9de78349382ad097c83ffe9db857f4")
+    ASSET_INITRD = Asset(
+        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
+        "netboot-3.24.2/initramfs-virt",
+        "385418a99b17c0ef44947d88ea448d43b2df4a2c3343da72e724c6cf3b05e9f7")
+
+    VIRTIO_PATH = "/machine/peripheral/net0/virtio-backend"
+
+    def setUp(self):
+        super().setUp()
+        self.qemu_wrapper = []
+        self.require_accelerator("kvm")
+        self.require_device("virtio-net-pci")
+        self.set_machine("q35")
+
+    def has_hmp(self, vm):
+        commands = vm.cmd('query-commands')
+        return any(cmd['name'] == 'human-monitor-command' for cmd in commands)
+
+    def check_commands(self, vm):
+        if self.has_hmp(vm):
+            vm.cmd(
+                "human-monitor-command",
+                command_line="info virtio-status " + self.VIRTIO_PATH,
+            )
+        vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
+
+    @skipIfMissingCommands("unshare")
+    @skipIfMissingEnv("QEMU_FAILING_TESTS")
+    def test_vhost(self):
+        self.require_netdev("tap")
+        for device in ("/dev/net/tun", "/dev/vhost-net"):
+            if not os.access(device, os.R_OK | os.W_OK):
+                self.skipTest(f"Read/write access to {device} is required")
+
+        wrapper = ["unshare", "-Urn", "--"]
+        probe = subprocess.run(wrapper + ["true"],
+                               capture_output=True,
+                               text=True, check=False)
+        if probe.returncode:
+            self.skipTest("User/network namespaces unavailable: " +
+                          probe.stderr.strip())
+
+        vm = self.get_vm("wrapped", wrapper=wrapper)
+
+        kernel = self.ASSET_KERNEL.fetch()
+        initrd = self.ASSET_INITRD.fetch()
+
+        vm.set_console()
+        vm.add_args("-accel", "kvm")
+        vm.add_args("-kernel", kernel,
+                    "-initrd", initrd,
+                    "-append", "console=ttyS0 modules=virtio_net",
+                    "-netdev",
+                    "tap,id=net,script=,downscript=,vhost=on",
+                    "-device",
+                    "virtio-net-pci,id=net0,netdev=net,romfile=")
+        vm.launch()
+
+        # modules=virtio_net ensures the driver is loaded by this point
+        self.wait_for_console_pattern("Loading boot drivers: ok.", vm=vm)
+        vm.cmd(
+            "x-query-virtio-vhost-queue-status", path=self.VIRTIO_PATH, queue=0
+        )
+
+        self.check_commands(vm)
+
+    @skipIfMissingEnv("QEMU_FAILING_TESTS")
+    def test_no_vhost(self):
+        self.vm.add_args("-accel", "kvm",
+                         "-S", "-net", "none", "-device",
+                         "virtio-net-pci,id=net0,romfile=")
+        self.vm.launch()
+        self.check_commands(self.vm)
+
+
+if __name__ == "__main__":
+    LinuxKernelTest.main()
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] qapi/virtio: Restore backend features in x-query-virtio-status
  2026-09-22 21:32 [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
  2026-09-22 21:32 ` [PATCH 1/3] tests/funtional: add test_virtio_status.py Vladimir Sementsov-Ogievskiy
@ 2026-09-22 21:32 ` Vladimir Sementsov-Ogievskiy
  2026-09-22 21:32 ` [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features Vladimir Sementsov-Ogievskiy
  2026-10-06 10:00 ` [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
  3 siblings, 0 replies; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-09-22 21:32 UTC (permalink / raw)
  To: mst
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, vsementsov, qemu-stable

Commit 1ee0bc0c9bf0 removed vhost_dev.backend_features and its
representation in VhostStatus. It also removed the assignment to
VirtioStatus.backend_features, although both that field and its source,
VirtIODevice.backend_features_ex, still exist.

The resulting NULL pointer causes HMP info virtio-status and QMP
x-query-virtio-status to crash. This affects virtio devices even without
an active vhost backend.

Restore the assignment from VirtIODevice.backend_features_ex and
enable corresponding test, which becomes fixed.

Fixes: 1ee0bc0c9bf0 ("vhost: drop backend_features field")
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/virtio/virtio-qmp.c                        | 2 ++
 tests/functional/x86_64/test_virtio_status.py | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index 5aaeebdd96a..8b7cd7a3106 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -713,6 +713,8 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)
                                                  vdev->guest_features_ex);
     status->host_features = qmp_decode_features(vdev->device_id,
                                                 vdev->host_features_ex);
+    status->backend_features = qmp_decode_features(vdev->device_id,
+                                                   vdev->backend_features_ex);
 
     switch (vdev->device_endian) {
     case VIRTIO_DEVICE_ENDIAN_LITTLE:
diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
index c8cbdf7c42e..1e72c713cc6 100755
--- a/tests/functional/x86_64/test_virtio_status.py
+++ b/tests/functional/x86_64/test_virtio_status.py
@@ -84,7 +84,6 @@ def test_vhost(self):
 
         self.check_commands(vm)
 
-    @skipIfMissingEnv("QEMU_FAILING_TESTS")
     def test_no_vhost(self):
         self.vm.add_args("-accel", "kvm",
                          "-S", "-net", "none", "-device",
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features
  2026-09-22 21:32 [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
  2026-09-22 21:32 ` [PATCH 1/3] tests/funtional: add test_virtio_status.py Vladimir Sementsov-Ogievskiy
  2026-09-22 21:32 ` [PATCH 2/3] qapi/virtio: Restore backend features in x-query-virtio-status Vladimir Sementsov-Ogievskiy
@ 2026-09-22 21:32 ` Vladimir Sementsov-Ogievskiy
  2026-09-28 13:07   ` Markus Armbruster
  2026-10-06 10:00 ` [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
  3 siblings, 1 reply; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-09-22 21:32 UTC (permalink / raw)
  To: mst
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, vsementsov, qemu-stable, Nikolay Kuratov

Commit f9a8f5812607 moved protocol_features to the vhost-user backend.
As a result, VhostStatus.protocol_features is only populated for
vhost-user devices.

For an active kernel vhost device, HMP info virtio-status and QMP
x-query-virtio-status crashes now because of unset protocol-features.

Make protocol-features optional in VhostStatus and skip dumping a
missing object in HMP.

For QMP we can change the x-query-virtio-status command semantics
because it is unstable.

Enable corresponding test, it works now.

Fixes: f9a8f5812607 ("vhost: move protocol_features to vhost_user")
Co-authored-by: Nikolay Kuratov <kniv@yandex-team.ru>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/virtio/virtio-hmp-cmds.c                   | 6 ++++--
 qapi/virtio.json                              | 5 +++--
 tests/functional/x86_64/test_virtio_status.py | 1 -
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/virtio/virtio-hmp-cmds.c b/hw/virtio/virtio-hmp-cmds.c
index e5da6f00699..5b08a06ec42 100644
--- a/hw/virtio/virtio-hmp-cmds.c
+++ b/hw/virtio/virtio-hmp-cmds.c
@@ -176,8 +176,10 @@ void hmp_virtio_status(MonitorHMP *hmp, const QDict *qdict)
         hmp_virtio_dump_features(hmp, s->vhost_dev->features);
         monitor_hmp_printf(hmp, "    Acked features:\n");
         hmp_virtio_dump_features(hmp, s->vhost_dev->acked_features);
-        monitor_hmp_printf(hmp, "    Protocol features:\n");
-        hmp_virtio_dump_protocols(hmp, s->vhost_dev->protocol_features);
+        if (s->vhost_dev->protocol_features) {
+            monitor_hmp_printf(hmp, "    Protocol features:\n");
+            hmp_virtio_dump_protocols(hmp, s->vhost_dev->protocol_features);
+        }
     }
 
     qapi_free_VirtioStatus(s);
diff --git a/qapi/virtio.json b/qapi/virtio.json
index 1fc4e38a44d..f8e699a0e4e 100644
--- a/qapi/virtio.json
+++ b/qapi/virtio.json
@@ -85,7 +85,8 @@
 #
 # @acked-features: vhost_dev acked_features
 #
-# @protocol-features: vhost_dev protocol_features
+# @protocol-features: vhost-user protocol features.  Present only for
+#     vhost-user devices.
 #
 # @max-queues: vhost_dev max_queues
 #
@@ -104,7 +105,7 @@
             'vq-index': 'int',
             'features': 'VirtioDeviceFeatures',
             'acked-features': 'VirtioDeviceFeatures',
-            'protocol-features': 'VhostDeviceProtocols',
+            '*protocol-features': 'VhostDeviceProtocols',
             'max-queues': 'uint64',
             'backend-cap': 'uint64',
             'log-enabled': 'bool',
diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
index 1e72c713cc6..a88823004f8 100755
--- a/tests/functional/x86_64/test_virtio_status.py
+++ b/tests/functional/x86_64/test_virtio_status.py
@@ -45,7 +45,6 @@ def check_commands(self, vm):
         vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
 
     @skipIfMissingCommands("unshare")
-    @skipIfMissingEnv("QEMU_FAILING_TESTS")
     def test_vhost(self):
         self.require_netdev("tap")
         for device in ("/dev/net/tun", "/dev/vhost-net"):
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features
  2026-09-22 21:32 ` [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features Vladimir Sementsov-Ogievskiy
@ 2026-09-28 13:07   ` Markus Armbruster
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Armbruster @ 2026-09-28 13:07 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: mst, eblake, th.huth+qemu, philmd, berrange, pbonzini, zhao1.liu,
	qemu-devel, qemu-stable, Nikolay Kuratov

Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:

> Commit f9a8f5812607 moved protocol_features to the vhost-user backend.
> As a result, VhostStatus.protocol_features is only populated for
> vhost-user devices.
>
> For an active kernel vhost device, HMP info virtio-status and QMP
> x-query-virtio-status crashes now because of unset protocol-features.
>
> Make protocol-features optional in VhostStatus and skip dumping a
> missing object in HMP.
>
> For QMP we can change the x-query-virtio-status command semantics
> because it is unstable.

Suggest

  This is a compatibility break.  Okay, since VhostStatus is only used
  by x-query-virtio-status, which is unstable.

> Enable corresponding test, it works now.
>
> Fixes: f9a8f5812607 ("vhost: move protocol_features to vhost_user")
> Co-authored-by: Nikolay Kuratov <kniv@yandex-team.ru>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  hw/virtio/virtio-hmp-cmds.c                   | 6 ++++--
>  qapi/virtio.json                              | 5 +++--
>  tests/functional/x86_64/test_virtio_status.py | 1 -
>  3 files changed, 7 insertions(+), 5 deletions(-)
>

The actual bug is in qmp_x_query_virtio_status(), which can leave
status->vhost_dev->protocol null:

           if (hdev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {
               vhost_user_qmp_status(hdev, status);
           }

A non-optional struct pointer must not be null.  I believe the visitor
detects this programming error and crashes.

An optional struct pointer may be null: it means "absent".  Making the
struct optional fixes the crash.

> diff --git a/hw/virtio/virtio-hmp-cmds.c b/hw/virtio/virtio-hmp-cmds.c
> index e5da6f00699..5b08a06ec42 100644
> --- a/hw/virtio/virtio-hmp-cmds.c
> +++ b/hw/virtio/virtio-hmp-cmds.c
> @@ -176,8 +176,10 @@ void hmp_virtio_status(MonitorHMP *hmp, const QDict *qdict)
>          hmp_virtio_dump_features(hmp, s->vhost_dev->features);
>          monitor_hmp_printf(hmp, "    Acked features:\n");
>          hmp_virtio_dump_features(hmp, s->vhost_dev->acked_features);
> -        monitor_hmp_printf(hmp, "    Protocol features:\n");
> -        hmp_virtio_dump_protocols(hmp, s->vhost_dev->protocol_features);
> +        if (s->vhost_dev->protocol_features) {
> +            monitor_hmp_printf(hmp, "    Protocol features:\n");
> +            hmp_virtio_dump_protocols(hmp, s->vhost_dev->protocol_features);
> +        }

This isn't the bug fix, it's the adjustment for optional, as you write
in the commit message.

>      }
>  
>      qapi_free_VirtioStatus(s);
> diff --git a/qapi/virtio.json b/qapi/virtio.json
> index 1fc4e38a44d..f8e699a0e4e 100644
> --- a/qapi/virtio.json
> +++ b/qapi/virtio.json
> @@ -85,7 +85,8 @@
>  #
>  # @acked-features: vhost_dev acked_features
>  #
> -# @protocol-features: vhost_dev protocol_features
> +# @protocol-features: vhost-user protocol features.  Present only for
> +#     vhost-user devices.
>  #
>  # @max-queues: vhost_dev max_queues
>  #
> @@ -104,7 +105,7 @@
>              'vq-index': 'int',
>              'features': 'VirtioDeviceFeatures',
>              'acked-features': 'VirtioDeviceFeatures',
> -            'protocol-features': 'VhostDeviceProtocols',
> +            '*protocol-features': 'VhostDeviceProtocols',
>              'max-queues': 'uint64',
>              'backend-cap': 'uint64',
>              'log-enabled': 'bool',
> diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
> index 1e72c713cc6..a88823004f8 100755
> --- a/tests/functional/x86_64/test_virtio_status.py
> +++ b/tests/functional/x86_64/test_virtio_status.py
> @@ -45,7 +45,6 @@ def check_commands(self, vm):
>          vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
>  
>      @skipIfMissingCommands("unshare")
> -    @skipIfMissingEnv("QEMU_FAILING_TESTS")
>      def test_vhost(self):
>          self.require_netdev("tap")
>          for device in ("/dev/net/tun", "/dev/vhost-net"):

Reviewed-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] virtio: two fixes
  2026-09-22 21:32 [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
                   ` (2 preceding siblings ...)
  2026-09-22 21:32 ` [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features Vladimir Sementsov-Ogievskiy
@ 2026-10-06 10:00 ` Vladimir Sementsov-Ogievskiy
  3 siblings, 0 replies; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-10-06 10:00 UTC (permalink / raw)
  To: mst
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, qemu-stable

ping

On 23.09.26 00:32, Vladimir Sementsov-Ogievskiy wrote:
> Hi all! There two fixes for my old patches. I apologize if
> this affected anyone.
> 
> Vladimir Sementsov-Ogievskiy (3):
>    tests/funtional: add test_virtio_status.py
>    qapi/virtio: Restore backend features in x-query-virtio-status
>    qapi/monitor: Handle missing vhost-user protocol features
> 
>   MAINTAINERS                                   |  1 +
>   hw/virtio/virtio-hmp-cmds.c                   |  6 +-
>   hw/virtio/virtio-qmp.c                        |  2 +
>   qapi/virtio.json                              |  5 +-
>   tests/functional/qemu_test/testcase.py        |  9 +-
>   tests/functional/x86_64/meson.build           |  2 +
>   tests/functional/x86_64/test_virtio_status.py | 95 +++++++++++++++++++
>   7 files changed, 112 insertions(+), 8 deletions(-)
>   create mode 100755 tests/functional/x86_64/test_virtio_status.py
> 


-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] tests/funtional: add test_virtio_status.py
  2026-09-22 21:32 ` [PATCH 1/3] tests/funtional: add test_virtio_status.py Vladimir Sementsov-Ogievskiy
@ 2026-10-28 16:21   ` Michael S. Tsirkin
  2026-10-28 20:05     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2026-10-28 16:21 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, qemu-stable

Typo in the subject

On Wed, Sep 23, 2026 at 12:32:08AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Add test that run x-query-virtio-status QMP command, and its
> HMP analog.
> 
> Now QEMU crashes in these scenarios due to bugs, so the test-cases
> are skipped. You may run them by setting QEMU_FAILING_TESTS
> environment variable.
> 
> Following commits will fix bug and enable the test-cases.
> 
> Wrap QEMU run by "unshare" to access vhost-net without sudo.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  MAINTAINERS                                   |  1 +
>  tests/functional/qemu_test/testcase.py        |  9 +-
>  tests/functional/x86_64/meson.build           |  2 +
>  tests/functional/x86_64/test_virtio_status.py | 97 +++++++++++++++++++
>  4 files changed, 105 insertions(+), 4 deletions(-)
>  create mode 100755 tests/functional/x86_64/test_virtio_status.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6be9c5725b9..8bd7c8472d9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2535,6 +2535,7 @@ F: include/hw/virtio/
>  F: docs/devel/virtio*
>  F: docs/devel/migration/virtio.rst
>  F: tests/functional/x86_64/test_virtio_version.py
> +F: tests/functional/x86_64/test_virtio_status.py
>  
>  virtio-balloon
>  M: Michael S. Tsirkin <mst@redhat.com>
> diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> index bf2dc1dc101..d719b79eb1e 100644
> --- a/tests/functional/qemu_test/testcase.py
> +++ b/tests/functional/qemu_test/testcase.py
> @@ -387,12 +387,13 @@ def require_device(self, devicename):
>          if helptxt.find(devicename) < 0:
>              self.skipTest('no support for device ' + devicename)
>  
> -    def _new_vm(self, name, monitor_address):
> +    def _new_vm(self, name, monitor_address, wrapper):
>          vm = QEMUMachine(self.qemu_bin,
>                           name=name,
>                           base_temp_dir=self.workdir,
>                           log_dir=self.log_file(),
> -                         monitor_address=monitor_address)
> +                         monitor_address=monitor_address,
> +                         wrapper=wrapper)
>          self.log.debug('QEMUMachine "%s" created', name)
>          self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
>  
> @@ -407,11 +408,11 @@ def _new_vm(self, name, monitor_address):
>      def vm(self):
>          return self.get_vm(name='default')
>  
> -    def get_vm(self, name=None, monitor_address=None):
> +    def get_vm(self, name=None, monitor_address=None, wrapper=()):
>          if not name:
>              name = str(uuid.uuid4())
>          if self._vms.get(name) is None:
> -            self._vms[name] = self._new_vm(name, monitor_address)
> +            self._vms[name] = self._new_vm(name, monitor_address, wrapper)
>              if self.cpu is not None:
>                  self._vms[name].add_args('-cpu', self.cpu)
>              if self.machine is not None:
> diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
> index 0353b2af8e1..62dedb2e203 100644
> --- a/tests/functional/x86_64/meson.build
> +++ b/tests/functional/x86_64/meson.build
> @@ -7,6 +7,7 @@ test_x86_64_timeouts = {
>    'netdev_ethtool' : 180,
>    'replay' : 480,
>    'virtio_balloon': 120,
> +  'virtio_status': 120,
>  }
>  
>  tests_x86_64_system_quick = [
> @@ -50,5 +51,6 @@ tests_x86_64_system_thorough = [
>    'vhost_user_bridge',
>    'virtio_balloon',
>    'virtio_gpu',
> +  'virtio_status',
>    'rebuild_vmfd',
>  ]
> diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
> new file mode 100755
> index 00000000000..c8cbdf7c42e
> --- /dev/null
> +++ b/tests/functional/x86_64/test_virtio_status.py
> @@ -0,0 +1,97 @@
> +#!/usr/bin/env python3
> +#
> +# SPDX-License-Identifier: MIT

QEMU uses GPL v2.0 or later.

> +
> +import os
> +import subprocess
> +
> +from qemu_test import (
> +    Asset,
> +    LinuxKernelTest,
> +    skipIfMissingCommands,
> +    skipIfMissingEnv,
> +)
> +
> +
> +class VirtioStatus(LinuxKernelTest):
> +    ASSET_KERNEL = Asset(
> +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
> +        "netboot-3.24.2/vmlinuz-virt",
> +        "be8ae7782de532d1a791c97fbf9ddc955b9de78349382ad097c83ffe9db857f4")
> +    ASSET_INITRD = Asset(
> +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
> +        "netboot-3.24.2/initramfs-virt",
> +        "385418a99b17c0ef44947d88ea448d43b2df4a2c3343da72e724c6cf3b05e9f7")
> +
> +    VIRTIO_PATH = "/machine/peripheral/net0/virtio-backend"
> +
> +    def setUp(self):
> +        super().setUp()
> +        self.qemu_wrapper = []
> +        self.require_accelerator("kvm")
> +        self.require_device("virtio-net-pci")
> +        self.set_machine("q35")
> +
> +    def has_hmp(self, vm):
> +        commands = vm.cmd('query-commands')
> +        return any(cmd['name'] == 'human-monitor-command' for cmd in commands)
> +
> +    def check_commands(self, vm):
> +        if self.has_hmp(vm):
> +            vm.cmd(
> +                "human-monitor-command",
> +                command_line="info virtio-status " + self.VIRTIO_PATH,
> +            )
> +        vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
> +
> +    @skipIfMissingCommands("unshare")
> +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
> +    def test_vhost(self):
> +        self.require_netdev("tap")
> +        for device in ("/dev/net/tun", "/dev/vhost-net"):
> +            if not os.access(device, os.R_OK | os.W_OK):
> +                self.skipTest(f"Read/write access to {device} is required")
> +
> +        wrapper = ["unshare", "-Urn", "--"]
> +        probe = subprocess.run(wrapper + ["true"],
> +                               capture_output=True,
> +                               text=True, check=False)
> +        if probe.returncode:
> +            self.skipTest("User/network namespaces unavailable: " +
> +                          probe.stderr.strip())
> +
> +        vm = self.get_vm("wrapped", wrapper=wrapper)
> +
> +        kernel = self.ASSET_KERNEL.fetch()
> +        initrd = self.ASSET_INITRD.fetch()
> +
> +        vm.set_console()
> +        vm.add_args("-accel", "kvm")
> +        vm.add_args("-kernel", kernel,
> +                    "-initrd", initrd,
> +                    "-append", "console=ttyS0 modules=virtio_net",
> +                    "-netdev",
> +                    "tap,id=net,script=,downscript=,vhost=on",
> +                    "-device",
> +                    "virtio-net-pci,id=net0,netdev=net,romfile=")
> +        vm.launch()
> +
> +        # modules=virtio_net ensures the driver is loaded by this point
> +        self.wait_for_console_pattern("Loading boot drivers: ok.", vm=vm)
> +        vm.cmd(
> +            "x-query-virtio-vhost-queue-status", path=self.VIRTIO_PATH, queue=0
> +        )
> +
> +        self.check_commands(vm)
> +
> +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
> +    def test_no_vhost(self):
> +        self.vm.add_args("-accel", "kvm",
> +                         "-S", "-net", "none", "-device",
> +                         "virtio-net-pci,id=net0,romfile=")
> +        self.vm.launch()
> +        self.check_commands(self.vm)
> +
> +
> +if __name__ == "__main__":
> +    LinuxKernelTest.main()
> -- 
> 2.43.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] tests/funtional: add test_virtio_status.py
  2026-10-28 16:21   ` Michael S. Tsirkin
@ 2026-10-28 20:05     ` Vladimir Sementsov-Ogievskiy
  2026-10-28 20:16       ` Michael S. Tsirkin
  0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-10-28 20:05 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, qemu-stable

On 28.10.26 19:21, Michael S. Tsirkin wrote:
> Typo in the subject
> 
> On Wed, Sep 23, 2026 at 12:32:08AM +0300, Vladimir Sementsov-Ogievskiy wrote:
>> Add test that run x-query-virtio-status QMP command, and its
>> HMP analog.
>>
>> Now QEMU crashes in these scenarios due to bugs, so the test-cases
>> are skipped. You may run them by setting QEMU_FAILING_TESTS
>> environment variable.
>>
>> Following commits will fix bug and enable the test-cases.
>>
>> Wrap QEMU run by "unshare" to access vhost-net without sudo.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   MAINTAINERS                                   |  1 +
>>   tests/functional/qemu_test/testcase.py        |  9 +-
>>   tests/functional/x86_64/meson.build           |  2 +
>>   tests/functional/x86_64/test_virtio_status.py | 97 +++++++++++++++++++
>>   4 files changed, 105 insertions(+), 4 deletions(-)
>>   create mode 100755 tests/functional/x86_64/test_virtio_status.py
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 6be9c5725b9..8bd7c8472d9 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -2535,6 +2535,7 @@ F: include/hw/virtio/
>>   F: docs/devel/virtio*
>>   F: docs/devel/migration/virtio.rst
>>   F: tests/functional/x86_64/test_virtio_version.py
>> +F: tests/functional/x86_64/test_virtio_status.py
>>   
>>   virtio-balloon
>>   M: Michael S. Tsirkin <mst@redhat.com>
>> diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
>> index bf2dc1dc101..d719b79eb1e 100644
>> --- a/tests/functional/qemu_test/testcase.py
>> +++ b/tests/functional/qemu_test/testcase.py
>> @@ -387,12 +387,13 @@ def require_device(self, devicename):
>>           if helptxt.find(devicename) < 0:
>>               self.skipTest('no support for device ' + devicename)
>>   
>> -    def _new_vm(self, name, monitor_address):
>> +    def _new_vm(self, name, monitor_address, wrapper):
>>           vm = QEMUMachine(self.qemu_bin,
>>                            name=name,
>>                            base_temp_dir=self.workdir,
>>                            log_dir=self.log_file(),
>> -                         monitor_address=monitor_address)
>> +                         monitor_address=monitor_address,
>> +                         wrapper=wrapper)
>>           self.log.debug('QEMUMachine "%s" created', name)
>>           self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
>>   
>> @@ -407,11 +408,11 @@ def _new_vm(self, name, monitor_address):
>>       def vm(self):
>>           return self.get_vm(name='default')
>>   
>> -    def get_vm(self, name=None, monitor_address=None):
>> +    def get_vm(self, name=None, monitor_address=None, wrapper=()):
>>           if not name:
>>               name = str(uuid.uuid4())
>>           if self._vms.get(name) is None:
>> -            self._vms[name] = self._new_vm(name, monitor_address)
>> +            self._vms[name] = self._new_vm(name, monitor_address, wrapper)
>>               if self.cpu is not None:
>>                   self._vms[name].add_args('-cpu', self.cpu)
>>               if self.machine is not None:
>> diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
>> index 0353b2af8e1..62dedb2e203 100644
>> --- a/tests/functional/x86_64/meson.build
>> +++ b/tests/functional/x86_64/meson.build
>> @@ -7,6 +7,7 @@ test_x86_64_timeouts = {
>>     'netdev_ethtool' : 180,
>>     'replay' : 480,
>>     'virtio_balloon': 120,
>> +  'virtio_status': 120,
>>   }
>>   
>>   tests_x86_64_system_quick = [
>> @@ -50,5 +51,6 @@ tests_x86_64_system_thorough = [
>>     'vhost_user_bridge',
>>     'virtio_balloon',
>>     'virtio_gpu',
>> +  'virtio_status',
>>     'rebuild_vmfd',
>>   ]
>> diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
>> new file mode 100755
>> index 00000000000..c8cbdf7c42e
>> --- /dev/null
>> +++ b/tests/functional/x86_64/test_virtio_status.py
>> @@ -0,0 +1,97 @@
>> +#!/usr/bin/env python3
>> +#
>> +# SPDX-License-Identifier: MIT
> 
> QEMU uses GPL v2.0 or later.

Hmm, but there are files with "SPDX-License-Identifier: MIT".. Is there a generic requirement somewhere?

I just wanted to create less problems for people, after this https://lore.kernel.org/qemu-devel/f88e2d78-68c3-4c56-9d3b-4deba3c49b20@oracle.com/ story.

If you still prefer GPL v2.0, I don't care, let's switch. Should I resend this patch alone?

> 
>> +
>> +import os
>> +import subprocess
>> +
>> +from qemu_test import (
>> +    Asset,
>> +    LinuxKernelTest,
>> +    skipIfMissingCommands,
>> +    skipIfMissingEnv,
>> +)
>> +
>> +
>> +class VirtioStatus(LinuxKernelTest):
>> +    ASSET_KERNEL = Asset(
>> +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
>> +        "netboot-3.24.2/vmlinuz-virt",
>> +        "be8ae7782de532d1a791c97fbf9ddc955b9de78349382ad097c83ffe9db857f4")
>> +    ASSET_INITRD = Asset(
>> +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
>> +        "netboot-3.24.2/initramfs-virt",
>> +        "385418a99b17c0ef44947d88ea448d43b2df4a2c3343da72e724c6cf3b05e9f7")
>> +
>> +    VIRTIO_PATH = "/machine/peripheral/net0/virtio-backend"
>> +
>> +    def setUp(self):
>> +        super().setUp()
>> +        self.qemu_wrapper = []
>> +        self.require_accelerator("kvm")
>> +        self.require_device("virtio-net-pci")
>> +        self.set_machine("q35")
>> +
>> +    def has_hmp(self, vm):
>> +        commands = vm.cmd('query-commands')
>> +        return any(cmd['name'] == 'human-monitor-command' for cmd in commands)
>> +
>> +    def check_commands(self, vm):
>> +        if self.has_hmp(vm):
>> +            vm.cmd(
>> +                "human-monitor-command",
>> +                command_line="info virtio-status " + self.VIRTIO_PATH,
>> +            )
>> +        vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
>> +
>> +    @skipIfMissingCommands("unshare")
>> +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
>> +    def test_vhost(self):
>> +        self.require_netdev("tap")
>> +        for device in ("/dev/net/tun", "/dev/vhost-net"):
>> +            if not os.access(device, os.R_OK | os.W_OK):
>> +                self.skipTest(f"Read/write access to {device} is required")
>> +
>> +        wrapper = ["unshare", "-Urn", "--"]
>> +        probe = subprocess.run(wrapper + ["true"],
>> +                               capture_output=True,
>> +                               text=True, check=False)
>> +        if probe.returncode:
>> +            self.skipTest("User/network namespaces unavailable: " +
>> +                          probe.stderr.strip())
>> +
>> +        vm = self.get_vm("wrapped", wrapper=wrapper)
>> +
>> +        kernel = self.ASSET_KERNEL.fetch()
>> +        initrd = self.ASSET_INITRD.fetch()
>> +
>> +        vm.set_console()
>> +        vm.add_args("-accel", "kvm")
>> +        vm.add_args("-kernel", kernel,
>> +                    "-initrd", initrd,
>> +                    "-append", "console=ttyS0 modules=virtio_net",
>> +                    "-netdev",
>> +                    "tap,id=net,script=,downscript=,vhost=on",
>> +                    "-device",
>> +                    "virtio-net-pci,id=net0,netdev=net,romfile=")
>> +        vm.launch()
>> +
>> +        # modules=virtio_net ensures the driver is loaded by this point
>> +        self.wait_for_console_pattern("Loading boot drivers: ok.", vm=vm)
>> +        vm.cmd(
>> +            "x-query-virtio-vhost-queue-status", path=self.VIRTIO_PATH, queue=0
>> +        )
>> +
>> +        self.check_commands(vm)
>> +
>> +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
>> +    def test_no_vhost(self):
>> +        self.vm.add_args("-accel", "kvm",
>> +                         "-S", "-net", "none", "-device",
>> +                         "virtio-net-pci,id=net0,romfile=")
>> +        self.vm.launch()
>> +        self.check_commands(self.vm)
>> +
>> +
>> +if __name__ == "__main__":
>> +    LinuxKernelTest.main()
>> -- 
>> 2.43.0
> 


-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] tests/funtional: add test_virtio_status.py
  2026-10-28 20:05     ` Vladimir Sementsov-Ogievskiy
@ 2026-10-28 20:16       ` Michael S. Tsirkin
  0 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2026-10-28 20:16 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: eblake, armbru, th.huth+qemu, philmd, berrange, pbonzini,
	zhao1.liu, qemu-devel, qemu-stable

On Wed, Oct 28, 2026 at 11:05:53PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> On 28.10.26 19:21, Michael S. Tsirkin wrote:
> > Typo in the subject
> > 
> > On Wed, Sep 23, 2026 at 12:32:08AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > Add test that run x-query-virtio-status QMP command, and its
> > > HMP analog.
> > > 
> > > Now QEMU crashes in these scenarios due to bugs, so the test-cases
> > > are skipped. You may run them by setting QEMU_FAILING_TESTS
> > > environment variable.
> > > 
> > > Following commits will fix bug and enable the test-cases.
> > > 
> > > Wrap QEMU run by "unshare" to access vhost-net without sudo.
> > > 
> > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> > > ---
> > >   MAINTAINERS                                   |  1 +
> > >   tests/functional/qemu_test/testcase.py        |  9 +-
> > >   tests/functional/x86_64/meson.build           |  2 +
> > >   tests/functional/x86_64/test_virtio_status.py | 97 +++++++++++++++++++
> > >   4 files changed, 105 insertions(+), 4 deletions(-)
> > >   create mode 100755 tests/functional/x86_64/test_virtio_status.py
> > > 
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index 6be9c5725b9..8bd7c8472d9 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -2535,6 +2535,7 @@ F: include/hw/virtio/
> > >   F: docs/devel/virtio*
> > >   F: docs/devel/migration/virtio.rst
> > >   F: tests/functional/x86_64/test_virtio_version.py
> > > +F: tests/functional/x86_64/test_virtio_status.py
> > >   virtio-balloon
> > >   M: Michael S. Tsirkin <mst@redhat.com>
> > > diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> > > index bf2dc1dc101..d719b79eb1e 100644
> > > --- a/tests/functional/qemu_test/testcase.py
> > > +++ b/tests/functional/qemu_test/testcase.py
> > > @@ -387,12 +387,13 @@ def require_device(self, devicename):
> > >           if helptxt.find(devicename) < 0:
> > >               self.skipTest('no support for device ' + devicename)
> > > -    def _new_vm(self, name, monitor_address):
> > > +    def _new_vm(self, name, monitor_address, wrapper):
> > >           vm = QEMUMachine(self.qemu_bin,
> > >                            name=name,
> > >                            base_temp_dir=self.workdir,
> > >                            log_dir=self.log_file(),
> > > -                         monitor_address=monitor_address)
> > > +                         monitor_address=monitor_address,
> > > +                         wrapper=wrapper)
> > >           self.log.debug('QEMUMachine "%s" created', name)
> > >           self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
> > > @@ -407,11 +408,11 @@ def _new_vm(self, name, monitor_address):
> > >       def vm(self):
> > >           return self.get_vm(name='default')
> > > -    def get_vm(self, name=None, monitor_address=None):
> > > +    def get_vm(self, name=None, monitor_address=None, wrapper=()):
> > >           if not name:
> > >               name = str(uuid.uuid4())
> > >           if self._vms.get(name) is None:
> > > -            self._vms[name] = self._new_vm(name, monitor_address)
> > > +            self._vms[name] = self._new_vm(name, monitor_address, wrapper)
> > >               if self.cpu is not None:
> > >                   self._vms[name].add_args('-cpu', self.cpu)
> > >               if self.machine is not None:
> > > diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build
> > > index 0353b2af8e1..62dedb2e203 100644
> > > --- a/tests/functional/x86_64/meson.build
> > > +++ b/tests/functional/x86_64/meson.build
> > > @@ -7,6 +7,7 @@ test_x86_64_timeouts = {
> > >     'netdev_ethtool' : 180,
> > >     'replay' : 480,
> > >     'virtio_balloon': 120,
> > > +  'virtio_status': 120,
> > >   }
> > >   tests_x86_64_system_quick = [
> > > @@ -50,5 +51,6 @@ tests_x86_64_system_thorough = [
> > >     'vhost_user_bridge',
> > >     'virtio_balloon',
> > >     'virtio_gpu',
> > > +  'virtio_status',
> > >     'rebuild_vmfd',
> > >   ]
> > > diff --git a/tests/functional/x86_64/test_virtio_status.py b/tests/functional/x86_64/test_virtio_status.py
> > > new file mode 100755
> > > index 00000000000..c8cbdf7c42e
> > > --- /dev/null
> > > +++ b/tests/functional/x86_64/test_virtio_status.py
> > > @@ -0,0 +1,97 @@
> > > +#!/usr/bin/env python3
> > > +#
> > > +# SPDX-License-Identifier: MIT
> > 
> > QEMU uses GPL v2.0 or later.
> 
> Hmm, but there are files with "SPDX-License-Identifier: MIT".. Is there a generic requirement somewhere?
> 
> I just wanted to create less problems for people, after this https://lore.kernel.org/qemu-devel/f88e2d78-68c3-4c56-9d3b-4deba3c49b20@oracle.com/ story.

After a change from GPLv2 was rejected?


> If you still prefer GPL v2.0, I don't care, let's switch. Should I resend this patch alone?
> 
> > 
> > > +
> > > +import os
> > > +import subprocess
> > > +
> > > +from qemu_test import (
> > > +    Asset,
> > > +    LinuxKernelTest,
> > > +    skipIfMissingCommands,
> > > +    skipIfMissingEnv,
> > > +)
> > > +
> > > +
> > > +class VirtioStatus(LinuxKernelTest):
> > > +    ASSET_KERNEL = Asset(
> > > +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
> > > +        "netboot-3.24.2/vmlinuz-virt",
> > > +        "be8ae7782de532d1a791c97fbf9ddc955b9de78349382ad097c83ffe9db857f4")
> > > +    ASSET_INITRD = Asset(
> > > +        "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/"
> > > +        "netboot-3.24.2/initramfs-virt",
> > > +        "385418a99b17c0ef44947d88ea448d43b2df4a2c3343da72e724c6cf3b05e9f7")
> > > +
> > > +    VIRTIO_PATH = "/machine/peripheral/net0/virtio-backend"
> > > +
> > > +    def setUp(self):
> > > +        super().setUp()
> > > +        self.qemu_wrapper = []
> > > +        self.require_accelerator("kvm")
> > > +        self.require_device("virtio-net-pci")
> > > +        self.set_machine("q35")
> > > +
> > > +    def has_hmp(self, vm):
> > > +        commands = vm.cmd('query-commands')
> > > +        return any(cmd['name'] == 'human-monitor-command' for cmd in commands)
> > > +
> > > +    def check_commands(self, vm):
> > > +        if self.has_hmp(vm):
> > > +            vm.cmd(
> > > +                "human-monitor-command",
> > > +                command_line="info virtio-status " + self.VIRTIO_PATH,
> > > +            )
> > > +        vm.cmd("x-query-virtio-status", path=self.VIRTIO_PATH)
> > > +
> > > +    @skipIfMissingCommands("unshare")
> > > +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
> > > +    def test_vhost(self):
> > > +        self.require_netdev("tap")
> > > +        for device in ("/dev/net/tun", "/dev/vhost-net"):
> > > +            if not os.access(device, os.R_OK | os.W_OK):
> > > +                self.skipTest(f"Read/write access to {device} is required")
> > > +
> > > +        wrapper = ["unshare", "-Urn", "--"]
> > > +        probe = subprocess.run(wrapper + ["true"],
> > > +                               capture_output=True,
> > > +                               text=True, check=False)
> > > +        if probe.returncode:
> > > +            self.skipTest("User/network namespaces unavailable: " +
> > > +                          probe.stderr.strip())
> > > +
> > > +        vm = self.get_vm("wrapped", wrapper=wrapper)
> > > +
> > > +        kernel = self.ASSET_KERNEL.fetch()
> > > +        initrd = self.ASSET_INITRD.fetch()
> > > +
> > > +        vm.set_console()
> > > +        vm.add_args("-accel", "kvm")
> > > +        vm.add_args("-kernel", kernel,
> > > +                    "-initrd", initrd,
> > > +                    "-append", "console=ttyS0 modules=virtio_net",
> > > +                    "-netdev",
> > > +                    "tap,id=net,script=,downscript=,vhost=on",
> > > +                    "-device",
> > > +                    "virtio-net-pci,id=net0,netdev=net,romfile=")
> > > +        vm.launch()
> > > +
> > > +        # modules=virtio_net ensures the driver is loaded by this point
> > > +        self.wait_for_console_pattern("Loading boot drivers: ok.", vm=vm)
> > > +        vm.cmd(
> > > +            "x-query-virtio-vhost-queue-status", path=self.VIRTIO_PATH, queue=0
> > > +        )
> > > +
> > > +        self.check_commands(vm)
> > > +
> > > +    @skipIfMissingEnv("QEMU_FAILING_TESTS")
> > > +    def test_no_vhost(self):
> > > +        self.vm.add_args("-accel", "kvm",
> > > +                         "-S", "-net", "none", "-device",
> > > +                         "virtio-net-pci,id=net0,romfile=")
> > > +        self.vm.launch()
> > > +        self.check_commands(self.vm)
> > > +
> > > +
> > > +if __name__ == "__main__":
> > > +    LinuxKernelTest.main()
> > > -- 
> > > 2.43.0
> > 
> 
> 
> -- 
> Best regards,
> Vladimir



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-28 20:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22 21:32 [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy
2026-09-22 21:32 ` [PATCH 1/3] tests/funtional: add test_virtio_status.py Vladimir Sementsov-Ogievskiy
2026-10-28 16:21   ` Michael S. Tsirkin
2026-10-28 20:05     ` Vladimir Sementsov-Ogievskiy
2026-10-28 20:16       ` Michael S. Tsirkin
2026-09-22 21:32 ` [PATCH 2/3] qapi/virtio: Restore backend features in x-query-virtio-status Vladimir Sementsov-Ogievskiy
2026-09-22 21:32 ` [PATCH 3/3] qapi/monitor: Handle missing vhost-user protocol features Vladimir Sementsov-Ogievskiy
2026-09-28 13:07   ` Markus Armbruster
2026-10-06 10:00 ` [PATCH 0/3] virtio: two fixes Vladimir Sementsov-Ogievskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.