Bug 1064041 - virt-sparsify fails if a btrfs filesystem contains readonly snapshots
Summary: virt-sparsify fails if a btrfs filesystem contains readonly snapshots
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1079625 1218766
Blocks: 1288337 1301891
TreeView+ depends on / blocked
 
Reported: 2014-02-11 21:20 UTC by Richard W.M. Jones
Modified: 2016-11-03 17:46 UTC (History)
9 users (show)

Fixed In Version: libguestfs-1.32.0-2.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1079625 (view as bug list)
Environment:
Last Closed: 2016-11-03 17:46:31 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 12:06:51 UTC

Description Richard W.M. Jones 2014-02-11 21:20:18 UTC
Description of problem:

(Reported by Jeff Bastien here:
https://bugzilla.redhat.com/show_bug.cgi?id=1064008#c20 )

# virt-sparsify opensuse.img --convert qcow2 opensuse.qcow2qemu-img version 1.5
Create overlay file to protect source disk ...
Examine source disk ...
◓ 25% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒═════════════════════════════════════════════════⟧ --:--
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Fill free space in /dev/sda5 with zero ...
Clearing Linux swap on /dev/sda6 ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Fill free space in /dev/sda7 with zero ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Fill free space in /dev/sda8 with zero ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
Fill free space in btrfsvol:/dev/sda7/.snapshots with zero ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
Fill free space in btrfsvol:/dev/sda7/.snapshots/1/snapshot with zero ...
Fatal error: exception Guestfs.Error("zero_free_space: open: /sysroot//qvm8re6w.spf: Read-only file system")

Version-Release number of selected component (if applicable):

libguestfs 1.22.6-20.el7

Comment 2 Richard W.M. Jones 2014-02-11 21:27:57 UTC
Reproducer:

---------------------------------------------------------------
guestfish -x -N fs:btrfs -m /dev/sda1 <<EOF
btrfs-subvolume-create /vol1

# libguestfs has no API for this yet:
debug sh "btrfs subvolume snapshot -r /sysroot/vol1 /sysroot/snapshot"

# This will fail with the same error as virt-sparsify:
-zero-free-space /snapshot
EOF

virt-sparsify test1.img test1-out.img
---------------------------------------------------------------

The virt-sparsify command at the end will fail with:

Input disk virtual size = 104857600 bytes (100.0M)
Create overlay file in /tmp to protect source disk ...
Examine source disk ...
Fill free space in /dev/sda1 with zero ...
Fill free space in btrfsvol:/dev/sda1/snapshot with zero ...
Fatal error: exception Guestfs.Error("zero_free_space: open: /sysroot//idpr6elo.o7z: Read-only file system")

Comment 3 Richard W.M. Jones 2014-02-11 21:31:01 UTC
Virt-sparsify should generally avoid read-only filesystems.
The same thing would happen if, for example, there was an ISO9660
filesystem contained in any partition and you tried to sparsify
the disk image.

Comment 4 RHEL Product and Program Management 2014-03-22 06:03:45 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 6 Pino Toscano 2015-10-16 09:09:21 UTC
As written in https://bugzilla.redhat.com/show_bug.cgi?id=1079625#c1:

Fixed upstream with
https://github.com/libguestfs/libguestfs/commit/864c2ee371f65388b18e737136663986cfc9eb08

Also,
https://github.com/libguestfs/libguestfs/commit/4bb3c44a286beb0dd8cdf337d64d8ce71e361dd6
makes virt-sparsify ignore read-only filesystems.

Both available in libguestfs >= 1.29.24.

So this bug fix will be picked by the rebase (bug #1218766).

Comment 9 Xianghua Chen 2016-06-28 02:58:56 UTC
Verified with the packages:
libguestfs-1.32.5-6.el7.x86_64

Verify steps:
1. Prepare a RHEL guest image with a snapshot:
# qemu-img snapshot -l rhel7.1.qcow2
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         snapshot1                 0 2016-06-28 10:35:03   00:00:00.000

2. virt-sparsify rhel7.1.qcow2  --convert raw rhel7.1.raw
[   0.1] Create overlay file in /tmp to protect source disk
[   0.1] Examine source disk
[   2.7] Fill free space in /dev/rhel/root with zero
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 290.1] Clearing Linux swap on /dev/rhel/swap
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 313.8] Fill free space in /dev/sda1 with zero
[ 314.4] Fill free space in /dev/sda2 with zero
[ 315.5] Fill free space in volgroup rhel with zero
[ 324.8] Copy to destination and make sparse
[ 757.1] Sparsify operation completed with no errors.
virt-sparsify: Before deleting the old disk, carefully check that the 
target disk boots and works correctly.


No error occurs. 

So Verified.

Comment 11 errata-xmlrpc 2016-11-03 17:46:31 UTC
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


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