[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 26/55] scsi-disk: store valid mode pages in a table
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 26/55] scsi-disk: store valid mode pages in a table |
Date: |
Mon, 31 Oct 2011 14:30:01 +0100 |
From: Paolo Bonzini <address@hidden>
A small refactoring of the MODE SENSE implementation in scsi-disk.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/scsi-disk.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index bdb98ef..8f3ada6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -607,10 +607,23 @@ static int scsi_emulate_mechanism_status(SCSIDiskState
*s, uint8_t *outbuf)
static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
int page_control)
{
+ static const int mode_sense_valid[0x3f] = {
+ [MODE_PAGE_HD_GEOMETRY] = (1 << TYPE_DISK),
+ [MODE_PAGE_FLEXIBLE_DISK_GEOMETRY] = (1 << TYPE_DISK),
+ [MODE_PAGE_CACHING] = (1 << TYPE_DISK) | (1 <<
TYPE_ROM),
+ [MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM),
+ };
+
BlockDriverState *bdrv = s->bs;
int cylinders, heads, secs;
uint8_t *p = *p_outbuf;
+ if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
+ return -1;
+ }
+
+ p[0] = page;
+
/*
* If Changeable Values are requested, a mask denoting those mode
parameters
* that are changeable shall be returned. As we currently don't support
@@ -619,10 +632,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
*/
switch (page) {
case MODE_PAGE_HD_GEOMETRY:
- if (s->qdev.type == TYPE_ROM) {
- return -1;
- }
- p[0] = 4;
p[1] = 0x16;
if (page_control == 1) { /* Changeable Values */
break;
@@ -654,10 +663,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
break;
case MODE_PAGE_FLEXIBLE_DISK_GEOMETRY:
- if (s->qdev.type == TYPE_ROM) {
- return -1;
- }
- p[0] = 5;
p[1] = 0x1e;
if (page_control == 1) { /* Changeable Values */
break;
@@ -707,10 +712,6 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
break;
case MODE_PAGE_CAPABILITIES:
- if (s->qdev.type != TYPE_ROM) {
- return -1;
- }
- p[0] = 0x2a;
p[1] = 0x14;
if (page_control == 1) { /* Changeable Values */
break;
--
1.7.6.4
- [Qemu-devel] [PATCH 48/55] scsi: make reqops const, (continued)
- [Qemu-devel] [PATCH 48/55] scsi: make reqops const, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 53/55] scsi-generic: bump SCSIRequest reference count until aio completion runs, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 27/55] atapi/scsi-disk: make mode page values coherent between the two, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 28/55] scsi-disk: support DVD profile in GET CONFIGURATION, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 54/55] scsi: push request restart to SCSIDevice, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 29/55] scsi-disk: support READ DVD STRUCTURE, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 25/55] scsi-disk: add stubs for more MMC commands, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 43/55] scsi-generic: snoop READ CAPACITY commands to get block size, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 32/55] qdev: switch children device list to QTAILQ, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 19/55] atapi/scsi: unify definitions for MMC, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 26/55] scsi-disk: store valid mode pages in a table,
Kevin Wolf <=
- [Qemu-devel] [PATCH 39/55] scsi-generic: drop SCSIGenericState, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 24/55] scsi-disk: fix coding style issues (braces), Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 31/55] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo), Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 34/55] scsi: implement REPORT LUNS for arbitrary LUNs, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 55/55] scsi-disk: add scsi-block for device passthrough, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 41/55] scsi-generic: check ioctl statuses when SG_IO succeeds, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 40/55] scsi-generic: remove scsi_req_fixup, Kevin Wolf, 2011/10/31
- [Qemu-devel] [PATCH 22/55] scsi: notify the device when unit attention is reported, Kevin Wolf, 2011/10/31
- Re: [Qemu-devel] [PULL 00/55] Block patches, Anthony Liguori, 2011/10/31