Search in sources :

Example 6 with VmNumaNode

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

the class UpdateVmCommand method updateVmNumaNodes.

private void updateVmNumaNodes() {
    if (!getParameters().isUpdateNuma()) {
        return;
    }
    List<VmNumaNode> newList = getParameters().getVmStaticData().getvNumaNodeList();
    VmNumaNodeOperationParameters params = new VmNumaNodeOperationParameters(getParameters().getVm(), new ArrayList<>(newList));
    addLogMessages(backend.runInternalAction(ActionType.SetVmNumaNodes, params));
}
Also used : VmNumaNodeOperationParameters(org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 7 with VmNumaNode

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

the class MemoryPolicyUnit method filter.

@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
    // If Vm in Paused mode - no additional memory allocation needed
    if (vm.getStatus() == VMStatus.Paused) {
        return hosts;
    }
    List<VmNumaNode> vmNumaNodes = vmNumaNodeDao.getAllVmNumaNodeByVmId(vm.getId());
    boolean vmNumaPinned = isVmNumaPinned(vmNumaNodes);
    List<VDS> filteredList = new ArrayList<>();
    for (VDS vds : hosts) {
        // Check physical memory needed to start / receive the VM
        // This is probably not needed for all VMs, but QEMU might attempt full
        // allocation without provoked and fail if there is not enough memory
        int pendingRealMemory = PendingMemory.collectForHost(getPendingResourceManager(), vds.getId());
        if (!slaValidator.hasPhysMemoryToRunVM(vds, vm, pendingRealMemory)) {
            Long hostAvailableMem = vds.getMemFree() + vds.getSwapFree();
            log.debug("Host '{}' has insufficient memory to run the VM. Only {} MB of physical memory + swap are available.", vds.getName(), hostAvailableMem);
            messages.addMessage(vds.getId(), String.format("$availableMem %1$d", hostAvailableMem));
            messages.addMessage(vds.getId(), EngineMessage.VAR__DETAIL__NOT_ENOUGH_MEMORY.toString());
            continue;
        }
        // * there isn't enough memory for pinned vNode in pNode
        if (vm.getNumaTuneMode() == NumaTuneMode.STRICT && vmNumaPinned && (!vds.isNumaSupport() || !canVmNumaPinnedToVds(vm, vmNumaNodes, vds))) {
            log.debug("Host '{}' cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes", vds.getName());
            messages.addMessage(vds.getId(), EngineMessage.VAR__DETAIL__NOT_MEMORY_PINNED_NUMA.toString());
            continue;
        }
        filteredList.add(vds);
    }
    List<VDS> resultList = new ArrayList<>();
    List<VDS> overcommitFailed = new ArrayList<>();
    boolean canDelay = false;
    for (VDS vds : filteredList) {
        // Otherwise, pending memory will not change by waiting.
        if (vds.getPendingVmemSize() > 0) {
            canDelay = true;
        }
        // Check logical memory using overcommit, pending and guaranteed memory rules
        if (slaValidator.hasOvercommitMemoryToRunVM(vds, vm)) {
            resultList.add(vds);
        } else {
            overcommitFailed.add(vds);
        }
    }
    // Wait a while, to see if pending memory was freed on some host
    if (canDelay && resultList.isEmpty()) {
        log.debug("Not enough memory on hosts. Delaying...");
        overcommitFailed.clear();
        runVmDelayer.delay(filteredList.stream().map(VDS::getId).collect(Collectors.toList()));
        for (VDS vds : filteredList) {
            // Refresh pending memory
            int pendingMemory = PendingOvercommitMemory.collectForHost(getPendingResourceManager(), vds.getId());
            vds.setPendingVmemSize(pendingMemory);
            // Check logical memory using overcommit, pending and guaranteed memory rules
            if (slaValidator.hasOvercommitMemoryToRunVM(vds, vm)) {
                resultList.add(vds);
            } else {
                overcommitFailed.add(vds);
            }
        }
    }
    for (VDS vds : overcommitFailed) {
        log.debug("Host '{}' is already too close to the memory overcommitment limit. It can only accept {} MB of additional memory load.", vds.getName(), vds.getMaxSchedulingMemory());
        messages.addMessage(vds.getId(), String.format("$availableMem %1$.0f", vds.getMaxSchedulingMemory()));
        messages.addMessage(vds.getId(), EngineMessage.VAR__DETAIL__NOT_ENOUGH_MEMORY.toString());
    }
    return resultList;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList)

Example 8 with VmNumaNode

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

the class VmNumaNodeDaoImpl method insertNumaNodeMap.

private void insertNumaNodeMap(List<VmNumaNode> numaNodes) {
    List<MapSqlParameterSource> vNodeToPnodeExecutions = new ArrayList<>();
    for (VmNumaNode node : numaNodes) {
        node.getVdsNumaNodeList().stream().map(index -> createVnodeToPnodeParametersMapper(index, node.getId())).forEach(vNodeToPnodeExecutions::add);
    }
    getCallsHandler().executeStoredProcAsBatch("InsertNumaNodeMap", vNodeToPnodeExecutions);
}
Also used : Arrays(java.util.Arrays) CollectionUtils.pairsToMap(org.ovirt.engine.core.utils.CollectionUtils.pairsToMap) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Guid(org.ovirt.engine.core.compat.Guid) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) Pair(org.ovirt.engine.core.common.utils.Pair) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Example 9 with VmNumaNode

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

the class BackendVmNumaNodeResource method getRemoveParameters.

private ActionParametersBase getRemoveParameters() {
    VmNumaNode entity = new VmNumaNode();
    entity.setId(guid);
    VmNumaNodeOperationParameters parameters = new VmNumaNodeOperationParameters(collection.parentId, entity);
    return parameters;
}
Also used : VmNumaNodeOperationParameters(org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 10 with VmNumaNode

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

the class BackendVmNumaNodesResource method mapCollection.

protected VirtualNumaNodes mapCollection(List<VmNumaNode> entities) {
    VirtualNumaNodes collection = instantiate(collectionType);
    List<VirtualNumaNode> list = collection.getVirtualNumaNodes();
    for (VmNumaNode entity : entities) {
        VirtualNumaNode candidate = populate(map(entity), entity);
        candidate = addLinks(candidate);
        list.add(candidate);
    }
    return collection;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) VirtualNumaNode(org.ovirt.engine.api.model.VirtualNumaNode) VirtualNumaNodes(org.ovirt.engine.api.model.VirtualNumaNodes)

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