mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
storage: add support for Vendor and Model in XML
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
This commit is contained in:
parent
3223871e2e
commit
20be699ee3
1
AUTHORS
1
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....]
|
||||
|
||||
|
@ -70,6 +70,8 @@
|
||||
<source>
|
||||
<host name="iscsi.example.com"/>
|
||||
<device path="demo-target"/>
|
||||
<vendor name="Acme"/>
|
||||
<product name="model"/&t;
|
||||
</source>
|
||||
...</pre>
|
||||
|
||||
@ -108,6 +110,16 @@
|
||||
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>
|
||||
|
@ -103,6 +103,23 @@
|
||||
<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'/>
|
||||
@ -286,6 +303,9 @@
|
||||
<value>nfs</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
@ -307,6 +327,9 @@
|
||||
<value>lvm2</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
@ -321,6 +344,9 @@
|
||||
<value>lvm2</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
@ -330,13 +356,20 @@
|
||||
<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>
|
||||
|
||||
@ -345,6 +378,9 @@
|
||||
<ref name='sourceinfohost'/>
|
||||
<ref name='sourceinfodir'/>
|
||||
<ref name='sourcefmtnetfs'/>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
@ -359,6 +395,9 @@
|
||||
</optional>
|
||||
</oneOrMore>
|
||||
<ref name='sourcefmtlogical'/>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
@ -366,6 +405,9 @@
|
||||
<element name='source'>
|
||||
<ref name='sourceinfodev'/>
|
||||
<ref name='sourcefmtdisk'/>
|
||||
<optional>
|
||||
<ref name='sourceinfovendor'/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
@ -379,12 +421,19 @@
|
||||
<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>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
19
tests/storagepoolxml2xmlin/pool-iscsi-vendor-product.xml
Normal file
19
tests/storagepoolxml2xmlin/pool-iscsi-vendor-product.xml
Normal file
@ -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>
|
22
tests/storagepoolxml2xmlout/pool-iscsi-vendor-product.xml
Normal file
22
tests/storagepoolxml2xmlout/pool-iscsi-vendor-product.xml
Normal file
@ -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>
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user