I have a form where user can upload images (images of different OS).
How can I detect whether the image is QEMU image of type "qcow2" ?
To run it, download and unzip the image in a folder and run the QEMU command. Replace linux-0.2. img with the name of your guest OS image file. If it has a GUI and you want to use your mouse with it, double-click on the window and QEMU will grab your mouse.
You can mount a QEMU disk image using two basic methods: using an offset to mount the image directly, or using the libguestfs-tools package.
qemu-img command allows to inspect, check, create, convert, resize and take snapshot of qcow images. The e2fsprogs command e2image also has support for generating qcow2 files to avoid the use of sparse file support.
You can use qemu-img info
to check the image format.
qemu-img info image-qcow.qcow2
the result will be something like this
image: image-qcow.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 136K
cluster_size: 65536
Source: http://lnx.cx/docs/vdg/html/ch02s03.html
After that, if you want to get the file format you can parse the output to get it.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With