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));
}
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;
}
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);
}
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;
}
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;
}
Aggregations