[pve-devel] [PATCH 3/7] resize disk : allow resize pending disk

Alexandre Derumier aderumier at odiso.com
Wed Dec 31 14:38:10 CET 2014


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm  |   18 ++++++++++++++----
 PVE/QemuServer.pm |    4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 328a82c..a45509e 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2744,9 +2744,15 @@ __PACKAGE__->register_method({
                 if $digest && $digest ne $conf->{digest};
             PVE::QemuServer::check_lock($conf) if !$skiplock;
 
-	    die "disk '$disk' does not exist\n" if !$conf->{$disk};
+	    die "disk '$disk' does not exist\n" if !$conf->{$disk} && !$conf->{pending}->{$disk};
+	
+	    my $drive = undef;
 
-	    my $drive = PVE::QemuServer::parse_drive($disk, $conf->{$disk});
+	    if($conf->{pending}->{$disk}) {
+		$drive = PVE::QemuServer::parse_drive($disk, $conf->{pending}->{$disk});
+	    } else {
+		$drive = PVE::QemuServer::parse_drive($disk, $conf->{$disk});
+	    }
 
 	    my $volid = $drive->{file};
 
@@ -2782,11 +2788,15 @@ __PACKAGE__->register_method({
 
             PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: resize --disk $disk --size $sizestr");
 
-	    PVE::QemuServer::qemu_block_resize($vmid, "drive-$disk", $storecfg, $volid, $newsize);
+	    PVE::QemuServer::qemu_block_resize($vmid, "drive-$disk", $storecfg, $volid, $newsize, $conf->{pending}->{$disk});
 
 	    $drive->{size} = $newsize;
-	    $conf->{$disk} = PVE::QemuServer::print_drive($vmid, $drive);
 
+	    if ($conf->{pending}->{$disk}) {
+		$conf->{pending}->{$disk} = PVE::QemuServer::print_drive($vmid, $drive);
+	    } else {
+		$conf->{$disk} = PVE::QemuServer::print_drive($vmid, $drive);
+	    }
 	    PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
 	};
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1d85ac8..67e3015 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3416,13 +3416,13 @@ sub vm_monitor_command {
 }
 
 sub qemu_block_resize {
-    my ($vmid, $deviceid, $storecfg, $volid, $size) = @_;
+    my ($vmid, $deviceid, $storecfg, $volid, $size, $pending) = @_;
 
     my $running = check_running($vmid);
 
     return if !PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
 
-    return if !$running;
+    return if !$running || $pending;
 
     vm_mon_cmd($vmid, "block_resize", device => $deviceid, size => int($size));
 
-- 
1.7.10.4




More information about the pve-devel mailing list