[PATCH v2 39/39] virsh: Introduce nvme disk to domblklist

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

 



This is slightly more complicated because NVMe disk source is not
a simple attribute to <source/> element. The format in which the
PCI address and namespace ID are printed is the same as QEMU
accepts them:

  nvme://XXXX:XX:XX.X/X

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virsh-domain-monitor.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0e2c4191d7..f663a87f8f 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -627,8 +627,8 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     for (i = 0; i < ndisks; i++) {
         ctxt->node = disks[i];
 
+        type = virXPathString("string(./@type)", ctxt);
         if (details) {
-            type = virXPathString("string(./@type)", ctxt);
             device = virXPathString("string(./@device)", ctxt);
             if (!type || !device) {
                 vshPrint(ctl, "unable to query block list details");
@@ -641,11 +641,30 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, "unable to query block list");
             goto cleanup;
         }
-        source = virXPathString("string(./source/@file"
-                                "|./source/@dev"
-                                "|./source/@dir"
-                                "|./source/@name"
-                                "|./source/@volume)", ctxt);
+
+        if (STREQ_NULLABLE(type, "nvme")) {
+            VIR_AUTOFREE(char *) namespace = NULL;
+            virPCIDeviceAddress addr = { 0 };
+            xmlNodePtr addrNode = NULL;
+
+            if (!(namespace = virXPathString("string(./source/@namespace)", ctxt)) ||
+                !(addrNode = virXPathNode("./source/address", ctxt)) ||
+                virPCIDeviceAddressParseXML(addrNode, &addr) < 0) {
+                vshError(ctl, "Unable to query NVMe disk address");
+                goto cleanup;
+            }
+
+            if (virAsprintf(&source, "nvme://%04x:%02x:%02x.%d/%s",
+                            addr.domain, addr.bus, addr.slot, addr.function, namespace) < 0)
+                goto cleanup;
+        } else {
+            source = virXPathString("string(./source/@file"
+                                    "|./source/@dev"
+                                    "|./source/@dir"
+                                    "|./source/@name"
+                                    "|./source/@volume)", ctxt);
+        }
+
         if (details) {
             if (vshTableRowAppend(table, type, device, target,
                                   NULLSTR_MINUS(source), NULL) < 0)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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