[PATCHv2 03/16] storage: match RNG to supported driver types

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

 



At one point, the code passed through arbitrary strings for file
formats, which supposedly lets qemu handle a new file type even
before libvirt has been taught to handle it.  However, to properly
label files, libvirt has to learn the file type anyway, so we
might as well make our life easier by only accepting file types
that we are prepared to handle.  This patch lets the RNG validation
ensure that only known strings are let through.

* docs/schemas/domaincommon.rng (driverFormat): Limit to list of
supported strings.
* docs/schemas/domainsnapshot.rng (driver): Likewise.
---
 docs/schemas/domaincommon.rng   | 27 ++++++++++++++++++++++++---
 docs/schemas/domainsnapshot.rng |  2 +-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 70bc0e2..1bfebde 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1188,11 +1188,32 @@
       <ref name="genericName"/>
     </attribute>
     <optional>
-      <attribute name="type">
-        <ref name="genericName"/>
+      <attribute name='type'>
+        <choice>
+          <ref name='diskFormat'/>
+          <value>aio</value> <!-- back-compat for 'raw' -->
+        </choice>
       </attribute>
     </optional>
   </define>
+  <define name='diskFormat'>
+    <choice>
+      <value>raw</value>
+      <value>dir</value>
+      <value>bochs</value>
+      <value>cloop</value>
+      <value>cow</value>
+      <value>dmg</value>
+      <value>iso</value>
+      <value>qcow</value>
+      <value>qcow2</value>
+      <value>qed</value>
+      <value>vmdk</value>
+      <value>vpc</value>
+      <value>fat</value>
+      <value>vhd</value>
+    </choice>
+  </define>
   <define name="driverCache">
     <attribute name="cache">
       <choice>
@@ -3352,7 +3373,7 @@
       </attribute>
       <optional>
         <attribute name='format'>
-          <ref name="genericName"/>
+          <ref name='diskFormat'/>
         </attribute>
       </optional>
       <optional>
diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng
index 0ef0631..ecaafe9 100644
--- a/docs/schemas/domainsnapshot.rng
+++ b/docs/schemas/domainsnapshot.rng
@@ -105,7 +105,7 @@
               <element name='driver'>
                 <optional>
                   <attribute name='type'>
-                    <ref name='genericName'/>
+                    <ref name='diskFormat'/>
                   </attribute>
                 </optional>
                 <empty/>
-- 
1.7.11.7

--
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]