[pve-devel] [PATCH v4 storage] volume_resize: align size to 1 KiB

Fabian Ebner f.ebner at proxmox.com
Wed Feb 19 11:31:31 CET 2020


1. Avoids the error
qemu-img: The new size must be a multiple of 512
for qcow2 disks.
2. Because volume_import expects disk sizes to be a multiple of 1 KiB.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/Storage.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 62d72de..3247c61 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -207,6 +207,9 @@ sub volume_size_info {
 sub volume_resize {
     my ($cfg, $volid, $size, $running) = @_;
 
+    my $padding = (1024 - $size % 1024) % 1024;
+    $size = $size + $padding;
+
     my ($storeid, $volname) = parse_volume_id($volid, 1);
     if ($storeid) {
         my $scfg = storage_config($cfg, $storeid);
-- 
2.20.1





More information about the pve-devel mailing list