Commit aedf53821fef9f662c2f4fc0a83bc09e0768ed54

Authored by bellard
1 parent 7f5e1452

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
Showing 1 changed file with 9 additions and 2 deletions
hw/ide.c
@@ -297,6 +297,7 @@ typedef struct IDEState { @@ -297,6 +297,7 @@ typedef struct IDEState {
297 int64_t nb_sectors; 297 int64_t nb_sectors;
298 int mult_sectors; 298 int mult_sectors;
299 int irq; 299 int irq;
  300 + int drive_serial;
300 /* ide regs */ 301 /* ide regs */
301 uint8_t feature; 302 uint8_t feature;
302 uint8_t error; 303 uint8_t error;
@@ -359,6 +360,7 @@ static void ide_identify(IDEState *s) @@ -359,6 +360,7 @@ static void ide_identify(IDEState *s)
359 { 360 {
360 uint16_t *p; 361 uint16_t *p;
361 unsigned int oldsize; 362 unsigned int oldsize;
  363 + char buf[20];
362 364
363 memset(s->io_buffer, 0, 512); 365 memset(s->io_buffer, 0, 512);
364 p = (uint16_t *)s->io_buffer; 366 p = (uint16_t *)s->io_buffer;
@@ -368,7 +370,8 @@ static void ide_identify(IDEState *s) @@ -368,7 +370,8 @@ static void ide_identify(IDEState *s)
368 put_le16(p + 4, 512 * s->sectors); /* XXX: retired, remove ? */ 370 put_le16(p + 4, 512 * s->sectors); /* XXX: retired, remove ? */
369 put_le16(p + 5, 512); /* XXX: retired, remove ? */ 371 put_le16(p + 5, 512); /* XXX: retired, remove ? */
370 put_le16(p + 6, s->sectors); 372 put_le16(p + 6, s->sectors);
371 - padstr((uint8_t *)(p + 10), "QM00001", 20); /* serial number */ 373 + snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial);
  374 + padstr((uint8_t *)(p + 10), buf, 20); /* serial number */
372 put_le16(p + 20, 3); /* XXX: retired, remove ? */ 375 put_le16(p + 20, 3); /* XXX: retired, remove ? */
373 put_le16(p + 21, 512); /* cache size in sectors */ 376 put_le16(p + 21, 512); /* cache size in sectors */
374 put_le16(p + 22, 4); /* ecc bytes */ 377 put_le16(p + 22, 4); /* ecc bytes */
@@ -404,12 +407,14 @@ static void ide_identify(IDEState *s) @@ -404,12 +407,14 @@ static void ide_identify(IDEState *s)
404 static void ide_atapi_identify(IDEState *s) 407 static void ide_atapi_identify(IDEState *s)
405 { 408 {
406 uint16_t *p; 409 uint16_t *p;
  410 + char buf[20];
407 411
408 memset(s->io_buffer, 0, 512); 412 memset(s->io_buffer, 0, 512);
409 p = (uint16_t *)s->io_buffer; 413 p = (uint16_t *)s->io_buffer;
410 /* Removable CDROM, 50us response, 12 byte packets */ 414 /* Removable CDROM, 50us response, 12 byte packets */
411 put_le16(p + 0, (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0)); 415 put_le16(p + 0, (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0));
412 - padstr((uint8_t *)(p + 10), "QM00001", 20); /* serial number */ 416 + snprintf(buf, sizeof(buf), "QM%05d", s->drive_serial);
  417 + padstr((uint8_t *)(p + 10), buf, 20); /* serial number */
413 put_le16(p + 20, 3); /* buffer type */ 418 put_le16(p + 20, 3); /* buffer type */
414 put_le16(p + 21, 512); /* cache size in sectors */ 419 put_le16(p + 21, 512); /* cache size in sectors */
415 put_le16(p + 22, 4); /* ecc bytes */ 420 put_le16(p + 22, 4); /* ecc bytes */
@@ -1432,6 +1437,7 @@ void ide_init(int iobase, int iobase2, int irq, @@ -1432,6 +1437,7 @@ void ide_init(int iobase, int iobase2, int irq,
1432 BlockDriverState *hd0, BlockDriverState *hd1) 1437 BlockDriverState *hd0, BlockDriverState *hd1)
1433 { 1438 {
1434 IDEState *s, *ide_state; 1439 IDEState *s, *ide_state;
  1440 + static int drive_serial = 1;
1435 int i, cylinders, heads, secs; 1441 int i, cylinders, heads, secs;
1436 int64_t nb_sectors; 1442 int64_t nb_sectors;
1437 1443
@@ -1473,6 +1479,7 @@ void ide_init(int iobase, int iobase2, int irq, @@ -1473,6 +1479,7 @@ void ide_init(int iobase, int iobase2, int irq,
1473 bdrv_set_change_cb(s->bs, cdrom_change_cb, s); 1479 bdrv_set_change_cb(s->bs, cdrom_change_cb, s);
1474 } 1480 }
1475 } 1481 }
  1482 + s->drive_serial = drive_serial++;
1476 s->irq = irq; 1483 s->irq = irq;
1477 ide_reset(s); 1484 ide_reset(s);
1478 } 1485 }