Bug 1725330 - virt-clone shouldn't advertise that it works on a suspended VM
Summary: virt-clone shouldn't advertise that it works on a suspended VM
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: virt-manager
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-06-29 16:29 UTC by Erick
Modified: 2020-01-29 23:57 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-29 23:57:45 UTC
Embargoed:


Attachments (Terms of Use)

Description Erick 2019-06-29 16:29:23 UTC
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.

Comment 1 Erick 2019-06-29 16:57:15 UTC
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.

Comment 2 Cole Robinson 2019-07-02 19:59:05 UTC
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

Comment 3 Peter Krempa 2019-07-03 05:53:27 UTC
<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.

Comment 4 Cole Robinson 2019-09-03 16:03:05 UTC
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

Comment 5 Cole Robinson 2020-01-29 23:57:45 UTC
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


Note You need to log in before you can comment on or make changes to this bug.