Description of problem: When trying to apply virt-clone to a suspended kvm vm, the command fails, while according to the man-page for virt-clone this should work. Version-Release number of selected component (if applicable): virt-clone 2.1.0 How reproducible: Steps to Reproduce: 1. virsh suspend <domain> 2. virsh list shows <domain> as paused. 3. virt-clone --original <domain> --name <domain>-test --file <domain>-test.qcow2 3. Actual results: WARNING Setting the graphics device port to autoport, in order to avoid conflicting. ERROR Couldn't create storage volume '<domain>-test.qcow2': 'internal error: Child process (/usr/bin/qemu-img convert -f qcow2 -O qcow2 -o compat=1.1,lazy_refcounts <path>/<domain>.qcow2 <path>/<domain>-test.qcow2) unexpected exit status 1: qemu-img: Could not open '<path>/<domain>.qcow2': Failed to get shared "write" lock Is another process using the image [<path>/<domain>.qcow2]? <domain> represents the name of the domain in question, <path> represents the absolute path of the image location. Expected results: a clone is generated of the paused VM. Additional info: when performing the attempt to clone the VM via virt-manager, the same error occurs. No selinux deny messages.
I just rechecked the man-page and I found no explicit confirmation that cloning a suspended VM should work. However when experimenting with trying to clone the running VM I get the error: ERROR Domain with devices to clone must be paused or shutoff. which suggests that cloning a paused VM should work.
Thanks for the report. The 'write' lock is something newer qemu does, locking an image when a VM has it open. This prevents other uses of qemu/qemu-img from being able to accidentally alter a disk that is in use, it's a safety thing. It wasn't there forever though so previously you could clone a paused VM, although it wasn't the safest thing to do. For other hypervisors and in certain situations it is potentially okay though, so virt-clone isn't exactly wrong here. I believe if you want qemu to not do this write locking, you can add the <shareable/> element to your VM <disk> config, and then the clone operation should work. or just fully shut down the VM first which is the safest
<shareable> will only work if the image format for the disk in the VM is 'raw'. For any other format that is not possible as e.g. qemu is caching the image metadata (qcow2 internals). The image on disk thus may look corrupt if viewed from a different process. Libvirt will report an error if <shareable> is used with non-raw images.
libvirt is working as correctly here, the virt-clone message just doesn't apply in this case. We should probably just drop the 'suspended' bit from the message. Moving to virt-manager upstream to track that
Fixed upstream now: commit 140a1f3b15d47ea5d2d56bdf56d0484419023280 Author: Cole Robinson <crobinso> Date: Wed Jan 29 16:14:55 2020 -0500 cloner: Drop ability to clone a paused VM