[PATCH v3 6/9] virstoragefile: Add quorum in virstoragefile

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

 



Add VIR_STORAGE_TYPE_QUORUM in virStorageType.
Add VIR_STORAGE_FILE_QUORUM in virStorageFileFormat.

Add threshold value in _virStorageSource

Signed-off-by: Matthias Gatto <matthias.gatto@xxxxxxxxxxxx>
---
 docs/formatdomain.html.in      | 20 +++++++++-
 docs/schemas/domaincommon.rng  | 90 +++++++++++++++++++++++++++---------------
 docs/schemas/storagecommon.rng |  1 +
 docs/schemas/storagevol.rng    |  1 +
 src/conf/domain_conf.c         |  2 +
 src/qemu/qemu_command.c        |  1 +
 src/qemu/qemu_driver.c         |  4 ++
 src/qemu/qemu_migration.c      |  1 +
 src/util/virstoragefile.c      | 25 ++++++++----
 src/util/virstoragefile.h      |  3 ++
 10 files changed, 106 insertions(+), 42 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 679194f..263baaf 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1835,8 +1835,9 @@
             <dd>
             Valid values are "file", "block",
             "dir" (<span class="since">since 0.7.5</span>),
-            "network" (<span class="since">since 0.8.7</span>), or
-            "volume" (<span class="since">since 1.0.5</span>)
+            "network" (<span class="since">since 0.8.7</span>),
+            "volume" (<span class="since">since 1.0.5</span>), or
+            "quorum" (<span class="since">since 1.2.13</span>)
             and refer to the underlying source for the disk.
             </dd>
           <dt><code>device</code> attribute
@@ -1897,6 +1898,14 @@
             <code>snapshot='yes'</code> with a transient disk generally
             does not make sense.
             </dd>
+          <dt><code>threshold</code> attribute
+          <span class="since">since 1.2.13</span></dt>
+            <dd>
+            Only use with a quorum disk.
+            Indicate the minimum of positive vote a quorum must have to validate
+            a data to be write. The minimum value is "2". The number of backingStores
+            contain by the quorum must be superior to the threshold.
+            </dd>
         </dl>
       </dd>
       <dt><code>source</code></dt>
@@ -1967,6 +1976,11 @@
               'file=/dev/disk/by-path/ip-example.com:3260-iscsi-iqn.2013-07.com.example:iscsi-pool-lun-1').
               </p>
               </dd>
+            <dt><code>type='quorum'</code>
+            <span class="since">since 1.2.13</span></dt>
+              <dd>
+              A quorum contain no source element, but a serie of backingStores instead.
+              </dd>
           </dl>
         With "file", "block", and "volume", one or more optional
         sub-elements <code>seclabel</code>, <a href="#seclabel">described
@@ -2098,6 +2112,8 @@
         <code>backingStore</code> element means the sibling source is
         self-contained and is not based on any backing store. The following
         attributes and sub-elements are supported in
+        <span class="since">Since 1.2.11</span>. This elements is used to
+        describe a quorum child.
         <code>backingStore</code>:
         <dl>
           <dt><code>type</code> attribute</dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index d467dce..2556489 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1231,6 +1231,40 @@
     </attribute>
   </define>
 
+  <define name='diskDevice'>
+    <choice>
+      <group>
+        <optional>
+          <attribute name="device">
+            <choice>
+              <value>floppy</value>
+              <value>disk</value>
+              <value>cdrom</value>
+            </choice>
+          </attribute>
+        </optional>
+      </group>
+      <group>
+        <attribute name="device">
+          <choice>
+            <value>lun</value>
+          </choice>
+        </attribute>
+        <optional>
+          <ref name="rawIO"/>
+        </optional>
+        <optional>
+          <attribute name="sgio">
+            <choice>
+              <value>filtered</value>
+              <value>unfiltered</value>
+            </choice>
+          </attribute>
+        </optional>
+      </group>
+    </choice>
+  </define>
+
   <!--
       A disk description can be either of type file or block
       The name of the attribute on the source element depends on the type
