storagevolxml2argvtest: Use internal wrapping of command line arguments

virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-03-31 10:46:36 +02:00
parent eba7491c59
commit 19d7f60133
25 changed files with 92 additions and 78 deletions

View File

@ -1,4 +1,6 @@
qemu-img \
convert \
-f raw \
-O raw /var/lib/libvirt/images/test.iso /var/lib/libvirt/images/sparse.img
-O raw \
/var/lib/libvirt/images/test.iso \
/var/lib/libvirt/images/sparse.img

View File

@ -1,3 +1,5 @@
qemu-img \
create \
-f raw /var/lib/libvirt/images/test.iso 1024K
-f raw \
/var/lib/libvirt/images/test.iso \
1024K

View File

@ -1,4 +1,6 @@
qemu-img \
convert \
-f qcow2 \
-O raw /var/lib/libvirt/images/OtherDemo.img /dev/HostVG/Swap
-O raw \
/var/lib/libvirt/images/OtherDemo.img \
/dev/HostVG/Swap

View File

@ -2,6 +2,6 @@ qemu-img \
create \
-f luks \
--object secret,id=LuksDemo.img_encrypt0,file=/path/to/secretFile \
-o key-secret=LuksDemo.img_encrypt0,cipher-alg=serpent-256,cipher-mode=cbc,\
hash-alg=sha256,ivgen-alg=plain64,\
ivgen-hash-alg=sha256 /var/lib/libvirt/images/LuksDemo.img 5242880K
-o key-secret=LuksDemo.img_encrypt0,cipher-alg=serpent-256,cipher-mode=cbc,hash-alg=sha256,ivgen-alg=plain64,ivgen-hash-alg=sha256 \
/var/lib/libvirt/images/LuksDemo.img \
5242880K

View File

@ -2,7 +2,8 @@ qemu-img \
create \
-f luks \
--object secret,id=LuksDemo.img_encrypt0,file=/path/to/secretFile \
-o key-secret=LuksDemo.img_encrypt0 /var/lib/libvirt/images/LuksDemo.img \
-o key-secret=LuksDemo.img_encrypt0 \
/var/lib/libvirt/images/LuksDemo.img \
5242880K
qemu-img \
convert \
@ -10,9 +11,6 @@ convert \
-n \
--target-image-opts \
--object secret,id=LuksDemo.img_encrypt0,file=/path/to/secretFile \
--object secret,id=OtherDemo.img_encrypt0,\
file=/path/to/inputSecretFile driver=luks,\
file.filename=/var/lib/libvirt/images/OtherDemo.img,\
key-secret=OtherDemo.img_encrypt0 driver=luks,\
file.filename=/var/lib/libvirt/images/LuksDemo.img,\
key-secret=LuksDemo.img_encrypt0
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/inputSecretFile \
driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,key-secret=OtherDemo.img_encrypt0 \
driver=luks,file.filename=/var/lib/libvirt/images/LuksDemo.img,key-secret=LuksDemo.img_encrypt0

View File

@ -1,14 +1,14 @@
qemu-img \
create \
-f qcow2 \
-o compat=0.10 /var/lib/libvirt/images/sparse-qcow2.img 1073741824K
-o compat=0.10 \
/var/lib/libvirt/images/sparse-qcow2.img \
1073741824K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemo.img_encrypt0,\
file=/path/to/inputSecretFile driver=luks,\
file.filename=/var/lib/libvirt/images/OtherDemo.img,\
key-secret=OtherDemo.img_encrypt0 driver=qcow2,\
file.filename=/var/lib/libvirt/images/sparse-qcow2.img
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/inputSecretFile \
driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,key-secret=OtherDemo.img_encrypt0 \
driver=qcow2,file.filename=/var/lib/libvirt/images/sparse-qcow2.img

View File

@ -1,13 +1,13 @@
qemu-img \
create \
-f raw /var/lib/libvirt/images/sparse.img 1073741824K
-f raw \
/var/lib/libvirt/images/sparse.img \
1073741824K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemo.img_encrypt0,\
file=/path/to/inputSecretFile driver=luks,\
file.filename=/var/lib/libvirt/images/OtherDemo.img,\
key-secret=OtherDemo.img_encrypt0 driver=raw,\
file.filename=/var/lib/libvirt/images/sparse.img
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/inputSecretFile \
driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,key-secret=OtherDemo.img_encrypt0 \
driver=raw,file.filename=/var/lib/libvirt/images/sparse.img

View File

