[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 6/9] Support startupPolicy for 'volume' disk



"startupPolicy" is only valid for file type storage volume, otherwise
it fails on starting the domain (no way to error out earlier when
parsing).
---
 docs/formatdomain.html.in     |    7 ++++---
 docs/schemas/domaincommon.rng |    3 +++
 src/conf/domain_conf.c        |    9 +++++++--
 src/storage/storage_driver.c  |    6 ++++++
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ac5657a..8186f3b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1458,11 +1458,12 @@
         <span class="since">Since 0.0.3; <code>type='dir'</code> since
         0.7.5; <code>type='network'</code> since 0.8.7;
         <code>type='volume'</code> since 1.0.3</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>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 88612ae..6d426ac 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1094,6 +1094,9 @@
                 <attribute name="volume">
                   <ref name="volName"/>
                 </attribute>
+                <optional>
+                  <ref name="startupPolicy"/>
+                </optional>
               </element>
             </optional>
             <ref name="diskspec"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5e65406..9f61c57 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3817,6 +3817,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                 case VIR_DOMAIN_DISK_TYPE_VOLUME:
                     if (virDomainDiskSourcePoolDefParse(cur, def) < 0)
                         goto error;
+                    startupPolicy = virXMLPropString(cur, "startupPolicy");
                     break;
                 default:
                     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -12319,9 +12320,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,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 9f60f2c..3e710ef 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2427,6 +2427,12 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn,
             goto cleanup;
         }
 
+        if (disk->startupPolicy && vol->type != VIR_STORAGE_VOL_FILE) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("'startupPolicy' is only valid for 'file' type volume"));
+            goto cleanup;
+        }
+
         switch (vol->type) {
         case VIR_STORAGE_VOL_FILE:
         case VIR_STORAGE_VOL_BLOCK:
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]