Search in sources :

Example 1 with VmNumaNode

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;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VM(org.ovirt.engine.core.common.businessentities.VM)

Example 2 with VmNumaNode

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;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 3 with VmNumaNode

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;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 4 with VmNumaNode

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);
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 5 with VmNumaNode

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;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VM(org.ovirt.engine.core.common.businessentities.VM)

Aggregations

VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)34 ArrayList (java.util.ArrayList)17 Guid (org.ovirt.engine.core.compat.Guid)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)5 Test (org.junit.Test)4 VmNumaNodeOperationParameters (org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters)4 Arrays (java.util.Arrays)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 LinkedHashSet (java.util.LinkedHashSet)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1