[libvirt] [PATCH 31/35] tests: qemublock: basic qcow2 tests

Peter Krempa posted 35 patches 7 years ago
[libvirt] [PATCH 31/35] tests: qemublock: basic qcow2 tests
Posted by Peter Krempa 7 years ago
Add tests for backing chain handling, including a very long chain which
is fully specified in the XML and an unterminated chain.

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

file-qcow2-backing-chain-encryption.xml:
-drive file=/var/lib/libvirt/images/a,encrypt.format=luks,
    encrypt.key-secret=node-b-f-encalias,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-qcow2-backing-chain-noopts.xml:
-drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-qcow2-backing-chain-unterminated.xml:
-drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemublocktest.c                              |   3 +
 .../file-qcow2-backing-chain-encryption.json       |  34 ++++++
 .../file-qcow2-backing-chain-encryption.xml        |  31 +++++
 .../xml2json/file-qcow2-backing-chain-noopts.json  | 130 +++++++++++++++++++++
 .../xml2json/file-qcow2-backing-chain-noopts.xml   | 113 ++++++++++++++++++
 .../file-qcow2-backing-chain-unterminated.json     |  25 ++++
 .../file-qcow2-backing-chain-unterminated.xml      |  24 ++++
 7 files changed, 360 insertions(+)
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 55d028e9fb..44d76bebbb 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -460,6 +460,9 @@ mymain(void)
     TEST_DISK_TO_JSON("file-raw-aio_native");
     TEST_DISK_TO_JSON("file-backing_basic-aio_threads");
     TEST_DISK_TO_JSON("file-raw-luks");
