Richard W.M. Jones
2015-Nov-04 10:11 UTC
[Libguestfs] [PATCH] sparsify: in-place: Refuse to run on overlay files (RHBZ#1277705).
$ qemu-img create -f qcow2 -b /tmp/centos-6.img overlay.qcow2 $ virt-sparsify --in-place overlay.qcow2 virt-sparsify: error: disk image 'overlay.qcow2' appears to have a backing file. You should use copying mode sparsification for this file (see the virt-sparsify(1) manual). Thanks: Yaniv Kaul --- sparsify/in_place.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml index 3a2b32c..669c639 100644 --- a/sparsify/in_place.ml +++ b/sparsify/in_place.ml @@ -30,6 +30,11 @@ open Cmdline module G = Guestfs let rec run disk format ignores machine_readable zeroes + (* If the disk has a backing file, refuse to run (RHBZ#1277705). *) + if (new G.guestfs ())#disk_has_backing_file disk then + error (f_"disk image '%s' appears to have a backing file. You should use copying mode sparsification for this file (see the virt-sparsify(1) manual).") + disk; + (* Connect to libguestfs. *) let g = new G.guestfs () in if trace () then g#set_trace true; -- 2.5.0
Pino Toscano
2015-Nov-04 10:23 UTC
Re: [Libguestfs] [PATCH] sparsify: in-place: Refuse to run on overlay files (RHBZ#1277705).
On Wednesday 04 November 2015 10:11:17 Richard W.M. Jones wrote:> $ qemu-img create -f qcow2 -b /tmp/centos-6.img overlay.qcow2 > $ virt-sparsify --in-place overlay.qcow2 > virt-sparsify: error: disk image 'overlay.qcow2' appears to have a backing > file. You should use copying mode sparsification for this file (see the > virt-sparsify(1) manual). > > Thanks: Yaniv Kaul > --- > sparsify/in_place.ml | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml > index 3a2b32c..669c639 100644 > --- a/sparsify/in_place.ml > +++ b/sparsify/in_place.ml > @@ -30,6 +30,11 @@ open Cmdline > module G = Guestfs > > let rec run disk format ignores machine_readable zeroes > + (* If the disk has a backing file, refuse to run (RHBZ#1277705). *) > + if (new G.guestfs ())#disk_has_backing_file disk then > + error (f_"disk image '%s' appears to have a backing file. You should use copying mode sparsification for this file (see the virt-sparsify(1) manual).") > + disk; > + > (* Connect to libguestfs. *) > let g = new G.guestfs () in > if trace () then g#set_trace true;Can you please also document in virt-sparsify(1)? Looks good otherwise. Thanks, -- Pino Toscano
Reasonably Related Threads
- [PATCH] OCaml tools: use open_guestfs everywhere
- Re: Fwd: [Bug 1277705] virt-sparsify --in-place should not sparsify a snapshot
- [PATCH 0/3] add crypto/LUKS support in some OCaml-based tools
- Re: Fwd: [Bug 1277705] virt-sparsify --in-place should not sparsify a snapshot
- [PATCH 0/1] WIP: Support LUKS-encrypted partitions