--- Begin Message ---
Signed-off-by: Alexandre Derumier <alexandre.derum...@groupe-cyllene.com>
---
src/PVE/Storage.pm | 4 ++--
src/PVE/Storage/LVMQcow2Plugin.pm | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index 97e77c8..385150e 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -982,7 +982,7 @@ sub unmap_volume {
}
sub vdisk_alloc {
- my ($cfg, $storeid, $vmid, $fmt, $name, $size) = @_;
+ my ($cfg, $storeid, $vmid, $fmt, $name, $size, $underlay_size) = @_;
die "no storage ID specified\n" if !$storeid;
@@ -1005,7 +1005,7 @@ sub vdisk_alloc {
# lock shared storage
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub
{
my $old_umask = umask(umask|0037);
- my $volname = eval { $plugin->alloc_image($storeid, $scfg, $vmid, $fmt,
$name, $size) };
+ my $volname = eval { $plugin->alloc_image($storeid, $scfg, $vmid, $fmt,
$name, $size, $underlay_size) };
my $err = $@;
umask $old_umask;
die $err if $err;
diff --git a/src/PVE/Storage/LVMQcow2Plugin.pm
b/src/PVE/Storage/LVMQcow2Plugin.pm
index bdb21cc..2a56c46 100644
--- a/src/PVE/Storage/LVMQcow2Plugin.pm
+++ b/src/PVE/Storage/LVMQcow2Plugin.pm
@@ -77,7 +77,7 @@ sub find_free_diskname {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $underlay_size) =
@_;
my $sparse = $scfg->{sparse};
@@ -87,6 +87,9 @@ sub alloc_image {
#set minimum size to chunksize
my $lv_size = $chunksize;
+ # we can force the min lv_size for copy. Add a extra chunk.
+ $lv_size = $underlay_size + $chunksize if $underlay_size;
+
#if no provisioning, $lv_size = $size + a extra chunk for metadatas
overhead
$lv_size = $size + $chunksize if !$sparse;
--
2.39.2
--- End Message ---