Re: Does libvirt have API to detect image format

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

 



On 08/11/2014 02:35 PM, Jianfeng Tang wrote:
>>
> 
> I am using backing store when I create my volume. However, the backing
> store file is from another team, which can be either in raw or in qcow2
> format.
> 
> Is there a libvirt API to detect image format by given an image file? Or I
> have to run qemu-img?

virStorageVolGetXMLDesc() in the C code ('virsh vol-dumpxml' from the
command line), if your volume resides within a storage pool.
Furthermore, if there is ANY possibility that the file might be raw but
that the volume has been in use by a possibly malicious guest, you
CANNOT blindly trust a file probe that says qcow2, because a guest can
write header information into a raw disk in order to make probes return
qcow2.  So take the output with a grain of salt (it is safe to blindly
trust a claim of 'raw', but blindly trusting a claim of 'qcow2' is risky
if you don't know the history behind the image).

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

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux