[PATCH] qemu: domfsinfo should print a target name on s390x, not a complete device path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While fixing domfsinfo for non-PCI (i.e. CCW) devices on s390x,
I accidentally used the whole device path for the devAlias field.
However, it should only contain the base target name.

Currently we have the wrong output:

 $ virsh domfsinfo guestname
  Mountpoint   Name   Type   Target
 ---------------------------------------
  /            sda3   xfs    /dev/sda3
  /boot        sda1   xfs    /dev/sda1

It should look like this instead:

 $ virsh domfsinfo guestname
  Mountpoint   Name   Type   Target
 ------------------------------------
  /            sda3   xfs    sda
  /boot        sda1   xfs    sda

Thus we have to strip the "/dev/" prefix and the partition number
from the string.

Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...")
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Reported-by: Sebastian Mitterle <smitterl@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 05f8eb2cb7..d92bee1d35 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18874,6 +18874,30 @@ qemuDomainGetFSInfoAgent(virQEMUDriverPtr driver,
     return ret;
 }
 
+/* Turn device node string like "/dev/vda1" into a target name like "vda" */
+static char *
+qemuAgentDevNodeToTarget(const char *devnode)
+{
+    char *str = g_strdup(devnode);
+    size_t len = strlen(str);
+
+    /* Remove the "/dev/" prefix from the string */
+    if (g_str_has_prefix(str, "/dev/")) {
+        len -= 5;
+        memmove(str, str + 5, len + 1);
+    }
+
+    /* Remove the partition number from the end of the string */
+    while (len > 0) {
+        len--;
+        if (!g_ascii_isdigit(str[len]))
+            break;
+        str[len] = 0;
+    }
+
+    return str;
+}
+
 static virDomainFSInfoPtr
 qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
                         virDomainDefPtr vmdef)
@@ -18903,7 +18927,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
         if (diskDef != NULL)
             ret->devAlias[i] = g_strdup(diskDef->dst);
         else if (agentdisk->devnode != NULL)
-            ret->devAlias[i] = g_strdup(agentdisk->devnode);
+            ret->devAlias[i] = qemuAgentDevNodeToTarget(agentdisk->devnode);
         else
             VIR_DEBUG("Missing devnode name for '%s'.", ret->mountpoint);
     }
-- 
2.18.4




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux