[pve-devel] [PATCH v4 qemu-server] Align size to 1 KiB bytes before doing 'qmp block_resize'

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


1. Avoids the error
"VM 111 qmp command 'block_resize' failed - 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>
---

Changes from v3:
    * No ABI change anymore
    * Now this resembles the first version of the patch again, with the
      difference of using 1024 instead of 512 (to make volume_import happy)
      and doing the alignment independently in two places: once inside the
      storage module and once before calling 'qmp block_resize'.

 PVE/QemuServer.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 23176dd..3bf60ea 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4656,6 +4656,9 @@ sub qemu_block_resize {
 
     return if !$running;
 
+    my $padding = (1024 - $size % 1024) % 1024;
+    $size = $size + $padding;
+
     mon_cmd($vmid, "block_resize", device => $deviceid, size => int($size));
 
 }
-- 
2.20.1




More information about the pve-devel mailing list