@@ -1238,37 +1272,7 @@
     -->
   <define name="disk">
     <element name="disk">
-      <choice>
-        <group>
-          <optional>
-            <attribute name="device">
-              <choice>
-                <value>floppy</value>
-                <value>disk</value>
-                <value>cdrom</value>
-              </choice>
-            </attribute>
-          </optional>
-        </group>
-        <group>
-          <attribute name="device">
-            <choice>
-              <value>lun</value>
-            </choice>
-          </attribute>
-          <optional>
-            <ref name="rawIO"/>
-          </optional>
-          <optional>
-            <attribute name="sgio">
-              <choice>
-                <value>filtered</value>
-                <value>unfiltered</value>
-              </choice>
-            </attribute>
-          </optional>
-        </group>
-      </choice>
+      <ref name="diskDevice"/>
       <optional>
         <ref name="snapshot"/>
       </optional>
@@ -1280,9 +1284,15 @@
     </element>
   </define>
 
+  <define name="diskBackingStoreArray">
+    <zeroOrMore>
+      <ref name="diskBackingStore"/>
+    </zeroOrMore>
+  </define>
+
   <define name="diskBackingChain">
     <choice>
-      <ref name="diskBackingStore"/>
+      <ref name="diskBackingStoreArray"/>
       <ref name="diskBackingStoreLast"/>
     </choice>
   </define>
@@ -1293,6 +1303,9 @@
         <ref name="positiveInteger"/>
       </attribute>
       <interleave>
+        <optional>
+          <ref name="diskDevice"/>
+        </optional>
         <ref name="diskSource"/>
         <ref name="diskBackingChain"/>
         <ref name="diskFormat"/>
@@ -1324,9 +1337,22 @@
       <ref name="diskSourceDir"/>
       <ref name="diskSourceNetwork"/>
       <ref name="diskSourceVolume"/>
+      <ref name="diskSourceQuorum"/>
     </choice>
   </define>
 
+  <define name="diskSourceQuorum">
+    <optional>
+      <attribute name="type">
+        <value>quorum</value>
+      </attribute>
+      <attribute name="threshold">
+        <ref name="unsignedInt"/>
+      </attribute>
+    </optional>
+  </define>
+
+
   <define name="diskSourceFile">
     <optional>
       <attribute name="type">
diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng
index 5f71b10..ba9f485 100644
--- a/docs/schemas/storagecommon.rng
+++ b/docs/schemas/storagecommon.rng
@@ -76,6 +76,7 @@
       <value>fat</value>
       <value>vhd</value>
       <value>ploop</value>
+      <value>quorum</value>
       <ref name='storageFormatBacking'/>
     </choice>
   </define>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7450547..a718576 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -20,6 +20,7 @@
             <value>dir</value>
             <value>network</value>
             <value>netdir</value>
+            <value>quorum</value>
           </choice>
         </attribute>
       </optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2286665..b149065 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5581,6 +5581,7 @@ virDomainDiskSourceParse(xmlNodePtr node,
         if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)
             goto cleanup;
         break;
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -16638,6 +16639,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
                                                  skipSeclabels);
             break;
 
