Martin Betak has uploaded a new change for review. Change subject: scheduling: Add HostDevice Policy Unit ......................................................................
scheduling: Add HostDevice Policy Unit Added policy unit to filter hosts based on the new 'hostdevPassthrough' flag in cases when the VM needs host devices. Change-Id: I3e048fe3a9fc47ddbff0a8eb9e7a195b20465205 Signed-off-by: Martin Betak <mbe...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Backend.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HostDevicePolicyUnit.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties A packaging/dbscripts/upgrade/03_06_1500_add_host_device_policy_unit.sql 6 files changed, 67 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/77/42077/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Backend.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Backend.java index 3441dc9..4a2de69 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Backend.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/Backend.java @@ -29,6 +29,7 @@ import org.ovirt.engine.core.bll.attestationbroker.AttestThread; import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.bll.context.EngineContext; +import org.ovirt.engine.core.bll.hostdev.HostDeviceManager; import org.ovirt.engine.core.bll.interceptors.CorrelationIdTrackerInterceptor; import org.ovirt.engine.core.bll.interfaces.BackendCommandObjectsHandler; import org.ovirt.engine.core.bll.interfaces.BackendInternal; @@ -112,6 +113,9 @@ private Instance<SchedulerUtil> taskSchedulers; @Inject @Any private Instance<BackendService> services; + + @Inject + HostDeviceManager hostDeviceManager; public static BackendInternal getInstance() { return Injector.get(BackendInternal.class); @@ -207,6 +211,9 @@ //TODO temporal solution DbFacade in Utils SimpleDependecyInjector.getInstance().bind(dbFacade); + // TODO: temporary solution until PolicyUnits can inject HostDeviceManager + SimpleDependecyInjector.getInstance().bind(hostDeviceManager); + // When getting a proxy to this bean using JBoss embedded, the initialize method is called for each method // invocation on the proxy, as it is called by setup method which is @PostConstruct - the initialized flag // makes sure that initialization occurs only once per class (which is ok, as this is a @Service) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java index 6850204..eb64d97 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java @@ -15,6 +15,7 @@ import org.ovirt.engine.core.bll.scheduling.policyunits.EvenGuestDistributionWeightPolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.HaReservationBalancePolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.HaReservationWeightPolicyUnit; +import org.ovirt.engine.core.bll.scheduling.policyunits.HostDevicePolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.HostedEngineHAClusterFilterPolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.HostedEngineHAClusterWeightPolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.MemoryPolicyUnit; @@ -115,6 +116,8 @@ } case "Emulated-Machine": return new EmulatedMachineFilterPolicyUnit(policyUnit, pendingResourceManager); + case "HostDevice": + return new HostDevicePolicyUnit(policyUnit, pendingResourceManager); default: break; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HostDevicePolicyUnit.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HostDevicePolicyUnit.java new file mode 100644 index 0000000..bb66095 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HostDevicePolicyUnit.java @@ -0,0 +1,53 @@ +package org.ovirt.engine.core.bll.scheduling.policyunits; + +import org.ovirt.engine.core.bll.hostdev.HostDeviceManager; +import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl; +import org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VM; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.scheduling.PerHostMessages; +import org.ovirt.engine.core.common.scheduling.PolicyUnit; +import org.ovirt.engine.core.common.utils.SimpleDependecyInjector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Filters hosts based on the passthroughSupported flag when the VM requires hostdev passthrough + */ +public class HostDevicePolicyUnit extends PolicyUnitImpl { + + private static final Logger log = LoggerFactory.getLogger(HostDevicePolicyUnit.class); + + private HostDeviceManager hostDeviceManager; + + public HostDevicePolicyUnit(PolicyUnit policyUnit, PendingResourceManager pendingResourceManager) { + super(policyUnit, pendingResourceManager); + hostDeviceManager = SimpleDependecyInjector.getInstance().get(HostDeviceManager.class); + } + + @Override + public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) { + + // noop if VM does not require host devices + if (!hostDeviceManager.checkVmNeedsDirectPassthrough(vm)) { + return hosts; + } + + List<VDS> list = new ArrayList<>(); + for (VDS host : hosts) { + if (host.isHostDevicePassthroughEnabled()) { + list.add(host); + } else { + messages.addMessage(host.getId(), VdcBllMessages.VAR__DETAIL__HOSTDEV_DISABLED.toString()); + log.debug("Host '{}' does not support host device passthrough", host.getName()); + } + } + + return list; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 84720ad..b543262 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -1160,6 +1160,7 @@ VAR__DETAIL__NUMA_PINNING_FAILED, VAR__DETAIL__NOT_HE_HOST, VAR__DETAIL__SAME_HOST, + VAR__DETAIL__HOSTDEV_DISABLED, SCHEDULING_NO_HOSTS, SCHEDULING_HOST_FILTERED_REASON, SCHEDULING_HOST_FILTERED_REASON_WITH_DETAIL, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 6a1ffdc..e88d186 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1357,6 +1357,7 @@ VAR__DETAIL__NUMA_PINNING_FAILED=$detailMessage it has insufficient NUMA node free memory to run the VM VAR__DETAIL__NOT_HE_HOST=$detailMessage it is not a Hosted Engine host. VAR__DETAIL__SAME_HOST=$detailMessage it currently hosts the VM. +VAR__DETAIL__HOSTDEV_DISABLED=$detailMessage it does not support host device passthrough. SCHEDULING_NO_HOSTS=There are no hosts to use. Check that the cluster contains at least one host in Up state. VAR__FILTERTYPE__EXTERNAL=$filterType external VAR__FILTERTYPE__INTERNAL=$filterType internal diff --git a/packaging/dbscripts/upgrade/03_06_1500_add_host_device_policy_unit.sql b/packaging/dbscripts/upgrade/03_06_1500_add_host_device_policy_unit.sql new file mode 100644 index 0000000..1b4651e --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_1500_add_host_device_policy_unit.sql @@ -0,0 +1,2 @@ +INSERT INTO policy_units (id, name, is_internal, type, enabled, custom_properties_regex, description) +VALUES ('728a21f1-f97e-4d32-bc3e-b3cc49756abb', 'HostDevice', true, 0, true, NULL, 'Filters out hosts not supporting VM required host devices'); -- To view, visit https://gerrit.ovirt.org/42077 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e048fe3a9fc47ddbff0a8eb9e7a195b20465205 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Betak <mbe...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches