[libvirt] [PATCH 25/35] tests: qemublock: Add basic 'raw' file test

Peter Krempa posted 35 patches 7 years ago
[libvirt] [PATCH 25/35] tests: qemublock: Add basic 'raw' file test
Posted by Peter Krempa 7 years ago
Test the JSON props generator with a very simple 'raw' image with no
other options. The node-names for the image are 31 bytes long so that we
validate our node name detector.

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

-drive file=/var/lib/libvirt/images/i.img,format=raw,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                                 |  2 ++
 tests/qemublocktestdata/xml2json/file-raw-noopts.json | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-raw-noopts.xml  | 12 ++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 tests/qemublocktestdata/xml2json/file-raw-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-raw-noopts.xml

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 161053a717..c9a2f91992 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -404,6 +404,8 @@ mymain(void)
     TEST_DISK_TO_JSON_FULL("nodename-long-format", true);
     TEST_DISK_TO_JSON_FULL("nodename-long-protocol", true);

+    TEST_DISK_TO_JSON("file-raw-noopts");
+
  cleanup:
     virHashFree(diskxmljsondata.schema);
     qemuTestDriverFree(&driver);
diff --git a/tests/qemublocktestdata/xml2json/file-raw-noopts.json b/tests/qemublocktestdata/xml2json/file-raw-noopts.json
new file mode 100644
index 0000000000..25de571428
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-raw-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "0123456789ABCDEF0123456789ABCDE",
+  "read-only": false,
+  "driver": "raw",
+  "file": {
+    "driver": "file",
+    "filename": "/var/lib/libvirt/images/i.img",
+    "node-name": "0123456789ABCDEF0123456789ABCDE",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-raw-noopts.xml b/tests/qemublocktestdata/xml2json/file-raw-noopts.xml
new file mode 100644
index 0000000000..8255e64eb7
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-raw-noopts.xml
@@ -0,0 +1,12 @@
+<disk device='disk'>
+  <driver name='qemu' type='raw'/>
+  <source file='/var/lib/libvirt/images/i.img'>
+    <privateData>
+      <nodenames>
+        <nodename type='storage' name='0123456789ABCDEF0123456789ABCDE'/>
+        <nodename type='format' name='0123456789ABCDEF0123456789ABCDE'/>
+      </nodenames>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 25/35] tests: qemublock: Add basic 'raw' file test
Posted by John Ferlan 7 years ago

On 04/25/2018 11:15 AM, Peter Krempa wrote:
> Test the JSON props generator with a very simple 'raw' image with no
> other options. The node-names for the image are 31 bytes long so that we
> validate our node name detector.
> 
> The top level disk image would generate the following '-drive' cmdline:
> 
> -drive file=/var/lib/libvirt/images/i.img,format=raw,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

One would think we'd be able to test that too ;-)

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

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 25/35] tests: qemublock: Add basic 'raw' file test
Posted by Peter Krempa 7 years ago
On Wed, May 02, 2018 at 18:39:44 -0400, John Ferlan wrote:
> 
> 
> On 04/25/2018 11:15 AM, Peter Krempa wrote:
> > Test the JSON props generator with a very simple 'raw' image with no
> > other options. The node-names for the image are 31 bytes long so that we
> > validate our node name detector.
> > 
> > The top level disk image would generate the following '-drive' cmdline:
> > 
> > -drive file=/var/lib/libvirt/images/i.img,format=raw,if=none,id=drive-dummy
> > -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> One would think we'd be able to test that too ;-)

I've actually generated these by instrumenting the test function to call
the old generators as well. The thing is that the mapping to -drive
command line is valid only for now, when I'm striving to fully replace
-drive. Once blockdev is used new features will be added only to the
blockdev infrastructure so the mapping to -drive will become invalid.
Thus I chose to not test this aspect.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list