[pve-devel] [PATCH 4/4] cpu hotplug : add new cpu hotplug method for qemu 2.7
Signed-off-by: Alexandre Derumier--- PVE/QemuServer.pm | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e3c2550..46d0403 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -3776,7 +3776,7 @@ sub qemu_cpu_hotplug { my $currentvcpus = $conf->{vcpus} || $maxcpus; -if ($vcpus < $currentvcpus) { +if ($vcpus < $currentvcpus) { if (qemu_machine_feature_enabled ($machine_type, undef, 2, 7)) { @@ -3806,8 +3806,30 @@ sub qemu_cpu_hotplug { die "vcpus in running vm is different than configuration\n" if scalar(@{$currentrunningvcpus}) != $currentvcpus; -for (my $i = $currentvcpus; $i < $vcpus; $i++) { - vm_mon_cmd($vmid, "cpu-add", id => int($i)); +if (qemu_machine_feature_enabled ($machine_type, undef, 2, 7)) { + + for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) { + my $cpustr = print_cpu_device($conf, $i); + qemu_deviceadd($vmid, $cpustr); + + my $retry = 0; + my $currentrunningvcpus = undef; + while (1) { + $currentrunningvcpus = vm_mon_cmd($vmid, "query-cpus"); + last if scalar(@{$currentrunningvcpus}) == $i; + raise_param_exc({ "cpu hotplug" => "error hotplug cpu$i" }) if $retry > 10; + sleep 1; + $retry++; + } +#update conf after each succesfull cpu hotplug + $conf->{vcpus} = scalar(@{$currentrunningvcpus}); + PVE::QemuConfig->write_config($vmid, $conf); + } +} else { + + for (my $i = $currentvcpus; $i < $vcpus; $i++) { + vm_mon_cmd($vmid, "cpu-add", id => int($i)); + } } } -- 2.1.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH 4/4] cpu hotplug : add new cpu hotplug method for qemu 2.7
Signed-off-by: Alexandre Derumier--- PVE/QemuServer.pm | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 40e9e52..0c6d604 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -3777,7 +3777,7 @@ sub qemu_cpu_hotplug { my $currentvcpus = $conf->{vcpus} || $maxcpus; -if ($vcpus < $currentvcpus) { +if ($vcpus < $currentvcpus) { if (qemu_machine_feature_enabled ($machine_type, $kvmver, 2, 7)) { @@ -3807,8 +3807,30 @@ sub qemu_cpu_hotplug { die "vcpus in running vm is different than configuration\n" if scalar(@{$currentrunningvcpus}) != $currentvcpus; -for (my $i = $currentvcpus; $i < $vcpus; $i++) { - vm_mon_cmd($vmid, "cpu-add", id => int($i)); +if (qemu_machine_feature_enabled ($machine_type, $kvmver, 2, 7)) { + + for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) { + my $cpustr = print_cpu_device($conf, $i); + qemu_deviceadd($vmid, $cpustr); + + my $retry = 0; + my $currentrunningvcpus = undef; + while (1) { + $currentrunningvcpus = vm_mon_cmd($vmid, "query-cpus"); + last if scalar(@{$currentrunningvcpus}) == $i; + raise_param_exc({ "cpu hotplug" => "error hotplug cpu$i" }) if $retry > 10; + sleep 1; + $retry++; + } +#update conf after each succesfull cpu hotplug + $conf->{vcpus} = scalar(@{$currentrunningvcpus}); + PVE::QemuConfig->write_config($vmid, $conf); + } +} else { + + for (my $i = $currentvcpus; $i < $vcpus; $i++) { + vm_mon_cmd($vmid, "cpu-add", id => int($i)); + } } } -- 2.1.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH 4/4] cpu hotplug : add new cpu hotplug method for qemu 2.7
Signed-off-by: Alexandre Derumier--- PVE/QemuServer.pm | 26 -- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 8e840f5..7220cb2 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -3729,8 +3729,30 @@ sub qemu_cpu_hotplug { die "vcpus in running vm is different than configuration\n" if scalar(@{$currentrunningvcpus}) != $currentvcpus; -for (my $i = $currentvcpus; $i < $vcpus; $i++) { - vm_mon_cmd($vmid, "cpu-add", id => int($i)); +if (qemu_machine_feature_enabled ($machine_type, $kvmver, 2, 7)) { + + for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) { + my $cpustr = print_cpu_device($conf, $i); + qemu_deviceadd($vmid, $cpustr); + + my $retry = 0; + my $currentrunningvcpus = undef; + while (1) { + $currentrunningvcpus = vm_mon_cmd($vmid, "query-cpus"); + last if scalar(@{$currentrunningvcpus}) == $i; + raise_param_exc({ "cpu hotplug" => "error hotplug cpu$i" }) if $retry > 10; + sleep 1; + $retry++; + } +#update conf after each succesfull cpu hotplug + $conf->{vcpus} = scalar(@{$currentrunningvcpus}); + PVE::QemuConfig->write_config($vmid, $conf); + } +} else { + + for (my $i = $currentvcpus; $i < $vcpus; $i++) { + vm_mon_cmd($vmid, "cpu-add", id => int($i)); + } } } -- 2.1.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel