]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: add support for Vendor and Model in XML
authorPatrick Dignan <pat_dignan@dell.com>
Tue, 17 Aug 2010 17:44:27 +0000 (12:44 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 19 Aug 2010 21:58:43 +0000 (15:58 -0600)
I wrote a patch to add support for listing the Vendor and Model of a
storage pool in the storage pool XML.  This would allow vendor
extensions of specific devices.  The patch includes a test for the new
attributes as well.

Patrick Dignan

AUTHORS
docs/formatstorage.html.in
docs/schemas/storagepool.rng
src/conf/storage_conf.c
src/conf/storage_conf.h
tests/storagepoolxml2xmlin/pool-iscsi-vendor-product.xml [new file with mode: 0644]
tests/storagepoolxml2xmlout/pool-iscsi-vendor-product.xml [new file with mode: 0644]
tests/storagepoolxml2xmltest.c

diff --git a/AUTHORS b/AUTHORS
index 3c7319b2b3c2ab53a2836935012967019aa21933..8b037a185a3cae83e4e3afcc8b532780e460cfde 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -127,6 +127,7 @@ Patches have also been contributed by:
   Justin Clift         <jclift@redhat.com>
   Alan Pevec           <apevec@redhat.com>
   Aurelien Rougemont   <beorn@binaries.fr>
+  Patrick Dignan       <pat_dignan@dell.com>
 
   [....send patches to get your name here....]
 
index 5c1d36c6850ac08e209254b58f399220af10ca69..91f70a343d48de9ce68325b5b1c3da50ad7958b0 100644 (file)
@@ -70,6 +70,8 @@
         &lt;source&gt;
           &lt;host name="iscsi.example.com"/&gt;
           &lt;device path="demo-target"/&gt;
+          &lt;vendor name="Acme"/&gt;
+          &lt;product name="model"/&t;
         &lt;/source&gt;
         ...</pre>
 
         type, or network filesystem type, or partition table type, or
         LVM metadata type. All drivers are required to have a default
         value for this, so it is optional. <span class="since">Since 0.4.1</span></dd>
+
+      <dt><code>vendor</code></dt>
+      <dd>Provides optional information about the vendor of the
+        storage device. This contains a single
+        attribute <code>name</code> whose value is backend
+        specific. <span class="since">Since 0.8.4</span></dd>
+      <dt><code>product</code></dt>
+      <dd>Provides an optional product name of the storage device.
+        This contains a single attribute <code>name</code> whose value
+        is backend specific.  <span class="since">Since 0.8.4</span></dd>
     </dl>
 
     <h3><a name="StoragePoolTarget">Target elements</a></h3>
index b911f7cddabe765016405415569106ce4909c7a0..54eb80231478b4e0f0f2da358a4d1b7f800ff394 100644 (file)
     <ref name='target'/>
   </define>
 
+  <define name='sourceinfovendor'>
+    <optional>
+      <element name='vendor'>
+        <attribute name='name'>
+          <text/>
+        </attribute>
+      </element>
+    </optional>
+    <optional>
+      <element name='product'>
+        <attribute name='name'>
+          <text/>
+        </attribute>
+      </element>
+    </optional>
+  </define>
+
   <define name='commonmetadata'>
     <element name='name'>
       <ref name='name'/>
             <value>nfs</value>
           </choice>
         </attribute>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
       </element>
     </optional>
   </define>
             <value>lvm2</value>
           </choice>
         </attribute>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
       </element>
     </optional>
   </define>
             <value>lvm2</value>
           </choice>
         </attribute>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
       </element>
     </optional>
   </define>
     <optional>
       <element name='source'>
         <empty/>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
       </element>
     </optional>
   </define>
+
   <define name='sourcefs'>
     <element name='source'>
       <ref name='sourceinfodev'/>
       <ref name='sourcefmtfs'/>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
     </element>
   </define>
 
       <ref name='sourceinfohost'/>
       <ref name='sourceinfodir'/>
       <ref name='sourcefmtnetfs'/>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
     </element>
   </define>
 
         </optional>
       </oneOrMore>
       <ref name='sourcefmtlogical'/>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
     </element>
   </define>
 
     <element name='source'>
       <ref name='sourceinfodev'/>
       <ref name='sourcefmtdisk'/>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
     </element>
   </define>
 
       <optional>
         <ref name='sourceinfoauth'/>
       </optional>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
     </element>
   </define>
 
   <define name='sourcescsi'>
     <element name='source'>
       <ref name='sourceinfoadapter'/>
+      <optional>
+        <ref name='sourceinfovendor'/>
+      </optional>
+
     </element>
   </define>
 
index 18a6472512b100d76af321b5d830f1a51f1f50c4..168243fec94b25690151928720c8444b00399381 100644 (file)
@@ -284,6 +284,8 @@ virStoragePoolSourceFree(virStoragePoolSourcePtr source) {
     VIR_FREE(source->name);
     VIR_FREE(source->adapter);
     VIR_FREE(source->initiator.iqn);
+    VIR_FREE(source->vendor);
+    VIR_FREE(source->product);
 
     if (source->authType == VIR_STORAGE_POOL_AUTH_CHAP) {
         VIR_FREE(source->auth.chap.login);
@@ -465,6 +467,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
             goto cleanup;
     }
 
+    source->vendor = virXPathString("string(./vendor/@name)", ctxt);
+    source->product = virXPathString("string(./product/@name)", ctxt);
+
     ret = 0;
 cleanup:
     ctxt->node = relnode;
@@ -838,6 +843,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
         virBufferVSprintf(buf,"    <auth type='chap' login='%s' passwd='%s'/>\n",
                           src->auth.chap.login,
                           src->auth.chap.passwd);
+
+    if (src->vendor != NULL) {
+        virBufferEscapeString(buf,"    <vendor name='%s'/>\n", src->vendor);
+    }
+
+    if (src->product != NULL) {
+        virBufferEscapeString(buf,"    <product name='%s'/>\n", src->product);
+    }
+
     virBufferAddLit(buf,"  </source>\n");
 
     return 0;
index bedee9efeeed99b3e4fe82014d51b309cfc53e32..fef0a462ceea75787f49f6459e87f2e01322420c 100644 (file)
@@ -237,6 +237,12 @@ struct _virStoragePoolSource {
         virStoragePoolAuthChap chap;
     } auth;
 
+    /* Vendor of the source */
+    char *vendor;
+
+    /* Product name of the source*/
+    char *product;
+
     int format; /* Pool type specific format such as filesystem type, or lvm version, etc */
 };
 
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-vendor-product.xml b/tests/storagepoolxml2xmlin/pool-iscsi-vendor-product.xml
new file mode 100644 (file)
index 0000000..01fbd9b
--- /dev/null
@@ -0,0 +1,19 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <source>
+    <host name="iscsi.example.com"/>
+    <device path="demo-target"/>
+    <auth type='chap' login='foobar' passwd='frobbar'/>
+    <vendor name='test-vendor'/>
+    <product name='test-product'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-iscsi-vendor-product.xml b/tests/storagepoolxml2xmlout/pool-iscsi-vendor-product.xml
new file mode 100644 (file)
index 0000000..baab6c0
--- /dev/null
@@ -0,0 +1,22 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='iscsi.example.com'/>
+    <device path='demo-target'/>
+    <auth type='chap' login='foobar' passwd='frobbar'/>
+    <vendor name='test-vendor'/>
+    <product name='test-product'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
index 33a73439103a5d7ec1663e6931e0546aa6575064..2ec29e3260e51b22c2a36e1c68f638606d9d90c1 100644 (file)
@@ -96,6 +96,7 @@ mymain(int argc, char **argv)
     DO_TEST("pool-scsi");
     DO_TEST("pool-mpath");
     DO_TEST("pool-iscsi-multiiqn");
+    DO_TEST("pool-iscsi-vendor-product");
 
     return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }