Daniel Erez has uploaded a new change for review.

Change subject: core: allow read-only for VirtIO-SCSI DirectLUN disks
......................................................................

core: allow read-only for VirtIO-SCSI DirectLUN disks

In order to support read-only property for VirtIO-SCSI
DirectLUN disks, the device type for such disks should
be 'disk' (SCSI emulation) instead of 'lun' (SCSI pass-through).
I.e. representation in the domain xml sent to libvirt should
look like [1] instead of [2].

Note that this limitation (enabling pass-through for read-only
VirtIO-SCSI DirectLUN disks) could be removed once 'Support
read only VirtIO-SCSI direct LUNs in QEMU' bug [3] is resolved.

To provide full flexibility, added a new check-box for enabling
pass-through (see screenshot [4]). I.e. the user can choose between
emulated and pass-through ('disk' vs. 'lun'); read-only is
currently supported only for emulated.

[1] <disk type='block' device='disk'>...</disk>
[2] <disk type='block' device='lun'>...</disk>
[3] https://bugzilla.redhat.com/1110396
[4] screenshot: http://i.imgur.com/5mS3xSk.jpg

Change-Id: Ic317722be9ef8978b50352c12bc06ea8c906dcd0
Bug-Url: https://bugzilla.redhat.com/1118847
Signed-off-by: Daniel Erez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/DiskValidatorTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.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
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/HotPlugDiskVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.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/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
A packaging/dbscripts/upgrade/03_05_0810_update_sgio_for_readonly_disks.sql
17 files changed, 135 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/30885/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java
index 772d6d1..ce10244 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java
@@ -102,11 +102,15 @@
     public ValidationResult isReadOnlyPropertyCompatibleWithInterface() {
         if (Boolean.TRUE.equals(disk.getReadOnly())) {
             DiskInterface diskInterface = disk.getDiskInterface();
-            if (diskInterface == DiskInterface.IDE ||
-                    (diskInterface == DiskInterface.VirtIO_SCSI  && 
disk.getDiskStorageType() == DiskStorageType.LUN )) {
+
+            if (diskInterface == DiskInterface.IDE) {
                 return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR,
                         String.format("$interface %1$s", diskInterface));
             }
+
+            if (disk.isScsiPassthrough()) {
+                return new 
ValidationResult(VdcBllMessages.SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK);
+            }
         }
         return ValidationResult.VALID;
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/DiskValidatorTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/DiskValidatorTest.java
index dee52b2..e9c918a 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/DiskValidatorTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/DiskValidatorTest.java
@@ -23,6 +23,7 @@
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.DiskInterface;
 import org.ovirt.engine.core.common.businessentities.LunDisk;
+import org.ovirt.engine.core.common.businessentities.ScsiGenericIO;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
@@ -165,13 +166,12 @@
                 
both(failsWith(VdcBllMessages.ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR)).
                         and(replacements(hasItem(String.format("$interface 
%1$s", DiskInterface.IDE)))));
 
-
         setupForLun();
         lunDisk.setReadOnly(true);
         lunDisk.setDiskInterface(DiskInterface.VirtIO_SCSI);
+        lunDisk.setSgio(ScsiGenericIO.FILTERED);
         assertThat(lunValidator.isReadOnlyPropertyCompatibleWithInterface(),
-                
both(failsWith(VdcBllMessages.ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR)).
-                        and(replacements(hasItem(String.format("$interface 
%1$s", DiskInterface.VirtIO_SCSI)))));
+                
failsWith(VdcBllMessages.SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK));
     }
 
     @Test
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
index f0363c0..c38e1c2 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java
@@ -171,6 +171,10 @@
         this.sgio = sgio;
     }
 
+    public boolean isScsiPassthrough() {
+        return getSgio() != null;
+    }
+
     public DiskAlignment getAlignment() {
         return alignment;
     }
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 31d4a22..1a4fadd 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
@@ -779,6 +779,7 @@
     DISK_IS_ALREADY_SHARED_BETWEEN_VMS(ErrorType.CONFLICT),
     VM_CANNOT_RUN_FROM_DISK_WITHOUT_PLUGGED_DISK(ErrorType.CONFLICT),
     SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK(ErrorType.NOT_SUPPORTED),
+    
SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK(ErrorType.NOT_SUPPORTED),
     
VIRTIO_SCSI_INTERFACE_IS_NOT_AVAILABLE_FOR_CLUSTER_LEVEL(ErrorType.INCOMPATIBLE_VERSION),
     CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED(ErrorType.CONFLICT),
     CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS(ErrorType.CONFLICT),
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 3fd7f88..39195e9 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -965,6 +965,7 @@
 ERROR_CANNOT_DETACH_DISK_WITH_SNAPSHOT=Cannot ${action} ${type}. The disk is 
already configured in a snapshot. In order to detach it, remove the disk's 
snapshots.
 DISK_IS_ALREADY_SHARED_BETWEEN_VMS=Cannot ${action} ${type}. Disk is shared 
between vms and cannot become unshareable . Detach the disk from the rest of 
the vms it is attached to and then update the disk to be unshareable.
 SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK="Cannot ${action} ${type}. 
SCSI Generic IO is not supported for image disk."
+SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK="Cannot ${action} 
${type}. SCSI device pass-throguh is not supported for a read-only disk."
 VIRTIO_SCSI_INTERFACE_IS_NOT_AVAILABLE_FOR_CLUSTER_LEVEL=Virtio-SCSI interface 
is only available on cluster level 3.3 or higher.
 CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED=Cannot ${action} ${type}. 
VirtIO-SCSI is disabled for the VM
 CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS=Cannot disable VirtIO-SCSI when disks 
with a VirtIO-SCSI interface are plugged into the VM.
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/HotPlugDiskVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/HotPlugDiskVDSCommand.java
index 9f92325..0abdede 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/HotPlugDiskVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/HotPlugDiskVDSCommand.java
@@ -68,7 +68,24 @@
             drive.put(VdsProperties.PropagateErrors, 
disk.getPropagateErrors().toString().toLowerCase());
         } else {
             LunDisk lunDisk = (LunDisk) disk;
-            drive.put(VdsProperties.Device, VmDeviceType.LUN.getName());
+
+            // If SCSI pass-through is enabled (VirtIO-SCSI/DirectLUN disk and 
SGIO is defined),
+            // set device type as 'lun' (instead of 'disk') and set the 
specified SGIO
+            boolean isVirtioScsi = 
getParameters().getDisk().getDiskInterface() == DiskInterface.VirtIO_SCSI;
+            boolean isScsiPassthrough = 
getParameters().getDisk().isScsiPassthrough();
+            if (isVirtioScsi) {
+                if (isScsiPassthrough) {
+                    drive.put(VdsProperties.Device, 
VmDeviceType.LUN.getName());
+                    drive.put(VdsProperties.Sgio, 
getParameters().getDisk().getSgio().toString().toLowerCase());
+                }
+                else {
+                    drive.put(VdsProperties.Device, 
VmDeviceType.DISK.getName());
+                }
+            }
+            else {
+                drive.put(VdsProperties.Device, VmDeviceType.LUN.getName());
+            }
+
             drive.put(VdsProperties.Guid, lunDisk.getLun().getLUN_id());
             drive.put(VdsProperties.Format, 
VolumeFormat.RAW.toString().toLowerCase());
             drive.put(VdsProperties.PropagateErrors, 
PropagateErrors.Off.toString()
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
index e434f17..8908966 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
@@ -286,7 +286,9 @@
                     break;
                 case VirtIO_SCSI:
                     struct.put(VdsProperties.INTERFACE, VdsProperties.Scsi);
-                    if (disk.getDiskStorageType() == DiskStorageType.LUN) {
+                    // If SCSI pass-through is enabled (DirectLUN disk and 
SGIO is defined),
+                    // set device type as 'lun' (instead of 'disk') and set 
the specified SGIO.
+                    if (disk.getDiskStorageType() == DiskStorageType.LUN && 
disk.isScsiPassthrough()) {
                         struct.put(VdsProperties.Device, 
VmDeviceType.LUN.getName());
                         struct.put(VdsProperties.Sgio, 
disk.getSgio().toString().toLowerCase());
                     }
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 af0164d..8176c69 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
@@ -2628,6 +2628,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. SCSI Generic IO is not 
supported for image disk.")
     String SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK();
 
+    @DefaultStringValue("Cannot ${action} ${type}. SCSI device pass-throguh is 
not supported for a read-only disk.")
+    String SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK();
+
     @DefaultStringValue("VirtIO-SCSI interface is only available on cluster 
level 3.3 or higher.")
     String VIRTIO_SCSI_INTERFACE_IS_NOT_AVAILABLE_FOR_CLUSTER_LEVEL();
 
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 56da05e..38fd447 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
@@ -1139,6 +1139,9 @@
     @DefaultStringValue("Read Only")
     String isReadOnlyVmDiskPopup();
 
+    @DefaultStringValue("Enable SCSI Pass-Through")
+    String isScsiPassthroughEditor();
+
     @DefaultStringValue("Allow Privileged SCSI I/O")
     String isSgIoUnfilteredEditor();
 
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 e25c949..078087a 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
@@ -166,6 +166,11 @@
     EntityModelCheckBoxEditor isReadOnlyEditor;
 
     @UiField(provided = true)
+    @Path("isScsiPassthrough.entity")
+    @WithElementId("isScsiPassthrough")
+    EntityModelCheckBoxEditor isScsiPassthroughEditor;
+
+    @UiField(provided = true)
     @Path("isSgIoUnfiltered.entity")
     @WithElementId("isSgIoUnfiltered")
     EntityModelCheckBoxEditor isSgIoUnfilteredEditor;
@@ -276,6 +281,7 @@
         isBootableEditor.setLabel(constants.isBootableVmDiskPopup());
         isShareableEditor.setLabel(constants.isShareableVmDiskPopup());
         isReadOnlyEditor.setLabel(constants.isReadOnlyVmDiskPopup());
+        isScsiPassthroughEditor.setLabel(constants.isScsiPassthroughEditor());
         isSgIoUnfilteredEditor.setLabel(constants.isSgIoUnfilteredEditor());
         attachEditor.setLabel(constants.attachDiskVmDiskPopup());
         isPluggedEditor.setLabel(constants.activateVmDiskPopup());
@@ -318,6 +324,7 @@
         isBootableEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
         isShareableEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
         isReadOnlyEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
+        isScsiPassthroughEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
         isSgIoUnfilteredEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
         isPluggedEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
         attachEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
@@ -804,11 +811,12 @@
         storageTypeEditor.setTabIndex(nextTabIndex++);
         plugDiskToVmEditor.setTabIndex(nextTabIndex++);
         wipeAfterDeleteEditor.setTabIndex(nextTabIndex++);
+        isPluggedEditor.setTabIndex(nextTabIndex++);
         isBootableEditor.setTabIndex(nextTabIndex++);
         isShareableEditor.setTabIndex(nextTabIndex++);
-        isSgIoUnfilteredEditor.setTabIndex(nextTabIndex++);
         isReadOnlyEditor.setTabIndex(nextTabIndex++);
-        isPluggedEditor.setTabIndex(nextTabIndex++);
+        isScsiPassthroughEditor.setTabIndex(nextTabIndex++);
+        isSgIoUnfilteredEditor.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 159da4f..b7003ca 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
@@ -62,6 +62,10 @@
                        padding-left: 75px;
                }
 
+        .checkBoxSecondary {
+            margin-left: 20px;
+        }
+
                .externalDiskPanel {
                        height: 298px;
                        width: 100%;
@@ -119,8 +123,9 @@
                                        <ge:EntityModelCheckBoxEditor 
ui:field="wipeAfterDeleteEditor" addStyleNames="{style.checkBoxEditor}"/>
                                        <ge:EntityModelCheckBoxEditor 
ui:field="isBootableEditor" addStyleNames="{style.checkBoxEditor}" />
                                        <ge:EntityModelCheckBoxEditor 
ui:field="isShareableEditor" addStyleNames="{style.checkBoxEditor}"/>
-                                       <ge:EntityModelCheckBoxEditor 
ui:field="isSgIoUnfilteredEditor" addStyleNames="{style.checkBoxEditor}"/>
                     <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}"/>
                                </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 71086ae..cc6d564 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
@@ -66,6 +66,7 @@
     private EntityModel<Boolean> isAttachDisk;
     private EntityModel<Boolean> isInternal;
     private EntityModel<Boolean> isDirectLunDiskAvaialable;
+    private EntityModel<Boolean> isScsiPassthrough;
     private EntityModel<Boolean> isSgIoUnfiltered;
     private EntityModel<String> sizeExtend;
 
@@ -147,6 +148,14 @@
 
     public void setIsDirectLunDiskAvaialable(EntityModel<Boolean> 
isDirectLunDiskAvaialable) {
         this.isDirectLunDiskAvaialable = isDirectLunDiskAvaialable;
+    }
+
+    public EntityModel<Boolean> getIsScsiPassthrough() {
+        return isScsiPassthrough;
+    }
+
+    public void setIsScsiPassthrough(EntityModel<Boolean> isScsiPassthrough) {
+        this.isScsiPassthrough = isScsiPassthrough;
     }
 
     public EntityModel<Boolean> getIsSgIoUnfiltered() {
@@ -284,9 +293,17 @@
 
         setIsReadOnly(new EntityModel<Boolean>());
         getIsReadOnly().setEntity(false);
+        getIsReadOnly().getEntityChangedEvent().addListener(this);
+
+        setIsScsiPassthrough(new EntityModel<Boolean>());
+        getIsScsiPassthrough().setIsAvailable(false);
+        getIsScsiPassthrough().setEntity(true);
+        getIsScsiPassthrough().getEntityChangedEvent().addListener(this);
 
         setIsSgIoUnfiltered(new EntityModel<Boolean>());
         getIsSgIoUnfiltered().setIsAvailable(false);
+        getIsSgIoUnfiltered().setEntity(false);
+        getIsSgIoUnfiltered().getEntityChangedEvent().addListener(this);
 
         setIsDirectLunDiskAvaialable(new EntityModel<Boolean>());
         getIsDirectLunDiskAvaialable().setEntity(true);
@@ -654,9 +671,28 @@
         boolean isInternal = getIsInternal().getEntity();
         DiskInterface diskInterface = getDiskInterface().getSelectedItem();
         getIsSgIoUnfiltered().setIsAvailable(!isInternal && 
DiskInterface.VirtIO_SCSI.equals(diskInterface));
+        getIsScsiPassthrough().setIsAvailable(!isInternal && 
DiskInterface.VirtIO_SCSI.equals(diskInterface));
 
+        updateScsiPassthroguhChangeability();
         updateReadOnlyChangeability();
         updatePlugChangeability();
+    }
+
+    protected void updateScsiPassthroguhChangeability() {
+        getIsScsiPassthrough().setIsChangable(!getIsReadOnly().getEntity() && 
isEditEnabled());
+        
getIsScsiPassthrough().setChangeProhibitionReason(CONSTANTS.cannotEnableScsiPassthroughForLunReadOnlyDisk());
+
+        updateSgIoUnfilteredChangeability();
+    }
+
+    protected void updateSgIoUnfilteredChangeability() {
+        if (!getIsScsiPassthrough().getEntity()) {
+            
getIsSgIoUnfiltered().setChangeProhibitionReason(CONSTANTS.cannotEnableSgioWhenScsiPassthroughDisabled());
+            getIsSgIoUnfiltered().setIsChangable(false);
+            getIsSgIoUnfiltered().setEntity(false);
+            return;
+        }
+        getIsSgIoUnfiltered().setIsChangable(isEditEnabled());
     }
 
     protected void updateReadOnlyChangeability() {
@@ -669,14 +705,18 @@
             return;
         }
 
-        boolean isDirectLUN = 
Boolean.FALSE.equals(getIsInternal().getEntity());
-        if (diskInterface == DiskInterface.VirtIO_SCSI && isDirectLUN) {
-            
getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableVirtIoScsiInterfaceForLunReadOnlyDisk());
+        boolean isDirectLUN = !getIsInternal().getEntity();
+        boolean isScsiPassthrough = getIsScsiPassthrough().getEntity();
+        if (diskInterface == DiskInterface.VirtIO_SCSI && isDirectLUN && 
isScsiPassthrough) {
+            
getIsReadOnly().setChangeProhibitionReason(CONSTANTS.cannotEnableReadonlyWhenScsiPassthroughEnabled());
             getIsReadOnly().setIsChangable(false);
             getIsReadOnly().setEntity(false);
             return;
         }
+
+
         getIsReadOnly().setIsChangable(isEditEnabled());
+        getIsReadOnly().setEntity(getIsNew() ? Boolean.FALSE : 
getDisk().getReadOnly());
     }
 
     private void updatePlugChangeability() {
@@ -862,7 +902,8 @@
             LunDisk lunDisk = getLunDisk();
             DiskInterface diskInterface = getDiskInterface().getSelectedItem();
             if (DiskInterface.VirtIO_SCSI.equals(diskInterface)) {
-                
lunDisk.setSgio(Boolean.TRUE.equals(getIsSgIoUnfiltered().getEntity()) ?
+                lunDisk.setSgio(!getIsScsiPassthrough().getEntity() ? null :
+                        getIsSgIoUnfiltered().getEntity() ?
                         ScsiGenericIO.UNFILTERED : ScsiGenericIO.FILTERED);
             }
             setDisk(lunDisk);
@@ -898,17 +939,19 @@
     public void eventRaised(Event ev, Object sender, EventArgs args) {
         super.eventRaised(ev, sender, args);
 
-        if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition) && 
sender == getIsWipeAfterDelete())
-        {
-            wipeAfterDelete_EntityChanged(args);
-        }
-        else if 
(ev.matchesDefinition(EntityModel.entityChangedEventDefinition) && sender == 
getIsAttachDisk())
-        {
-            attachDisk_EntityChanged(args);
-        }
-        else if (ev.matchesDefinition(ListModel.entityChangedEventDefinition) 
&& sender == getIsInternal())
-        {
-            isInternal_EntityChanged();
+        if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition)) {
+            if (sender == getIsWipeAfterDelete()) {
+                wipeAfterDelete_EntityChanged(args);
+            } else if (sender == getIsAttachDisk()) {
+                attachDisk_EntityChanged(args);
+            } else if (sender == getIsReadOnly()) {
+                updateScsiPassthroguhChangeability();
+            } else if (sender == getIsScsiPassthrough()) {
+                updateSgIoUnfilteredChangeability();
+                updateReadOnlyChangeability();
+            } else if (sender == getIsInternal()) {
+                isInternal_EntityChanged();
+            }
         }
         else if 
(ev.matchesDefinition(ListModel.selectedItemChangedEventDefinition) && sender 
== getVolumeType())
         {
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 f2e2b57..484c921 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
@@ -39,6 +39,7 @@
         getDescription().setEntity(getDisk().getDiskDescription());
         getIsShareable().setEntity(getDisk().isShareable());
         getIsWipeAfterDelete().setEntity(getDisk().isWipeAfterDelete());
+        getIsScsiPassthrough().setEntity(getDisk().isScsiPassthrough());
         getIsSgIoUnfiltered().setEntity(getDisk().getSgio() == 
ScsiGenericIO.UNFILTERED);
         getIsReadOnly().setEntity(getDisk().getReadOnly());
 
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index 7bbb2ba..9fa4e03 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -2258,8 +2258,14 @@
     @DefaultStringValue("An IDE disk can't be read-only.")
     String cannotEnableIdeInterfaceForReadOnlyDisk();
 
-    @DefaultStringValue("A VirtIO-ISCSI direct LUN disk can't be read-only.")
-    String cannotEnableVirtIoScsiInterfaceForLunReadOnlyDisk();
+    @DefaultStringValue("A VirtIO-SCSI DirectLUN disk can't be set as 
read-only when SCSI pass-through is enabled.")
+    String cannotEnableReadonlyWhenScsiPassthroughEnabled();
+
+    @DefaultStringValue("Privileged SCSI I/O can be set only when SCSI 
pass-through is enabled.")
+    String cannotEnableSgioWhenScsiPassthroughDisabled();
+
+    @DefaultStringValue("SCSI pass-through is not supported for read-only 
disks.")
+    String cannotEnableScsiPassthroughForLunReadOnlyDisk();
 
     @DefaultStringValue("Global Maintenance Enabled")
     String haGlobalMaintenance();
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index e55aa6c..312b0c6 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -925,6 +925,7 @@
 ERROR_CANNOT_DETACH_DISK_WITH_SNAPSHOT=Cannot ${action} ${type}. The disk is 
already configured in a snapshot. In order to detach it, remove the disk's 
snapshots.
 DISK_IS_ALREADY_SHARED_BETWEEN_VMS=Cannot ${action} ${type}. Disk is shared 
between vms and cannot become unshareable . Detach the disk from the rest of 
the vms it is attached to and then update the disk to be unshareable.
 SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK="Cannot ${action} ${type}. 
SCSI Generic IO is not supported for image disk."
+SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK="Cannot ${action} 
${type}. SCSI device pass-throguh is not supported for a read-only disk."
 VIRTIO_SCSI_INTERFACE_IS_NOT_AVAILABLE_FOR_CLUSTER_LEVEL=Virtio-SCSI interface 
is only available on cluster level 3.3 or higher.
 CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED=Cannot ${action} ${type}. 
VirtIO-SCSI is disabled for the VM
 CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS=Cannot disable VirtIO-SCSI when disks 
with a VirtIO-SCSI interface are plugged into the VM.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 0e7df58..5b19688 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -965,6 +965,7 @@
 ERROR_CANNOT_DETACH_DISK_WITH_SNAPSHOT=Cannot ${action} ${type}. The disk is 
already configured in a snapshot. In order to detach it, remove the disk's 
snapshots.
 DISK_IS_ALREADY_SHARED_BETWEEN_VMS=Cannot ${action} ${type}. Disk is shared 
between vms and cannot become unshareable . Detach the disk from the rest of 
the vms it is attached to and then update the disk to be unshareable.
 SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK="Cannot ${action} ${type}. 
SCSI Generic IO is not supported for image disk."
+SCSI_PASSTHROUGH_IS_NOT_SUPPORTED_FOR_READ_ONLY_DISK="Cannot ${action} 
${type}. SCSI device pass-throguh is not supported for a read-only disk."
 VIRTIO_SCSI_INTERFACE_IS_NOT_AVAILABLE_FOR_CLUSTER_LEVEL=Virtio-SCSI interface 
is only available on cluster level 3.3 or higher.
 CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED=Cannot ${action} ${type}. 
VirtIO-SCSI is disabled for the VM
 CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS=Cannot disable VirtIO-SCSI when disks 
with a VirtIO-SCSI interface are plugged into the VM.
diff --git 
a/packaging/dbscripts/upgrade/03_05_0810_update_sgio_for_readonly_disks.sql 
b/packaging/dbscripts/upgrade/03_05_0810_update_sgio_for_readonly_disks.sql
new file mode 100644
index 0000000..c7dc4be
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_05_0810_update_sgio_for_readonly_disks.sql
@@ -0,0 +1,8 @@
+-- Since SCSI device pass-through is not supported for read-only disks,
+-- nullify 'sgio' property for such disks.
+-- As discussed in BZ1118847, read-only/virtio-scsi/direct-lun disks
+-- should use SCSI device emulation instead.
+
+UPDATE base_disks
+SET sgio = NULL
+WHERE base_disks.disk_id IN (SELECT device_id FROM vm_device WHERE is_readonly 
= TRUE);


-- 
To view, visit http://gerrit.ovirt.org/30885
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic317722be9ef8978b50352c12bc06ea8c906dcd0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Daniel Erez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to