mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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).
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user