Ala Hino has uploaded a new change for review. Change subject: Core: Prevent VM migration when SCSI reservation is used ......................................................................
Core: Prevent VM migration when SCSI reservation is used Added an option to enable admin mark whether SCSI reservation is used when creating Direct Lun. When migrating a VM, if SCSI reservation is marked, operation fails. Change-Id: Ia38c03dae04c9dbb30c882941391b1909f5af416 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1159420 Signed-off-by: Ala Hino <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/LunDisk.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericDaoDbFacade.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskDaoDbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/DiskMapper.java M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.ui.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java M packaging/dbscripts/create_views.sql A packaging/dbscripts/upgrade/03_06_0840_add_uses_scsi_reservation.sql M packaging/dbscripts/vm_device_sp.sql 23 files changed, 203 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/37664/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java index 3a0d31e..eb88777 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java @@ -170,6 +170,12 @@ return false; } + // verify that scsi reservation is enabled only when scsi passthrough is enabled + LunDisk lunDisk = ((LunDisk) getParameters().getDiskInfo()); + if (lunDisk.isScsiReservationUsed() && !lunDisk.isScsiPassthrough()) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_ILLEGAL_SCSI_RESERVATION_USE); + } + return true; } @@ -367,11 +373,11 @@ if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) { createDiskBasedOnImage(); } else { - createDiskBasedOnLun(); + createDiskBasedOnLun(((LunDisk) getParameters().getDiskInfo()).isScsiReservationUsed()); } } - private void createDiskBasedOnLun() { + private void createDiskBasedOnLun(final boolean isScsiReservationUsed) { final LUNs lun = ((LunDisk) getParameters().getDiskInfo()).getLun(); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override @@ -386,7 +392,8 @@ null, shouldDiskBePlugged(), Boolean.TRUE.equals(getParameters().getDiskInfo().getReadOnly()), - null); + null, + isScsiReservationUsed); } return null; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 8ca127b..8f72a16 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -27,6 +27,7 @@ import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmPauseStatus; import org.ovirt.engine.core.common.businessentities.network.InterfaceStatus; import org.ovirt.engine.core.common.businessentities.network.Network; @@ -40,6 +41,7 @@ import org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.utils.NetworkUtils; @NonTransactiveCommandAttribute @@ -372,6 +374,10 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_PINNED_TO_HOST); } + if (vmUsesScsiReservation()) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_USES_SCSI_RESERVATION); + } + if (vm.getMigrationSupport() == MigrationSupport.IMPLICITLY_NON_MIGRATABLE && !getParameters().isForceMigrationForNonMigratableVm()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NON_MIGRTABLE_AND_IS_NOT_FORCED_BY_USER_TO_MIGRATE); @@ -520,4 +526,17 @@ public void onPowerringUp() { // nothing to do } + + private boolean vmUsesScsiReservation() { + List<VmDevice> vmManagedDevices = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmId(getVmId()); + if (vmManagedDevices != null && !vmManagedDevices.isEmpty()) { + for (VmDevice device : vmManagedDevices) { + if (device.isScsiReservationUsed()) { + return true; + } + } + } + + return false; + } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java index 96ee6eb..ed44fcb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java @@ -34,6 +34,7 @@ import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.ImageStatus; +import org.ovirt.engine.core.common.businessentities.LunDisk; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType; import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; @@ -122,7 +123,7 @@ @Override protected void executeVmCommand() { - ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm()); + ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm()); if (resizeDiskImageRequested()) { extendDiskImageSize(); @@ -383,6 +384,8 @@ getImageDao().update(diskImage.getImage()); updateQuota(diskImage); updateDiskProfile(); + } else { + updateLunProperties(); } reloadDisks(); @@ -402,6 +405,11 @@ getVmDeviceDao().clearDeviceAddress(getOldDisk().getId()); } } + + private void updateLunProperties() { + vmDeviceForVm.setScsiReservationUsed(((LunDisk)getNewDisk()).isScsiReservationUsed()); + getVmDeviceDao().update(vmDeviceForVm); + } }); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java index 018821e..d28afcb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java @@ -607,14 +607,44 @@ customProp, null, null); - dao.save(managedDevice); - // If we add Disk/Interface/CD/Floppy, we have to recalculate boot order - if (type == VmDeviceGeneralType.DISK || type == VmDeviceGeneralType.INTERFACE) { - // recalculate boot sequence - VmBase vmBase = DbFacade.getInstance().getVmStaticDao().get(id.getVmId()); - updateBootOrderInVmDeviceAndStoreToDB(vmBase); - } - return managedDevice; + + return addManagedDevice(id, type, device, specParams, is_plugged, isReadOnly, customProp, false); + } + + /** + * adds managed device to vm_device + * + * @param id + * @param type + * @param device + * @param customProp device custom properties + * @return New created VmDevice instance + */ + public static VmDevice addManagedDevice(VmDeviceId id, + VmDeviceGeneralType type, + VmDeviceType device, + Map<String, Object> specParams, + boolean is_plugged, + Boolean isReadOnly, + Map<String, String> customProp, + boolean isScsiReservationUsed) { + VmDevice managedDevice = + new VmDevice(id, + type, + device.getName(), + "", + 0, + specParams, + true, + is_plugged, + isReadOnly, + "", + customProp, + null, + null, + isScsiReservationUsed); + + return addManagedDeviceImpl(managedDevice); } /** @@ -1211,4 +1241,16 @@ return result; } + + private static VmDevice addManagedDeviceImpl(VmDevice managedDevice) { + dao.save(managedDevice); + VmDeviceGeneralType type = managedDevice.getType(); + // If we add Disk/Interface/CD/Floppy, we have to recalculate boot order + if (type == VmDeviceGeneralType.DISK || type == VmDeviceGeneralType.INTERFACE) { + // recalculate boot sequence + VmBase vmBase = DbFacade.getInstance().getVmStaticDao().get(managedDevice.getId().getVmId()); + updateBootOrderInVmDeviceAndStoreToDB(vmBase); + } + return managedDevice; + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/LunDisk.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/LunDisk.java index 302463a..e7ccb2f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/LunDisk.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/LunDisk.java @@ -14,6 +14,8 @@ */ private LUNs lun; + private boolean isScsiReservationUsed; + @Override public DiskStorageType getDiskStorageType() { return DiskStorageType.LUN; @@ -37,6 +39,14 @@ return false; } + public boolean isScsiReservationUsed() { + return isScsiReservationUsed; + } + + public void setScsiReservationUsed(boolean isScsiReservationUsed) { + this.isScsiReservationUsed = isScsiReservationUsed; + } + @Override public int hashCode() { final int prime = 31; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java index 8ac4514..7677c46 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java @@ -81,6 +81,8 @@ */ private String logicalName; + private boolean isScsiReservationUsed; + /** * Map of custom properties */ @@ -114,6 +116,21 @@ this.customProperties = customProperties; this.snapshotId = snapshotId; this.logicalName = logicalName; + } + + public VmDevice(VmDeviceId id, VmDeviceGeneralType type, String device, String address, + int bootOrder, + Map<String, Object> specParams, + boolean isManaged, + Boolean isPlugged, + Boolean isReadOnly, + String alias, + Map<String, String> customProperties, + Guid snapshotId, + String logicalName, + boolean isScsiReservationUsed) { + this(id, type, device, address, bootOrder, specParams, isManaged, isPlugged, isReadOnly, alias, customProperties, snapshotId, logicalName); + this.setScsiReservationUsed(isScsiReservationUsed); } @Override @@ -329,4 +346,12 @@ public int compareTo(VmDevice other) { return BusinessEntityComparator.<VmDevice, VmDeviceId>newInstance().compare(this, other); } + + public boolean isScsiReservationUsed() { + return isScsiReservationUsed; + } + + public void setScsiReservationUsed(boolean isScsiReservationUsed) { + this.isScsiReservationUsed = isScsiReservationUsed; + } } 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 7e9a979..7b55b9e 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 @@ -728,6 +728,8 @@ USER_FAILED_TO_AUTHENTICATION_WRONG_AUTHENTICATION_METHOD(ErrorType.NO_AUTHENTICATION), ACTION_TYPE_FAILED_VM_IS_PINNED_TO_HOST(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_VM_USES_SCSI_RESERVATION(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_ILLEGAL_SCSI_RESERVATION_USE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_VM_IS_NON_MIGRTABLE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_VM_IS_NON_MIGRTABLE_AND_IS_NOT_FORCED_BY_USER_TO_MIGRATE(ErrorType.CONFLICT), VDS_CANNOT_MAINTENANCE_IT_INCLUDES_NON_MIGRATABLE_VM(ErrorType.CONFLICT), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericDaoDbFacade.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericDaoDbFacade.java index 99e388a..517192b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericDaoDbFacade.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericDaoDbFacade.java @@ -95,6 +95,7 @@ @Override public void update(T entity) { + update(entity, getProcedureNameForUpdate()); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskDaoDbFacadeImpl.java index 74567a1..2c1760a 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DiskDaoDbFacadeImpl.java @@ -142,6 +142,9 @@ disk.setPlugged(rs.getBoolean("is_plugged")); disk.setReadOnly(rs.getBoolean("is_readonly")); disk.setLogicalName(rs.getString("logical_name")); + if (disk.getDiskStorageType() == DiskStorageType.LUN) { + ((LunDisk) disk).setScsiReservationUsed(rs.getBoolean("is_scsi_reservation_used")); + } return disk; } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java index 31c09d7..11e5e34 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java @@ -49,7 +49,8 @@ .addValue("custom_properties", SerializationFactory.getSerializer().serialize(entity.getCustomProperties())) .addValue("snapshot_id", entity.getSnapshotId()) - .addValue("logical_name", entity.getLogicalName()); + .addValue("logical_name", entity.getLogicalName()) + .addValue("is_scsi_reservation_used", entity.isScsiReservationUsed()); } @Override @@ -162,6 +163,7 @@ .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); vmDevice.setSnapshotId(getGuid(rs, "snapshot_id")); vmDevice.setLogicalName(rs.getString("logical_name")); + vmDevice.setScsiReservationUsed(rs.getBoolean("is_scsi_reservation_used")); return vmDevice; } } diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index cca2c37..043e9a1 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -3666,6 +3666,7 @@ <xs:element ref="quota" minOccurs="0" maxOccurs="1"/> <xs:element name="lun_storage" type="Storage" minOccurs="0"/> <xs:element name="sgio" type="xs:string" minOccurs="0"/> + <xs:element name="uses_scsi_reservation" type="xs:boolean" minOccurs="0"/> <xs:element ref="snapshot" minOccurs="0" maxOccurs="1"/> <xs:element ref="disk_profile" minOccurs="0" maxOccurs="1"/> <xs:element name="logical_name" type="xs:string" minOccurs="0" maxOccurs="1"/> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index e057ee2..2b5f14d 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -708,6 +708,7 @@ disk.quota.id: xs:string disk.disk_profile.id: xs:string disk.sgio: xs:string + disk.uses_scsi_reservation: xs:boolean disk.read_only: xs:boolean description: update the size, boot flag and other parameters of the disk attached to the virtual machine urlparams: {} @@ -746,6 +747,7 @@ disk.wipe_after_delete: xs:boolean disk.quota.id: xs:string disk.sgio: xs:string + disk.uses_scsi_reservation: xs:boolean disk.lun_storage.host: xs:string description: add a new direct lun disk to the virtual machine, this operation does not require size but needs lun connection details - mandatoryArguments: {disk.id: 'xs:string'} diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/DiskMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/DiskMapper.java index ad359fd..fc23353 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/DiskMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/DiskMapper.java @@ -86,6 +86,7 @@ ScsiGenericIO scsiGenericIO = ScsiGenericIO.fromValue(disk.getSgio()); if (scsiGenericIO != null) { engineDisk.setSgio(map(scsiGenericIO, null)); + ((LunDisk)engineDisk).setScsiReservationUsed(disk.isSetUsesScsiReservation()); } } } else { @@ -171,6 +172,7 @@ model.setLunStorage(StorageLogicalUnitMapper.map(((LunDisk) entity).getLun(), new Storage())); if (entity.getSgio() != null && entity.getDiskInterface() == map(DiskInterface.VIRTIO_SCSI, null)) { model.setSgio(map(entity.getSgio(), null)); + model.setUsesScsiReservation(((LunDisk)entity).isScsiReservationUsed()); } } return model; diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index df810da..68a25d4 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -514,6 +514,12 @@ @DefaultStringValue("Cannot ${action} ${type}. VM is pinned to Host.") String ACTION_TYPE_FAILED_VM_IS_PINNED_TO_HOST(); + @DefaultStringValue("Cannot ${action} ${type}. VM uses Scsi reservation.") + String ACTION_TYPE_FAILED_VM_USES_SCSI_RESERVATION(); + + @DefaultStringValue("Cannot ${action} ${type}. Scsi reservation can be set only when SCSI passthrough is set.") + String ACTION_TYPE_FAILED_ILLEGAL_SCSI_RESERVATION_USE(); + @DefaultStringValue("Note: The VM is pinned to Host '${VdsName}' but cannot run on it.") String VM_PINNED_TO_HOST_CANNOT_RUN_ON_THE_DEFAULT_VDS(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index 8896ffa..ea8ce32 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -1169,6 +1169,9 @@ @DefaultStringValue("Read Only") String isReadOnlyVmDiskPopup(); + @DefaultStringValue("SCSI Reservation Used") + String isScsiReservationUsedEditor(); + @DefaultStringValue("Enable SCSI Pass-Through") String isScsiPassthroughEditor(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.java index 0090a91..eb2567b 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.java @@ -151,6 +151,11 @@ EntityModelCheckBoxEditor isReadOnlyEditor; @UiField(provided = true) + @Path("isScsiReservationUsed.entity") + @WithElementId("isScsiReservationUsed") + EntityModelCheckBoxEditor isScsiReservationUsedEditor; + + @UiField(provided = true) @Path("isScsiPassthrough.entity") @WithElementId("isScsiPassthrough") EntityModelCheckBoxEditor isScsiPassthroughEditor; @@ -227,6 +232,7 @@ isBootableEditor.setLabel(constants.isBootableVmDiskPopup()); isShareableEditor.setLabel(constants.isShareableVmDiskPopup()); isReadOnlyEditor.setLabel(constants.isReadOnlyVmDiskPopup()); + isScsiReservationUsedEditor.setLabel(constants.isScsiReservationUsedEditor()); isScsiPassthroughEditor.setLabel(constants.isScsiPassthroughEditor()); isSgIoUnfilteredEditor.setLabel(constants.isSgIoUnfilteredEditor()); } @@ -275,6 +281,7 @@ isBootableEditor = new EntityModelCheckBoxEditor(Align.RIGHT); isShareableEditor = new EntityModelCheckBoxEditor(Align.RIGHT); isReadOnlyEditor = new EntityModelCheckBoxEditor(Align.RIGHT); + isScsiReservationUsedEditor = new EntityModelCheckBoxEditor(Align.RIGHT); isScsiPassthroughEditor = new EntityModelCheckBoxEditor(Align.RIGHT); isSgIoUnfilteredEditor = new EntityModelCheckBoxEditor(Align.RIGHT); @@ -452,6 +459,7 @@ isReadOnlyEditor.setTabIndex(nextTabIndex++); isScsiPassthroughEditor.setTabIndex(nextTabIndex++); isSgIoUnfilteredEditor.setTabIndex(nextTabIndex++); + isScsiReservationUsedEditor.setTabIndex(nextTabIndex++); return nextTabIndex; } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.ui.xml index 782ab67..8c56b93 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDiskPopupWidget.ui.xml @@ -88,6 +88,7 @@ <ge:EntityModelCheckBoxEditor ui:field="isReadOnlyEditor" addStyleNames="{style.checkBoxEditor}"/> <ge:EntityModelCheckBoxEditor ui:field="isScsiPassthroughEditor" addStyleNames="{style.checkBoxEditor}"/> <ge:EntityModelCheckBoxEditor ui:field="isSgIoUnfilteredEditor" addStyleNames="{style.checkBoxEditor} {style.checkBoxSecondary}"/> + <ge:EntityModelCheckBoxEditor ui:field="isScsiReservationUsedEditor" addStyleNames="{style.checkBoxEditor} {style.checkBoxSecondary}"/> </g:VerticalPanel> </g:HorizontalPanel> <g:Label ui:field="message" addStyleNames="{style.errorMessageLabel}" /> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java index 4dce09c..2ef6bdd 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java @@ -64,6 +64,7 @@ private EntityModel<Boolean> isPlugged; private EntityModel<Boolean> isReadOnly; private EntityModel<Boolean> isDirectLunDiskAvaialable; + private EntityModel<Boolean> isScsiReservationUsed; private EntityModel<Boolean> isScsiPassthrough; private EntityModel<Boolean> isSgIoUnfiltered; private EntityModel<String> sizeExtend; @@ -126,6 +127,14 @@ public void setIsDirectLunDiskAvaialable(EntityModel<Boolean> isDirectLunDiskAvaialable) { this.isDirectLunDiskAvaialable = isDirectLunDiskAvaialable; + } + + public EntityModel<Boolean> getIsScsiReservationUsed() { + return isScsiReservationUsed; + } + + public void setIsScsiReservationUsed(EntityModel<Boolean> isScsiReservationUsed) { + this.isScsiReservationUsed = isScsiReservationUsed; } public EntityModel<Boolean> getIsScsiPassthrough() { @@ -246,6 +255,10 @@ setIsReadOnly(new EntityModel<Boolean>()); getIsReadOnly().setEntity(false); getIsReadOnly().getEntityChangedEvent().addListener(this); + + setIsScsiReservationUsed(new EntityModel<Boolean>()); + getIsScsiReservationUsed().setEntity(false); + setIsScsiPassthrough(new EntityModel<Boolean>()); getIsScsiPassthrough().setIsAvailable(false); @@ -651,8 +664,10 @@ DiskInterface diskInterface = getDiskInterface().getSelectedItem(); getIsSgIoUnfiltered().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface)); getIsScsiPassthrough().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface)); + getIsScsiReservationUsed().setIsAvailable(isLunDisk && DiskInterface.VirtIO_SCSI.equals(diskInterface)); updateScsiPassthroguhChangeability(); + changeScsiReservationChangeability(); updateReadOnlyChangeability(); updatePlugChangeability(); } @@ -672,6 +687,16 @@ return; } getIsSgIoUnfiltered().setIsChangable(isEditEnabled()); + } + + protected void changeScsiReservationChangeability() { + boolean isScsiPassThroughEnabled = getIsScsiPassthrough().getEntity(); + if (isScsiPassThroughEnabled) { + getIsScsiReservationUsed().setIsChangable(true); + } else { + getIsScsiReservationUsed().setEntity(false); + getIsScsiReservationUsed().setIsChangable(false); + } } protected void updateReadOnlyChangeability() { @@ -855,10 +880,14 @@ else { LunDisk lunDisk = getLunDisk(); DiskInterface diskInterface = getDiskInterface().getSelectedItem(); - if (DiskInterface.VirtIO_SCSI.equals(diskInterface)) { - lunDisk.setSgio(!getIsScsiPassthrough().getEntity() ? null : - getIsSgIoUnfiltered().getEntity() ? + if (DiskInterface.VirtIO_SCSI.equals(diskInterface) && getIsScsiPassthrough().getEntity()) { + lunDisk.setSgio(getIsSgIoUnfiltered().getEntity() ? ScsiGenericIO.UNFILTERED : ScsiGenericIO.FILTERED); + lunDisk.setScsiReservationUsed(getIsScsiReservationUsed().getEntity()); + } else { + getIsScsiPassthrough().setEntity(false); + lunDisk.setSgio(null); + lunDisk.setScsiReservationUsed(false); } setDisk(lunDisk); } @@ -903,8 +932,10 @@ if (sender == getIsReadOnly()) { updateScsiPassthroguhChangeability(); } else if (sender == getIsScsiPassthrough()) { + updateScsiPassthroguhChangeability(); updateSgIoUnfilteredChangeability(); updateReadOnlyChangeability(); + changeScsiReservationChangeability(); } else if (sender == getDiskStorageType()) { diskStorageType_EntityChanged(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java index 1f16761..eacbbf2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java @@ -68,6 +68,7 @@ getDiskStorageType().setEntity(DiskStorageType.LUN); getSize().setEntity(lunDisk.getLun().getDeviceSize()); getSizeExtend().setIsAvailable(false); + getIsScsiReservationUsed().setEntity(lunDisk.isScsiReservationUsed()); } updateReadOnlyChangeability(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java index 04b2b74..86a8bdb 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java @@ -153,6 +153,7 @@ } else { LunDisk lunDisk = (LunDisk) getDisk(); + lunDisk.setScsiReservationUsed(getIsScsiReservationUsed().getEntity()); LUNs luns = (LUNs) getSanStorageModel().getAddedLuns().get(0).getEntity(); luns.setLunType(getStorageType().getSelectedItem()); lunDisk.setLun(luns); diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index 3311f6d..86f00b7 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -315,7 +315,7 @@ CREATE OR REPLACE VIEW all_disks_for_vms AS -SELECT all_disks_including_snapshots.*, vm_device.is_plugged, vm_device.is_readonly, vm_device.logical_name, vm_device.vm_id +SELECT all_disks_including_snapshots.*, vm_device.is_plugged, vm_device.is_readonly, vm_device.logical_name, vm_device.vm_id, vm_device.is_scsi_reservation_used FROM all_disks_including_snapshots JOIN vm_device ON vm_device.device_id = all_disks_including_snapshots.image_group_id WHERE ((vm_device.snapshot_id IS NULL AND all_disks_including_snapshots.active IS NOT FALSE) @@ -1671,7 +1671,7 @@ CREATE OR REPLACE VIEW vm_device_view AS SELECT device_id, vm_id, type, device, address, boot_order, spec_params, - is_managed, is_plugged, is_readonly, alias, custom_properties, snapshot_id, logical_name + is_managed, is_plugged, is_readonly, alias, custom_properties, snapshot_id, logical_name, is_scsi_reservation_used FROM vm_device; -- Permissions on VNIC Profiles diff --git a/packaging/dbscripts/upgrade/03_06_0840_add_uses_scsi_reservation.sql b/packaging/dbscripts/upgrade/03_06_0840_add_uses_scsi_reservation.sql new file mode 100644 index 0000000..883c433 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_0840_add_uses_scsi_reservation.sql @@ -0,0 +1 @@ +select fn_db_add_column('vm_device', 'is_scsi_reservation_used', 'BOOLEAN DEFAULT NULL'); diff --git a/packaging/dbscripts/vm_device_sp.sql b/packaging/dbscripts/vm_device_sp.sql index 19212f9..f378616 100644 --- a/packaging/dbscripts/vm_device_sp.sql +++ b/packaging/dbscripts/vm_device_sp.sql @@ -15,7 +15,8 @@ v_alias varchar(255), v_custom_properties text, v_snapshot_id uuid, - v_logical_name varchar(255)) + v_logical_name varchar(255), + v_is_scsi_reservation_used boolean) RETURNS VOID AS $procedure$ BEGIN @@ -33,7 +34,8 @@ alias, custom_properties, snapshot_id, - logical_name) + logical_name, + is_scsi_reservation_used) VALUES( v_device_id , v_vm_id , @@ -48,7 +50,8 @@ v_alias, v_custom_properties, v_snapshot_id, - v_logical_name); + v_logical_name, + v_is_scsi_reservation_used); END; $procedure$ LANGUAGE plpgsql; @@ -66,7 +69,8 @@ v_alias varchar(255), v_custom_properties text, v_snapshot_id uuid, - v_logical_name varchar(255)) + v_logical_name varchar(255), + v_is_scsi_reservation_used boolean) RETURNS VOID AS $procedure$ BEGIN @@ -84,6 +88,7 @@ custom_properties = v_custom_properties, snapshot_id = v_snapshot_id, logical_name = v_logical_name, + is_scsi_reservation_used = v_is_scsi_reservation_used, _update_date = current_timestamp WHERE device_id = v_device_id and vm_id = v_vm_id; END; $procedure$ -- To view, visit http://gerrit.ovirt.org/37664 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia38c03dae04c9dbb30c882941391b1909f5af416 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ala Hino <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
