aka_007
aka_007

Reputation: 269

How can I detect a QEMU image?

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" ?

Upvotes: 9

Views: 9128

Answers (1)

CrApHeR
CrApHeR

Reputation: 2655

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

Upvotes: 10

Related Questions