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>
|
Justin Clift <jclift@redhat.com>
|
||||||
Alan Pevec <apevec@redhat.com>
|
Alan Pevec <apevec@redhat.com>
|
||||||
Aurelien Rougemont <beorn@binaries.fr>
|
Aurelien Rougemont <beorn@binaries.fr>
|
||||||
|
Patrick Dignan <pat_dignan@dell.com>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@
|
|||||||
<source>
|
<source>
|
||||||
<host name="iscsi.example.com"/>
|
<host name="iscsi.example.com"/>
|
||||||
<device path="demo-target"/>
|
<device path="demo-target"/>
|
||||||
|
<vendor name="Acme"/>
|
||||||
|
<product name="model"/&t;
|
||||||
</source>
|
</source>
|
||||||
...</pre>
|
...</pre>
|
||||||
|
|
||||||
@ -108,6 +110,16 @@
|
|||||||
type, or network filesystem type, or partition table type, or
|
type, or network filesystem type, or partition table type, or
|
||||||
LVM metadata type. All drivers are required to have a default
|
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>
|
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>
|
</dl>
|
||||||
|
|
||||||
<h3><a name="StoragePoolTarget">Target elements</a></h3>
|
<h3><a name="StoragePoolTarget">Target elements</a></h3>
|
||||||
|
@ -103,6 +103,23 @@
|
|||||||
<ref name='target'/>
|
<ref name='target'/>
|
||||||
</define>
|
</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'>
|
<define name='commonmetadata'>
|
||||||
<element name='name'>
|
<element name='name'>
|
||||||
<ref name='name'/>
|
<ref name='name'/>
|
||||||
@ -286,6 +303,9 @@
|
|||||||
<value>nfs</value>
|
<value>nfs</value>
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
@ -307,6 +327,9 @@
|
|||||||
<value>lvm2</value>
|
<value>lvm2</value>
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
@ -321,6 +344,9 @@
|
|||||||
<value>lvm2</value>
|
<value>lvm2</value>
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
@ -330,13 +356,20 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<element name='source'>
|
<element name='source'>
|
||||||
<empty/>
|
<empty/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define name='sourcefs'>
|
<define name='sourcefs'>
|
||||||
<element name='source'>
|
<element name='source'>
|
||||||
<ref name='sourceinfodev'/>
|
<ref name='sourceinfodev'/>
|
||||||
<ref name='sourcefmtfs'/>
|
<ref name='sourcefmtfs'/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
@ -345,6 +378,9 @@
|
|||||||
<ref name='sourceinfohost'/>
|
<ref name='sourceinfohost'/>
|
||||||
<ref name='sourceinfodir'/>
|
<ref name='sourceinfodir'/>
|
||||||
<ref name='sourcefmtnetfs'/>
|
<ref name='sourcefmtnetfs'/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
@ -359,6 +395,9 @@
|
|||||||
</optional>
|
</optional>
|
||||||
</oneOrMore>
|
</oneOrMore>
|
||||||
<ref name='sourcefmtlogical'/>
|
<ref name='sourcefmtlogical'/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
@ -366,6 +405,9 @@
|
|||||||
<element name='source'>
|
<element name='source'>
|
||||||
<ref name='sourceinfodev'/>
|
<ref name='sourceinfodev'/>
|
||||||
<ref name='sourcefmtdisk'/>
|
<ref name='sourcefmtdisk'/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
@ -379,12 +421,19 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<ref name='sourceinfoauth'/>
|
<ref name='sourceinfoauth'/>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define name='sourcescsi'>
|
<define name='sourcescsi'>
|
||||||
<element name='source'>
|
<element name='source'>
|
||||||
<ref name='sourceinfoadapter'/>
|
<ref name='sourceinfoadapter'/>
|
||||||
|
<optional>
|
||||||
|
<ref name='sourceinfovendor'/>
|
||||||
|
</optional>
|
||||||
|
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
@ -284,6 +284,8 @@ virStoragePoolSourceFree(virStoragePoolSourcePtr source) {
|
|||||||
VIR_FREE(source->name);
|
VIR_FREE(source->name);
|
||||||
VIR_FREE(source->adapter);
|
VIR_FREE(source->adapter);
|
||||||
VIR_FREE(source->initiator.iqn);
|
VIR_FREE(source->initiator.iqn);
|
||||||
|
VIR_FREE(source->vendor);
|
||||||
|
VIR_FREE(source->product);
|
||||||
|
|
||||||
if (source->authType == VIR_STORAGE_POOL_AUTH_CHAP) {
|
if (source->authType == VIR_STORAGE_POOL_AUTH_CHAP) {
|
||||||
VIR_FREE(source->auth.chap.login);
|
VIR_FREE(source->auth.chap.login);
|
||||||
@ -465,6 +467,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source->vendor = virXPathString("string(./vendor/@name)", ctxt);
|
||||||
|
source->product = virXPathString("string(./product/@name)", ctxt);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
ctxt->node = relnode;
|
ctxt->node = relnode;
|
||||||
@ -838,6 +843,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'/>\n",
|
virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'/>\n",
|
||||||
src->auth.chap.login,
|
src->auth.chap.login,
|
||||||
src->auth.chap.passwd);
|
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");
|
virBufferAddLit(buf," </source>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -237,6 +237,12 @@ struct _virStoragePoolSource {
|
|||||||
virStoragePoolAuthChap chap;
|
virStoragePoolAuthChap chap;
|
||||||
} auth;
|
} 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 */
|
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-scsi");
|
||||||
DO_TEST("pool-mpath");
|
DO_TEST("pool-mpath");
|
||||||
DO_TEST("pool-iscsi-multiiqn");
|
DO_TEST("pool-iscsi-multiiqn");
|
||||||
|
DO_TEST("pool-iscsi-vendor-product");
|
||||||
|
|
||||||
return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user