From 734352d4347141d525a3120d06bca90b726ac3f5 Mon Sep 17 00:00:00 2001 From: Peter Krempa <pkrempa@redhat.com> Date: Thu, 25 Jul 2019 15:54:48 +0200 Subject: [PATCH] qemu: domain: Allow formatting top source only in qemuDomainObjPrivateXMLFormatBlockjobFormatChain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename qemuDomainObjPrivateXMLFormatBlockjobFormatChain to qemuDomainObjPrivateXMLFormatBlockjobFormatSource and add a 'chain' parameter which allows controlling whether the backing chain is formatted. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b9c5a4e541..ddab76d3af 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2315,10 +2315,11 @@ typedef struct qemuDomainPrivateBlockJobFormatData { static int -qemuDomainObjPrivateXMLFormatBlockjobFormatChain(virBufferPtr buf, - const char *chainname, - virStorageSourcePtr src, - virDomainXMLOptionPtr xmlopt) +qemuDomainObjPrivateXMLFormatBlockjobFormatSource(virBufferPtr buf, + const char *element, + virStorageSourcePtr src, + virDomainXMLOptionPtr xmlopt, + bool chain) { VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; @@ -2333,10 +2334,11 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatChain(virBufferPtr buf, if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, true, xmlflags, xmlopt) < 0) return -1; - if (virDomainDiskBackingStoreFormat(&childBuf, src, xmlopt, xmlflags) < 0) + if (chain && + virDomainDiskBackingStoreFormat(&childBuf, src, xmlopt, xmlflags) < 0) return -1; - if (virXMLFormatElement(buf, chainname, &attrBuf, &childBuf) < 0) + if (virXMLFormatElement(buf, element, &attrBuf, &childBuf) < 0) return -1; return 0; @@ -2375,17 +2377,19 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload, virBufferAddLit(&childBuf, "/>\n"); } else { if (job->chain && - qemuDomainObjPrivateXMLFormatBlockjobFormatChain(&chainsBuf, - "disk", - job->chain, - data->xmlopt) < 0) + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&chainsBuf, + "disk", + job->chain, + data->xmlopt, + true) < 0) return -1; if (job->mirrorChain && - qemuDomainObjPrivateXMLFormatBlockjobFormatChain(&chainsBuf, - "mirror", - job->mirrorChain, - data->xmlopt) < 0) + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&chainsBuf, + "mirror", + job->mirrorChain, + data->xmlopt, + true) < 0) return -1; if (virXMLFormatElement(&childBuf, "chains", NULL, &chainsBuf) < 0)