[pve-devel] [PATCH 11/12] cpu hotplug : implement pending changes
Alexandre Derumier
aderumier at odiso.com
Thu Oct 30 13:40:32 CET 2014
if cpu hotplug is not possible,
we simply return to keep the changes in pending
[CONF]
cores: 1
maxcpus:16
[CONF]
cores: 2
maxcpus:16
[CONF]
cores: 2
maxcpus:16
[PENDING]
cores: 1
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6f9dcd8..566adbb 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3254,24 +3254,28 @@ sub qemu_netdevdel {
sub qemu_cpu_hotplug {
my ($vmid, $conf, $cores) = @_;
- die "new cores config is not defined" if !$cores;
- die "you can't add more cores than maxcpus"
- if $conf->{maxcpus} && ($cores > $conf->{maxcpus});
+ return if !$cores;
+ return if !$conf->{maxcpus};
return if !check_running($vmid);
+ return if $cores > $conf->{maxcpus};
+
my $currentcores = $conf->{cores} if $conf->{cores};
- die "current cores is not defined" if !$currentcores;
- die "maxcpus is not defined" if !$conf->{maxcpus};
- raise_param_exc({ 'cores' => "online cpu unplug is not yet possible" })
- if($cores < $currentcores);
+ return if !$currentcores;
+
+ return if($cores < $currentcores); # unplug is not yet possible
my $currentrunningcores = vm_mon_cmd($vmid, "query-cpus");
- raise_param_exc({ 'cores' => "cores number if running vm is different than configuration" })
- if scalar (@{$currentrunningcores}) != $currentcores;
+ return if scalar (@{$currentrunningcores}) != $currentcores;
for(my $i = $currentcores; $i < $cores; $i++) {
vm_mon_cmd($vmid, "cpu-add", id => int($i));
}
+
+ $conf->{cores} = $cores;
+ delete $conf->{pending}->{cores};
+ PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
+
}
sub qemu_block_set_io_throttle {
--
1.7.10.4
More information about the pve-devel
mailing list