[libvirt] [RFC PATCH 22/30] tests: qemublock: Add tests for all other format without special options

Peter Krempa posted 30 patches 7 years ago
[libvirt] [RFC PATCH 22/30] tests: qemublock: Add tests for all other format without special options
Posted by Peter Krempa 7 years ago
Similarly to the 'raw' case add tests for bochs, cloop, dmg, ploop, vdi
vhd, and vpc. Covering all supproted non-backing formats.

Note that the JSON name for 'ploop' maps to 'parallels' and 'vhd' maps
to 'vhdx'.

Files added here would result in the followint configs:

file-bochs-noopts.xml:
-drive file=/path/to/i.img,format=bochs,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-cloop-noopts.xml:
-drive file=/path/to/i.img,format=cloop,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-dmg-noopts.xml:
-drive file=/path/to/i.img,format=dmg,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-ploop-noopts.xml:
-drive file=/path/to/i.img,format=ploop,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-vdi-noopts.xml:
-drive file=/path/to/i.img,format=vdi,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-vhd-noopts.xml:
-drive file=/path/to/i.img,format=vhd,if=none,id=drive-dummy
-device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy

file-vpc-noopts.xml:
-drive file=/path/to/i.img,format=vpc,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                                   |  7 +++++++
 tests/qemublocktestdata/xml2json/file-bochs-noopts.json | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-bochs-noopts.xml  |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-cloop-noopts.json | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-cloop-noopts.xml  |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-dmg-noopts.json   | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-dmg-noopts.xml    |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-ploop-noopts.json | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-ploop-noopts.xml  |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-vdi-noopts.json   | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-vdi-noopts.xml    |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-vhd-noopts.json   | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-vhd-noopts.xml    |  9 +++++++++
 tests/qemublocktestdata/xml2json/file-vpc-noopts.json   | 12 ++++++++++++
 tests/qemublocktestdata/xml2json/file-vpc-noopts.xml    |  9 +++++++++
 15 files changed, 154 insertions(+)
 create mode 100644 tests/qemublocktestdata/xml2json/file-bochs-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-bochs-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-cloop-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-cloop-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-dmg-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-dmg-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-ploop-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-ploop-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-vdi-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-vdi-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-vhd-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-vhd-noopts.xml
 create mode 100644 tests/qemublocktestdata/xml2json/file-vpc-noopts.json
 create mode 100644 tests/qemublocktestdata/xml2json/file-vpc-noopts.xml

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index c9a2f91992..feb25c69e3 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -405,6 +405,13 @@ mymain(void)
     TEST_DISK_TO_JSON_FULL("nodename-long-protocol", true);

     TEST_DISK_TO_JSON("file-raw-noopts");
+    TEST_DISK_TO_JSON("file-bochs-noopts");
+    TEST_DISK_TO_JSON("file-cloop-noopts");
+    TEST_DISK_TO_JSON("file-dmg-noopts");
+    TEST_DISK_TO_JSON("file-ploop-noopts");
+    TEST_DISK_TO_JSON("file-vdi-noopts");
+    TEST_DISK_TO_JSON("file-vhd-noopts");
+    TEST_DISK_TO_JSON("file-vpc-noopts");

  cleanup:
     virHashFree(diskxmljsondata.schema);
