[PATCH 03/19] qemu: Probe whether an image is 'qcow2 v2' from query-named-block-nodes

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

 



Such images don't support stuff like dirty bitmaps. Note that the
synthetic test for detecting bitmaps is used as an example to prevent
adding additional test cases.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.h                       |  3 +++
 src/qemu/qemu_monitor_json.c                  | 11 +++++++++++
 tests/qemublocktest.c                         |  2 ++
 tests/qemublocktestdata/bitmap/synthetic.json |  2 +-
 tests/qemublocktestdata/bitmap/synthetic.out  |  1 +
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b0068f2a82..7a039641ba 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -732,6 +732,9 @@ struct _qemuBlockNamedNodeData {

     /* the cluster size of the image is valid only when > 0 */
     unsigned long long clusterSize;
+
+    /* image version */
+    bool qcow2v2;
 };

 GHashTable *
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d3b2a2c7a5..65c30e3bb4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2979,6 +2979,7 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
     GHashTable *nodes = opaque;
     virJSONValuePtr img;
     virJSONValuePtr bitmaps;
+    virJSONValuePtr format_specific;
     const char *nodename;
     g_autoptr(qemuBlockNamedNodeData) ent = NULL;

@@ -3001,6 +3002,16 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED,
     if ((bitmaps = virJSONValueObjectGetArray(val, "dirty-bitmaps")))
         qemuMonitorJSONBlockGetNamedNodeDataBitmaps(bitmaps, ent);

+    /* query qcow2 format specific props */
+    if ((format_specific = virJSONValueObjectGetObject(img, "format-specific")) &&
+        STREQ_NULLABLE(virJSONValueObjectGetString(format_specific, "type"), "qcow2")) {
+        virJSONValuePtr qcow2props = virJSONValueObjectGetObject(format_specific, "data");
+
+        if (qcow2props &&
+            STREQ_NULLABLE(virJSONValueObjectGetString(qcow2props, "compat"), "0.10"))
+            ent->qcow2v2 = true;
+    }
+
     if (virHashAddEntry(nodes, nodename, ent) < 0)
         return -1;

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index ddaf73359d..bbfcfee92d 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -599,6 +599,8 @@ testQemuDetectBitmapsWorker(GHashTable *nodedata,
         return;

     virBufferAsprintf(buf, "%s:\n", nodename);
+    if (data->qcow2v2)
+        virBufferAddLit(buf, " qcow2 v2\n");
     virBufferAdjustIndent(buf, 1);

     for (i = 0; i < data->nbitmaps; i++) {
diff --git a/tests/qemublocktestdata/bitmap/synthetic.json b/tests/qemublocktestdata/bitmap/synthetic.json
index 3712c8e5fc..cd468a42a2 100644
--- a/tests/qemublocktestdata/bitmap/synthetic.json
+++ b/tests/qemublocktestdata/bitmap/synthetic.json
@@ -12,7 +12,7 @@
       "format-specific": {
         "type": "qcow2",
         "data": {
-          "compat": "1.1",
+          "compat": "0.10",
           "compression-type": "zlib",
           "lazy-refcounts": false,
           "bitmaps": [
diff --git a/tests/qemublocktestdata/bitmap/synthetic.out b/tests/qemublocktestdata/bitmap/synthetic.out
index cde7228e01..2d9545fc9b 100644
--- a/tests/qemublocktestdata/bitmap/synthetic.out
+++ b/tests/qemublocktestdata/bitmap/synthetic.out
@@ -1,4 +1,5 @@
 libvirt-1-format:
+ qcow2 v2
   current: record:1 busy:0 persist:1 inconsist:1 gran:65536 dirty:0
    top-ok: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
  top-inactive: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
-- 
2.29.2




[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