[libvirt] [PATCH 19/23] tests: qemumonitorjson: Add case for two disks sharing a backing image

Peter Krempa posted 23 patches 8 years, 11 months ago
[libvirt] [PATCH 19/23] tests: qemumonitorjson: Add case for two disks sharing a backing image
Posted by Peter Krempa 8 years, 11 months ago
Since we have to match the images by filename a common backing image
will break the detection process. Add a test case to see that the code
correctly did not continue the detection process.
---
 .../qemumonitorjson-nodename-same-backing.json     | 316 +++++++++++++++++++++
 .../qemumonitorjson-nodename-same-backing.result   |  11 +
 tests/qemumonitorjsontest.c                        |   1 +
 3 files changed, 328 insertions(+)
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.json
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result

diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.json b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.json
new file mode 100644
index 000000000..78954bb25
--- /dev/null
+++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.json
@@ -0,0 +1,316 @@
+[
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 10485760,
+        "filename": "/var/lib/libvirt/images/base.qcow2",
+        "cluster-size": 65536,
+        "format": "qcow2",
+        "actual-size": 200704,
+        "format-specific": {
+          "type": "qcow2",
+          "data": {
+            "compat": "1.1",
+            "lazy-refcounts": false,
+            "refcount-bits": 16,
+            "corrupt": false
+          }
+        },
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": true,
+      "node-name": "#block729",
+      "backing_file_depth": 0,
+      "drv": "qcow2",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/base.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 197120,
+        "filename": "/var/lib/libvirt/images/base.qcow2",
+        "format": "file",
+        "actual-size": 200704,
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": true,
+      "node-name": "#block628",
+      "backing_file_depth": 0,
+      "drv": "file",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/base.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "backing-image": {
+          "virtual-size": 10485760,
+          "filename": "/var/lib/libvirt/images/base.qcow2",
+          "cluster-size": 65536,
+          "format": "qcow2",
+          "actual-size": 200704,
+          "format-specific": {
+            "type": "qcow2",
+            "data": {
+              "compat": "1.1",
+              "lazy-refcounts": false,
+              "refcount-bits": 16,
+              "corrupt": false
+            }
+          },
+          "dirty-flag": false
+        },
+        "backing-filename-format": "qcow2",
+        "virtual-size": 10485760,
+        "filename": "/var/lib/libvirt/images/b.qcow2",
+        "cluster-size": 65536,
+        "format": "qcow2",
+        "actual-size": 200704,
+        "format-specific": {
+          "type": "qcow2",
+          "data": {
+            "compat": "1.1",
+            "lazy-refcounts": false,
+            "refcount-bits": 16,
+            "corrupt": false
+          }
+        },
+        "full-backing-filename": "/var/lib/libvirt/images/base.qcow2",
+        "backing-filename": "/var/lib/libvirt/images/base.qcow2",
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": false,
+      "node-name": "#block574",
+      "backing_file_depth": 1,
+      "drv": "qcow2",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "backing_file": "/var/lib/libvirt/images/base.qcow2",
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/b.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 197120,
+        "filename": "/var/lib/libvirt/images/b.qcow2",
+        "format": "file",
+        "actual-size": 200704,
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": false,
+      "node-name": "#block405",
+      "backing_file_depth": 0,
+      "drv": "file",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/b.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 10485760,
+        "filename": "/var/lib/libvirt/images/base.qcow2",
+        "cluster-size": 65536,
+        "format": "qcow2",
+        "actual-size": 200704,
+        "format-specific": {
+          "type": "qcow2",
+          "data": {
+            "compat": "1.1",
+            "lazy-refcounts": false,
+            "refcount-bits": 16,
+            "corrupt": false
+          }
+        },
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": true,
+      "node-name": "#block399",
+      "backing_file_depth": 0,
+      "drv": "qcow2",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/base.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 197120,
+        "filename": "/var/lib/libvirt/images/base.qcow2",
+        "format": "file",
+        "actual-size": 200704,
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": true,
+      "node-name": "#block257",
+      "backing_file_depth": 0,
+      "drv": "file",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/base.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "backing-image": {
+          "virtual-size": 10485760,
+          "filename": "/var/lib/libvirt/images/base.qcow2",
+          "cluster-size": 65536,
+          "format": "qcow2",
+          "actual-size": 200704,
+          "format-specific": {
+            "type": "qcow2",
+            "data": {
+              "compat": "1.1",
+              "lazy-refcounts": false,
+              "refcount-bits": 16,
+              "corrupt": false
+            }
+          },
+          "dirty-flag": false
+        },
+        "backing-filename-format": "qcow2",
+        "virtual-size": 10485760,
+        "filename": "/var/lib/libvirt/images/a.qcow2",
+        "cluster-size": 65536,
+        "format": "qcow2",
+        "actual-size": 200704,
+        "format-specific": {
+          "type": "qcow2",
+          "data": {
+            "compat": "1.1",
+            "lazy-refcounts": false,
+            "refcount-bits": 16,
+            "corrupt": false
+          }
+        },
+        "full-backing-filename": "/var/lib/libvirt/images/base.qcow2",
+        "backing-filename": "/var/lib/libvirt/images/base.qcow2",
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": false,
+      "node-name": "#block170",
+      "backing_file_depth": 1,
+      "drv": "qcow2",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "backing_file": "/var/lib/libvirt/images/base.qcow2",
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/a.qcow2",
+      "encryption_key_missing": false
+    },
+    {
+      "iops_rd": 0,
+      "detect_zeroes": "off",
+      "image": {
+        "virtual-size": 197120,
+        "filename": "/var/lib/libvirt/images/a.qcow2",
+        "format": "file",
+        "actual-size": 200704,
+        "dirty-flag": false
+      },
+      "iops_wr": 0,
+      "ro": false,
+      "node-name": "#block057",
+      "backing_file_depth": 0,
+      "drv": "file",
+      "iops": 0,
+      "bps_wr": 0,
+      "write_threshold": 0,
+      "encrypted": false,
+      "bps": 0,
+      "bps_rd": 0,
+      "cache": {
+        "no-flush": false,
+        "direct": false,
+        "writeback": true
+      },
+      "file": "/var/lib/libvirt/images/a.qcow2",
+      "encryption_key_missing": false
+    }
+  ]
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result
new file mode 100644
index 000000000..2c774be27
--- /dev/null
+++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result
@@ -0,0 +1,11 @@
+filename    : '/var/lib/libvirt/images/a.qcow2'
+format node : '#block170'
+storage node: '#block057'
+backingfile : '/var/lib/libvirt/images/base.qcow2'
+backing ptr : '<null>'
+
+filename    : '/var/lib/libvirt/images/b.qcow2'
+format node : '#block574'
+storage node: '#block405'
+backingfile : '/var/lib/libvirt/images/base.qcow2'
+backing ptr : '<null>'
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index fd27df184..7e3e7db27 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2907,6 +2907,7 @@ mymain(void)

     DO_TEST_BLOCK_NODE_DETECT("1", "#block118");
     DO_TEST_BLOCK_NODE_DETECT("2", "#block161");
