Search in sources :

Example 16 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class NumaSupportModel method initVNumaNodes.

protected void initVNumaNodes() {
    unassignedNumaNodes = new LinkedHashSet<>();
    assignedNumaNodes = new HashMap<>();
    final Set<Integer> hostIndices = new HashSet<>();
    for (VdsNumaNode numaNode : numaNodeList) {
        hostIndices.add(numaNode.getIndex());
    }
    for (final VM vm : getVmsWithvNumaNodeList()) {
        numaModelsPerVm.put(vm.getId(), new HashMap<Integer, VNodeModel>());
        for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) {
            VNodeModel vNodeModel = new VNodeModel(vm, vmNumaNode);
            numaModelsPerVm.get(vm.getId()).put(vNodeModel.getIndex(), vNodeModel);
            if (vNodeModel.isPinned()) {
                if (!hostIndices.contains(vNodeModel.getHostNodeIndex())) {
                    // host numa node does not exist. Unpin the numa node and update the configuration
                    vNodeModel.unpin();
                    vmsToUpdate.add(vm.getId());
                }
            }
            if (!vNodeModel.isPinned()) {
                // virtual numa node is not assigned to any host numa node
                unassignedNumaNodes.add(vNodeModel);
            } else {
                // virtual numa node is assigned to a host numa node
                assignVNumaToPhysicalNuma(vNodeModel);
            }
        }
    }
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VM(org.ovirt.engine.core.common.businessentities.VM) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 17 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class NumaSupportModel method getUpdateParameters.

/**
 * Return a list of action parameters which contain numa pinning updates for different VMs.
 * Used when accessing the numa support screen from the host list panel.
 * @return List of updated numa configurations
 */
public ArrayList<ActionParametersBase> getUpdateParameters() {
    final ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (Guid vmId : vmsToUpdate) {
        final List<VmNumaNode> numaNodes = new ArrayList<>();
        for (final VNodeModel model : numaModelsPerVm.get(vmId).values()) {
            numaNodes.add(model.toVmNumaNode());
        }
        parameters.add(new VmNumaNodeOperationParameters(vmId, numaNodes));
    }
    return parameters;
}
Also used : VmNumaNodeOperationParameters(org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 18 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class VNodeModel method toVmNumaNode.

/**
 * Convert the model representation of a virtual numa node to a real virtual numa node
 * @return the numa node
 */
public VmNumaNode toVmNumaNode() {
    final VmNumaNode newNode = new VmNumaNode();
    newNode.setIndex(vmNumaNode.getIndex());
    newNode.setId(vmNumaNode.getId());
    newNode.setMemTotal(vmNumaNode.getMemTotal());
    newNode.setCpuIds(vmNumaNode.getCpuIds());
    if (isPinned()) {
        newNode.setVdsNumaNodeList(Arrays.asList(hostNodeIndex));
    }
    return newNode;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 19 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class VmInfoBuilderImpl method buildVmNumaProperties.

/**
 * Numa will use the same compatibilityVersion as cpu pinning since numa may also add cpu pinning configuration and
 * the two features have almost the same libvirt version support
 */
@Override
public void buildVmNumaProperties() {
    List<VdsNumaNode> totalVdsNumaNodes = vmInfoBuildUtils.getVdsNumaNodes(vdsId);
    if (totalVdsNumaNodes.isEmpty()) {
        log.warn("No NUMA nodes found for host {} for vm {} {}", vdsId, vm.getName(), vm.getId());
        return;
    }
    List<VmNumaNode> vmNumaNodes = vmInfoBuildUtils.getVmNumaNodes(vm);
    if (vmNumaNodes.isEmpty()) {
        return;
    }
    NumaTuneMode numaTune = vm.getNumaTuneMode();
    if (numaTune != null) {
        Map<String, Object> numaTuneSetting = NumaSettingFactory.buildVmNumatuneSetting(numaTune, vmNumaNodes);
        if (!numaTuneSetting.isEmpty()) {
            createInfo.put(VdsProperties.NUMA_TUNE, numaTuneSetting);
        }
    }
    List<Map<String, Object>> createVmNumaNodes = NumaSettingFactory.buildVmNumaNodeSetting(vmNumaNodes);
    if (!createVmNumaNodes.isEmpty()) {
        createInfo.put(VdsProperties.VM_NUMA_NODES, createVmNumaNodes);
    }
    if (StringUtils.isEmpty(vm.getCpuPinning())) {
        Map<String, Object> cpuPinDict = NumaSettingFactory.buildCpuPinningWithNumaSetting(vmNumaNodes, totalVdsNumaNodes);
        if (!cpuPinDict.isEmpty()) {
            createInfo.put(VdsProperties.cpuPinning, cpuPinDict);
        }
    }
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NumaTuneMode(org.ovirt.engine.core.common.businessentities.NumaTuneMode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 20 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class RemoveVmNumaNodesCommand method executeCommand.

@Override
protected void executeCommand() {
    boolean succeeded = false;
    try {
        List<VmNumaNode> vmNumaNodes = getParameters().getVmNumaNodeList();
        List<Guid> guids = new ArrayList<>();
        for (VmNumaNode node : vmNumaNodes) {
            guids.add(node.getId());
        }
        vmNumaNodeDao.massRemoveNumaNodeByNumaNodeId(guids);
        succeeded = true;
    } finally {
        setSucceeded(succeeded);
    }
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

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