@ -2,15 +2,14 @@ qemu-img \
create \
-f luks \
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
-o key-secret=OtherDemo.img_encrypt0 /var/lib/libvirt/images/OtherDemo.img \
-o key-secret=OtherDemo.img_encrypt0 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemo.img_encrypt0,\
file=/path/to/secretFile driver=qcow2,\
file.filename=/var/lib/libvirt/images/sparse-qcow2.img driver=luks,\
file.filename=/var/lib/libvirt/images/OtherDemo.img,\
key-secret=OtherDemo.img_encrypt0
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
driver=qcow2,file.filename=/var/lib/libvirt/images/sparse-qcow2.img \
driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,key-secret=OtherDemo.img_encrypt0

View File

@ -2,14 +2,14 @@ qemu-img \
create \
-f luks \
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
-o key-secret=OtherDemo.img_encrypt0 /var/lib/libvirt/images/OtherDemo.img \
-o key-secret=OtherDemo.img_encrypt0 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile driver=raw,\
file.filename=/var/lib/libvirt/images/sparse.img driver=luks,\
file.filename=/var/lib/libvirt/images/OtherDemo.img,\
key-secret=OtherDemo.img_encrypt0
--object secret,id=OtherDemo.img_encrypt0,file=/path/to/secretFile \
driver=raw,file.filename=/var/lib/libvirt/images/sparse.img \
driver=luks,file.filename=/var/lib/libvirt/images/OtherDemo.img,key-secret=OtherDemo.img_encrypt0

View File

@ -2,5 +2,6 @@ qemu-img \
create \
-f luks \
--object secret,id=LuksDemo.img_encrypt0,file=/path/to/secretFile \
-o key-secret=LuksDemo.img_encrypt0 /var/lib/libvirt/images/LuksDemo.img \
-o key-secret=LuksDemo.img_encrypt0 \
/var/lib/libvirt/images/LuksDemo.img \
5242880K

View File

@ -2,4 +2,6 @@ qemu-img \
create \
-f qcow2 \
-b /dev/null \
-o backing_fmt=raw,compat=1.1 /var/lib/libvirt/images/OtherDemo.img 5242880K
-o backing_fmt=raw,compat=1.1 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K

View File

@ -2,4 +2,6 @@ qemu-img \
create \
-f qcow2 \
-b /dev/null \
-o backing_fmt=raw,compat=0.10 /var/lib/libvirt/images/OtherDemo.img 5242880K
-o backing_fmt=raw,compat=0.10 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K

View File

@ -2,4 +2,6 @@ qemu-img \
convert \
-f raw \
-O qcow2 \
-o compat=0.10 /dev/HostVG/Swap /var/lib/libvirt/images/OtherDemo.img
-o compat=0.10 \
/dev/HostVG/Swap \
/var/lib/libvirt/images/OtherDemo.img

View File

@ -2,5 +2,6 @@ qemu-img \
create \
-f qcow2 \
-b /dev/null \
-o backing_fmt=raw,compat=1.1,\
lazy_refcounts /var/lib/libvirt/images/OtherDemo.img 5242880K
-o backing_fmt=raw,compat=1.1,lazy_refcounts \
/var/lib/libvirt/images/OtherDemo.img \
5242880K

View File

@ -2,17 +2,15 @@ qemu-img \
create \
-f qcow2 \
--object secret,id=OtherDemoLuks.img_encrypt0,file=/path/to/secretFile \
-o encrypt.format=luks,encrypt.key-secret=OtherDemoLuks.img_encrypt0,\
compat=0.10 /var/lib/libvirt/images/OtherDemoLuks.img 5242880K
-o encrypt.format=luks,encrypt.key-secret=OtherDemoLuks.img_encrypt0,compat=0.10 \
/var/lib/libvirt/images/OtherDemoLuks.img \
5242880K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemoLuks.img_encrypt0,file=/path/to/secretFile \
--object secret,id=OtherDemoLuksConvert.img_encrypt0,\
file=/path/to/inputSecretFile driver=qcow2,\
file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,\
encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 driver=qcow2,\
file.filename=/var/lib/libvirt/images/OtherDemoLuks.img,\
encrypt.key-secret=OtherDemoLuks.img_encrypt0
--object secret,id=OtherDemoLuksConvert.img_encrypt0,file=/path/to/inputSecretFile \
driver=qcow2,file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 \
driver=qcow2,file.filename=/var/lib/libvirt/images/OtherDemoLuks.img,encrypt.key-secret=OtherDemoLuks.img_encrypt0

View File

@ -1,14 +1,14 @@
qemu-img \
create \
-f qcow2 \
-o compat=0.10 /var/lib/libvirt/images/sparse-qcow2.img 1073741824K
-o compat=0.10 \
/var/lib/libvirt/images/sparse-qcow2.img \
1073741824K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemoLuksConvert.img_encrypt0,\
file=/path/to/inputSecretFile driver=qcow2,\
file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,\
encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 driver=qcow2,\
file.filename=/var/lib/libvirt/images/sparse-qcow2.img
--object secret,id=OtherDemoLuksConvert.img_encrypt0,file=/path/to/inputSecretFile \
driver=qcow2,file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 \
driver=qcow2,file.filename=/var/lib/libvirt/images/sparse-qcow2.img

