When the block copy operation is started with a reused external file in incremental mode libvirt will need to open and insert the backing chain for that file into qemu (in -blockdev mode). This means that we'll need to track the backing chain and metadata such as node names for the full chain of <mirror>. This patch invokes the full backing chain formatter and parser for <mirror> so that the chain can be kept with <mirror>. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 13 ++++++++----- tests/qemustatusxml2xmldata/blockjob-mirror-in.xml | 13 +++++++++++++ tests/qemuxml2argvdata/disk-mirror.xml | 6 ++++++ tests/qemuxml2xmloutdata/disk-mirror-active.xml | 6 ++++++ 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1828e0795b..623ef28719 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5676,6 +5676,7 @@ </choice> </attribute> </optional> + <ref name="diskBackingChain"/> </element> </define> <define name="diskAuth"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5b13402154..585b5515f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9342,6 +9342,7 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, unsigned int flags, virDomainXMLOptionPtr xmlopt) { + VIR_XPATH_NODE_AUTORESTORE(ctxt); VIR_AUTOFREE(char *) mirrorFormat = NULL; VIR_AUTOFREE(char *) mirrorType = NULL; VIR_AUTOFREE(char *) ready = NULL; @@ -9358,14 +9359,16 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, } if ((mirrorType = virXMLPropString(cur, "type"))) { - if (!(def->mirror = virDomainStorageSourceParseFull("string(./mirror/@type)", + ctxt->node = cur; + + if (!(def->mirror = virDomainStorageSourceParseFull("string(./@type)", NULL, - "./mirror/source", + "./source", NULL, - false, false, ctxt, flags, xmlopt))) + false, true, ctxt, flags, xmlopt))) return -1; - mirrorFormat = virXPathString("string(./mirror/format/@type)", ctxt); + mirrorFormat = virXPathString("string(./format/@type)", ctxt); } else { if (!(def->mirror = virStorageSourceNew())) return -1; @@ -24127,7 +24130,7 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr); - if (virDomainDiskSourceFormat(buf, disk->mirror, 0, 0, true, false, false, + if (virDomainDiskSourceFormat(buf, disk->mirror, 0, flags, true, false, true, xmlopt) < 0) return -1; virBufferAdjustIndent(buf, -2); diff --git a/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml b/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml index 32bde1ba66..df23ac00aa 100644 --- a/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml @@ -65,6 +65,7 @@ <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'> <format type='qcow2'/> <source file='/tmp/copy.img'/> + <backingStore/> </mirror> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> @@ -76,6 +77,18 @@ <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'> <format type='qcow2'/> <source file='/tmp/logcopy.img'/> + <backingStore type='block' index='1'> + <format type='raw'/> + <source dev='/dev/HostVG/backing'> + <privateData> + <nodenames> + <nodename type='storage' name='test-backing-storage'/> + <nodename type='format' name='test-backing-format'/> + </nodenames> + </privateData> + </source> + <backingStore/> + </backingStore> </mirror> <target dev='vdb' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> diff --git a/tests/qemuxml2argvdata/disk-mirror.xml b/tests/qemuxml2argvdata/disk-mirror.xml index e89eee47ed..c1e6e94e33 100644 --- a/tests/qemuxml2argvdata/disk-mirror.xml +++ b/tests/qemuxml2argvdata/disk-mirror.xml @@ -36,6 +36,7 @@ <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'> <format type='qcow2'/> <source file='/tmp/copy.img'/> + <backingStore/> </mirror> <target dev='vda' bus='virtio'/> </disk> @@ -45,6 +46,11 @@ <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'> <format type='qcow2'/> <source file='/tmp/logcopy.img'/> + <backingStore type='block' index='1'> + <format type='raw'/> + <source dev='/dev/HostVG/backing'/> + <backingStore/> + </backingStore> </mirror> <target dev='vdb' bus='virtio'/> </disk> diff --git a/tests/qemuxml2xmloutdata/disk-mirror-active.xml b/tests/qemuxml2xmloutdata/disk-mirror-active.xml index d689eac6b8..32ffc647be 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-active.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-active.xml @@ -40,6 +40,7 @@ <mirror type='file' file='/tmp/copy.img' format='qcow2' job='copy'> <format type='qcow2'/> <source file='/tmp/copy.img'/> + <backingStore/> </mirror> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> @@ -51,6 +52,11 @@ <mirror type='file' file='/tmp/logcopy.img' format='qcow2' job='copy' ready='abort'> <format type='qcow2'/> <source file='/tmp/logcopy.img'/> + <backingStore type='block' index='1'> + <format type='raw'/> + <source dev='/dev/HostVG/backing'/> + <backingStore/> + </backingStore> </mirror> <target dev='vdb' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list