[pve-devel] [PATCH qemu-server] qemu_block_resize: align size to 512
    Fabian Ebner 
    f.ebner at proxmox.com
       
    Thu Jan  9 11:20:07 CET 2020
    
    
  
Doing 'qm resize 111 scsi0 +0.2G' where scsi0 is a qcow2 disk
produced the following errors:
"VM 111 qmp command 'block_resize' failed - The new size must be a multiple of 512"
if the VM is running and
"qemu-img: The new size must be a multiple of 512"
if the VM isn't running
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/QemuServer.pm | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2b68d81..2c92c3b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4668,6 +4668,10 @@ sub qemu_block_resize {
 
     my $running = check_running($vmid);
 
+    # aligning to 512 is required for qcow2 disks
+    my $padding = (512 - $size % 512) % 512;
+    $size = $size + $padding;
+
     $size = 0 if !PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
 
     return if !$running;
-- 
2.20.1
    
    
More information about the pve-devel
mailing list