[pve-devel] [PATCH 3/3] forbid maxcpus change when vm is running

Alexandre Derumier aderumier at odiso.com
Tue Jan 7 13:32:52 CET 2014


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index b2c8908..2427925 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -898,6 +898,8 @@ my $update_vm_api  = sub {
 
     my $defaults = PVE::QemuServer::load_defaults();
 
+    my $running = PVE::QemuServer::check_running($vmid);
+
     &$resolve_cdrom_alias($param);
 
     # now try to verify all parameters
@@ -952,6 +954,18 @@ my $update_vm_api  = sub {
 		if $balloon && $balloon > $maxmem;
 	}
 
+	if ($running && defined($param->{maxcpus})){
+	    if( (defined($conf->{maxcpus}) && $param->{maxcpus} != $conf->{maxcpus}) || (!$conf->{maxcpus} && $param->{maxcpus}) ){
+		    raise_param_exc({ maxcpus => "you can't change maxcpus when vm is running" });
+	    }
+	}
+
+	foreach my $opt (@delete) { # delete
+	   if ($running && $opt eq 'maxcpus' && defined($conf->{maxcpus})){
+		raise_param_exc({ maxcpus => "you can't change maxcpus when vm is running" });
+	   }
+	}
+
 	PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: " . join (' ', @paramarr));
 
 	my $worker = sub {
-- 
1.7.10.4




More information about the pve-devel mailing list