... and the VDISK_REMOVABLE bit in the value of the 'info' node.
They both apply to the media and not the device itself. PV devices are always
removable.
The comment in libxl_disk.c concerning the 'removable' flag states that:
"Currently there is only one removable device -- CDROM"
This is not conclusive but it is reasonable to infer from that the removabilty
refers to the media and not the drive itself. (CDROM drives in typical servers
are not removable).
The code in Linux xen-blkback/xenbus.c sets VDISK_REMOVABLE if the underlying
block device has the GENHD_FL_REMOVABLE flag, and the comment above the
definition of that flag in genhd.h states:
"``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device gives access
to removable media.
When set, the device remains present even when media is not inserted.
Must not be set for devices which are removed entirely when the media is
removed."
This patch, therefore, stops using these values to indicate the removability
of the target devices and instead uses them as they were intended, to indicate
the removability of the media.
NOTE: The code in XENCRSH is modified to simply ignore the 'removable' node.
The value currently sampled is not used.
The Removable BOOLEAN field currently in XENVBD_CAPS is also moved into
XENVBD_FEATURES for consistency with other values sampled from xenstore
nodes.
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
NTSTATUS Status;
PCHAR Buffer;
- Status = StoreRead(NULL, Frontend->BackendPath,
- "removable", &Buffer);
- if (NT_SUCCESS(Status)) {
- Frontend->Removable = (strtoul(Buffer, NULL, 10) == 1);
- AustereFree(Buffer);
- }
-
Status = StoreRead(NULL, Frontend->BackendPath,
"feature-barrier", &Buffer);
if (NT_SUCCESS(Status)) {
Frontend->FeatureDiscard = FALSE;
}
- LogVerbose("Features: DomId=%d, RingOrder=0, %s %s %s\n",
+ LogVerbose("Features: DomId=%d, RingOrder=0, %s %s\n",
Frontend->BackendId,
- Frontend->Removable ? "REMOVABLE" : "NOT_REMOVABLE",
Frontend->FeatureBarrier ? "BARRIER" : "NOT_BARRIER",
Frontend->FeatureDiscard ? "DISCARD" : "NOT_DISCARD");
}
// Capabilities
BOOLEAN Connected;
- BOOLEAN Removable;
- BOOLEAN SurpriseRemovable;
BOOLEAN FeatureBarrier;
BOOLEAN FeatureDiscard;
BOOLEAN Paging;
IN PXENVBD_FRONTEND Frontend
);
-#endif // _XENVBD_FRONTEND_H
\ No newline at end of file
+#endif // _XENVBD_FRONTEND_H
case StorQueryCapabilities: {
PSTOR_DEVICE_CAPABILITIES Caps = Srb->DataBuffer;
- Caps->Removable = TargetGetRemovable(Target);
- Caps->EjectSupported = TargetGetRemovable(Target);
- Caps->SurpriseRemovalOK = TargetGetSurpriseRemovable(Target);
+ Caps->Removable = 1;
+ Caps->EjectSupported = 1;
+ Caps->SurpriseRemovalOK = 1;
Caps->UniqueID = 1;
} break;
if (!Changed)
return;
- Frontend->Caps.SurpriseRemovable = !!(Frontend->DiskInfo.DiskInfo & VDISK_REMOVABLE);
if (Frontend->DiskInfo.DiskInfo & VDISK_READONLY) {
Warning("Target[%d] : DiskInfo contains VDISK_READONLY flag!\n", Frontend->TargetId);
}
Trace("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->TargetId,
Frontend->DiskInfo.SectorCount, Frontend->DiskInfo.SectorSize,
Frontend->DiskInfo.PhysSectorSize);
- Trace("Target[%d] : %d %s (%08x) %s\n", Frontend->TargetId,
+ Trace("Target[%d] : %d %s (%08x)\n", Frontend->TargetId,
__Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
- Frontend->DiskInfo.DiskInfo,
- Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
+ Frontend->DiskInfo.DiskInfo);
}
static FORCEINLINE VOID
Changed = FrontendReadFeature(Frontend,
FeatureRemovable,
- &Frontend->Caps.Removable);
+ &Frontend->Features.Removable);
Changed |= FrontendReadValue32(Frontend,
FeatureMaxIndirectSegments,
TRUE,
Frontend->TargetId,
Frontend->Features.Persistent ? "PERSISTENT " : "",
Frontend->Features.Indirect ? "INDIRECT " : "",
- Frontend->Caps.Removable ? "REMOVABLE" : "");
+ Frontend->Features.Removable ? "REMOVABLE" : "");
if (Frontend->Features.Indirect) {
Verbose("Target[%d] : INDIRECT %x\n",
XENBUS_DEBUG(Printf,
&Frontend->DebugInterface,
- "Caps: %s%s%s%s%s%s\n",
+ "Caps: %s%s%s%s\n",
Frontend->Caps.Connected ? "CONNECTED " : "",
- Frontend->Caps.Removable ? "REMOVABLE " : "",
- Frontend->Caps.SurpriseRemovable ? "SURPRISE " : "",
Frontend->Caps.Paging ? "PAGING " : "",
Frontend->Caps.Hibernation ? "HIBER " : "",
Frontend->Caps.DumpFile ? "DUMP " : "");
XENBUS_DEBUG(Printf,
&Frontend->DebugInterface,
- "Features: %s%s%s%s%s\n",
+ "Features: %s%s%s%s%s%s\n",
Frontend->Features.Persistent ? "PERSISTENT " : "",
Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
+ Frontend->Features.Removable ? "REMOVABLE " : "",
Frontend->DiskInfo.Barrier ? "BARRIER " : "",
Frontend->DiskInfo.FlushCache ? "FLUSH " : "",
Frontend->DiskInfo.Discard ? "DISCARD " : "");
typedef struct _XENVBD_CAPS {
BOOLEAN Connected;
- BOOLEAN Removable;
- BOOLEAN SurpriseRemovable;
BOOLEAN Paging;
BOOLEAN Hibernation;
BOOLEAN DumpFile;
typedef struct _XENVBD_FEATURES {
ULONG Indirect;
BOOLEAN Persistent;
+ BOOLEAN Removable;
} XENVBD_FEATURES, *PXENVBD_FEATURES;
typedef struct _XENVBD_DISKINFO {
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;
- UNREFERENCED_PARAMETER(Target);
-
Srb->SrbStatus = SRB_STATUS_ERROR;
if (Data == NULL)
RtlZeroMemory(Data, Length);
Data->DeviceType = DIRECT_ACCESS_DEVICE;
Data->DeviceTypeQualifier = DEVICE_CONNECTED;
+ Data->RemovableMedia = Features->Removable ||
+ (DiskInfo->DiskInfo & VDISK_REMOVABLE);
Data->Versions = 4;
Data->ResponseDataFormat = 2;
Data->AdditionalLength = INQUIRYDATABUFFERSIZE - 4;
return FrontendGetDeviceId(Target->Frontend);
}
-//TARGET_GET_PROPERTY(Removable, BOOLEAN)
-BOOLEAN
-TargetGetRemovable(
- IN PXENVBD_TARGET Target
- )
-{
- return FrontendGetCaps(Target->Frontend)->Removable;
-}
-
-//TARGET_GET_PROPERTY(SurpriseRemovable, BOOLEAN)
-BOOLEAN
-TargetGetSurpriseRemovable(
- IN PXENVBD_TARGET Target
- )
-{
- return FrontendGetCaps(Target->Frontend)->SurpriseRemovable;
-}
-
TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE)
//TARGET_GET_PROPERTY(Missing, BOOLEAN)
TARGET_GET_PROPERTY(DeviceObject, PDEVICE_OBJECT)
TARGET_GET_PROPERTY(TargetId, ULONG)
TARGET_GET_PROPERTY(DeviceId, ULONG)
-TARGET_GET_PROPERTY(Removable, BOOLEAN)
-TARGET_GET_PROPERTY(SurpriseRemovable, BOOLEAN)
TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE)
TARGET_GET_PROPERTY(Missing, BOOLEAN)