Skip to contentSkip to conversation

vfio queue

GIT PULL Applied Cédric Le Goater 2 participants 9 messages Dec 1

lore
Share & tools
lore
#1 lore raw

[PULL 4/7] tests/unit/test-qtree: Drop unused destroy counters

In reply to Cédric Le Goater

destroyed_key_count and destroyed_value_count have been incremented in the key and value destroy notifies since the QTree import (commit e3feb2cc224f) but never checked. clang 23 reports them as -Wunused-but-set-global:

../tests/unit/test-qtree.c:42:14: error: variable 'destroyed_key_count' set but not used [-Werror,-Wunused-but-set-global]
42 | static guint destroyed_key_count;
| ^
../tests/unit/test-qtree.c:43:14: error: variable 'destroyed_value_count' set but not used [-Werror,-Wunused-but-set-global]
43 | static guint destroyed_value_count;
| ^
2 errors generated.

---
 tests/unit/test-qtree.c | 4 ----
 1 file changed, 4 deletions(-)
tests/unit/test-qtree.c +0 -4
index 4d836d22c717..1f506ac72ef5 100644
@@ -39,19 +39,15 @@ static gint my_search(gconstpointer a, gconstpointer b)
 
 static gpointer destroyed_key;
 static gpointer destroyed_value;
-static guint destroyed_key_count;
-static guint destroyed_value_count;
 
 static void my_key_destroy(gpointer key)
 {
     destroyed_key = key;
-    destroyed_key_count++;
 }
 
 static void my_value_destroy(gpointer value)
 {
     destroyed_value = value;
-    destroyed_value_count++;
 }
 
 static gint my_traverse(gpointer key, gpointer value, gpointer data)
Signature · 1 line
2.56.1
#2 lore raw

[PULL 1/7] qemu-vmsr-helper: Actually drop privileges

In reply to Cédric Le Goater

The uid and gid parsed from -u/--user and -g/--group are never used. clang 23 reports them as -Wunused-but-set-global:

../tools/i386/qemu-vmsr-helper.c:59:12: error: variable 'uid' set but not used [-Werror,-Wunused-but-set-global]
59 | static int uid = -1;
| ^
../tools/i386/qemu-vmsr-helper.c:60:12: error: variable 'gid' set but not used [-Werror,-Wunused-but-set-global]
60 | static int gid = -1;
| ^
2 errors generated.

The warning hides a real bug: drop_privileges() never calls capng_apply() and never switches to the requested user. Call capng_change_id() before capng_apply() so CAP_SYS_RAWIO survives the uid change.

Fixes 84369d762127 ("tools: build qemu-vmsr-helper")
Cc Anthony Harivel <[email protected]>
---
 tools/i386/qemu-vmsr-helper.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/i386/qemu-vmsr-helper.c +10 -0
index f12fd3c3e816..7b65387f9938 100644
@@ -323,6 +323,16 @@ static int drop_privileges(void)
         return -1;
     }
 
+    if (uid != -1 || gid != -1) {
+        if (capng_change_id(uid, gid, CAPNG_DROP_SUPP_GRP) < 0) {
+            return -1;
+        }
+    }
+
+    if (capng_apply(CAPNG_SELECT_BOTH) != 0) {
+        return -1;
+    }
+
     return 0;
 }
 #endif
Signature · 1 line
2.56.1
#3 lore raw

[PULL 6/7] vfio/pci: Fix crash when BAR has zero size

In reply to Cédric Le Goater

When the host kernel fails to assign a BAR (broken BIOS "Above 4G Decoding" or ReBAR configuration), the VFIO kernel interface reports a zero size. In that case, vfio_region_setup() skips allocating region->mem, leaving it NULL.

Then, vfio_bar_quirk_setup() calls the BAR quirk probes and passes a NULL region->mem pointer to memory_region_add_subregion_overlap(), causing a segfault in memory_region_update_container_subregions().

Skip quirk setup in vfio_realize() for zero size regions.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2732

---
 hw/vfio/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/vfio/pci.c +3 -1
