[pve-devel] [PATCH 1/2] add qm disk resize

Dietmar Maurer dietmar at proxmox.com
Tue Aug 7 07:51:55 CEST 2012


I think this is simply too dangerous. You can't simply use the size 
hint ($old_drive->{size}) - that value can be totally wrong (just good 
enough to display on the gui).

Also, I do not think we should add this to the update API. Maybe a special
resize API is better suited, with extra  qm command:

# qm resize <vmid> -ide1 +10G

What do you think?
 

> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Montag, 06. August 2012 11:57
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH 1/2] add qm disk resize
> 
> this add disk resizing if new size is bigger than old size.
> 
> if new size is lower than old size, we die (can't shrink).
> 
> if new size equal old size, we don't resize.
> 
> (shrinking should work in theory, but too dangerous)
> 
> qm set vmid -virtio0 storage:volume,size=XXG
> 
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>  PVE/API2/Qemu.pm |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index
> 47c588f..b014e36 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -701,6 +701,14 @@ my $vmconfig_update_disk = sub {
>                 &$safe_int_ne($drive->{iops_wr}, $old_drive->{iops_wr})) {
>                 PVE::QemuServer::qemu_block_set_io_throttle($vmid,"drive-
> $opt",$drive->{bps}, $drive->{bps_rd}, $drive->{bps_wr}, $drive->{iops},
> $drive->{iops_rd}, $drive->{iops_wr}) if
> !PVE::QemuServer::drive_is_cdrom($drive);
>              }
> +
> +	    if ($old_drive->{size} && $drive->{size} && $drive->{size} >
> $old_drive->{size}) {
> +               PVE::QemuServer::qemu_block_resize($vmid, "drive-$opt",
> $storecfg, $drive->{file}, $drive->{size});
> +	    }
> +	    elsif ($old_drive->{size} && $drive->{size} && $drive->{size} <
> $old_drive->{size}) {
> +	       die "can't shrink drive size";
> +	    }
> +
>  	}
>      }
> 
> --
> 1.7.2.5
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





More information about the pve-devel mailing list