From: Andrew McNeil Date: Mon, 30 Nov 2009 19:01:34 +0000 (+0000) Subject: Fix minor bug where we only passed back 8 bytes of sense data for faked errors, rathe... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=751d1eb6cd784ae346689bec685f22c7be4725c3;p=xenclient%2Fioemu-pq.git Fix minor bug where we only passed back 8 bytes of sense data for faked errors, rather than the full 18. --- diff --git a/master/atapi-succeed-on-lock-door b/master/atapi-succeed-on-lock-door index fc2928f..7d6abda 100644 --- a/master/atapi-succeed-on-lock-door +++ b/master/atapi-succeed-on-lock-door @@ -1,8 +1,48 @@ diff --git a/hw/atapi-pt.c b/hw/atapi-pt.c -index d810262..3774b8e 100644 +index aed333d..10d35a7 100644 --- a/hw/atapi-pt.c +++ b/hw/atapi-pt.c -@@ -1213,12 +1213,7 @@ static void ide_atapi_pt_cmd(IDEState *s) +@@ -599,7 +599,7 @@ static const struct { + {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, // 0x08-0x0f + {{-1}},{{-1}}, // 0x10-0x11 + {{ 0, 0, 0, 0}, { 0, 4, 1, 1}, { 5, 4, 1, 1}, "Inquiry"}, // 0x12 GPCMD_INQUIRY +- {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, // 0x13-0xa ++ {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, {{-1}},{{-1}}, // 0x13-0x1a + {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, "Start/Stop Unit"}, // 0x1b GPCMD_START_STOP_UNIT + {{-1}},{{-1}}, // 0x1c-0x1d + {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, "Prevent/Allow Medium Removal"}, // 0x1e GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL +@@ -767,10 +767,12 @@ static uint32_t ide_atapi_pt_get_data_size(int size_select, uint8_t command, uin + + static void ide_atapi_pt_set_error(IDEState *s, int sense_key, int asc, int ascq, int error) + { ++ memset(&s->atapi_pt.sense, 0, 18); + s->atapi_pt.sense.sense_key = sense_key; + s->atapi_pt.sense.asc = asc; + s->atapi_pt.sense.ascq = ascq; + s->atapi_pt.sense.error_code = error; ++ s->atapi_pt.sense.add_sense_len = 10; + + DEBUG_PRINTF("[\e[1;31mERROR\e[m] (%s) sense: 0x%02x,%02x,%02x (%s)\n", + atapi_cmd_to_str(s->atapi_pt.request[0]), +@@ -1168,7 +1170,7 @@ static void ide_atapi_pt_cmd(IDEState *s) + DEBUG_PRINTF("Sending fake inquiry reply:\n"); + DEBUG_HEXDUMP(inquiry_data, 96); + memcpy(s->io_buffer, inquiry_data, 96); +- memset(&s->atapi_pt.sense, 0, 18); ++ memset(&s->atapi_pt.sense, 0, sizeof(sense)); + ide_atapi_cmd_reply(s, 96, s->atapi_pt.din_xfer_len); + pthread_mutex_unlock(&s->atapi_pt.sgio_mutex); + return; +@@ -1182,7 +1184,7 @@ static void ide_atapi_pt_cmd(IDEState *s) + } + + DEBUG_PRINTF("Blocking command due to exclusivity lock\n"); +- memcpy(&s->atapi_pt.sense, sense, 18); ++ memcpy(&s->atapi_pt.sense, sense, sizeof(sense)); + ide_atapi_pt_set_error(s, sense[2], sense[12], sense[13], 0x70); + pthread_mutex_unlock(&s->atapi_pt.sgio_mutex); + return; +@@ -1216,12 +1218,7 @@ static void ide_atapi_pt_cmd(IDEState *s) { case GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL: // we don't allow locking, to prevent a VM from hogging the drive