+    TEST_DISK_TO_JSON("file-qcow2-backing-chain-noopts");
+    TEST_DISK_TO_JSON("file-qcow2-backing-chain-unterminated");
+    TEST_DISK_TO_JSON("file-qcow2-backing-chain-encryption");

  cleanup:
     virHashFree(diskxmljsondata.schema);
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json
new file mode 100644
index 0000000000..94e2ecd1e2
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json
@@ -0,0 +1,34 @@
+{
+  "node-name": "node-b-f",
+  "read-only": false,
+  "driver": "qcow2",
+  "encrypt": {
+    "format": "luks",
+    "key-secret": "node-b-f-encalias"
+  },
+  "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": "qcow2",
+  "encrypt": {
+    "format": "aes",
+    "key-secret": "node-b-f-encalias"
+  },
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/b",
+    "node-name": "node-b-s",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": null
+}
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml
new file mode 100644
index 0000000000..a1292284bf
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml
@@ -0,0 +1,31 @@
+<disk type='file' device='disk'>
+  <driver name='qemu' type='qcow2'/>
+  <source file='/var/lib/libvirt/images/a'>
+    <encryption format='luks'>
+      <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
+    </encryption>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='node-a-s'/>
+        <nodename type='format' name='node-b-f'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <backingStore type='file' index='1'>
+    <format type='qcow2'/>
+    <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>
+      <encryption format='qcow'>
+        <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
+      </encryption>
+    </source>
+    <backingStore/>
+  </backingStore>
+  <target dev='vda' bus='virtio'/>
+  <alias name='virtio-disk0'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json
new file mode 100644
index 0000000000..3e7c08f080
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json
@@ -0,0 +1,130 @@
+{
+  "node-name": "#block126",
+  "read-only": false,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1507297895",
+    "node-name": "#block004",
+    "read-only": false,
+    "discard": "unmap"
+  },
+  "backing": "#block313"
+}
+{
+  "node-name": "#block313",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1484071872",
+    "node-name": "#block256",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block556"
+}
+{
+  "node-name": "#block556",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483615252",
+    "node-name": "#block418",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block767"
+}
+{
+  "node-name": "#block767",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483605924",
+    "node-name": "#block624",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block937"
+}
+{
+  "node-name": "#block937",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483605920",
+    "node-name": "#block869",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block1157"
+}
+{
+  "node-name": "#block1157",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483546244",
+    "node-name": "#block1047",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block1392"
+}
+{
+  "node-name": "#block1392",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483545901",
+    "node-name": "#block1279",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block1523"
+}
+{
+  "node-name": "#block1523",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483545313",
+    "node-name": "#block1444",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block1742"
+}
+{
+  "node-name": "#block1742",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1483536402",
+    "node-name": "#block1602",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": "#block1909"
+}
+{
+  "node-name": "#block1909",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.qcow2",
+    "node-name": "#block1864",
+    "read-only": true,
+    "discard": "unmap"
+  },
+  "backing": null
+}
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml
new file mode 100644
index 0000000000..12db679f37
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml
@@ -0,0 +1,113 @@
+<disk type='file' device='disk'>
+  <driver name='qemu' type='qcow2'/>
+  <source file='/var/lib/libvirt/images/rhel7.3.1507297895'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='#block004'/>
+        <nodename type='format' name='#block126'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <backingStore type='file' index='1'>
+    <format type='qcow2'/>
+    <source file='/var/lib/libvirt/images/rhel7.3.1484071872'>
+      <privateData>
+        <nodenames>
+          <nodename type='storage' name='#block256'/>
+          <nodename type='format' name='#block313'/>
+        </nodenames>
+      </privateData>
+    </source>
+    <backingStore type='file' index='2'>
+      <format type='qcow2'/>
+      <source file='/var/lib/libvirt/images/rhel7.3.1483615252'>
+        <privateData>
+          <nodenames>
+            <nodename type='storage' name='#block418'/>
+            <nodename type='format' name='#block556'/>
+          </nodenames>
+        </privateData>
+      </source>
+      <backingStore type='file' index='3'>
+        <format type='qcow2'/>
+        <source file='/var/lib/libvirt/images/rhel7.3.1483605924'>
+          <privateData>
+            <nodenames>
+              <nodename type='storage' name='#block624'/>
+              <nodename type='format' name='#block767'/>
+            </nodenames>
+          </privateData>
+        </source>
+        <backingStore type='file' index='4'>
+          <format type='qcow2'/>
+          <source file='/var/lib/libvirt/images/rhel7.3.1483605920'>
+            <privateData>
+              <nodenames>
+                <nodename type='storage' name='#block869'/>
+                <nodename type='format' name='#block937'/>
+              </nodenames>
+            </privateData>
+          </source>
+          <backingStore type='file' index='5'>
+            <format type='qcow2'/>
+            <source file='/var/lib/libvirt/images/rhel7.3.1483546244'>
+              <privateData>
+                <nodenames>
+                  <nodename type='storage' name='#block1047'/>
+                  <nodename type='format' name='#block1157'/>
+                </nodenames>
+              </privateData>
+            </source>
+            <backingStore type='file' index='6'>
+              <format type='qcow2'/>
+              <source file='/var/lib/libvirt/images/rhel7.3.1483545901'>
+                <privateData>
+                  <nodenames>
+                    <nodename type='storage' name='#block1279'/>
+                    <nodename type='format' name='#block1392'/>
+                  </nodenames>
+                </privateData>
+              </source>
+              <backingStore type='file' index='7'>
+                <format type='qcow2'/>
+                <source file='/var/lib/libvirt/images/rhel7.3.1483545313'>
+                  <privateData>
+                    <nodenames>
+                      <nodename type='storage' name='#block1444'/>
+                      <nodename type='format' name='#block1523'/>
+                    </nodenames>
+                  </privateData>
+                </source>
+                <backingStore type='file' index='8'>
+                  <format type='qcow2'/>
+                  <source file='/var/lib/libvirt/images/rhel7.3.1483536402'>
+                    <privateData>
+                      <nodenames>
+                        <nodename type='storage' name='#block1602'/>
+                        <nodename type='format' name='#block1742'/>
+                      </nodenames>
+                    </privateData>
+                  </source>
+                  <backingStore type='file' index='9'>
+                    <format type='qcow2'/>
+                    <source file='/var/lib/libvirt/images/rhel7.3.qcow2'>
+                      <privateData>
+                        <nodenames>
+                          <nodename type='storage' name='#block1864'/>
+                          <nodename type='format' name='#block1909'/>
+                        </nodenames>
+                      </privateData>
+                    </source>
+                    <backingStore/>
+                  </backingStore>
+                </backingStore>
+              </backingStore>
+            </backingStore>
+          </backingStore>
+        </backingStore>
+      </backingStore>
+    </backingStore>
+  </backingStore>
+  <target dev='vda' bus='virtio'/>
+  <alias name='virtio-disk0'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json
new file mode 100644
index 0000000000..8fcdc48bb0
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json
@@ -0,0 +1,25 @@
+{
+  "node-name": "#block126",
+  "read-only": false,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1507297895",
+    "node-name": "#block004",
+    "read-only": false,
+    "discard": "unmap"
+  },
+  "backing": "#block313"
+}
+{
+  "node-name": "#block313",
+  "read-only": true,
+  "driver": "qcow2",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/rhel7.3.1484071872",
+    "node-name": "#block256",
+    "read-only": true,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml
new file mode 100644
index 0000000000..7520cfe86a
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml
@@ -0,0 +1,24 @@
+<disk type='file' device='disk'>
+  <driver name='qemu' type='qcow2'/>
+  <source file='/var/lib/libvirt/images/rhel7.3.1507297895'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='#block004'/>
+        <nodename type='format' name='#block126'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <backingStore type='file' index='1'>
+    <format type='qcow2'/>
+    <source file='/var/lib/libvirt/images/rhel7.3.1484071872'>
+      <privateData>
+        <nodenames>
+          <nodename type='storage' name='#block256'/>
+          <nodename type='format' name='#block313'/>
+        </nodenames>
+      </privateData>
+    </source>
+  </backingStore>
+  <target dev='vda' bus='virtio'/>
+  <alias name='virtio-disk0'/>
+</disk>
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 31/35] tests: qemublock: basic qcow2 tests
Posted by John Ferlan 7 years ago

