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 @@
-
+