index 960786607779..cb7cc011fcca 100644
@@ -3658,7 +3658,9 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp)
     }
 
     for (i = 0; i < PCI_ROM_SLOT; i++) {
-        vfio_bar_quirk_setup(vdev, i);
+        if (vdev->bars[i].size) {
+            vfio_bar_quirk_setup(vdev, i);
+        }
     }
 
     if (!vfio_pci_interrupt_setup(vdev, errp)) {
Signature · 1 line
2.56.1
#4 lore raw

[PULL 5/7] tests/unit/test-rcu-list: Drop unused n_nodes/n_updates counters

In reply to Cédric Le Goater

n_nodes lost its last user when commit 8a5956ad6392 ("rcu tests: fix compilation on 32-bit ppc") dropped the "val" list member; n_updates was never read. clang 23 reports them as -Wunused-but-set-global:

../tests/unit/test-rcu-list.c:34:18: error: variable 'n_updates' set but not used [-Werror,-Wunused-but-set-global]
34 | static long long n_updates = 0LL;
| ^
../tests/unit/test-rcu-list.c:37:18: error: variable 'n_nodes' set but not used [-Werror,-Wunused-but-set-global]
37 | static long long n_nodes = 0LL;
| ^
2 errors generated.

Remove both globals and the local accumulators feeding them.

---
 tests/unit/test-rcu-list.c | 11 -----------
 1 file changed, 11 deletions(-)
tests/unit/test-rcu-list.c +0 -11
index 8dde3e61a84b..e0c2778d47db 100644
@@ -31,10 +31,8 @@
 
 static QemuMutex counts_mutex;
 static long long n_reads = 0LL;
-static long long n_updates = 0LL;
 static int64_t n_reclaims;
 static int64_t n_nodes_removed;
-static long long n_nodes = 0LL;
 static int g_test_in_charge = 0;
 
 static int nthreadsrunning;
@@ -200,8 +198,6 @@ static void *rcu_q_reader(void *arg)
 static void *rcu_q_updater(void *arg)
 {
     int j, target_el;
-    long long n_nodes_local = 0;
-    long long n_updates_local = 0;
     long long n_removed_local = 0;
     struct list_element *el, *prev_el;
 
@@ -234,19 +230,15 @@ static void *rcu_q_updater(void *arg)
             j++;
             if (target_el == j) {
                 struct list_element *new_el = g_new(struct list_element, 1);
-                n_nodes_local++;
                 TEST_LIST_INSERT_AFTER_RCU(el, new_el, entry);
                 break;
             }
         }
 
-        n_updates_local += 2;
         synchronize_rcu();
     }
     synchronize_rcu();
     qemu_mutex_lock(&counts_mutex);
-    n_nodes += n_nodes_local;
-    n_updates += n_updates_local;
     qatomic_set(&n_nodes_removed, n_nodes_removed + n_removed_local);
     qemu_mutex_unlock(&counts_mutex);
     return NULL;
@@ -262,9 +254,6 @@ static void rcu_qtest_init(void)
         new_el = g_new(struct list_element, 1);
         TEST_LIST_INSERT_HEAD_RCU(&Q_list_head, new_el, entry);
     }
-    qemu_mutex_lock(&counts_mutex);
-    n_nodes += RCU_Q_LEN;
-    qemu_mutex_unlock(&counts_mutex);
 }
 
 static void rcu_qtest_run(int duration, int nreaders)
Signature · 1 line
2.56.1
#5 lore raw

[PULL 3/7] tests/qtest/migration: Drop orphaned tmpfs global

In reply to Cédric Le Goater

tmpfs has no users left since the unix migration tests derive the socket path from MigrationTestEnv (commit 718b9e4eb6bc and friends). clang 23 reports the leftover as -Wunused-but-set-global:

../tests/qtest/migration/compression-tests.c:21:14: error: variable 'tmpfs' set but not used [-Werror,-Wunused-but-set-global]
21 | static char *tmpfs;
| ^
1 error generated.

Remove the leftover global.

---
 tests/qtest/migration/compression-tests.c | 5 -----
 1 file changed, 5 deletions(-)
tests/qtest/migration/compression-tests.c +0 -5
index 848576054ff9..9aa5063871e8 100644
@@ -17,9 +17,6 @@
 #include "migration/migration-util.h"
 #include "qemu/module.h"
 
