mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-01 05:47:01 +03:00
F #6029: Sparsify backup file after flatten files
The result of a flatten operation can be optionally sparsify to free space. This needs 'virt-sparsify' tool from libguestfs package. Note: if not present the sparsify step will be skipped.
This commit is contained in:
parent
01c490a36d
commit
de10e618c9
@ -46,7 +46,7 @@ module TransferManager
|
||||
|
||||
# Given a sorted list of qcow2 files with backing chain properly reconstructed,
|
||||
# return a shell recipe that merges it into a single qcow2 image.
|
||||
def self.merge_chain(paths, workdir = nil)
|
||||
def self.merge_chain(paths, workdir = nil, sparsify = false)
|
||||
return '' unless paths.size > 1
|
||||
|
||||
clean = paths.first(paths.size - 1)
|
||||
@ -59,6 +59,10 @@ module TransferManager
|
||||
script << "qemu-img convert -O qcow2 '#{origfile}' '#{workfile}'"
|
||||
script << "mv '#{workfile}' '#{origfile}'"
|
||||
|
||||
if sparsify
|
||||
script << "[ $(type -P virt-sparsify) ] && virt-sparsify -q --in-place '#{origfile}'"
|
||||
end
|
||||
|
||||
script << "rm -f #{clean.map {|p| "'#{p}'" }.join(' ')}" unless clean.empty?
|
||||
|
||||
script.join("\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user