From 686bf67609d47d0ef273012f4bd118f68e3251f7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Oct 2026 07:56:49 +0200 Subject: [PATCH] test-sd-device: tolerate devices disappearing during enumeration test On CI (Azure runners) the accelerated networking PCI VF behind the Hyper-V vmbus PCI bridge may be hot-unplugged while the test runs, causing sd_device_new_from_syspath() to fail with ENODEV for a device we just enumerated: test_sd_device_one(/sys/devices/LNXSYSTM:00/.../pci7870:00/7870:00:00.0) Assertion failed: Expected "sd_device_new_from_syspath(&dev, syspath)" to succeed, but got error: -19/ENODEV Skip devices whose syspath vanished since enumeration rather than failing. (cherry picked from commit b43136ffcdbd62b5d11c226df9dd33372cff7823) --- src/libsystemd/sd-device/test-sd-device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index dde2bc9c86..0e546f2f72 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -110,7 +110,15 @@ static void test_sd_device_one(sd_device *d) { log_info("%s(%s)", __func__, syspath); - ASSERT_OK(sd_device_new_from_syspath(&dev, syspath)); + r = sd_device_new_from_syspath(&dev, syspath); + if (ERRNO_IS_DEVICE_ABSENT(r)) { + /* Devices may be hot-unplugged while we are running, e.g. on Azure the accelerated + * networking PCI VF behind a Hyper-V vmbus PCI bridge may be removed and re-added + * during host servicing. Don't fail the test if a device vanished since enumeration. */ + log_device_notice_errno(d, r, "Device disappeared while running the test, skipping: %m"); + return; + } + ASSERT_OK(r); ASSERT_OK(sd_device_get_syspath(dev, &val)); ASSERT_STREQ(syspath, val); ASSERT_NULL(dev = sd_device_unref(dev));