bdev/virtio: verify block device peripheral type

The virtio bdev should only attempt to issue SBC commands if the SCSI
device is a block device.

Change-Id: Ib29edbd19f9f34bdafe5ea3f7085c57537134625
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/382714
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Daniel Verkamp 2017-10-16 13:04:35 -07:00 committed by Jim Harris
parent fc5f527c21
commit 9864668f25

View File

@ -453,12 +453,21 @@ process_scan_inquiry(struct virtio_scsi_scan_base *base, struct virtio_req *vreq
{
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
struct spdk_scsi_cdb_inquiry_data *inquiry_data = vreq->iov[0].iov_base;
uint8_t target_id;
if (resp->response != VIRTIO_SCSI_S_OK || resp->status != SPDK_SCSI_STATUS_GOOD) {
return -1;
}
if (inquiry_data->peripheral_device_type != SPDK_SPC_PERIPHERAL_DEVICE_TYPE_DISK ||
inquiry_data->peripheral_qualifier != SPDK_SPC_PERIPHERAL_QUALIFIER_CONNECTED) {
SPDK_WARNLOG("Unsupported peripheral device type 0x%02x (qualifier 0x%02x)\n",
inquiry_data->peripheral_device_type,
inquiry_data->peripheral_qualifier);
return -1;
}
target_id = req->lun[1];
send_read_cap_10(base, target_id, vreq);
return 0;