use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method getVmWithNuma.
protected VM getVmWithNuma() {
VM vm = new VM();
String vmName = getModel().getName().getEntity();
if (vmName == null || vmName.isEmpty()) {
// $NON-NLS-1$
vmName = "new_vm";
}
vm.setName(vmName);
Integer nodeCount = getModel().getNumaNodeCount().getEntity();
vm.setvNumaNodeList(new ArrayList<>());
for (int i = 0; i < nodeCount; i++) {
VmNumaNode vmNumaNode = new VmNumaNode();
vmNumaNode.setIndex(i);
vm.getvNumaNodeList().add(vmNumaNode);
}
return vm;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaTestUtils method createVmNumaNode.
public static VmNumaNode createVmNumaNode(int index, List<VdsNumaNode> vdsNumaNodes) {
VmNumaNode numaNode = createVmNumaNode(index);
final List<Integer> numaPinning = new ArrayList<>();
for (VdsNumaNode vdsNumaNode : vdsNumaNodes) {
numaPinning.add(vdsNumaNode.getIndex());
}
numaNode.setVdsNumaNodeList(numaPinning);
return numaNode;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaTestUtils method createVmNumaNodeWithId.
public static VmNumaNode createVmNumaNodeWithId(int index, List<VdsNumaNode> vdsNumaNodes, Guid guid) {
final VmNumaNode numaNode = createVmNumaNode(index, vdsNumaNodes);
numaNode.setId(guid);
return numaNode;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaUnitToVmBaseBuilder method build.
@Override
protected void build(UnitVmModel model, VmBase vm) {
// Tune Mode:
vm.setNumaTuneMode(model.getNumaTuneMode().getSelectedItem());
// Virtual nodes:
Integer nodeCount = model.getNumaNodeCount().getEntity();
// clear NUMA nodes
if (nodeCount == null || nodeCount == 0) {
vm.setvNumaNodeList(null);
return;
}
List<VmNumaNode> nodeList = model.getVmNumaNodes();
if (nodeList == null || nodeList.size() != nodeCount) {
nodeList = new ArrayList<>(nodeCount);
for (int i = 0; i < nodeCount; i++) {
VmNumaNode newNode = new VmNumaNode();
newNode.setIndex(i);
nodeList.add(newNode);
}
}
long memTotal = model.getMemSize().getEntity();
// Numa node memory size has to be divisible by the hugepage size
long memGranularityKB = getHugePageSize(model).orElse(1024);
long memGranularityMB = MathUtils.leastCommonMultiple(memGranularityKB, 1024) / 1024;
long memBlocks = memTotal / memGranularityMB;
long memBlocksPerNode = memBlocks / nodeCount;
long remainingBlocks = memBlocks % nodeCount;
int coreCount = Integer.parseInt(model.getTotalCPUCores().getEntity());
int coresPerNode = coreCount / nodeCount;
int remainingCores = coreCount % nodeCount;
int nextCpuId = 0;
for (VmNumaNode vmNumaNode : nodeList) {
// Update Memory
long nodeBlocks = memBlocksPerNode + (remainingBlocks > 0 ? 1 : 0);
--remainingBlocks;
vmNumaNode.setMemTotal(nodeBlocks * memGranularityMB);
// Update cpus
int nodeCores = coresPerNode + (remainingCores > 0 ? 1 : 0);
--remainingCores;
List<Integer> coreList = new ArrayList<>(nodeCores);
for (int j = 0; j < nodeCores; j++, nextCpuId++) {
coreList.add(nextCpuId);
}
vmNumaNode.setCpuIds(coreList);
}
vm.setvNumaNodeList(nodeList);
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class ExistingVmModelBehavior method getVmWithNuma.
@Override
protected VM getVmWithNuma() {
VM dummyVm = super.getVmWithNuma();
dummyVm.setId(vm.getId());
List<VmNumaNode> vmNumaNodes = getModel().getVmNumaNodes();
if (vmNumaNodes != null && !vmNumaNodes.isEmpty() && vmNumaNodes.size() == dummyVm.getvNumaNodeList().size()) {
dummyVm.setvNumaNodeList(vmNumaNodes);
}
return dummyVm;
}
Aggregations