]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Support startupPolicy for 'volume' disk
authorOsier Yang <jyang@redhat.com>
Thu, 4 Apr 2013 19:37:58 +0000 (03:37 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 8 Apr 2013 10:54:37 +0000 (18:54 +0800)
"startupPolicy" is only valid for file type storage volume, otherwise
it fails on starting the domain.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml

index ae3d95a4c473bf3e4e07a78cb0bd2409cfd62d38..00a61be2321ffde9f95aa08664a212ff6308c6d1 100644 (file)
         0.7.5; <code>type='network'</code> since
         0.8.7; <code>protocol='iscsi'</code> since 1.0.4;
         <code>type='volume'</code> since 1.0.5;</span><br/>
-        For a "file" disk type which represents a cdrom or floppy
+        For a "file" or "volume" disk type which represents a cdrom or floppy
         (the <code>device</code> attribute), it is possible to define
         policy what to do with the disk if the source file is not accessible.
-        This is done by the <code>startupPolicy</code> attribute, accepting
-        these values:
+        (NB, <code>startupPolicy</code> is not valid for "volume" disk unless
+         the specified storage volume is of "file" type). This is done by the
+        <code>startupPolicy</code> attribute, accepting these values:
         <table class="top_table">
           <tr>
             <td> mandatory </td>
index 5ee3261bd90fb99940c6faf6aab3e528da9b4b89..39376f90df0ff505389990cf66f7f0d11f85fe2b 100644 (file)
                 <attribute name="volume">
                   <ref name="volName"/>
                 </attribute>
+                <optional>
+                  <ref name="startupPolicy"/>
+                </optional>
               </element>
             </optional>
             <ref name="diskspec"/>
index 8f0d872973946d8bd2a6263555c29e90b6cfe75a..2d95200924867411ced1f65f22cafa70a7fb4836 100644 (file)
@@ -4402,6 +4402,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                 case VIR_DOMAIN_DISK_TYPE_VOLUME:
                     if (virDomainDiskSourcePoolDefParse(cur, def) < 0)
                         goto error;
+                    startupPolicy = virXMLPropString(cur, "startupPolicy");
                     break;
                 default:
                     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -13022,9 +13023,13 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
             /* Parsing guarantees the def->srcpool->volume cannot be NULL
              * if def->srcpool->pool is not NULL.
              */
-            if (def->srcpool->pool)
-                virBufferAsprintf(buf, "      <source pool='%s' volume='%s'/>\n",
+            if (def->srcpool)
+                virBufferAsprintf(buf, "      <source pool='%s' volume='%s'",
                                   def->srcpool->pool, def->srcpool->volume);
+            if (def->startupPolicy)
+                virBufferEscapeString(buf, " startupPolicy='%s'/>\n", startupPolicy);
+            else
+                virBufferAddLit(buf, "/>\n");
             break;
         default:
             virReportError(VIR_ERR_INTERNAL_ERROR,
index 8eb4054c9ec32a1e8748b95a5476c9705130818a..a98d21c60da967dca6e5bdb947a18f343c036fde 100644 (file)
@@ -2703,6 +2703,13 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
     if (virStorageVolGetInfo(vol, &info) < 0)
         goto cleanup;
 
+    if (def->startupPolicy &&
+        info.type != VIR_STORAGE_VOL_FILE) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("'startupPolicy' is only valid for 'file' type volume"));
+        goto cleanup;
+    }
+
     switch (info.type) {
     case VIR_STORAGE_VOL_FILE:
     case VIR_STORAGE_VOL_BLOCK:
index 876eebeee44b7bf60fff8d5ca2b34d9aca78bbd3..a218e78700f20409e0eea173a119a524fe6348a5 100644 (file)
@@ -15,7 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='volume' device='cdrom'>
-      <source pool='blk-pool0' volume='blk-pool0-vol0'/>
+      <source pool='blk-pool0' volume='blk-pool0-vol0' startupPolicy='optional'/>
       <target dev='hda' bus='ide'/>
       <readonly/>
       <address type='drive' controller='0' bus='0' target='0' unit='1'/>