-
-static char *tmpfs;
-
 static void set_multifd_compression(QTestState *from, QTestState *to,
                                     const char *method)
 {
@@ -174,8 +171,6 @@ static void migration_test_add_compression_smoke(MigrationTestEnv *env)
 
 void migration_test_add_compression(MigrationTestEnv *env)
 {
-    tmpfs = env->tmpfs;
-
     migration_test_add_compression_smoke(env);
 
     if (!env->full_set) {
Signature · 1 line
2.56.1
#6 lore raw

[PULL 7/7] vfio-user: block migration

In reply to Cédric Le Goater

From: Oguzhan KAYNAK <[email protected]>

vfio-user devices lack a migration blocker, so migration can complete successfully without transferring device state. The destination VM is left with an unconfigured device, for example with its BARs unassigned, and -only-migratable does not reject such a device.

Block migration until vfio-user migration support is implemented. Block all migration modes because vfio-user does not support CPR either.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/5002

---
 hw/vfio-user/pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/vfio-user/pci.c +9 -0
index e3749cdd3939..d3ae2c150a1d 100644
@@ -11,6 +11,7 @@
 #include "qapi/qapi-type-infos-sockets.h"
 #include "qapi-visit-sockets.h"
 #include "qemu/error-report.h"
+#include "migration/blocker.h"
 
 #include "hw/core/qdev-properties.h"
 #include "hw/vfio/pci.h"
@@ -284,6 +285,13 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
         return;
     }
     vbasedev->proxy = proxy;
+
+    error_setg(&vbasedev->migration_blocker,
+               "%s: migration is not supported", vbasedev->name);
+    if (migrate_add_blocker(&vbasedev->migration_blocker, errp) < 0) {
+        goto error;
+    }
+
     vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
 
     if (udev->send_queued) {
@@ -358,6 +366,7 @@ out_teardown:
     vfio_pci_teardown_msi(vdev);
     vfio_pci_bars_exit(vdev);
 error:
+    migrate_del_blocker(&vbasedev->migration_blocker);
     error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
     vfio_pci_put_device(vdev);
 }
Signature · 1 line
2.56.1
#0 lore raw

The following changes since commit fae886567b48c672977acde6b775dd7e2d2121c1:

Merge tag 'hw-misc-20261130' of https://github.com/philmd/qemu into staging (2026-11-30 14:02:58 -0800)

are available in the Git repository at:

https://github.com/legoater/qemu/ tags/pull-vfio-20261201

for you to fetch changes up to a1fbdb9361f11f2cce2a253f3816a6474af155d2:

vfio-user: block migration (2026-12-01 09:36:50 +0100)

----------------------------------------------------------------
vfio queue:

* Fix clang 23 build failures
* Fix a crash in vfio/pci when the host fails to assign a BAR
* Block migration of vfio-user devices

----------------------------------------------------------------
Cédric Le Goater (6):
qemu-vmsr-helper: Actually drop privileges
qemu-keymap: Drop unused ctrl modifier tests/qtest/migration: Drop orphaned tmpfs global tests/unit/test-qtree: Drop unused destroy counters tests/unit/test-rcu-list: Drop unused n_nodes/n_updates counters vfio/pci: Fix crash when BAR has zero size

Oguzhan KAYNAK (1):
vfio-user: block migration

 hw/vfio-user/pci.c                        |  9 +++++++++
 hw/vfio/pci.c                             |  4 +++-
 qemu-keymap.c                             |  2 --
 tests/qtest/migration/compression-tests.c |  5 -----
 tests/unit/test-qtree.c                   |  4 ----
 tests/unit/test-rcu-list.c                | 11 -----------
 tools/i386/qemu-vmsr-helper.c             | 10 ++++++++++
 7 files changed, 22 insertions(+), 23 deletions(-)
#7 lore raw

[PULL 2/7] qemu-keymap: Drop unused ctrl modifier

The ctrl modifier mask has been set but never read since the tool was added in commit 6a021536e239 ("tools: add qemu-keymap"). This went unnoticed until clang 23 extended -Wunused-but-set-variable to file scope statics as -Wunused-but-set-global:

../qemu-keymap.c:28:23: error: variable 'ctrl' set but not used [-Werror,-Wunused-but-set-global]
28 | static xkb_mod_mask_t ctrl;
| ^
1 error generated.

Remove the dead variable.

---
 qemu-keymap.c | 2 --
 1 file changed, 2 deletions(-)
qemu-keymap.c +0 -2
index d63b6be8ce32..af3519fa0529 100644
@@ -25,7 +25,6 @@ struct xkb_rule_names names = {
 };
 
 static xkb_mod_mask_t shift;
-static xkb_mod_mask_t ctrl;
 static xkb_mod_mask_t altgr;
 static xkb_mod_mask_t numlock;
 
@@ -227,7 +226,6 @@ int main(int argc, char *argv[])
     }
 
     shift = get_mod(map, "Shift");
-    ctrl = get_mod(map, "Control");
     altgr = get_mod(map, "AltGr");
     if (!altgr) {
         altgr = get_mod(map, "Mod5");
Signature · 1 line
2.56.1
#8 lore raw
In reply to Cédric Le Goater
Quoted 10 lines · Cédric Le Goater

The following changes since commit fae886567b48c672977acde6b775dd7e2d2121c1:

   Merge tag 'hw-misc-20261130' ofhttps://github.com/philmd/qemu into staging (2026-11-30 14:02:58 -0800)

are available in the Git repository at:

   https://github.com/legoater/qemu/ tags/pull-vfio-20261201

for you to fetch changes up to a1fbdb9361f11f2cce2a253f3816a6474af155d2:

Quoted 8 lines
   vfio-user: block migration (2026-12-01 09:36:50 +0100)

----------------------------------------------------------------
vfio queue:

* Fix clang 23 build failures
* Fix a crash in vfio/pci when the host fails to assign a BAR
* Block migration of vfio-user devices

Applied, thanks.

r~