libvirt image based provisioning using logical volumes

716 views Asked by At

Are there known issues with image based provisioning using logical volumes in libvirt? I am getting this error while trying to do the same

Unable to save
Failed to create a compute kvm2 (Libvirt) instance test3.xxx.local: Call            
to virNetworkCreateXML failed: 
internal error: Child process (/usr/sbin/lvcreate --name 
test3.xxx.local-disk1 -L 1K --type snapshot --virtualsize 10485760K -s 
/vm-images-pool/images-vol/template_minimal) unexpected exit status 3: 2017-
01-05 00:42:08.133+0000: 12330: debug : virFileClose:102 : Closed fd 29   
2017-01-05 00:42:08.133+0000: 12330: debug : virFileClose:102 : Closed fd 31  
2017-01-05 00:42:08.133+0000: 12330: debug : virFileClose:102 : Closed fd 27 
Volume group name expected (no slash) Run `lvcreate --help' for more   
information

This link from Red Hat flags it as a known issue:

https://access.redhat.com/solutions/1995053

That doc has a date of October 20 2015. Not sure if anythig changed after that to support LV.

I tried to satisfy the requirement in that doc by creating a pool based on dir like this:

Setup:

  1. Storage pool vm-images-pool-dir of type dir
  2. Storage pool vm-images-pool of type logical

template_minimal is the image template.

[root@kvm2 libvirt]# virsh vol-list vm-images-pool-dir
Name                 Path
----------------------------------------------------------------------------
template_minimal     /vm-images-pool/images-vol/template_minimal

vm-images-pool storage pool is of type VG with one volume:

images-vol   vm-images-pool   -wi-ao---- 249.00g

images-vol is mounted under /vm-images-pool/images-vol/

Any insight is appreciated.

Thanks, TG

=======================================

more details.

Daniel, Thanks. I am a bit confused. I couldn't put the actual commands earlier since I had cleaned them up. I recreated the setup. Here are the commands I used:

virsh pool-define-as  vm-images-pool logical --source-dev /dev/mapper/mpathd
virsh pool-build vm-images-pool
virsh pool-start vm-images-pool
virsh vol-create-as vm-images-pool images-vol --capacity 249G
virsh pool-define-as vm-images-pool-dir dir - - - - /vm-images-pool/images- vol/
virsh pool-build vm-images-pool-dir
virsh pool-start vm-images-pool-dir
[root@kvm2 ~]# virsh vol-list vm-images-pool-dir
 Name                 Path
----------------------------------------------------------------------------  --
 lost+found           /vm-images-pool/images-vol/lost+found
 template_minimal     /vm-images-pool/images-vol/template_minimal

=======================================

/vm-images-pool/images-vol/template_minimal is the path used for template image

==================================

more tests:

mounted the logical volume at a mount point to match the directory based storage pool:

[root@kvm2 ~]# df -h /vm-images-pool-dir/images-vol
Filesystem                                Size  Used Avail Use% Mounted on
/dev/mapper/vm--images--pool-images--vol  245G  1.2G  232G   1% /vm-images-  pool-dir/images-vol


[root@kvm2 ~]# virsh vol-list vm-images-pool-dir
 Name                 Path
------------------------------------------------------------------------------
 lost+found           /vm-images-pool-dir/images-vol/lost+found
 template_minimal     /vm-images-pool-dir/images-vol/template_minimal

[root@kvm2 ~]#

used /vm-images-pool-dir/images-vol/template_minimal as the template path

same result

Unable to save
Failed to create a compute kvm2 (Libvirt) instance test3.xxx.local: Call    
to virNetworkCreateXML failed: internal error: Child process   
(/usr/sbin/lvcreate     --name test3.xxx.local-disk1 -L 1K --type 
snapshot --virtualsize 10485760K -    s /vm-images-pool-dir/images-
vol/template_minimal) unexpected exit status 3:     2017-01-05 
16:45:10.694+0000: 40712: debug : virFileClose:102 : Closed fd 27     2017-
01-05 16:45:10.694+0000: 40712: debug : virFileClose:102 : Closed fd 29 
2017-01-05 16:45:10.694+0000: 40712: debug : virFileClose:102 : Closed fd 24   
Volume group name expected (no slash) Run `lvcreate --help' for more 
information.

the source of the image is "/vm-images-pool-dir/images-vol/template_minimal" and the guest's target back end is a LV of 10G on another storage pool called "virtual-machines"

Not understanding what the 'lvcreate' commmand is trying to do, shouldnt it at least use "virtual-machines" as the target VG. The tool I am using is Satellite 6.2. I am thinking its something silly that I am overlooking. Not sure where :)

Thanks TG

2

There are 2 answers

3
DanielB On

Based on the paths in that command, it seems you wanted to create a new file based volume in the /vm-images-pool/images-vol/, ie your "vm-images-pool-dir" pool. The fact that you are seeing an error from "lvcreate" though, suggests that you mistakenly specified "vm-images-pool" to libvirt as the pool to use, causing it to try to create a logical volume instead. You don't show the actual command / API you are running, but check that you've given the right pool name to it.

0
Cedric Bosdonnat On

I know the question has long been asked, but I just hit the same problem and found the answer. I couldn't find the exact virsh command you are using leading to this error, but here I used the following XML file with virsh vol-create libvirtVG logical.xml

<volume >
  <name>vol02</name>
  <capacity unit='KiB'>2097152</capacity>
  <allocation unit='KiB'>0</allocation>
  <backingStore>
    <path>/dev/libvirtVG/sles15sp1</path>
  </backingStore>
</volume>

To be able to get rid of the error I had to set the allocation to the value of the capacity. You can also see that virt-manager is automatically doing it for you: https://github.com/virt-manager/virt-manager/blob/master/virtinst/storage.py#L646

The equivalent using the virsh vol-create-as command would be:

virsh vol-create-as libvirtVG vol02 2048MiB --allocation 2048MiB \
                    --backing-vol /dev/libvirtVG/sles15sp1