[Pkg-libvirt-commits] [libguestfs] 27/59: sysprep: Add disks with discard = "besteffort".

Hilko Bengen bengen at moszumanska.debian.org
Thu Mar 20 23:05:35 UTC 2014


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

bengen pushed a commit to branch experimental
in repository libguestfs.

commit b48e8850047f240dc67e1610757229e096ed9e25
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Mar 11 14:29:38 2014 +0000

    sysprep: Add disks with discard = "besteffort".
    
    Since virt-sysprep tends to delete a lot of files, adding discard
    support to it makes some sense.
    
    Note that this probably won't have any effect for most filesystems
    since:
    
    (a) ext4 mounts also need to use -o discard,
    
    (b) ext4, and maybe others, require you to call fstrim explicitly,
    they don't discard automatically (except for userspace tools like
    mkfs.ext4 but that doesn't apply in this case).
---
 sysprep/main.ml | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sysprep/main.ml b/sysprep/main.ml
index 6f631d5..9047a74 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -198,7 +198,11 @@ read the man page virt-sysprep(1).
       fun (g : Guestfs.guestfs) readonly ->
         let allowuuid = true in
         let readonlydisk = "ignore" (* ignore CDs, data drives *) in
-        ignore (g#add_domain ~readonly ?libvirturi ~allowuuid ~readonlydisk dom)
+        let discard = if readonly then None else Some "besteffort" in
+        ignore (g#add_domain
+                  ~readonly ?discard
+                  ?libvirturi ~allowuuid ~readonlydisk
+                  dom)
     | _, Some _ ->
       eprintf (f_"%s: you cannot give -a and -d options together\n") prog;
       eprintf (f_"Read virt-sysprep(1) man page for further information.\n");
@@ -209,7 +213,11 @@ read the man page virt-sysprep(1).
           fun (uri, format) ->
             let { URI.path = path; protocol = protocol;
                   server = server; username = username } = uri in
-            g#add_drive ~readonly ?format ~protocol ?server ?username path
+            let discard = if readonly then None else Some "besteffort" in
+            g#add_drive
+              ~readonly ?discard
+              ?format ~protocol ?server ?username
+              path
         ) files
   in
 

-- 
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