+        case VIR_STORAGE_TYPE_QUORUM:
         case VIR_STORAGE_TYPE_NONE:
         case VIR_STORAGE_TYPE_LAST:
             virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 06a59d0..d4123a0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3266,6 +3266,7 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
             goto cleanup;
         break;
 
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bdca5e0..2c8c147 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13123,6 +13123,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
         }
         break;
 
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
@@ -13186,6 +13187,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
         }
         break;
 
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
@@ -13210,6 +13212,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr
     case VIR_STORAGE_TYPE_FILE:
         return 0;
 
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_NETWORK:
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
@@ -13329,6 +13332,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
         }
         break;
 
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 879b1bf..a6fc51e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1510,6 +1510,7 @@ qemuMigrationPrecreateDisk(virConnectPtr conn,
     case VIR_STORAGE_TYPE_BLOCK:
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_NETWORK:
+    case VIR_STORAGE_TYPE_QUORUM:
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2a5321c..de55484 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -54,7 +54,8 @@ VIR_ENUM_IMPL(virStorage, VIR_STORAGE_TYPE_LAST,
               "block",
               "dir",
               "network",
-              "volume")
+              "volume",
+              "quorum")
 
 VIR_ENUM_IMPL(virStorageFileFormat,
               VIR_STORAGE_FILE_LAST,
@@ -63,7 +64,7 @@ VIR_ENUM_IMPL(virStorageFileFormat,
               "cloop", "dmg", "iso",
               "vpc", "vdi",
               /* Not direct file formats, but used for various drivers */
-              "fat", "vhd", "ploop",
+              "fat", "vhd", "ploop", "quorum",
               /* Formats with backing file below here */
               "cow", "qcow", "qcow2", "qed", "vmdk")
 
@@ -1875,6 +1876,7 @@ virStorageSourceCopy(const virStorageSource *src,
                      bool backingChain)
 {
     virStorageSourcePtr ret = NULL;
+    size_t i;
 
     if (VIR_ALLOC(ret) < 0)
         return NULL;
@@ -1887,6 +1889,8 @@ virStorageSourceCopy(const virStorageSource *src,
     ret->physical = src->physical;
     ret->readonly = src->readonly;
     ret->shared = src->shared;
+    ret->nBackingStores = src->nBackingStores;
+    ret->threshold = src->threshold;
 
     /* storage driver metadata are not copied */
     ret->drv = NULL;
@@ -1935,12 +1939,14 @@ virStorageSourceCopy(const virStorageSource *src,
         !(ret->auth = virStorageAuthDefCopy(src->auth)))
         goto error;
 
-    if (backingChain && virStorageSourceGetBackingStore(src, 0)) {
-        if (!virStorageSourceSetBackingStore(ret,
-                                             virStorageSourceCopy(virStorageSourceGetBackingStore(src, 0),
-                                                                  true),
-                                             0))
-            goto error;
+    for (i = 0; i < src->nBackingStores; ++i) {
+        if (backingChain && virStorageSourceGetBackingStore(src, i)) {
+            if (!virStorageSourceSetBackingStore(ret,
+                                                 virStorageSourceCopy(virStorageSourceGetBackingStore(src, i),
+                                                                      true),
+                                                 0))
+                goto error;
+        }
     }
 
     return ret;
@@ -2024,6 +2030,9 @@ virStorageSourceIsLocalStorage(virStorageSourcePtr src)
     case VIR_STORAGE_TYPE_FILE:
     case VIR_STORAGE_TYPE_BLOCK:
     case VIR_STORAGE_TYPE_DIR:
+        /* A quorum is actually both, but we consider it as local
+         * because it keep us to add a lot of exeption in the code*/
+    case VIR_STORAGE_TYPE_QUORUM:
         return true;
 
     case VIR_STORAGE_TYPE_NETWORK:
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b94f9d9..9d1b889 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -49,6 +49,7 @@ typedef enum {
     VIR_STORAGE_TYPE_DIR,
     VIR_STORAGE_TYPE_NETWORK,
     VIR_STORAGE_TYPE_VOLUME,
+    VIR_STORAGE_TYPE_QUORUM,
 
     VIR_STORAGE_TYPE_LAST
 } virStorageType;
@@ -73,6 +74,7 @@ typedef enum {
     VIR_STORAGE_FILE_FAT,
     VIR_STORAGE_FILE_VHD,
     VIR_STORAGE_FILE_PLOOP,
+    VIR_STORAGE_FILE_QUORUM,
 
     /* Not a format, but a marker: all formats below this point have
      * libvirt support for following a backing chain */
@@ -272,6 +274,7 @@ struct _virStorageSource {
     /* backing chain of the storage source */
     virStorageSourcePtr *backingStores;
     size_t      nBackingStores;
+    size_t      threshold;
 
     /* metadata for storage driver access to remote and local volumes */
     virStorageDriverDataPtr drv;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]