Red Hat Bugzilla – Bug 1277122
RFE: virt-sparsify: make '--in-place' sparsification safe to abort (gracefully or ungracefully)
Last modified: 2016-11-03 13:56:26 EDT
Description of problem: I'd be happy if there will be a possibility to use virt-sparsify in '--in-place' mode (where sparsification is not happening on a copy of the disk, but in place) and if a user stops gracefully the process or the process gets killed abruptly, the disk is still safe from corruption. TIA, Y.
I posted a thread upstream about this: https://lists.nongnu.org/archive/html/qemu-devel/2015-11/threads.html#00402 Paolo's reply hasn't appeared in that archive yet, but he agrees with me that this should be safe. However it would be nice for virt-sparsify to handle ^C gracefully, so I'm going to try to implement that.
Patch posted: https://www.redhat.com/archives/libguestfs/2015-November/thread.html#00032
This is upstream now: https://github.com/libguestfs/libguestfs/commit/8e3920a334d8d2b3c0a2be8ca84f8f935c41b106 We'll pick this change up in the rebase (bug 1218766).
From an oVirt operational point of view, you just need to send the virt-sparsify process either SIGINT or SIGQUIT (once). It will shut down gracefully (which may take some time), and then exit with an error code. If you send a second signal before virt-sparsify exits, then virt-sparsify will exit immediately (and *un*gracefully), so I don't recommend doing that.
Verified with packages: libguestfs-1.32.6-1.el7.x86_64 Steps: 1. Prepare a RHEL7 guest image: RHEL-Server-7.2-64-hvm.raw # qemu-img info RHEL-Server-7.2-64-hvm.raw image: RHEL-Server-7.2-64-hvm.raw file format: raw virtual size: 8.0G (8589934592 bytes) disk size: 8.0G # virt-filesystems -a RHEL-Server-7.2-64-hvm.raw -l Name Type VFS Label Size Parent /dev/sda1 filesystem xfs - 524288000 - /dev/rhel_dhcp-10-28/root filesystem xfs - 7159676928 - 2. # virt-sparsify --in-place RHEL-Server-7.2-64-hvm.raw 3. # qemu-img info RHEL-Server-7.2-64-hvm.raw image: RHEL-Server-7.2-64-hvm.raw file format: raw virtual size: 8.0G (8589934592 bytes) disk size: 2.2G # virt-filesystems -a RHEL-Server-7.2-64-hvm.raw -l Name Type VFS Label Size Parent /dev/sda1 filesystem xfs - 524288000 - /dev/rhel_dhcp-10-28/root filesystem xfs - 7159676928 - 4. Execute step 1-3 again, but use ctrl+c to stop it during the process in step 2. All commands finished successfully, and the guest images is shrinked and can be boot normally after execute virt-sparsify.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2576.html