ia64/linux-2.6.18-xen.hg

changeset 588:9c4a15e54814

pvSCSI: Add white list to SCSI command emulation

Add "white list" control to SCSI command emulation. Current setting
allows following mandatory and safe commands.

TEST UNIT READY
REZERO UNIT
REQUEST SENSE
FORMAT UNIT
READ BLOCK LIMITS
READ(06)
WRITE(06)
WRITE FILEMARKS
SPACE
INQUIRY
ERASE
MODE SENSE(06)
SEND DIAGNOSTIC
READ CAPACITY
READ(10)
WRITE(10)
REPORT LUN


Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Jun Kamada <kama@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jul 03 13:35:40 2008 +0100 (2008-07-03)
parents 999b88699ca4
children 920abc7b20ac
files drivers/xen/scsiback/emulate.c
line diff
     1.1 --- a/drivers/xen/scsiback/emulate.c	Thu Jul 03 11:03:53 2008 +0100
     1.2 +++ b/drivers/xen/scsiback/emulate.c	Thu Jul 03 13:35:40 2008 +0100
     1.3 @@ -93,7 +93,7 @@ static void scsiback_mk_sense_buffer(uin
     1.4  	data[13] = asq;
     1.5  }
     1.6  
     1.7 -static void resp_not_supported_cmd(pending_req_t *pending_req)
     1.8 +static void resp_not_supported_cmd(pending_req_t *pending_req, void *data)
     1.9  {
    1.10  	scsiback_mk_sense_buffer(pending_req->sense_buffer, ILLEGAL_REQUEST,
    1.11  		INVALID_OPCODE, 0);
    1.12 @@ -270,7 +270,7 @@ int __pre_do_emulation(pending_req_t *pe
    1.13  	    1: non emulation or should call native driver 
    1.14  	       after modifing the request buffer.
    1.15  	*/
    1.16 -	return (bitmap[op_code] & VSCSIIF_NEED_CMD_EXEC);
    1.17 +	return !!(bitmap[op_code] & VSCSIIF_NEED_CMD_EXEC);
    1.18  }
    1.19  
    1.20  void scsiback_rsp_emulation(pending_req_t *pending_req)
    1.21 @@ -308,16 +308,14 @@ void scsiback_emulation_init(void)
    1.22  
    1.23  	/* Initialize to default state */
    1.24  	for (i = 0; i < VSCSI_MAX_SCSI_OP_CODE; i++) {
    1.25 -		bitmap[i]        = VSCSIIF_NEED_CMD_EXEC;
    1.26 -		pre_function[i]  = NULL;
    1.27 +		bitmap[i]        = (VSCSIIF_NEED_EMULATE_REQBUF | 
    1.28 +					VSCSIIF_NEED_EMULATE_RSPBUF);
    1.29 +		pre_function[i]  = resp_not_supported_cmd;
    1.30  		post_function[i] = NULL;
    1.31  		/* means,
    1.32  		   - no need for pre-emulation
    1.33  		   - no need for post-emulation
    1.34  		   - call native driver
    1.35 -
    1.36 -		   (Current setting is black-list bases, white-list
    1.37 -		   bases may be appropriate for security.)
    1.38  		*/
    1.39  	}
    1.40  
    1.41 @@ -325,6 +323,77 @@ void scsiback_emulation_init(void)
    1.42  	  Register appropriate functions below as you need.
    1.43  	  (See scsi/scsi.h for definition of SCSI op_code.)
    1.44  	*/
    1.45 +
    1.46 +	/*
    1.47 +	  This command is Non emulation.
    1.48 +	*/
    1.49 +	bitmap[TEST_UNIT_READY] = VSCSIIF_NEED_CMD_EXEC;
    1.50 +	pre_function[TEST_UNIT_READY] = NULL;
    1.51 +	post_function[TEST_UNIT_READY] = NULL;
    1.52 +
    1.53 +	bitmap[REZERO_UNIT] = VSCSIIF_NEED_CMD_EXEC;
    1.54 +	pre_function[REZERO_UNIT] = NULL;
    1.55 +	post_function[REZERO_UNIT] = NULL;
    1.56 +
    1.57 +	bitmap[REQUEST_SENSE] = VSCSIIF_NEED_CMD_EXEC;
    1.58 +	pre_function[REQUEST_SENSE] = NULL;
    1.59 +	post_function[REQUEST_SENSE] = NULL;
    1.60 +
    1.61 +	bitmap[FORMAT_UNIT] = VSCSIIF_NEED_CMD_EXEC;
    1.62 +	pre_function[FORMAT_UNIT] = NULL;
    1.63 +	post_function[FORMAT_UNIT] = NULL;
    1.64 +
    1.65 +	bitmap[READ_BLOCK_LIMITS] = VSCSIIF_NEED_CMD_EXEC;
    1.66 +	pre_function[READ_BLOCK_LIMITS] = NULL;
    1.67 +	post_function[READ_BLOCK_LIMITS] = NULL;
    1.68 +
    1.69 +	bitmap[READ_6] = VSCSIIF_NEED_CMD_EXEC;
    1.70 +	pre_function[READ_6] = NULL;
    1.71 +	post_function[READ_6] = NULL;
    1.72 +
    1.73 +	bitmap[WRITE_6] = VSCSIIF_NEED_CMD_EXEC;
    1.74 +	pre_function[WRITE_6] = NULL;
    1.75 +	post_function[WRITE_6] = NULL;
    1.76 +
    1.77 +	bitmap[WRITE_FILEMARKS] = VSCSIIF_NEED_CMD_EXEC;
    1.78 +	pre_function[WRITE_FILEMARKS] = NULL;
    1.79 +	post_function[WRITE_FILEMARKS] = NULL;
    1.80 +
    1.81 +	bitmap[SPACE] = VSCSIIF_NEED_CMD_EXEC;
    1.82 +	pre_function[SPACE] = NULL;
    1.83 +	post_function[SPACE] = NULL;
    1.84 +
    1.85 +	bitmap[INQUIRY] = VSCSIIF_NEED_CMD_EXEC;
    1.86 +	pre_function[INQUIRY] = NULL;
    1.87 +	post_function[INQUIRY] = NULL;
    1.88 +
    1.89 +	bitmap[ERASE] = VSCSIIF_NEED_CMD_EXEC;
    1.90 +	pre_function[ERASE] = NULL;
    1.91 +	post_function[ERASE] = NULL;
    1.92 +
    1.93 +	bitmap[MODE_SENSE] = VSCSIIF_NEED_CMD_EXEC;
    1.94 +	pre_function[MODE_SENSE] = NULL;
    1.95 +	post_function[MODE_SENSE] = NULL;
    1.96 +
    1.97 +	bitmap[SEND_DIAGNOSTIC] = VSCSIIF_NEED_CMD_EXEC;
    1.98 +	pre_function[SEND_DIAGNOSTIC] = NULL;
    1.99 +	post_function[SEND_DIAGNOSTIC] = NULL;
   1.100 +
   1.101 +	bitmap[READ_CAPACITY] = VSCSIIF_NEED_CMD_EXEC;
   1.102 +	pre_function[READ_CAPACITY] = NULL;
   1.103 +	post_function[READ_CAPACITY] = NULL;
   1.104 +
   1.105 +	bitmap[READ_10] = VSCSIIF_NEED_CMD_EXEC;
   1.106 +	pre_function[READ_10] = NULL;
   1.107 +	post_function[READ_10] = NULL;
   1.108 +
   1.109 +	bitmap[WRITE_10] = VSCSIIF_NEED_CMD_EXEC;
   1.110 +	pre_function[WRITE_10] = NULL;
   1.111 +	post_function[WRITE_10] = NULL;
   1.112 +
   1.113 +	/*
   1.114 +	  This command is Full emulation.
   1.115 +	*/
   1.116  	pre_function[REPORT_LUNS] = __report_luns;
   1.117  	bitmap[REPORT_LUNS] = (VSCSIIF_NEED_EMULATE_REQBUF | 
   1.118  					VSCSIIF_NEED_EMULATE_RSPBUF);