KVM: running qemu-img info without exclusive access using force-share flag

By default, ‘qemu-image info’ will throw an error if it cannot get exclusive access to the disk file it is trying to read.

$ sudo qemu-img info mydisk.qcow2
qemu-img: Could not open 'mydisk.qcow2': Failed to get shared "write" lock
Is another process using the image [mydisk.qcow2]?

Although it is not listed in the man page, you can use the ‘force-share’ flag to run the info command without exclusive access.

$ sudo qemu-img info mydisk.qcow2 --force-share

REFERENCES

qemu-img man page

redhat docs, list/create/delete snapshot using qemu-img

NOTES

listing snapshots inside qcow2 image

qemu-img snapshot -l mydisk.qcow2 --force-share