2014-08-04 14:58 GMT+04:00 John Ferlan <jferlan(a)redhat.com>:
On 08/02/2014 04:24 PM, Vasiliy Tolstov wrote:
> Hi all. I'm using libvirt 1.2.6
> I want to use lvm storage for my virtual machines.
> But i want to use new lvm2 feature - thin pool. How can i do that in
> libvirt? If libvirt can't create it via pool xml, does (and how) to
> use this setup under libvirt?
>
The 'Thin Pool' is avoided by libvirt, but volumes found a "Sparse" or
"Snapshot" that are part of an lvm thin pool can be utilized by libvirt
- although as the storage administrator understand that if the volume
becomes "filled" - it will go "Inactive"
The key to whether an lvm volume is found is the attributes as seen from
the 'lvs' utility which spits out the following for example:
# lvs
LV VG Attr LSize Pool Origin Data% Move
Log Cpy%Sync Convert
home fedora -wi-ao---- 136.72g
root fedora -wi-ao---- 50.00g
swap fedora -wi-ao---- 7.64g
lv_test lv_pool swi-a-s--- 4.00m [lv_test_vorigin] 50.39
or for a filled and now inactive volume:
# lvs
LV VG Attr LSize Pool Origin Data% Move
Log Cpy%Sync Convert
home fedora -wi-ao---- 136.72g
root fedora -wi-ao---- 50.00g
swap fedora -wi-ao---- 7.64g
lv_test lv_pool swi-I-s--- 4.00m [lv_test_vorigin] 100.00
The 'Attr' column must have an active volume as seen by the 'a' in the
5th field and as Jan points out cannot be a "thin" pool as seen when
there's a 't' in the first column.
Assuming you know have the physical volume already created (via
pvcreate), then a pool definition could be:
# more lv_pool.xml
<pool type="logical">
<name>lv_pool</name>
<source>
<device path="/dev/sdb2"/>
<device path="/dev/sdb3"/>
</source>
<target>
<path>/dev/lv_pool</path>
</target>
</pool>
#
Where the device path entries would be your physical volumes.
Using 'virsh pool-build lv_pool' and 'virsh pool-start lv_pool' will set
things up allowing for the creation of a volume in the pool such as:
# more lv_test.xml
<volume>
<name>lv_test</name>
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
<device path='/dev/sdb3'>
</device>
</source>
<capacity>8388608</capacity>
<allocation>4194304</allocation>
<target>
<path>/dev/lv_pool/lv_test</path>
<permissions>
<mode>0660</mode>
<owner>0</owner>
<group>6</group>
<label>system_u:object_r:fixed_disk_device_t:s0</label>
</permissions>
</target>
</volume>
via 'virsh vol-create lv_pool lv_test.xml' where the 'capacity' and
'allocation' values are the key to determining whether a 'sparse' or
'snapshot' volume from an lvm thin pool will be created. If capacity is
not equal allocation, then the resulting libvirt command adds the
'--virtualsize' (or '--V') to the lvm command used to create the volume
in the pool, e.g.
# /usr/sbin/lvcreate --name lv_test -L 4096K --virtualsize 8192K lv_pool
John
Very good doc. Thanks!
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
jabber: vase(a)selfip.ru