mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
conf: Add storage pool device attribute part_separator
Add a new storage pool source device attribute 'part_separator=[yes|no]' in order to allow a 'disk' storage pool using a device mapper multipath device to not add the "p" partition separator to the generated device name when libvirt_parthelper is run. This will allow libvirt to find device mapper multipath devices which were configured in /etc/multipath.conf to use 'user_friendly_names' or custom 'alias' names for the LUN.
This commit is contained in:
parent
c03fbecc7c
commit
4f84617078
@ -87,6 +87,14 @@
|
|||||||
</source>
|
</source>
|
||||||
...</pre>
|
...</pre>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
...
|
||||||
|
<source>
|
||||||
|
<device path='/dev/mapper/mpatha' part_separator='no'/>
|
||||||
|
<format type='gpt'/>
|
||||||
|
</source>
|
||||||
|
...</pre>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
...
|
...
|
||||||
<source>
|
<source>
|
||||||
@ -118,10 +126,28 @@
|
|||||||
(pool types <code>fs</code>, <code>logical</code>, <code>disk</code>,
|
(pool types <code>fs</code>, <code>logical</code>, <code>disk</code>,
|
||||||
<code>iscsi</code>, <code>zfs</code>).
|
<code>iscsi</code>, <code>zfs</code>).
|
||||||
May be repeated multiple times depending on backend driver. Contains
|
May be repeated multiple times depending on backend driver. Contains
|
||||||
a single attribute <code>path</code> which is either the fully
|
a required attribute <code>path</code> which is either the fully
|
||||||
qualified path to the block device node or for <code>iscsi</code>
|
qualified path to the block device node or for <code>iscsi</code>
|
||||||
the iSCSI Qualified Name (IQN).
|
the iSCSI Qualified Name (IQN).
|
||||||
<span class="since">Since 0.4.1</span></dd>
|
<span class="since">Since 0.4.1</span>
|
||||||
|
<p>An optional attribute <code>part_separator</code> for each
|
||||||
|
<code>path</code> may be supplied. Valid values for the attribute
|
||||||
|
may be either "yes" or "no". This attribute is to be used for a
|
||||||
|
<code>disk</code> pool type using a <code>path</code> to a
|
||||||
|
device mapper multipath device configured to utilize either
|
||||||
|
'user_friendly_names' or a custom 'alias' name in the
|
||||||
|
/etc/multipath.conf. The attribute directs libvirt to not
|
||||||
|
generate device volume names with the partition character "p".
|
||||||
|
By default, when libvirt generates the partition names for
|
||||||
|
device mapper multipath devices it will add a "p" path separator
|
||||||
|
to the device name before adding the partition number. For example,
|
||||||
|
a <code>device path</code> of '/dev/mapper/mpatha' libvirt would
|
||||||
|
generate partition names of '/dev/mapper/mpathap1',
|
||||||
|
'/dev/mapper/mpathap2', etc. for each partition found. With
|
||||||
|
this attribute set to "no", libvirt will not append the "p" to
|
||||||
|
the name unless it ends with a number thus generating names
|
||||||
|
of '/dev/mapper/mpatha1', '/dev/mapper/mpatha2', etc.
|
||||||
|
<span class="since">Since 1.3.1</span></p></dd>
|
||||||
<dt><code>dir</code></dt>
|
<dt><code>dir</code></dt>
|
||||||
<dd>Provides the source for pools backed by directories (pool
|
<dd>Provides the source for pools backed by directories (pool
|
||||||
types <code>dir</code>, <code>netfs</code>, <code>gluster</code>),
|
types <code>dir</code>, <code>netfs</code>, <code>gluster</code>),
|
||||||
|
@ -278,6 +278,11 @@
|
|||||||
<empty/>
|
<empty/>
|
||||||
<ref name='devextents'/>
|
<ref name='devextents'/>
|
||||||
</choice>
|
</choice>
|
||||||
|
<optional>
|
||||||
|
<attribute name="part_separator">
|
||||||
|
<ref name="virYesNo"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_conf.c: config handling for storage driver
|
* storage_conf.c: config handling for storage driver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2014 Red Hat, Inc.
|
* Copyright (C) 2006-2016 Red Hat, Inc.
|
||||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -528,6 +528,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < nsource; i++) {
|
for (i = 0; i < nsource; i++) {
|
||||||
|
char *partsep;
|
||||||
virStoragePoolSourceDevice dev = { .path = NULL };
|
virStoragePoolSourceDevice dev = { .path = NULL };
|
||||||
dev.path = virXMLPropString(nodeset[i], "path");
|
dev.path = virXMLPropString(nodeset[i], "path");
|
||||||
|
|
||||||
@ -537,10 +538,25 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partsep = virXMLPropString(nodeset[i], "part_separator");
|
||||||
|
if (partsep) {
|
||||||
|
dev.part_separator = virTristateBoolTypeFromString(partsep);
|
||||||
|
if (dev.part_separator <= 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("invalid part_separator setting '%s'"),
|
||||||
|
partsep);
|
||||||
|
virStoragePoolSourceDeviceClear(&dev);
|
||||||
|
VIR_FREE(partsep);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
VIR_FREE(partsep);
|
||||||
|
}
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0) {
|
if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0) {
|
||||||
virStoragePoolSourceDeviceClear(&dev);
|
virStoragePoolSourceDeviceClear(&dev);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source->dir = virXPathString("string(./dir/@path)", ctxt);
|
source->dir = virXPathString("string(./dir/@path)", ctxt);
|
||||||
@ -1051,8 +1067,14 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</device>\n");
|
virBufferAddLit(buf, "</device>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferEscapeString(buf, "<device path='%s'/>\n",
|
virBufferEscapeString(buf, "<device path='%s'",
|
||||||
src->devices[i].path);
|
src->devices[i].path);
|
||||||
|
if (src->devices[i].part_separator !=
|
||||||
|
VIR_TRISTATE_SWITCH_ABSENT) {
|
||||||
|
virBufferAsprintf(buf, " part_separator='%s'",
|
||||||
|
virTristateBoolTypeToString(src->devices[i].part_separator));
|
||||||
|
}
|
||||||
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_conf.h: config handling for storage driver
|
* storage_conf.h: config handling for storage driver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2008, 2010-2014 Red Hat, Inc.
|
* Copyright (C) 2006-2008, 2010-2016 Red Hat, Inc.
|
||||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -157,6 +157,7 @@ struct _virStoragePoolSourceDevice {
|
|||||||
virStoragePoolSourceDeviceExtentPtr freeExtents;
|
virStoragePoolSourceDeviceExtentPtr freeExtents;
|
||||||
char *path;
|
char *path;
|
||||||
int format; /* Pool specific source format */
|
int format; /* Pool specific source format */
|
||||||
|
int part_separator; /* enum virTristateSwitch */
|
||||||
|
|
||||||
/* When the source device is a physical disk,
|
/* When the source device is a physical disk,
|
||||||
* the geometry data is needed
|
* the geometry data is needed
|
||||||
|
14
tests/storagepoolxml2xmlin/pool-disk-device-nopartsep.xml
Normal file
14
tests/storagepoolxml2xmlin/pool-disk-device-nopartsep.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<pool type='disk'>
|
||||||
|
<name>multipath</name>
|
||||||
|
<uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
|
||||||
|
<capacity unit='bytes'>0</capacity>
|
||||||
|
<allocation unit='bytes'>0</allocation>
|
||||||
|
<available unit='bytes'>0</available>
|
||||||
|
<source>
|
||||||
|
<device path='/dev/mapper/mpatha' part_separator='no'/>
|
||||||
|
<format type='gpt'/>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<path>/dev</path>
|
||||||
|
</target>
|
||||||
|
</pool>
|
14
tests/storagepoolxml2xmlout/pool-disk-device-nopartsep.xml
Normal file
14
tests/storagepoolxml2xmlout/pool-disk-device-nopartsep.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<pool type='disk'>
|
||||||
|
<name>multipath</name>
|
||||||
|
<uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
|
||||||
|
<capacity unit='bytes'>0</capacity>
|
||||||
|
<allocation unit='bytes'>0</allocation>
|
||||||
|
<available unit='bytes'>0</available>
|
||||||
|
<source>
|
||||||
|
<device path='/dev/mapper/mpatha' part_separator='no'/>
|
||||||
|
<format type='gpt'/>
|
||||||
|
</source>
|
||||||
|
<target>
|
||||||
|
<path>/dev</path>
|
||||||
|
</target>
|
||||||
|
</pool>
|
@ -80,6 +80,7 @@ mymain(void)
|
|||||||
DO_TEST("pool-logical-nopath");
|
DO_TEST("pool-logical-nopath");
|
||||||
DO_TEST("pool-logical-create");
|
DO_TEST("pool-logical-create");
|
||||||
DO_TEST("pool-disk");
|
DO_TEST("pool-disk");
|
||||||
|
DO_TEST("pool-disk-device-nopartsep");
|
||||||
DO_TEST("pool-iscsi");
|
DO_TEST("pool-iscsi");
|
||||||
DO_TEST("pool-iscsi-auth");
|
DO_TEST("pool-iscsi-auth");
|
||||||
DO_TEST("pool-netfs");
|
DO_TEST("pool-netfs");
|
||||||
|
Loading…
Reference in New Issue
Block a user