Skip to content

Commit

Permalink
core: block hot plug CPU with exclusive pinning
Browse files Browse the repository at this point in the history
This patch prevent the user from hotplugging CPU when the VM is set with
exclusive pinning as we don't support it. Currently it will add a new
CPU without any pinning, which breaks the VM configuration.
With this patch, it won't be allowed and the user will be noticed.

Change-Id: Ie8d32b9e85879e6764bab63399c3d5762ba806db
Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Jun 16, 2022
1 parent 82bd88a commit 7668403
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,13 @@ protected boolean validate() {
return failValidation(EngineMessage.USE_HOST_CPU_REQUESTED_ON_UNSUPPORTED_ARCH);
}

if (isHotSetEnabled() && !validateCPUHotplug(getParameters().getVmStaticData())) {
return failValidation(EngineMessage.CPU_HOTPLUG_TOPOLOGY_INVALID);
if (isHotSetEnabled() && getVm().isRunningOrPaused() && getVds() != null) {
if (!validateCPUHotplug(getParameters().getVmStaticData())) {
return failValidation(EngineMessage.CPU_HOTPLUG_TOPOLOGY_INVALID);
}
if (!validateCpuPinningPolicyWithHotplug(getParameters().getVmStaticData())) {
return failValidation(EngineMessage.CPU_HOTPLUG_WITH_EXCLUSIVE_PIN);
}
}

if (!validateMemoryAlignment(getParameters().getVmStaticData())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,20 @@ protected boolean setAndValidateCpuProfile() {
}

protected boolean validateCPUHotplug(VmStatic vmStaticData) {
if (getVm().isRunningOrPaused()) {
// Can't set more CPUs than available on the host where VM is running.
// Potential overcommit (interference with other running VMs) will be resolved by scheduler.
// In alignment with the CPUPolicyUnit, VM's hyperthreading is not considered.
if (getVds() != null && vmStaticData.getNumOfCpus(false) > getVds().getCpuThreads()) {
return false;
}
// Can't set more CPUs than available on the host where VM is running.
// Potential overcommit (interference with other running VMs) will be resolved by scheduler.
// In alignment with the CPUPolicyUnit, VM's hyperthreading is not considered.
if (vmStaticData.getNumOfCpus(false) > getVds().getCpuThreads()) {
return false;
}
return true;
}

protected boolean validateCpuPinningPolicyWithHotplug(VmStatic vmStaticData) {
if (getVm().getCpuPinningPolicy().isExclusive()
&& vmStaticData.getNumOfCpus(false) > getVm().getNumOfCpus(false)) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ public enum EngineMessage {
CPU_TYPE_UNSUPPORTED_FOR_THE_GUEST_OS(ErrorType.BAD_PARAMETERS),
CPU_TYPE_UNKNOWN(ErrorType.BAD_PARAMETERS),
CPU_HOTPLUG_TOPOLOGY_INVALID(ErrorType.BAD_PARAMETERS),
CPU_HOTPLUG_WITH_EXCLUSIVE_PIN(ErrorType.NOT_SUPPORTED),

MEMORY_SIZE_NOT_MULTIPLE_OF_256_ON_PPC(ErrorType.CONSTRAINT_VIOLATION),
ACTION_TYPE_FAILED_NOT_PLUGGED_MEMORY_ON_ARCH_MUST_BE_DIVIDABLE_BY(ErrorType.CONSTRAINT_VIOLATION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3159,6 +3159,8 @@ public interface AppErrors extends ConstantsWithLookup {

String CPU_HOTPLUG_TOPOLOGY_INVALID();

String CPU_HOTPLUG_WITH_EXCLUSIVE_PIN();

String ACTION_TYPE_FAILED_VM_IS_DURING_BACKUP();

String ACTION_TYPE_FAILED_INCREMENTAL_BACKUP_NOT_SUPPORTED_FOR_RAW_DISK();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ SCHEDULE_HOUR_OUT_OF_RANGE=Invalid value for hour. Must be a number between 0 an
CLUSTER_CANNOT_DISABLE_VIRT_WHEN_CLUSTER_CONTAINS_VMS=Cannot disable virt service on the cluster as it contains VMs.
ACTION_TYPE_FAILED_MEMORY_TOO_OLD=Cannot ${action} ${type}. Memory cannot be restored because it is originated from Cluster Compatibility Version that is no longer supported\: ${Cv}.
CPU_HOTPLUG_TOPOLOGY_INVALID=The requested number of vCPUs is not available on the host the VM is running on
CPU_HOTPLUG_WITH_EXCLUSIVE_PIN=Hot-plug CPU is not supported with exclusive CPU pinning policy
ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY=Cannot ${action} ${type}. Storage connection id is not empty.
VMPAYLOAD_FLOPPY_EXCEEDED=Payload Floppy cannot be used when using an additional Floppy
VAR__ENTITIES__CLUSTERS=$entities Clusters
Expand Down

0 comments on commit 7668403

Please sign in to comment.