diff --git a/tests/qemublocktestdata/xml2json/file-bochs-noopts.json b/tests/qemublocktestdata/xml2json/file-bochs-noopts.json
new file mode 100644
index 0000000000..22e2560998
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-bochs-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "bochs",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-bochs-noopts.xml b/tests/qemublocktestdata/xml2json/file-bochs-noopts.xml
new file mode 100644
index 0000000000..ebe9da438c
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-bochs-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='bochs'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-cloop-noopts.json b/tests/qemublocktestdata/xml2json/file-cloop-noopts.json
new file mode 100644
index 0000000000..b72bb5df56
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-cloop-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "cloop",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-cloop-noopts.xml b/tests/qemublocktestdata/xml2json/file-cloop-noopts.xml
new file mode 100644
index 0000000000..d48219145d
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-cloop-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='cloop'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-dmg-noopts.json b/tests/qemublocktestdata/xml2json/file-dmg-noopts.json
new file mode 100644
index 0000000000..9f2912b8d3
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-dmg-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "dmg",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-dmg-noopts.xml b/tests/qemublocktestdata/xml2json/file-dmg-noopts.xml
new file mode 100644
index 0000000000..27f4fa8cd6
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-dmg-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='dmg'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-ploop-noopts.json b/tests/qemublocktestdata/xml2json/file-ploop-noopts.json
new file mode 100644
index 0000000000..64006d28a3
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-ploop-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "parallels",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-ploop-noopts.xml b/tests/qemublocktestdata/xml2json/file-ploop-noopts.xml
new file mode 100644
index 0000000000..5f47f6b73b
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-ploop-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='ploop'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-vdi-noopts.json b/tests/qemublocktestdata/xml2json/file-vdi-noopts.json
new file mode 100644
index 0000000000..ce8e359c91
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vdi-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "vdi",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-vdi-noopts.xml b/tests/qemublocktestdata/xml2json/file-vdi-noopts.xml
new file mode 100644
index 0000000000..5d2e76656b
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vdi-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='vdi'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-vhd-noopts.json b/tests/qemublocktestdata/xml2json/file-vhd-noopts.json
new file mode 100644
index 0000000000..d4b8e1f55a
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vhd-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "vhdx",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-vhd-noopts.xml b/tests/qemublocktestdata/xml2json/file-vhd-noopts.xml
new file mode 100644
index 0000000000..c6a9686a95
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vhd-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='vhd'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
diff --git a/tests/qemublocktestdata/xml2json/file-vpc-noopts.json b/tests/qemublocktestdata/xml2json/file-vpc-noopts.json
new file mode 100644
index 0000000000..be1ec795a7
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vpc-noopts.json
@@ -0,0 +1,12 @@
+{
+  "node-name": "test1",
+  "read-only": false,
+  "driver": "vpc",
+  "file": {
+    "driver": "file",
+    "filename": "/path/to/i.img",
+    "node-name": "test2",
+    "read-only": false,
+    "discard": "unmap"
+  }
+}
diff --git a/tests/qemublocktestdata/xml2json/file-vpc-noopts.xml b/tests/qemublocktestdata/xml2json/file-vpc-noopts.xml
new file mode 100644
index 0000000000..5f79c4a826
--- /dev/null
+++ b/tests/qemublocktestdata/xml2json/file-vpc-noopts.xml
@@ -0,0 +1,9 @@
+<disk device='disk'>
+  <driver name='qemu' type='vpc'/>
+  <source file='/path/to/i.img'>
+    <privateData>
+      <nodename format='test1' storage='test2'/>
+    </privateData>
+  </source>
+  <target dev='vda'/>
+</disk>
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 22/30] tests: qemublock: Add tests for all other format without special options
Posted by Kevin Wolf 7 years ago
Am 19.04.2018 um 17:25 hat Peter Krempa geschrieben:
> Similarly to the 'raw' case add tests for bochs, cloop, dmg, ploop, vdi
> vhd, and vpc. Covering all supproted non-backing formats.
> 
> Note that the JSON name for 'ploop' maps to 'parallels' and 'vhd' maps
> to 'vhdx'.

Your -drive lines below mention format=ploop/vhd, though. That wouldn't
actually work.

(Also 'vhd' as an alias for 'vhdx' is super confusing, because VHD is
really the name of the format implemented by QEMU's 'vpc' driver - which
is already a source of confusion on its own.)

