Martin Betak has uploaded a new change for review. Change subject: backend: Add HostDev passthrough support #2 ......................................................................
backend: Add HostDev passthrough support #2 Add Vm Device for passthrough device -> VmHostDevice and related Add/Remove commands. Change-Id: I93c746cdda71678f7840d37683b890080a74341d Signed-off-by: Martin Betak <mbe...@redhat.com> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmHostDevicesQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AbstractVmHostDeviceCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AddVmHostDeviceCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/RemoveVmHostDeviceCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmHostDevice.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java 9 files changed, 96 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/37619/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmHostDevicesQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmHostDevicesQuery.java new file mode 100644 index 0000000..55a9f03 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmHostDevicesQuery.java @@ -0,0 +1,39 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; +import org.ovirt.engine.core.common.businessentities.VmHostDevice; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.common.utils.VmDeviceType; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +public class GetVmHostDevicesQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> { + + @Inject + DbFacade dbFacade; + + public GetVmHostDevicesQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + List<VmHostDevice> result = new ArrayList<>(); + List<VmDevice> vmHostDevices = dbFacade.getVmDeviceDao().getVmDeviceByVmIdTypeAndDevice( + getParameters().getId(), + VmDeviceGeneralType.HOST_DEVICE, + VmDeviceType.HOST_DEVICE.getName(), + getUserID(), + getParameters().isFiltered()); + + for (VmDevice device : vmHostDevices) { + result.add(new VmHostDevice(device)); + } + + setReturnValue(result); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AbstractVmHostDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AbstractVmHostDeviceCommand.java new file mode 100644 index 0000000..b4b6a4c --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AbstractVmHostDeviceCommand.java @@ -0,0 +1,18 @@ +package org.ovirt.engine.core.bll.hostdev; + +import org.ovirt.engine.core.bll.CommandBase; +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.action.VdcActionParametersBase; + +import java.util.List; + +public class AbstractVmHostDeviceCommand extends CommandBase<VdcActionParametersBase> { + @Override + protected void executeCommand() { + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return null; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AddVmHostDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AddVmHostDeviceCommand.java new file mode 100644 index 0000000..fe82c8a --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/AddVmHostDeviceCommand.java @@ -0,0 +1,4 @@ +package org.ovirt.engine.core.bll.hostdev; + +public class AddVmHostDeviceCommand extends AbstractVmHostDeviceCommand { +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/RemoveVmHostDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/RemoveVmHostDeviceCommand.java new file mode 100644 index 0000000..7b67dd9 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdev/RemoveVmHostDeviceCommand.java @@ -0,0 +1,4 @@ +package org.ovirt.engine.core.bll.hostdev; + +public class RemoveVmHostDeviceCommand extends AbstractVmHostDeviceCommand { +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index c179b56..883173b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -400,6 +400,11 @@ UpdateGraphicsDevice(2251, ActionGroup.EDIT_VM_PROPERTIES, false, QuotaDependency.NONE), RemoveGraphicsDevice(2252, ActionGroup.EDIT_VM_PROPERTIES, false, QuotaDependency.NONE), + // Vm Host Device CRUD + AddVmHostDevice(2350, ActionGroup.EDIT_VM_PROPERTIES, false, QuotaDependency.NONE), + UpdateVmHostDevice(2351, ActionGroup.EDIT_VM_PROPERTIES, false, QuotaDependency.NONE), + RemoveVmHostDevice(2352, ActionGroup.EDIT_VM_PROPERTIES, false, QuotaDependency.NONE), + // Audit Log RemoveAuditLogById(2100, false, QuotaDependency.NONE), ClearAllDismissedAuditLogs(2101, false, QuotaDependency.NONE), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java index d917b63..c4aaa88 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java @@ -72,6 +72,11 @@ WATCHDOG, /** + * A pass-through host device + */ + HOST_DEVICE, + + /** * Unknown device */ UNKNOWN; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmHostDevice.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmHostDevice.java new file mode 100644 index 0000000..9fca132 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmHostDevice.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.core.common.businessentities; + +import org.ovirt.engine.core.common.utils.VmDeviceType; + +public class VmHostDevice extends VmDevice { + + public VmHostDevice() { + setType(VmDeviceGeneralType.HOST_DEVICE); + setDevice(VmDeviceType.HOST_DEVICE.getName()); + setIsManaged(true); + setIsPlugged(true); + } + + public VmHostDevice(VmDevice device) { + this(); + setId(device.getId()); + setSpecParams(device.getSpecParams()); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 3bf9473..a8a42a6 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -378,6 +378,7 @@ GetConsoleDevices(VdcQueryAuthType.User), GetRngDevice(VdcQueryAuthType.User), GetGraphicsDevices(VdcQueryAuthType.User), + GetVmHostDevices(VdcQueryAuthType.User), GetDeviceCustomProperties(VdcQueryAuthType.User), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java index 6a3fb75..c35b5ce 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java @@ -29,6 +29,7 @@ WATCHDOG("watchdog"), VIRTIOSCSI("virtio-scsi"), VIRTIOSERIAL("virtio-serial"), + HOST_DEVICE("host-device"), OTHER("other", "0"), UNKNOWN("unknown", "-1"); -- To view, visit http://gerrit.ovirt.org/37619 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I93c746cdda71678f7840d37683b890080a74341d 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