Discussion:
[libvirt] [PATCH 0/5] Various cleanups and fixes (blockdev-add saga)
Peter Krempa
2018-12-05 13:20:11 UTC
Permalink
Few random patches extracted from my blockdev series.

Peter Krempa (5):
tests: qemuxml2xml: Add few debug statements for status XML testing
util: xml: Always consume args of virXMLFormatElement
qemu: domain: Initialize proper element in
qemuDomainPrepareStorageSourceBlockdev
conf: snapshot: Remove file format check from parser
tests: qemuxml2argv: Remove disks from few tests which don't need them

src/conf/domain_conf.c | 12 ++----------
src/conf/snapshot_conf.c | 12 +++---------
src/qemu/qemu_domain.c | 9 +++------
src/util/virxml.c | 16 ++++++++++++----
.../channel-unix-guestfwd.x86_64-2.5.0.args | 2 --
.../channel-unix-guestfwd.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 5 -----
.../console-virtio-unix.x86_64-2.5.0.args | 2 --
.../console-virtio-unix.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/console-virtio-unix.xml | 5 -----
tests/qemuxml2argvdata/net-vhostuser.args | 3 ---
.../net-vhostuser.x86_64-2.5.0.args | 2 --
.../net-vhostuser.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/net-vhostuser.xml | 6 ------
.../parallel-unix-chardev.x86_64-2.5.0.args | 2 --
.../parallel-unix-chardev.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/parallel-unix-chardev.xml | 5 -----
tests/qemuxml2xmloutdata/net-vhostuser.xml | 6 ------
tests/qemuxml2xmltest.c | 9 ++++++---
19 files changed, 26 insertions(+), 78 deletions(-)
--
2.19.2
Peter Krempa
2018-12-05 13:20:12 UTC
Permalink
Add markers for allowing test debugging if one of the steps fails
without setting a proper error.

Signed-off-by: Peter Krempa <***@redhat.com>
---
tests/qemuxml2xmltest.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 25ab990a4b..c98b9571ef 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -74,17 +74,20 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
VIR_DOMAIN_DEF_PARSE_ACTUAL_NET |
VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
- VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL)))
+ VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))) {
+ VIR_TEST_DEBUG("\nfailed to parse '%s'\n", data->inName);
goto cleanup;
+ }

if (!(actual = virDomainObjFormat(driver.xmlopt, obj, NULL,
VIR_DOMAIN_DEF_FORMAT_SECURE |
VIR_DOMAIN_DEF_FORMAT_STATUS |
VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
- VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST)))
-
+ VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST))) {
+ VIR_TEST_DEBUG("\nfailed to format back '%s'\n", data->inName);
goto cleanup;
+ }

if (virTestCompareToFile(actual, data->outActiveName) < 0)
goto cleanup;
--
2.19.2
Peter Krempa
2018-12-05 13:20:13 UTC
Permalink
The function clears and frees the passed buffers on success, but not in
one case of failure. Modify the control flow that the args are always
consumed, record it in the docs and remove few pointless cleanup paths
in callers.