+    DO_TEST_BLOCK_NODE_DETECT("same-backing", "#block170,#block574");

 #undef DO_TEST_BLOCK_NODE_DETECT

-- 
2.12.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 19/23] tests: qemumonitorjson: Add case for two disks sharing a backing image
Posted by Eric Blake 8 years, 10 months ago
On 03/15/2017 11:37 AM, Peter Krempa wrote:
> Since we have to match the images by filename a common backing image
> will break the detection process. Add a test case to see that the code
> correctly did not continue the detection process.

Maybe qemu can be enhanced to add a new command that makes querying
relationships easier (won't happen any sooner than qemu 2.10).  Or maybe
libvirt just learns to always invent its own node names via
blockdev-add.  But in the meantime, testing our limitations is the best
we can do.

> ---
>  .../qemumonitorjson-nodename-same-backing.json     | 316 +++++++++++++++++++++
>  .../qemumonitorjson-nodename-same-backing.result   |  11 +
>  tests/qemumonitorjsontest.c                        |   1 +
>  3 files changed, 328 insertions(+)
>  create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.json
>  create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-nodename-same-backing.result

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 19/23] tests: qemumonitorjson: Add case for two disks sharing a backing image
Posted by Peter Krempa 8 years, 10 months ago
On Thu, Mar 23, 2017 at 17:19:40 -0500, Eric Blake wrote:
> On 03/15/2017 11:37 AM, Peter Krempa wrote:
> > Since we have to match the images by filename a common backing image
> > will break the detection process. Add a test case to see that the code
> > correctly did not continue the detection process.
> 
> Maybe qemu can be enhanced to add a new command that makes querying
> relationships easier (won't happen any sooner than qemu 2.10).  Or maybe
> libvirt just learns to always invent its own node names via
> blockdev-add.  But in the meantime, testing our limitations is the best
> we can do.

We really want to switch to -blockdev/blockdev-add and do our own node
names so such API would be of little use to libvirt.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list