From 1825b6f2ab8a186aaeec5bd1f41566638021a555 Mon Sep 17 00:00:00 2001 From: Stefan Chivu Date: Tue, 22 Nov 2022 15:44:46 +0200 Subject: [PATCH] Added function for enabling AllowFullSCSICommandSet By default, Hyper-V filters some of the SCSI commands received from the VMs. This change allows disabling the filter. Signed-off-by: Stefan Chivu Change-Id: I1b0fc8e7e75a6c5395aedd5b8e94b3bd000e1843 --- os_win/tests/unit/utils/compute/test_vmutils.py | 7 +++++++ os_win/utils/compute/vmutils.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/os_win/tests/unit/utils/compute/test_vmutils.py b/os_win/tests/unit/utils/compute/test_vmutils.py index 23df36f6..13409781 100644 --- a/os_win/tests/unit/utils/compute/test_vmutils.py +++ b/os_win/tests/unit/utils/compute/test_vmutils.py @@ -1272,6 +1272,13 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase): self._vmutils._jobutils.stop_jobs.assert_called_once_with( mock_vm, None) + @mock.patch.object(vmutils.VMUtils, '_modify_virtual_system') + def test_set_allow_full_scsi_command_set(self, mock_modify_virtual_system): + mock_vm = self._lookup_vm() + self._vmutils.enable_vm_full_scsi_command_set(mock.sentinel.vm_name) + self.assertTrue(mock_vm.AllowFullSCSICommandSet) + mock_modify_virtual_system.assert_called_once_with(mock_vm) + def test_set_secure_boot(self): vs_data = mock.MagicMock() self._vmutils._set_secure_boot(vs_data, msft_ca_required=False) diff --git a/os_win/utils/compute/vmutils.py b/os_win/utils/compute/vmutils.py index abcf451f..2ec9c3f0 100644 --- a/os_win/utils/compute/vmutils.py +++ b/os_win/utils/compute/vmutils.py @@ -880,6 +880,13 @@ class VMUtils(baseutils.BaseUtilsVirt): raise exceptions.HyperVException( _("Exceeded the maximum number of slots")) + def enable_vm_full_scsi_command_set(self, vm_name): + "Enables the full SCSI command set for the specified VM." + + vs_data = self._lookup_vm_check(vm_name) + vs_data.AllowFullSCSICommandSet = True + self._modify_virtual_system(vs_data) + def _get_vm_serial_ports(self, vmsettings): rasds = _wqlutils.get_element_associated_class( self._compat_conn, self._SERIAL_PORT_SETTING_DATA_CLASS,