Signed-off-by: Peter Krempa <***@redhat.com>
---
src/conf/domain_conf.c | 12 ++----------
src/qemu/qemu_domain.c | 5 +----
src/util/virxml.c | 16 ++++++++++++----
3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0c40a98f6b..b70dca6c61 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -24042,7 +24042,6 @@ virDomainDiskDefFormatIotune(virBufferPtr buf,
virDomainDiskDefPtr disk)
{
virBuffer childBuf = VIR_BUFFER_INITIALIZER;
- int ret = -1;

virBufferSetChildIndent(&childBuf, buf);

@@ -24077,10 +24076,7 @@ virDomainDiskDefFormatIotune(virBufferPtr buf,
FORMAT_IOTUNE(read_iops_sec_max_length);
FORMAT_IOTUNE(write_iops_sec_max_length);

- ret = virXMLFormatElement(buf, "iotune", NULL, &childBuf);
-
- virBufferFreeAndReset(&childBuf);
- return ret;
+ return virXMLFormatElement(buf, "iotune", NULL, &childBuf);
}

#undef FORMAT_IOTUNE
@@ -24091,7 +24087,6 @@ virDomainDiskDefFormatDriver(virBufferPtr buf,
virDomainDiskDefPtr disk)
{
virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
- int ret = -1;

virBufferEscapeString(&driverBuf, " name='%s'", virDomainDiskGetDriver(disk));

@@ -24143,10 +24138,7 @@ virDomainDiskDefFormatDriver(virBufferPtr buf,

virDomainVirtioOptionsFormat(&driverBuf, disk->virtio);

- ret = virXMLFormatElement(buf, "driver", &driverBuf, NULL);
-
- virBufferFreeAndReset(&driverBuf);
- return ret;
+ return virXMLFormatElement(buf, "driver", &driverBuf, NULL);
}


diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index dd17174e25..77814a0c2a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2234,14 +2234,11 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf,
{
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
bool bj = qemuDomainHasBlockjob(vm, false);
- int ret;

virBufferAsprintf(&attrBuf, " active='%s'",
virTristateBoolTypeToString(virTristateBoolFromBool(bj)));

- ret = virXMLFormatElement(buf, "blockjobs", &attrBuf, NULL);
- virBufferFreeAndReset(&attrBuf);
- return ret;
+ return virXMLFormatElement(buf, "blockjobs", &attrBuf, NULL);
}


diff --git a/src/util/virxml.c b/src/util/virxml.c
index 998d974882..3ed44e9036 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1359,6 +1359,8 @@ virXMLValidatorFree(virXMLValidatorPtr validator)
* @childBuf are NULL or are empty buffers the element is not
* formatted.
*
+ * Both passed buffers are always consumed and freed.
+ *
* Returns 0 on success, -1 on error.
*/
int
@@ -1367,15 +1369,16 @@ virXMLFormatElement(virBufferPtr buf,
virBufferPtr attrBuf,
virBufferPtr childBuf)
{
+ int ret = -1;
+
if ((!attrBuf || virBufferUse(attrBuf) == 0) &&
(!childBuf || virBufferUse(childBuf) == 0)) {
return 0;
}

if ((attrBuf && virBufferCheckError(attrBuf) < 0) ||
- (childBuf && virBufferCheckError(childBuf) < 0)) {
- return -1;
- }
+ (childBuf && virBufferCheckError(childBuf) < 0))
+ goto cleanup;

virBufferAsprintf(buf, "<%s", name);

@@ -1390,5 +1393,10 @@ virXMLFormatElement(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}

- return 0;
+ ret = 0;
+
+ cleanup:
+ virBufferFreeAndReset(attrBuf);
+ virBufferFreeAndReset(childBuf);
+ return ret;
}
--
2.19.2
Peter Krempa
2018-12-05 13:20:16 UTC
Permalink
Remove the disk from tests focusing on other aspects so that change to
-blockdev will touch less tests.

Signed-off-by: Peter Krempa <***@redhat.com>
---
.../channel-unix-guestfwd.x86_64-2.5.0.args | 2 --
.../channel-unix-guestfwd.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 5 -----
.../qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args | 2 --
.../qemuxml2argvdata/console-virtio-unix.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/console-virtio-unix.xml | 5 -----
tests/qemuxml2argvdata/net-vhostuser.args | 3 ---
tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args | 2 --
tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/net-vhostuser.xml | 6 ------
.../parallel-unix-chardev.x86_64-2.5.0.args | 2 --
.../parallel-unix-chardev.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/parallel-unix-chardev.xml | 5 -----
tests/qemuxml2xmloutdata/net-vhostuser.xml | 6 ------
14 files changed, 46 deletions(-)

diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args
index f0e718e4a2..e8776ca24e 100644
--- a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args
+++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args
@@ -23,8 +23,6 @@ server,nowait \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charchannel0,path=/tmp/guestfwd-listen.socket,server,nowait \
-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \
-chardev socket,id=charchannel1,path=/tmp/guestfwd-connect.socket \
diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args
index f9b9ee5fdb..db14217c1b 100644
--- a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args
@@ -24,8 +24,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charchannel0,fd=1729,server,nowait \
-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \
-chardev socket,id=charchannel1,path=/tmp/guestfwd-connect.socket \
diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.xml b/tests/qemuxml2argvdata/channel-unix-guestfwd.xml
index c9698a1259..01c9a24ff0 100644
--- a/tests/qemuxml2argvdata/channel-unix-guestfwd.xml
+++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.xml
@@ -14,11 +14,6 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
- <disk type='block' device='disk'>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
diff --git a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args
index 425bdc5d12..5c37b1903e 100644
--- a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args
+++ b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args
@@ -24,8 +24,6 @@ server,nowait \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charconsole0,path=/tmp/listen.socket,server,nowait \
-device virtconsole,chardev=charconsole0,id=console0 \
-chardev socket,id=charconsole1,path=/tmp/connect.socket \
diff --git a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args
index 193d4b1295..0749b888b6 100644
--- a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args
@@ -25,8 +25,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charconsole0,fd=1729,server,nowait \
-device virtconsole,chardev=charconsole0,id=console0 \
-chardev socket,id=charconsole1,path=/tmp/connect.socket \
diff --git a/tests/qemuxml2argvdata/console-virtio-unix.xml b/tests/qemuxml2argvdata/console-virtio-unix.xml
index 941e5a4a8a..1e11960c26 100644
--- a/tests/qemuxml2argvdata/console-virtio-unix.xml
+++ b/tests/qemuxml2argvdata/console-virtio-unix.xml
@@ -14,11 +14,6 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
- <disk type='block' device='disk'>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<console type='unix'>
diff --git a/tests/qemuxml2argvdata/net-vhostuser.args b/tests/qemuxml2argvdata/net-vhostuser.args
index 1b35a61e27..516cb23123 100644
--- a/tests/qemuxml2argvdata/net-vhostuser.args
+++ b/tests/qemuxml2argvdata/net-vhostuser.args
@@ -20,9 +20,6 @@ QEMU_AUDIO_DRV=none \
-no-shutdown \
-no-acpi \
-usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
-bootindex=1 \
-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
diff --git a/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args b/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args
index 677a3c9e49..8f67b14a2b 100644
--- a/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args
+++ b/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args
@@ -23,8 +23,6 @@ server,nowait \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
diff --git a/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args b/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args
index 7dee2bdf58..d96d8ca3a6 100644
--- a/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args
@@ -24,8 +24,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
diff --git a/tests/qemuxml2argvdata/net-vhostuser.xml b/tests/qemuxml2argvdata/net-vhostuser.xml
index 917d67b9eb..1c491549b6 100644
--- a/tests/qemuxml2argvdata/net-vhostuser.xml
+++ b/tests/qemuxml2argvdata/net-vhostuser.xml
@@ -14,12 +14,6 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-i686</emulator>
- <disk type='block' device='disk'>
- <driver name='qemu' type='raw'/>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args
index d7d55ac611..eb504a7210 100644
--- a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args
+++ b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args
@@ -23,8 +23,6 @@ server,nowait \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charparallel0,path=/tmp/parport0.socket,server,nowait \
-device isa-parallel,chardev=charparallel0,id=parallel0 \
-chardev socket,id=charparallel1,path=/tmp/parport1.socket \
diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args
index 94841ea8c0..e3fa87c503 100644
--- a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args
@@ -24,8 +24,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charparallel0,fd=1729,server,nowait \
-device isa-parallel,chardev=charparallel0,id=parallel0 \
-chardev socket,id=charparallel1,path=/tmp/parport1.socket \
diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.xml b/tests/qemuxml2argvdata/parallel-unix-chardev.xml
index d4fe94779e..2d0bae3589 100644
--- a/tests/qemuxml2argvdata/parallel-unix-chardev.xml
+++ b/tests/qemuxml2argvdata/parallel-unix-chardev.xml
@@ -14,11 +14,6 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
- <disk type='block' device='disk'>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
<controller type='ide' index='0'/>
<parallel type='unix'>
<source mode='bind' path='/tmp/parport0.socket'/>
diff --git a/tests/qemuxml2xmloutdata/net-vhostuser.xml b/tests/qemuxml2xmloutdata/net-vhostuser.xml
index b7f1bdc57f..9655c21ede 100644
--- a/tests/qemuxml2xmloutdata/net-vhostuser.xml
+++ b/tests/qemuxml2xmloutdata/net-vhostuser.xml
@@ -14,12 +14,6 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-i686</emulator>
- <disk type='block' device='disk'>
- <driver name='qemu' type='raw'/>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
--
2.19.2
Peter Krempa
2018-12-05 13:20:14 UTC
Permalink
We are preparing a certain disk source passed in as '@src' so the
individual functions should use that rather than disk->src which
corresponds to the top level element of the chain only.

Without this change TLS and persistent reservations would not work for
backing images of a chain when using -blockdev.

Signed-off-by: Peter Krempa <***@redhat.com>
---
src/qemu/qemu_domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 77814a0c2a..382da53b7a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -13462,10 +13462,10 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
src->nodeformat) < 0)
return -1;