View File

@ -1,13 +1,13 @@
qemu-img \
create \
-f raw /var/lib/libvirt/images/sparse.img 1073741824K
-f raw \
/var/lib/libvirt/images/sparse.img \
1073741824K
qemu-img \
convert \
--image-opts \
-n \
--target-image-opts \
--object secret,id=OtherDemoLuksConvert.img_encrypt0,\
file=/path/to/inputSecretFile driver=qcow2,\
file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,\
encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 driver=raw,\
file.filename=/var/lib/libvirt/images/sparse.img
--object secret,id=OtherDemoLuksConvert.img_encrypt0,file=/path/to/inputSecretFile \
driver=qcow2,file.filename=/var/lib/libvirt/images/OtherDemoLuksConvert.img,encrypt.key-secret=OtherDemoLuksConvert.img_encrypt0 \
driver=raw,file.filename=/var/lib/libvirt/images/sparse.img

View File

@ -3,6 +3,6 @@ create \
-f qcow2 \
-b /dev/null \
--object secret,id=OtherDemoLuks.img_encrypt0,file=/path/to/secretFile \
-o backing_fmt=raw,encrypt.format=luks,\
encrypt.key-secret=OtherDemoLuks.img_encrypt0,\
compat=0.10 /var/lib/libvirt/images/OtherDemoLuks.img 5242880K
-o backing_fmt=raw,encrypt.format=luks,encrypt.key-secret=OtherDemoLuks.img_encrypt0,compat=0.10 \
/var/lib/libvirt/images/OtherDemoLuks.img \
5242880K

View File

@ -2,6 +2,6 @@ qemu-img \
convert \
-f raw \
-O qcow2 \
-o preallocation=metadata,\
compat=0.10 /var/lib/libvirt/images/sparse.img \
-o preallocation=metadata,compat=0.10 \
/var/lib/libvirt/images/sparse.img \
/var/lib/libvirt/images/OtherDemo.img

View File

@ -1,5 +1,6 @@
qemu-img \
create \
-f qcow2 \
-o preallocation=metadata,\
compat=0.10 /var/lib/libvirt/images/OtherDemo.img 5242880K
-o preallocation=metadata,compat=0.10 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K

View File

@ -2,6 +2,6 @@ qemu-img \
convert \
-f raw \
-O qcow2 \
-o preallocation=falloc,\
compat=0.10 /var/lib/libvirt/images/sparse.img \
-o preallocation=falloc,compat=0.10 \
/var/lib/libvirt/images/sparse.img \
/var/lib/libvirt/images/OtherDemo.img

View File

@ -2,4 +2,5 @@ qemu-img \
create \
-f qcow2 \
-b /dev/null \
-o backing_fmt=raw,compat=0.10 /var/lib/libvirt/images/OtherDemo.img
-o backing_fmt=raw,compat=0.10 \
/var/lib/libvirt/images/OtherDemo.img

View File

@ -2,5 +2,6 @@ qemu-img \
create \
-f qcow2 \
-b /dev/null \
-o backing_fmt=raw,nocow=on,\
compat=0.10 /var/lib/libvirt/images/OtherDemo.img 5242880K
-o backing_fmt=raw,nocow=on,compat=0.10 \
/var/lib/libvirt/images/OtherDemo.img \
5242880K

View File

@ -1,4 +1,6 @@
qemu-img \
create \
-f qcow2 \
-o compat=0.10 /var/lib/libvirt/images/OtherDemo.img 0K
-o compat=0.10 \
/var/lib/libvirt/images/OtherDemo.img \
0K

View File

@ -104,13 +104,13 @@ testCompareXMLToArgvFiles(bool shouldFail,
}
if (convertStep != VIR_STORAGE_VOL_ENCRYPT_CONVERT) {
if (!(actualCmdline = virCommandToString(cmd, false)))
if (!(actualCmdline = virCommandToString(cmd, true)))
goto cleanup;
} else {
char *createCmdline = actualCmdline;
g_autofree char *cvtCmdline = NULL;
if (!(cvtCmdline = virCommandToString(cmd, false)))
if (!(cvtCmdline = virCommandToString(cmd, true)))
goto cleanup;
actualCmdline = g_strdup_printf("%s\n%s", createCmdline, cvtCmdline);
@ -127,7 +127,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
} while (convertStep != VIR_STORAGE_VOL_ENCRYPT_DONE);
if (virTestCompareToFile(actualCmdline, cmdline) < 0)
if (virTestCompareToFileFull(actualCmdline, cmdline, false) < 0)
goto cleanup;
ret = 0;