From aedf53821fef9f662c2f4fc0a83bc09e0768ed54 Mon Sep 17 00:00:00 2001 From: bellard Date: Mon, 17 May 2004 19:56:47 +0000 Subject: [PATCH] different serial number for each drive (initial patch by Mike Nordell) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@812 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/ide.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/ide.c b/hw/ide.c index 6c92bedbbd..6f0db4aaa6 100644 --- a/hw/ide.c +++ b/hw/ide.c @@ -297,6 +297,7 @@ typedef struct IDEState { int64_t nb_sectors; int mult_sectors; int irq; + int drive_serial; /* ide regs */ uint8_t feature; uint8_t error; @@ -359,6 +360,7 @@ static void ide_identify(IDEState *s) { uint16_t *p; unsigned int oldsize; + char buf[20]; memset(s->io_buffer, 0, 512); p = (uint16_t *)s->io_buffer; @@ -368,7 +370,8 @@ static void ide_identify(IDEState *s) put_le16(p + 4, 512 * s->sectors); /* XXX: retired, remove ? */ put_le16(p + 5, 512); /* XXX: retired, remove ? */ put_le16(p + 6, s->sectors); - padstr((uint8_t *)(p + 10), "QM00001", 20); /* serial number */ + snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial); + padstr((uint8_t *)(p + 10), buf, 20); /* serial number */ put_le16(p + 20, 3); /* XXX: retired, remove ? */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ @@ -404,12 +407,14 @@ static void ide_identify(IDEState *s) static void ide_atapi_identify(IDEState *s) { uint16_t *p; + char buf[20]; memset(s->io_buffer, 0, 512); p = (uint16_t *)s->io_buffer; /* Removable CDROM, 50us response, 12 byte packets */ put_le16(p + 0, (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0)); - padstr((uint8_t *)(p + 10), "QM00001", 20); /* serial number */ + snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial); + padstr((uint8_t *)(p + 10), buf, 20); /* serial number */ put_le16(p + 20, 3); /* buffer type */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ @@ -1432,6 +1437,7 @@ void ide_init(int iobase, int iobase2, int irq, BlockDriverState *hd0, BlockDriverState *hd1) { IDEState *s, *ide_state; + static int drive_serial = 1; int i, cylinders, heads, secs; int64_t nb_sectors; @@ -1473,6 +1479,7 @@ void ide_init(int iobase, int iobase2, int irq, bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } } + s->drive_serial = drive_serial++; s->irq = irq; ide_reset(s); } -- GitLab