[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] Interpret "removable" and "info" flags correctly
"removable" relates to the ability to remove the device (not media) "removable" = "1" is used to indicate the device can be hot unplugged, as PV devices should support hot plug/unplug in the majority of cases. "removable" = "0" is used to indicate that the device is being prevented from hot unplug by the tool stack. This will allow XenVbd to report the correct device capabilities to the OS to indicate that this disk is not capable of being removed. This will allow certain policies to be applied which restrict access to removable disks (for security and to prevent data exfiltration) "info" contains various flags for the media (not device) VDISK_CDROM implies RemovableMedia (a specific case of VDISK_REMOVABLE) VDISK_REMOVABLE imples RemovableMedia (underlying disk has GENHD_FL_REMOVABLE) VDISK_READONLY implies a READ_ONLY_DIRECT_ACCESS_DEVICE 'Standard' disks usually set no flags (i.e. media is RW and not removable) A CDROM will set VDISK_CDROM | VDISK_READONLY, to indicate the media is RO and removable. STOR_FEATURE_FULL_PNP_DEVICE_CAPABILITIES must be set, otherwise StorPort will not use the values provided for EjectSupported and SurpriseRemovalOK in the STOR_DEVICE_CAPABILITIES_EX structure. Without this, CM_DEVCAP_EJECTSUPPORTED and CM_DEVCAP_SURPRISEREMOVALOK are left unchanged, and prevents a non-removable device from identifying correctly as non-removable. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/xenvbd/adapter.c | 7 ++++--- src/xenvbd/target.c | 16 +++++++++++++--- src/xenvbd/target.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c index 5b17a6b..8a13af9 100644 --- a/src/xenvbd/adapter.c +++ b/src/xenvbd/adapter.c @@ -1927,10 +1927,10 @@ __AdapterSrbPnp( switch (Srb->PnPAction) { case StorQueryCapabilities: { - PSTOR_DEVICE_CAPABILITIES Caps = Srb->DataBuffer; + PSTOR_DEVICE_CAPABILITIES_EX Caps = Srb->DataBuffer; - Caps->Removable = 1; - Caps->EjectSupported = 1; + Caps->Removable = TargetGetRemovable(Target); + Caps->EjectSupported = TargetGetRemovable(Target); Caps->SurpriseRemovalOK = 1; Caps->UniqueID = 1; @@ -2280,6 +2280,7 @@ AdapterDriverEntry( InitData.MultipleRequestPerLu = TRUE; InitData.HwAdapterControl = AdapterHwAdapterControl; InitData.HwBuildIo = AdapterHwBuildIo; + InitData.FeatureSupport = STOR_FEATURE_FULL_PNP_DEVICE_CAPABILITIES; status = StorPortInitialize(DriverObject, RegistryPath, diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c index 7935fa0..e71200f 100644 --- a/src/xenvbd/target.c +++ b/src/xenvbd/target.c @@ -641,7 +641,6 @@ TargetInquiryStd( IN PSCSI_REQUEST_BLOCK Srb ) { - PXENVBD_FEATURES Features = FrontendGetFeatures(Target->Frontend); PXENVBD_DISKINFO DiskInfo = FrontendGetDiskInfo(Target->Frontend); PINQUIRYDATA Data = Srb->DataBuffer; ULONG Length = Srb->DataTransferLength; @@ -656,9 +655,11 @@ TargetInquiryStd( return; RtlZeroMemory(Data, Length); - Data->DeviceType = DIRECT_ACCESS_DEVICE; + Data->DeviceType = (DiskInfo->DiskInfo & VDISK_READONLY) ? + READ_ONLY_DIRECT_ACCESS_DEVICE : + DIRECT_ACCESS_DEVICE; Data->DeviceTypeQualifier = DEVICE_CONNECTED; - Data->RemovableMedia = Features->Removable || + Data->RemovableMedia = (DiskInfo->DiskInfo & VDISK_CDROM) || (DiskInfo->DiskInfo & VDISK_REMOVABLE); Data->Versions = 4; Data->ResponseDataFormat = 2; @@ -1475,6 +1476,15 @@ TargetGetDeviceId( return FrontendGetDeviceId(Target->Frontend); } +//TARGET_GET_PROPERTY(Removable, BOOLEAN) +BOOLEAN +TargetGetRemovable( + IN PXENVBD_TARGET Target + ) +{ + return FrontendGetFeatures(Target->Frontend)->Removable; +} + TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE) //TARGET_GET_PROPERTY(Missing, BOOLEAN) diff --git a/src/xenvbd/target.h b/src/xenvbd/target.h index 6feecc1..c6c027a 100644 --- a/src/xenvbd/target.h +++ b/src/xenvbd/target.h @@ -132,6 +132,7 @@ TARGET_GET_PROPERTY(Adapter, PXENVBD_ADAPTER) TARGET_GET_PROPERTY(DeviceObject, PDEVICE_OBJECT) TARGET_GET_PROPERTY(TargetId, ULONG) TARGET_GET_PROPERTY(DeviceId, ULONG) +TARGET_GET_PROPERTY(Removable, BOOLEAN) TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE) TARGET_GET_PROPERTY(Missing, BOOLEAN) -- 2.33.0.windows.2
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |