[Pkg-libvirt-commits] [libguestfs] 03/11: v2v: Check if there is sufficient free space for conversion (RHBZ#1139543).

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:44:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.41-1
in repository libguestfs.

commit be1c6965006dec258b915c9561ac66c8cb36dfe6
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Sep 9 10:46:55 2014 +0100

    v2v: Check if there is sufficient free space for conversion (RHBZ#1139543).
    
    Before trying to perform the conversion, estimate if there is
    sufficient free space on the guest filesystem(s) for the conversion to
    be successful.
    
    If not, you will see an error similar to this one:
    
    [   6.0] Checking for sufficient free disk space in the guest
    virt-v2v: error: not enough free space for conversion on filesystem '/'.
    4354048 bytes free < 20000000 bytes needed
---
 v2v/v2v.ml | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index dbe653f..8138b53 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -179,6 +179,10 @@ let rec main () =
   msg (f_"Inspecting the overlay");
   let inspect = inspect_source g root_choice in
 
+  (* Check there is enough free space to perform conversion. *)
+  msg (f_"Checking for sufficient free disk space in the guest");
+  check_free_space g;
+
   (* Conversion. *)
   let guestcaps =
     (match inspect.i_product_name with
@@ -381,4 +385,35 @@ and inspect_source g root_choice =
     i_apps = apps;
     i_apps_map = apps_map; }
 
+(* Conversion can fail if there is no space on the guest filesystems
+ * (RHBZ#1139543).  To avoid this situation, check there is some
+ * headroom.  Mainly we care about the root filesystem.
+ *)
+and check_free_space g =
+  let mps = g#mountpoints () in
+  List.iter (
+    fun (_, mp) ->
+      (* bfree = free blocks for root user *)
+      let { G.bfree = bfree; bsize = bsize } = g#statvfs mp in
+      let free_bytes = bfree *^ bsize in
+      let needed_bytes =
+        match mp with
+        | "/" ->
+          (* We may install some packages, and they would usually go
+           * on the root filesystem.
+           *)
+          20_000_000L
+        | "/boot" ->
+          (* We usually regenerate the initramfs, which has a typical size
+           * of 20-30MB.  Hence:
+           *)
+          50_000_000L
+        | _ ->
+          (* For everything else, just make sure there is some free space. *)
+          10_000_000L in
+      if free_bytes < needed_bytes then
+        error (f_"not enough free space for conversion on filesystem '%s'.  %Ld bytes free < %Ld bytes needed")
+          mp free_bytes needed_bytes
+  ) mps
+
 let () = run_main_and_handle_errors ~prog main

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list