mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
add "serial" parameter to -drive flag (Gleb Natapov)
Windows calculates HW "uniqueness" based on a hard drive serial number among other things. The patch allows to specify drive serial number from a command line. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6214 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
ff4b91c2f7
commit
fa879c6414
5 changed files with 44 additions and 15 deletions
|
@ -13,6 +13,8 @@
|
|||
* the host adapter emulator.
|
||||
*/
|
||||
|
||||
#include <qemu-common.h>
|
||||
#include <sysemu.h>
|
||||
//#define DEBUG_SCSI
|
||||
|
||||
#ifdef DEBUG_SCSI
|
||||
|
@ -68,6 +70,7 @@ struct SCSIDeviceState
|
|||
or from the AIO completion routines. */
|
||||
scsi_completionfn completion;
|
||||
void *opaque;
|
||||
char drive_serial_str[21];
|
||||
};
|
||||
|
||||
/* Global pool of SCSIRequest structures. */
|
||||
|
@ -408,6 +411,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
|
|||
break;
|
||||
case 0x80:
|
||||
{
|
||||
int l;
|
||||
|
||||
/* Device serial number, optional */
|
||||
if (len < 4) {
|
||||
BADF("Error: EVPD[Serial number] Inquiry buffer "
|
||||
|
@ -416,6 +421,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
|
|||
}
|
||||
|
||||
DPRINTF("Inquiry EVPD[Serial number] buffer size %d\n", len);
|
||||
l = MIN(len, strlen(s->drive_serial_str));
|
||||
|
||||
r->buf_len = 0;
|
||||
|
||||
|
@ -428,9 +434,9 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
|
|||
|
||||
outbuf[r->buf_len++] = 0x80; // this page
|
||||
outbuf[r->buf_len++] = 0x00;
|
||||
outbuf[r->buf_len++] = 0x01; // 1 byte data follow
|
||||
|
||||
outbuf[r->buf_len++] = '0'; // 1 byte data follow
|
||||
outbuf[r->buf_len++] = l;
|
||||
memcpy(&outbuf[r->buf_len], s->drive_serial_str, l);
|
||||
r->buf_len += l;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -812,7 +818,10 @@ SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq,
|
|||
} else {
|
||||
s->cluster_size = 1;
|
||||
}
|
||||
|
||||
strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),
|
||||
sizeof(s->drive_serial_str));
|
||||
if (strlen(s->drive_serial_str) == 0)
|
||||
strcpy(s->drive_serial_str, "0");
|
||||
d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));
|
||||
d->state = s;
|
||||
d->destroy = scsi_destroy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue