[pve-devel] [PATCH v2 qemu-server 2/2] qemu_block_resize: align size to 512 before issuing 'block_resize' qmp command

Fabian Ebner f.ebner at proxmox.com
Mon Jan 13 11:47:44 CET 2020


For qcow2, this is required and for raw, the qmp command aligns to 512 implicitly anyways

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

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2b68d81..922f9b0 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4672,6 +4672,11 @@ sub qemu_block_resize {
 
     return if !$running;
 
+    # for qcow2 images 'qmp block_resize' requires that the size is
+    # aligned to 512 and for raw images it happens implicitly anyways
+    my $padding = (512 - $size % 512) % 512;
+    $size = $size + $padding;
+
     mon_cmd($vmid, "block_resize", device => $deviceid, size => int($size));
 
 }
-- 
2.20.1





More information about the pve-devel mailing list