> Files added here would result in the followint configs:
> 
> file-bochs-noopts.xml:
> -drive file=/path/to/i.img,format=bochs,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-cloop-noopts.xml:
> -drive file=/path/to/i.img,format=cloop,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-dmg-noopts.xml:
> -drive file=/path/to/i.img,format=dmg,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-ploop-noopts.xml:
> -drive file=/path/to/i.img,format=ploop,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-vdi-noopts.xml:
> -drive file=/path/to/i.img,format=vdi,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-vhd-noopts.xml:
> -drive file=/path/to/i.img,format=vhd,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> file-vpc-noopts.xml:
> -drive file=/path/to/i.img,format=vpc,if=none,id=drive-dummy
> -device virtio-blk-pci,scsi=off,drive=drive-dummy,id=dummy
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>

Some of the cases tested here or in later patches are for configurations
that wouldn't work, but I guess for a test of parsing and storing XML,
that doesn't matter.

Kevin

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 22/30] tests: qemublock: Add tests for all other format without special options
Posted by Peter Krempa 7 years ago
On Fri, Apr 20, 2018 at 13:55:35 +0200, Kevin Wolf wrote:
> Am 19.04.2018 um 17:25 hat Peter Krempa geschrieben:
> > Similarly to the 'raw' case add tests for bochs, cloop, dmg, ploop, vdi
> > vhd, and vpc. Covering all supproted non-backing formats.
> > 
> > Note that the JSON name for 'ploop' maps to 'parallels' and 'vhd' maps
> > to 'vhdx'.
> 
> Your -drive lines below mention format=ploop/vhd, though. That wouldn't
> actually work.

So, is it something that we should actually forbid? I did not actually
try all of the weird formats, so I just assumed that if we'd happily
generate the -drive command line and the 'blockdev' version exists it's
equivalent.

> (Also 'vhd' as an alias for 'vhdx' is super confusing, because VHD is
> really the name of the format implemented by QEMU's 'vpc' driver - which
> is already a source of confusion on its own.)

Hmmm, maybe that is a bug in my implementation. Since libvirt has a VPC
format and also a VHD format I thohght that VHD is just another name for
'vhxd'. If they are different, we maybe should forbid it altogether. I
confess that I did a simple prefix match rather than any complex
analysis.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 22/30] tests: qemublock: Add tests for all other format without special options
Posted by Kevin Wolf 7 years ago
Am 20.04.2018 um 21:20 hat Peter Krempa geschrieben:
> On Fri, Apr 20, 2018 at 13:55:35 +0200, Kevin Wolf wrote:
> > Am 19.04.2018 um 17:25 hat Peter Krempa geschrieben:
> > > Similarly to the 'raw' case add tests for bochs, cloop, dmg, ploop, vdi
> > > vhd, and vpc. Covering all supproted non-backing formats.
> > > 
> > > Note that the JSON name for 'ploop' maps to 'parallels' and 'vhd' maps
> > > to 'vhdx'.
> > 
> > Your -drive lines below mention format=ploop/vhd, though. That wouldn't
> > actually work.
> 
> So, is it something that we should actually forbid? I did not actually
> try all of the weird formats, so I just assumed that if we'd happily
> generate the -drive command line and the 'blockdev' version exists it's
> equivalent.

I thought it's just a mistake in the commit message and that libvirt
actually does the translation described here. So it would use -drive
format=parallels instead of ploop.

> > (Also 'vhd' as an alias for 'vhdx' is super confusing, because VHD is
> > really the name of the format implemented by QEMU's 'vpc' driver - which
> > is already a source of confusion on its own.)
> 
> Hmmm, maybe that is a bug in my implementation. Since libvirt has a VPC
> format and also a VHD format I thohght that VHD is just another name for
> 'vhxd'. If they are different, we maybe should forbid it altogether. I
> confess that I did a simple prefix match rather than any complex
> analysis.

Maybe double-check, but your assumption might be right. There would be
little reason to have both VPC and VHD, when both are names for the same
thing (except as aliases, possibly).

Kevin
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list