- if (qemuDomainPrepareStorageSourcePR(disk->src, priv, src->nodestorage) < 0)
+ if (qemuDomainPrepareStorageSourcePR(src, priv, src->nodestorage) < 0)
return -1;

- if (qemuDomainPrepareStorageSourceTLS(disk->src, cfg, src->nodestorage,
+ if (qemuDomainPrepareStorageSourceTLS(src, cfg, src->nodestorage,
priv->qemuCaps) < 0)
return -1;
--
2.19.2
Peter Krempa
2018-12-05 13:20:15 UTC
Permalink
We already have a way stricter check in the code which is doing the
snapshot so duplicating it in the parser does not make much sense. Also
gets rid of an ugly ternary operator.

Signed-off-by: Peter Krempa <***@redhat.com>
---
src/conf/snapshot_conf.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index adba149241..5a511b4495 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -159,17 +159,11 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
goto cleanup;

- if ((driver = virXPathString("string(./driver/@type)", ctxt))) {
- def->src->format = virStorageFileFormatTypeFromString(driver);
- if (def->src->format < VIR_STORAGE_FILE_BACKING) {
+ if ((driver = virXPathString("string(./driver/@type)", ctxt)) &&
+ (def->src->format = virStorageFileFormatTypeFromString(driver)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- def->src->format <= 0
- ? _("unknown disk snapshot driver '%s'")
- : _("disk format '%s' lacks backing file "
- "support"),
- driver);
+ _("unknown disk snapshot driver '%s'"), driver);
goto cleanup;
- }
}

/* validate that the passed path is absolute */
--
2.19.2
Ján Tomko
2018-12-05 13:38:29 UTC
Permalink
Post by Peter Krempa
Few random patches extracted from my blockdev series.
tests: qemuxml2xml: Add few debug statements for status XML testing
util: xml: Always consume args of virXMLFormatElement
qemu: domain: Initialize proper element in
qemuDomainPrepareStorageSourceBlockdev
conf: snapshot: Remove file format check from parser
tests: qemuxml2argv: Remove disks from few tests which don't need them
src/conf/domain_conf.c | 12 ++----------
src/conf/snapshot_conf.c | 12 +++---------
src/qemu/qemu_domain.c | 9 +++------
src/util/virxml.c | 16 ++++++++++++----
.../channel-unix-guestfwd.x86_64-2.5.0.args | 2 --
.../channel-unix-guestfwd.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 5 -----
.../console-virtio-unix.x86_64-2.5.0.args | 2 --
.../console-virtio-unix.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/console-virtio-unix.xml | 5 -----
tests/qemuxml2argvdata/net-vhostuser.args | 3 ---
.../net-vhostuser.x86_64-2.5.0.args | 2 --
.../net-vhostuser.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/net-vhostuser.xml | 6 ------
.../parallel-unix-chardev.x86_64-2.5.0.args | 2 --
.../parallel-unix-chardev.x86_64-latest.args | 2 --
tests/qemuxml2argvdata/parallel-unix-chardev.xml | 5 -----
tests/qemuxml2xmloutdata/net-vhostuser.xml | 6 ------
tests/qemuxml2xmltest.c | 9 ++++++---
19 files changed, 26 insertions(+), 78 deletions(-)
Reviewed-by: Ján Tomko <***@redhat.com>

Jano

Loading...