[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt-users] Proper way to reference a disk



On 05/06/2015 02:05 PM, Michael Schwager wrote:
> Hi,
> We are running on CentOS 7.0. We want to move our VMs (kvm/qemu) from
> qcow/image files to logical volumes under LVM.
> 
> I have moved one of them but I had a little trouble editing the disk
> properly and I wonder what is the correct way to do it. Specifically, in
> the XML under the devices/disk section why does the source say "source file=",
> and not "source dev="?  The reason I ask is that I have a number of other
> machines to move and I don't want to mess them up.
> 
> The source file entry for the disk was like this in our xml file:
> <source file='/var/lib/libvirt/images/pxetest.qcow2'/>
> 
> I got the vm to work by converting the image to raw, then dumping via dd
> into the LV, and editing the XML using virsh as follows:
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw' cache='none'/>
>       <*source file*='/dev/kvm_temp/pxetest'/>

The key for what <source> looks like is the <disk type='...'> attribute
a couple lines earlier.  When type='file', then <source> lists a
file='...' absolute path, and libvirt treats it as a file (which sort of
works, except when querying for how much of the file is actually
allocated, because it assumes that stat() alone is good enough)

> By comparison I have a test machine on another real host upon which I
> loaded a VM and put its disk into a logical volume. Its disk section looks
> like this:
> 
>     <disk type='block' device='disk'>
>       <driver name='qemu' type='raw' cache='none' io='native'/>
>       <*source dev*='/dev/kvm_hosts/pxetest2'/>

And here, you used type='block', so <source> must list dev='...' and
give an absolute path to a block device (and here, when libvirt is
computing how much of the device is allocated, it relies on more than
just stat(), which can give more accurate numbers when doing things like
qcow2 format atop an LVM block device).

>       <target dev='hda' bus='ide'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
> 
> The source file / source dev thing really has me wondering.

Hopefully I answered it.  As a rule of thumb, if it is a block device,
use type='block' (or type='lun' if you need sgio passthrough support)
and <source dev='...'>); otherwise use type='file' and <source file='...'.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]