[PATCH 17/24] qemu: block: store and test driver names for detected storage nodes

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

 



Store the 'drv' field both for the storage node and for the format node
and format them in the test case.
---
 src/qemu/qemu_block.c                                      | 14 +++++++++++---
 src/qemu/qemu_block.h                                      |  4 ++++
 .../qemumonitorjson-nodename-basic.result                  |  6 ++++++
 tests/qemumonitorjsontest.c                                |  2 ++
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index bca6965fa..348961199 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -56,6 +56,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)

     VIR_FREE(data->qemufilename);

+    VIR_FREE(data->drvformat);
+    VIR_FREE(data->drvstorage);
+
     qemuBlockNodeNameBackingChainDataFree(data->backing);

     VIR_FREE(data);
@@ -108,7 +111,8 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
     virJSONValuePtr parentnodedata;
     virJSONValuePtr nodedata;
     const char *nodename = virJSONValueObjectGetString(next, "node-name");
-    const char *drvname;
+    const char *drvname = NULL;
+    const char *drvparent = NULL;
     const char *parentnodename = NULL;
     const char *filename = NULL;
     int ret = -1;
@@ -134,8 +138,10 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,

     if (parent &&
         (parentnodename = virJSONValueObjectGetString(parent, "node-name"))) {
-        if ((parentnodedata = virHashLookup(nodenamestable, parentnodename)))
+        if ((parentnodedata = virHashLookup(nodenamestable, parentnodename))) {
             filename = virJSONValueObjectGetString(parentnodedata, "file");
+            drvparent = virJSONValueObjectGetString(parentnodedata, "drv");
+        }
     }

     if (VIR_ALLOC(data) < 0)
@@ -143,7 +149,9 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,

     if (VIR_STRDUP(data->nodeformat, nodename) < 0 ||
         VIR_STRDUP(data->nodestorage, parentnodename) < 0 ||
-        VIR_STRDUP(data->qemufilename, filename) < 0)
+        VIR_STRDUP(data->qemufilename, filename) < 0 ||
+        VIR_STRDUP(data->drvformat, drvname) < 0 ||
+        VIR_STRDUP(data->drvstorage, drvparent) < 0)
         goto cleanup;

     if (backing &&
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 5d21057a7..c0ed43ec0 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -34,6 +34,10 @@ struct qemuBlockNodeNameBackingChainData {
     char *nodeformat;   /* node name of the format layer */
     char *nodestorage;  /* node name of the storage backing the format node */

+    /* for testing purposes */
+    char *drvformat;
+    char *drvstorage;
+
     qemuBlockNodeNameBackingChainDataPtr backing;
 };

diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result b/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result
index bc183f8b9..ad8b9b46e 100644
--- a/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result
+++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result
@@ -1,10 +1,16 @@
 drive-virtio-disk0
 filename    : '/var/lib/libvirt/images/rhel7.3.1483545313'
 format node : '#block187'
+format drv  : 'qcow2'
 storage node: '#block033'
+storage drv : 'file'
   filename    : '/var/lib/libvirt/images/rhel7.3.1483536402'
   format node : '#block306'
+  format drv  : 'qcow2'
   storage node: '#block220'
+  storage drv : 'file'
     filename    : '/var/lib/libvirt/images/rhel7.3.qcow2'
     format node : '#block558'
+    format drv  : 'qcow2'
     storage node: '#block481'
+    storage drv : 'file'
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 88169832e..346d5c401 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2714,8 +2714,10 @@ testBlockNodeNameDetectFormat(void *payload,
         virBufferAsprintf(buf, "filename    : '%s'\n", entry->qemufilename);
         virBufferAsprintf(buf, "format node : '%s'\n",
                           NULLSTR(entry->nodeformat));
+        virBufferAsprintf(buf, "format drv  : '%s'\n", NULLSTR(entry->drvformat));
         virBufferAsprintf(buf, "storage node: '%s'\n",
                           NULLSTR(entry->nodestorage));
+        virBufferAsprintf(buf, "storage drv : '%s'\n", NULLSTR(entry->drvstorage));

         virBufferAdjustIndent(buf, 2);

-- 
2.13.2

--
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