From b50e1049234473b36e798b8ebd842cb84ef023dc Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 16 Jun 2014 13:34:36 -0600 Subject: [PATCH] blockjob: don't remove older-style mirror XML Commit 7c6fc39 introduced a regression in the XML produced for older clients. The argument at the time was that clients shouldn't be depending on output-only data for something that is only going to be triggered for a transient guest; but John Ferlan reported that the automated testsuite was such a client. It's better to be safe than sorry by guaranteeing back-compat cruft. Note that later patches will be using for active block commit, but there we don't have to worry about back-compat. * src/conf/domain_conf.c (virDomainDiskDefFormat): Restore old style output when necessary. * docs/schemas/domaincommon.rng: Validate back-compat style. * docs/formatdomain.html.in: Update the documentation. * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml: Update tests. * tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise. Signed-off-by: Eric Blake --- docs/formatdomain.html.in | 12 +++++++----- docs/schemas/domaincommon.rng | 12 ++++++++++-- src/conf/domain_conf.c | 19 +++++++++++++------ .../qemuxml2argv-disk-mirror.xml | 4 ++-- .../qemuxml2xmlout-disk-mirror-old.xml | 4 ++-- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1b6ced87c5..79b85d5f0d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1891,11 +1891,13 @@ attribute ready is present, then it is known the disk is ready to pivot; otherwise, the disk is probably still copying. For now, this element only valid in output; it is - ignored on input. Since 1.2.6 - (Older libvirt since 0.9.12 allowed - only mirroring to a file, with the information reported - in file and format attributes - of mirror rather than subelements.) + ignored on input. The source sub-element exists + for all two-phase jobs since 1.2.6. + Older libvirt supported only block copy to a + file, since 0.9.12; for + compatibility with older clients, such jobs include redundant + information in the attributes file + and format in the mirror element.
target
The target element controls the bus / device diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6cc922c2a3..33d0308cf9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4176,7 +4176,7 @@ - + @@ -4185,8 +4185,16 @@ + + + + + + + + - + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be81dbec85..41142897a1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15187,19 +15187,26 @@ virDomainDiskDefFormat(virBufferPtr buf, /* For now, mirroring is currently output-only: we only output it * for live domains, therefore we ignore it on input except for - * the internal parse on libvirtd restart. We only output the - * new style similar to backingStore, even though the parser - * code still accepts old style across libvirtd upgrades. */ + * the internal parse on libvirtd restart. We prefer to output + * the new style similar to backingStore, but for back-compat on + * blockcopy files we also have to output old style attributes. + * The parser accepts either style across libvirtd upgrades. */ if (def->mirror && !(flags & VIR_DOMAIN_XML_INACTIVE)) { + const char *formatStr = NULL; + + if (def->mirror->format) + formatStr = virStorageFileFormatTypeToString(def->mirror->format); virBufferAsprintf(buf, "mirror->type)); + if (def->mirror->type == VIR_STORAGE_TYPE_FILE) { + virBufferEscapeString(buf, " file='%s'", def->mirror->path); + virBufferEscapeString(buf, " format='%s'", formatStr); + } if (def->mirroring) virBufferAddLit(buf, " ready='yes'"); virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - if (def->mirror->format) - virBufferEscapeString(buf, "\n", - virStorageFileFormatTypeToString(def->mirror->format)); + virBufferEscapeString(buf, "\n", formatStr); if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0) < 0) return -1; virBufferAdjustIndent(buf, -2); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml index a937d0a5ca..72b03c96b0 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml @@ -17,7 +17,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml index a937d0a5ca..72b03c96b0 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml @@ -17,7 +17,7 @@ - + @@ -33,7 +33,7 @@ - +