[libvirt] [PATCH 27/35] tests: qemublock: Add tests for basic backing chain formats

Peter Krempa pkrempa at redhat.com
Wed Apr 25 15:15:35 UTC 2018


Formats supporting backing chain such as qed, vmdk, don't have any other
parameters than the backing store and 'qcow' has only encryption params
which will be tested extra. Add this test case so they are covered since
any further test cases will mainly care about 'qcow2' and 'raw'.

The top level disk image would generate the following '-drive' cmdline:

-drive file=/var/lib/libvirt/images/a,format=qed,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/qemublocktest.c                              |  2 +
 .../xml2json/file-backing_basic-noopts.json        | 51 ++++++++++++++++++++++
 .../xml2json/file-backing_basic-noopts.xml         | 46 +++++++++++++++++++
 3 files changed, 99 insertions(+)
 create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-noopts.xml

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index feb25c69e3..881d7c17ee 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -413,6 +413,8 @@ mymain(void)
     TEST_DISK_TO_JSON("file-vhd-noopts");
     TEST_DISK_TO_JSON("file-vpc-noopts");

+    TEST_DISK_TO_JSON("file-backing_basic-noopts");
+
  cleanup:
     virHashFree(diskxmljsondata.schema);
     qemuTestDriverFree(&driver);
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json
new file mode 100644
index 0000000000..3285a6ec67
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json
@@ -0,0 +1,51 @@
+{
+  "node-name": "node-a-f",
+  "read-only": false,
+  "driver": "qed",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/a",
+    "node-name": "node-a-s",
+    "read-only": false,
+    "discard": "unmap"
+  },
+  "backing": "node-b-f"
+}
+{
+  "node-name": "node-b-f",
+  "read-only": true,
+  "driver": "qcow",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/b",
+    "node-name": "node-b-s",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "node-c-f"
+}
+{
+  "node-name": "node-c-f",
+  "read-only": true,
+  "driver": "vmdk",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/c",
+    "node-name": "node-c-s",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "node-d-f"
+}
+{
+  "node-name": "node-d-f",
+  "read-only": true,
+  "driver": "raw",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/d",
+    "node-name": "node-d-s",
+    "read-only": true,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.xml b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.xml
new file mode 100644
index 0000000000..7c48433aec
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.xml
@@ -0,0 +1,46 @@
+<disk type='file' device='disk'>
+  <driver name='qemu' type='qed'/>
+  <source file='/var/lib/libvirt/images/a'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='node-a-s'/>
+        <nodename type='format' name='node-a-f'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <backingStore type='file' index='1'>
+    <format type='qcow'/>
+    <source file='/var/lib/libvirt/images/b'>
+      <privateData>
+        <nodenames>
+          <nodename type='storage' name='node-b-s'/>
+          <nodename type='format' name='node-b-f'/>
+        </nodenames>
+      </privateData>
+    </source>
+    <backingStore type='file' index='2'>
+      <format type='vmdk'/>
+      <source file='/var/lib/libvirt/images/c'>
+        <privateData>
+          <nodenames>
+            <nodename type='storage' name='node-c-s'/>
+            <nodename type='format' name='node-c-f'/>
+          </nodenames>
+        </privateData>
+      </source>
+      <backingStore type='file' index='3'>
+        <format type='raw'/>
+        <source file='/var/lib/libvirt/images/d'>
+          <privateData>
+            <nodenames>
+              <nodename type='storage' name='node-d-s'/>
+              <nodename type='format' name='node-d-f'/>
+            </nodenames>
+          </privateData>
+        </source>
+        <backingStore/>
+      </backingStore>
+    </backingStore>
+  </backingStore>
+  <target dev='vda'/>
+</disk>
-- 
2.16.2




More information about the libvir-list mailing list