]> xenbits.xensource.com Git - libvirt.git/commitdiff
blockjob: don't remove older-style mirror XML
authorEric Blake <eblake@redhat.com>
Mon, 16 Jun 2014 19:34:36 +0000 (13:34 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 16 Jun 2014 19:48:00 +0000 (13:48 -0600)
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 <mirror> 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 <eblake@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml

index 1b6ced87c532fa9984ec99adcd602f65f07d5798..79b85d5f0dc1e2463feacef10475d156572a1bf2 100644 (file)
         attribute <code>ready</code> 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.  <span class="since">Since 1.2.6</span>
-        (Older libvirt <span class="since">since 0.9.12</span> allowed
-        only mirroring to a file, with the information reported
-        in <code>file</code> and <code>format</code> attributes
-        of <code>mirror</code> rather than subelements.)
+        ignored on input.  The <code>source</code> sub-element exists
+        for all two-phase jobs <span class="since">since 1.2.6</span>.
+        Older libvirt supported only block copy to a
+        file, <span class="since">since 0.9.12</span>; for
+        compatibility with older clients, such jobs include redundant
+        information in the attributes <code>file</code>
+        and <code>format</code> in the <code>mirror</code> element.
       </dd>
       <dt><code>target</code></dt>
       <dd>The <code>target</code> element controls the bus / device
index 6cc922c2a328640e54fb560816078e4796f15b4b..33d0308cf9de2cd3f2bd5b8f10c66005179580a5 100644 (file)
   <define name='diskMirror'>
     <element name='mirror'>
       <choice>
-        <group>
+        <group> <!-- old format, for block copy back-compat -->
           <attribute name='file'>
             <ref name='absFilePath'/>
           </attribute>
               <ref name='storageFormat'/>
             </attribute>
           </optional>
+          <optional>
+            <interleave>
+              <ref name='diskSourceFile'/>
+              <optional>
+                <ref name="diskFormat"/>
+              </optional>
+            </interleave>
+          </optional>
         </group>
-        <group>
+        <group> <!-- preferred format -->
           <interleave>
             <ref name="diskSource"/>
             <optional>
index be81dbec8522d814a45d73e9866833473fd3bb23..41142897a115899dc4803dccbca5ab2325fe9e89 100644 (file)
@@ -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='%s'",
                           virStorageTypeToString(def->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, "<format type='%s'/>\n",
-                                  virStorageFileFormatTypeToString(def->mirror->format));
+        virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
         if (virDomainDiskSourceFormat(buf, def->mirror, 0, 0) < 0)
             return -1;
         virBufferAdjustIndent(buf, -2);
index a937d0a5cad5fd2e82b9ea65ff80c13273204052..72b03c96b05de6e3bcc7135dc5866c267d2b32c1 100644 (file)
@@ -17,7 +17,7 @@
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <backingStore/>
-      <mirror type='file' ready='yes'>
+      <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' ready='yes'>
         <source file='/dev/HostVG/QEMUGuest1Copy'/>
       </mirror>
       <target dev='hda' bus='ide'/>
@@ -33,7 +33,7 @@
     <disk type='file' device='disk'>
       <source file='/tmp/data.img'/>
       <backingStore/>
-      <mirror type='file'>
+      <mirror type='file' file='/tmp/copy.img' format='qcow2'>
         <format type='qcow2'/>
         <source file='/tmp/copy.img'/>
       </mirror>
index a937d0a5cad5fd2e82b9ea65ff80c13273204052..72b03c96b05de6e3bcc7135dc5866c267d2b32c1 100644 (file)
@@ -17,7 +17,7 @@
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <backingStore/>
-      <mirror type='file' ready='yes'>
+      <mirror type='file' file='/dev/HostVG/QEMUGuest1Copy' ready='yes'>
         <source file='/dev/HostVG/QEMUGuest1Copy'/>
       </mirror>
       <target dev='hda' bus='ide'/>
@@ -33,7 +33,7 @@
     <disk type='file' device='disk'>
       <source file='/tmp/data.img'/>
       <backingStore/>
-      <mirror type='file'>
+      <mirror type='file' file='/tmp/copy.img' format='qcow2'>
         <format type='qcow2'/>
         <source file='/tmp/copy.img'/>
       </mirror>