On 04/25/2018 11:15 AM, Peter Krempa wrote:
> Add tests for backing chain handling, including a very long chain which
> is fully specified in the XML and an unterminated chain.
> 
> The top level disk image would generate the following '-drive':
> 
> file-qcow2-backing-chain-encryption.xml:
> -drive file=/var/lib/libvirt/images/a,encrypt.format=luks,
>     encrypt.key-secret=node-b-f-encalias,format=qcow2,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-qcow2-backing-chain-noopts.xml:
> -drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-qcow2-backing-chain-unterminated.xml:
> -drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  tests/qemublocktest.c                              |   3 +
>  .../file-qcow2-backing-chain-encryption.json       |  34 ++++++
>  .../file-qcow2-backing-chain-encryption.xml        |  31 +++++
>  .../xml2json/file-qcow2-backing-chain-noopts.json  | 130 +++++++++++++++++++++
>  .../xml2json/file-qcow2-backing-chain-noopts.xml   | 113 ++++++++++++++++++
>  .../file-qcow2-backing-chain-unterminated.json     |  25 ++++
>  .../file-qcow2-backing-chain-unterminated.xml      |  24 ++++
>  7 files changed, 360 insertions(+)
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json
>  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml
> 

hahahaha... basic... hahahaha

and perhaps a more real-life example from -noopts output "#blockNNN"...
Too bad one of those rhel7.3 paths didn't have 3.14159265359 ...

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 31/35] tests: qemublock: basic qcow2 tests
Posted by Peter Krempa 7 years ago
On Wed, May 02, 2018 at 19:21:39 -0400, John Ferlan wrote:
> 
> 
> On 04/25/2018 11:15 AM, Peter Krempa wrote:
> > Add tests for backing chain handling, including a very long chain which
> > is fully specified in the XML and an unterminated chain.
> > 
> > The top level disk image would generate the following '-drive':
> > 
> > file-qcow2-backing-chain-encryption.xml:
> > -drive file=/var/lib/libvirt/images/a,encrypt.format=luks,
> >     encrypt.key-secret=node-b-f-encalias,format=qcow2,if=none,id=drive-dummy
> > -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> > 
> > file-qcow2-backing-chain-noopts.xml:
> > -drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
> > -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> > 
> > file-qcow2-backing-chain-unterminated.xml:
> > -drive file=/var/lib/libvirt/images/rhel7.3.1507297895,format=qcow2,if=none,id=drive-dummy
> > -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> >  tests/qemublocktest.c                              |   3 +
> >  .../file-qcow2-backing-chain-encryption.json       |  34 ++++++
> >  .../file-qcow2-backing-chain-encryption.xml        |  31 +++++
> >  .../xml2json/file-qcow2-backing-chain-noopts.json  | 130 +++++++++++++++++++++
> >  .../xml2json/file-qcow2-backing-chain-noopts.xml   | 113 ++++++++++++++++++
> >  .../file-qcow2-backing-chain-unterminated.json     |  25 ++++
> >  .../file-qcow2-backing-chain-unterminated.xml      |  24 ++++
> >  7 files changed, 360 insertions(+)
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.json
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.xml
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.xml
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.json
> >  create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminated.xml
> > 
> 
> hahahaha... basic... hahahaha

Oh, right. That was the patch subject prior to adding more of the tests
:)

> and perhaps a more real-life example from -noopts output "#blockNNN"...

Oh, yeah, the node names are super fake (or in the case of the -noopts
test harvested from a real qemu run and then dumped from the status XML)
in all of the tests. The libvirt generated node names will be different,
but for the sake of testing this should be enough.

> Too bad one of those rhel7.3 paths didn't have 3.14159265359 ...

Well, the number after dot is the timestamp when the snapshot was taken.

Your example is still possible:

$ date --date='@14159265359'
Sun Sep  9 10:15:59 CET 2418

If you drop the 9 at the end to get to the correct magnitude you'll get:

$ date --date='@1415926535'
Fri Nov 14 01:55:35 CET 2014

sooo, in 2014, there was no rhel 7.3, and I hope that no sane person
will use rhel 7.3 in year 2418. Maybe rhel 107.3 will be possible at
that time though ;)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list