]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Probe whether an image is 'qcow2 v2' from query-named-block-nodes
authorPeter Krempa <pkrempa@redhat.com>
Fri, 29 Jan 2021 13:35:57 +0000 (14:35 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Sat, 20 Feb 2021 12:20:32 +0000 (13:20 +0100)
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@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
tests/qemublocktest.c
tests/qemublocktestdata/bitmap/synthetic.json
tests/qemublocktestdata/bitmap/synthetic.out

index 32dc96ee825e66b36a2d8b86cfbd1c40499c1f7b..0108703a33b6035a8d8f660fce4d79d3f635bf85 100644 (file)
@@ -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 *
index f8c78d909335f871e50cb915f9f9c52b9020ae4c..3a073063652b6747dabfe0e331483aa7326c77f3 100644 (file)
@@ -2978,6 +2978,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;
 
@@ -3000,6 +3001,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;
 
index ddaf73359d4207bb7664ca0c05e6707f858b592f..bbfcfee92d767248d64b5b4c7666f9f95c29b39a 100644 (file)
@@ -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++) {
index 3712c8e5fc5a4038ce2c64a4e7054d8abbb96895..cd468a42a2c3185b9ac991a8ffa77f8b3102eda4 100644 (file)
@@ -12,7 +12,7 @@
       "format-specific": {
         "type": "qcow2",
         "data": {
-          "compat": "1.1",
+          "compat": "0.10",
           "compression-type": "zlib",
           "lazy-refcounts": false,
           "bitmaps": [
index cde7228e01c256f360a79fd29259da9e6dc76f69..2d9545fc9be08d3353a8ceee1edd5852e4b28f13 100644 (file)
@@ -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