Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
libvirt (10.0.0-2ubuntu108.9) noble; urgency=medium

* d/p/u/lp-2117467-virdevmapper-device-name-for-targets.patch:
virdevmapper: Always use device name for finding targets. This ensures
that all the target devices of a multipath device are added to the
namespace/cgroup of the guest domain.
Closes LP: #2117467.

-- Bhavin Gandhi <bhavin192@geeksocket.in> Tue, 22 Jul 2025 17:26:55 +0530

libvirt (10.0.0-2ubuntu8.8) noble; urgency=medium

[ Lukas Märdian ]
Expand Down
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ubuntu/lp-2095488-virsysinfo-Try-reading-DMI-table.patch
ubuntu/lp-2095488-virsysinfo-fix-RISC-V-detection.patch
ubuntu/lp2051239/1-qemu-capabilities-Add-QEMU_CAPS_VIRTIO_CCW_DEVICE.patch
ubuntu/lp2051239/2-qemu-command-add-multi-boot-device-support-on-s39.patch
ubuntu/lp-2117467-virdevmapper-device-name-for-targets.patch

# Ubuntu Apparmor Changes
ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From bf8c7af771f1e2de24b28c2d04b6113796937f7f Mon Sep 17 00:00:00 2001
From: Bhavin Gandhi <bhavin192@geeksocket.in>
Date: Thu, 3 Jul 2025 00:39:33 +0530
Subject: [PATCH] virdevmapper: Always use device name for finding targets

DM_TABLE_DEPS expects a device name in dm_ioctl.name. In one of the
cases, full path of the device was getting returned causing the ioctl
call to fail with `ENXIO (No such device or address)`.

Also rename the function and variable names to better reflect that we
are dealing with DM device names and not paths.

This got introduced in 22494556542c676d1b9e7f1c1f2ea13ac17e1e3e
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/790

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Bhavin Gandhi <bhavin192@geeksocket.in>

Origin: upstream, https://gitlab.com/libvirt/libvirt/-/commit/bf8c7af771
Bug-Ubuntu: https://bugs.launchpad.net/libvirt/+bug/2117467
Last-Update: 2024-07-22

---
src/util/virdevmapper.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
index d0eae671abc..42c86d89cfe 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -164,7 +164,7 @@ virDMOpen(void)


static char *
-virDMSanitizepath(const char *path)
+virDMGetDeviceName(const char *path)
{
g_autofree char *dmDirPath = NULL;
struct dirent *ent = NULL;
@@ -205,7 +205,7 @@ virDMSanitizepath(const char *path)

if (stat(tmp, &sb[1]) == 0 &&
sb[0].st_rdev == sb[1].st_rdev) {
- return g_steal_pointer(&tmp);
+ return g_strdup(ent->d_name);
}
}

@@ -219,7 +219,7 @@ virDevMapperGetTargetsImpl(int controlFD,
GSList **devPaths,
unsigned int ttl)
{
- g_autofree char *sanitizedPath = NULL;
+ g_autofree char *deviceName = NULL;
g_autofree char *buf = NULL;
struct dm_ioctl dm = { 0 };
struct dm_target_deps *deps = NULL;
@@ -233,10 +233,10 @@ virDevMapperGetTargetsImpl(int controlFD,
if (!virIsDevMapperDevice(path))
return 0;

- if (!(sanitizedPath = virDMSanitizepath(path)))
+ if (!(deviceName = virDMGetDeviceName(path)))
return 0;

- if (virStrcpy(dm.name, sanitizedPath, DM_NAME_LEN) < 0) {
+ if (virStrcpy(dm.name, deviceName, DM_NAME_LEN) < 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Resolved device mapper name too long"));
return -1;
10 changes: 5 additions & 5 deletions src/util/virdevmapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ virDMOpen(void)


static char *
virDMSanitizepath(const char *path)
virDMGetDeviceName(const char *path)
{
g_autofree char *dmDirPath = NULL;
struct dirent *ent = NULL;
Expand Down Expand Up @@ -205,7 +205,7 @@ virDMSanitizepath(const char *path)

if (stat(tmp, &sb[1]) == 0 &&
sb[0].st_rdev == sb[1].st_rdev) {
return g_steal_pointer(&tmp);
return g_strdup(ent->d_name);
}
}

Expand All @@ -219,7 +219,7 @@ virDevMapperGetTargetsImpl(int controlFD,
GSList **devPaths,
unsigned int ttl)
{
g_autofree char *sanitizedPath = NULL;
g_autofree char *deviceName = NULL;
g_autofree char *buf = NULL;
struct dm_ioctl dm = { 0 };
struct dm_target_deps *deps = NULL;
Expand All @@ -233,10 +233,10 @@ virDevMapperGetTargetsImpl(int controlFD,
if (!virIsDevMapperDevice(path))
return 0;

if (!(sanitizedPath = virDMSanitizepath(path)))
if (!(deviceName = virDMGetDeviceName(path)))
return 0;

if (virStrcpy(dm.name, sanitizedPath, DM_NAME_LEN) < 0) {
if (virStrcpy(dm.name, deviceName, DM_NAME_LEN) < 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Resolved device mapper name too long"));
return -1;
Expand Down