Skip to content

Commit

Permalink
engine: let backend decide when update numa
Browse files Browse the repository at this point in the history
When updating a VM, it was required to send updateNuma
parameter that determined if the numa node changes will be saved.

The UI had to handle the logic which started to be quite complicated
- the numa nodes changes with memory, cpu, hugepages, numa count,
numa pinning, numa tune mode change.

This patch adds the possibility to leave out that parameter and
in that case the new numa node list is compared to the one
in the database. If they differ, the new numa node list will
be saved.
  • Loading branch information
ljelinkova authored and ahadas committed Jul 5, 2022
1 parent 536a45a commit 2d8e98f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.ovirt.engine.core.common.businessentities.ActionGroup;
import org.ovirt.engine.core.common.businessentities.ArchitectureType;
import org.ovirt.engine.core.common.businessentities.BiosType;
import org.ovirt.engine.core.common.businessentities.CpuPinningPolicy;
import org.ovirt.engine.core.common.businessentities.DisplayType;
import org.ovirt.engine.core.common.businessentities.GraphicsDevice;
import org.ovirt.engine.core.common.businessentities.GraphicsType;
Expand Down Expand Up @@ -957,6 +958,14 @@ private void initNuma() {
getVm().setvNumaNodeList(vNumaNodeList);
}

if (getParameters().getVm().getCpuPinningPolicy() == CpuPinningPolicy.RESIZE_AND_PIN_NUMA) {
getParameters().setUpdateNuma(false);
}

if (getParameters().isUpdateNuma() == null) {
getParameters().setUpdateNuma(!vNumaNodeList.equals(getParameters().getVm().getvNumaNodeList()));
}

// we always need to verify new or existing numa nodes with the updated VM configuration
if (!getParameters().isUpdateNuma()) {
getParameters().getVm().setvNumaNodeList(vNumaNodeList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void setValue(T value) {
private VM vm;
private boolean copyTemplatePermissions;
private boolean applyChangesLater;
private boolean updateNuma;
private Boolean updateNuma;
private String vmLargeIcon;
private Version clusterLevelChangeFromVersion;
private Map<VmExternalDataKind, String> vmExternalData;
Expand Down Expand Up @@ -346,14 +346,15 @@ public void setApplyChangesLater(boolean applyChangesLater) {
}

/**
* Since NUMA configuration can be updated, this flag indicates whether client
* sends NUMA info that needs to be updated.
* This flag indicates whether NUMA info from the client should be saved.
* @return true if the backend should save the NUMA info, false if not, null if
* the clients leaves that decision on the backend
*/
public boolean isUpdateNuma() {
public Boolean isUpdateNuma() {
return updateNuma;
}

public void setUpdateNuma(boolean updateNuma) {
public void setUpdateNuma(Boolean updateNuma) {
this.updateNuma = updateNuma;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,10 +683,7 @@ public ActionParametersBase getParameters(Vm incoming,

VmManagementParametersBase params = new VmManagementParametersBase(updated);

if (incoming.isSetNumaTuneMode()) {
params.setUpdateNuma(true);
}

params.setUpdateNuma(incoming.isSetNumaTuneMode());
params.setApplyChangesLater(isNextRunRequested());
params.setMemoryHotUnplugEnabled(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,6 @@ protected void updateNumaFields() {
if (!getModel().getTotalCPUCores().getEntity().equals(Integer.toString(getVm().getNumOfCpus()))) {
getModel().getTotalCPUCores().setEntity(Integer.toString(getVm().getNumOfCpus()));
}

if (!getModel().getNumaNodeCount().getEntity().equals(initialVmNumaNodes.size())) {
getModel().getNumaNodeCount().setEntity(initialVmNumaNodes.size());
}

if (!getModel().getVmNumaNodes().equals(initialVmNumaNodes)) {
getModel().setVmNumaNodes(initialVmNumaNodes);
}
}
}

Expand All @@ -530,41 +522,4 @@ public void updateMaxMemory() {
super.updateMaxMemory();
}
}

/**
* Returns true if the NUMA should be updated on the backend.
*/
@Override
public boolean shouldUpdateNuma() {

if (getModel().getCpuPinningPolicy().getSelectedItem().getPolicy() == CpuPinningPolicy.RESIZE_AND_PIN_NUMA) {
return false;
}

if (vm.getCpuPinningPolicy() == CpuPinningPolicy.RESIZE_AND_PIN_NUMA && getModel().getCpuPinningPolicy()
.getSelectedItem()
.getPolicy() != CpuPinningPolicy.RESIZE_AND_PIN_NUMA) {
return true;
}

if (!getModel().getNumaNodeCount().getEntity().equals(initialVmNumaNodes.size())) {
return true;
}

if (!getModel().getVmNumaNodes().equals(initialVmNumaNodes)) {
return true;
}

if (getModel().getVmNumaNodes().size() > 0) {
if (!getModel().getMemSize().getEntity().equals(vm.getMemSizeMb())) {
return true;
}

if (!getModel().getTotalCPUCores().getEntity().equals(Integer.toString(vm.getNumOfCpus()))) {
return true;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,8 @@ public VmManagementParametersBase fillVmManagementParameters(VmManagementParamet
params.setTpmEnabled(model.getTpmEnabled().getEntity());
params.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
params.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
params.setUpdateNuma(model.getBehavior().shouldUpdateNuma());
// it will be calculated on the backend
params.setUpdateNuma(null);
params.setAffinityGroups(model.getAffinityGroupList().getSelectedItems());
params.setAffinityLabels(model.getLabelList().getSelectedItems());
if (model.getIsHeadlessModeEnabled().getEntity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1874,8 +1874,4 @@ protected DisplayType getDefaultDisplayType(Set<DisplayType> displayTypes) {
}
return displayTypes.iterator().next();
}

public boolean shouldUpdateNuma() {
return getModel().getNumaNodeCount().getEntity() > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ noteThisActionWillRemoveTemplatePermanentlyFromStorageDomains=Note\: This action
nullOperationInvalidBondMode=Cannot add vm network to bond in bond mode 0, 5 or 6.
nullOperationTooManyNonVlans=Cannot have more than one non-VLAN network on one interface.
nullOperationDuplicateVlanIds=Cannot have networks with duplicate VLAN Id's on one interface.
numaDisabledInfoMessage=NUMA Pinning is currently disabled. To enable NUMA Pinning, make sure you've specified NUMA Node count greater than 0, you're not using Resize and Pin CPU Pinning Policy and you've pined the VM to host(s) that support NUMA topology. Make sure to check that all of your pinned host(s) have the same NUMA topology set up.
numaDisabledInfoMessage=NUMA Pinning is currently disabled. To enable NUMA Pinning, make sure you've specified NUMA Node count greater than 0, you're not using Resize and Pin CPU Pinning Policy and you've pinned the VM to host(s) that support NUMA topology. Make sure to check that all of your pinned host(s) have the same NUMA topology set up.
numaDisabledForDedicatedCpusInfoMessage=NUMA is currently disabled because the VM is running with Dedicated Cpu Policy.
numaInfoMessage=To configure a VM's virtual node span on top of a physical host(s) NUMA nodes, select 'NUMA Pinning' below.\nIn the case that there is more than one pinned host, only the first pinned host in the list will be displayed in 'NUMA Pinning' dialog.\n\nPlease note that when a VM's virtual node(s) are pinned to a physical host's NUMA nodes, the default migration mode changes to 'Allow manual migration only'.
oVirtEngineForServersAndDesktopsAbout=oVirt Engine for Servers and Desktops\:
Expand Down

0 comments on commit 2d8e98f

Please sign in to comment.