From bb9de84f1d903d3d2086645deee14b1db90b67d6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 21 Mar 2012 09:28:36 -0300 Subject: [RHEL6 qemu-kvm PATCH 5/6] scsi: copy serial number into VPD page 0x83 RH-Author: Paolo Bonzini Message-id: <1332322116-12270-6-git-send-email-pbonzini@redhat.com> Patchwork-id: 38776 O-Subject: [RHEL 6.3 qemu-kvm PATCH 5/5] scsi: copy serial number into VPD page 0x83 Bugzilla: 801416 RH-Acked-by: Markus Armbruster RH-Acked-by: Laszlo Ersek RH-Acked-by: Gerd Hoffmann Bugzilla: 801416 Currently QEMU passes the qdev device id to the guest in an ASCII-string designator in page 0x83. While this is fine, it does not match what real hardware does; usually the ASCII-string designator there hosts another copy of the serial number (there can be other designators, for example with a world-wide name). Do the same for QEMU SCSI disks. ATAPI does not support VPD pages, so it does not matter there. Signed-off-by: Paolo Bonzini (cherry-picked from commit fd9307912d0a2ffa0310f9e20935d96d5af0a1ca) --- hw/scsi-disk.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Signed-off-by: Eduardo Habkost --- hw/scsi-disk.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 30858a4..e32f6bd 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -477,8 +477,9 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) case 0x83: /* Device identification page, mandatory */ { - int max_len = 255 - 8; - int id_len = strlen(bdrv_get_device_name(s->qdev.conf.bs)); + const char *str = s->serial ?: bdrv_get_device_name(s->qdev.conf.bs); + int max_len = s->serial ? 20 : 255 - 8; + int id_len = strlen(str); if (id_len > max_len) { id_len = max_len; @@ -492,7 +493,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) outbuf[buflen++] = 0; // reserved outbuf[buflen++] = id_len; // length of data following - memcpy(outbuf+buflen, bdrv_get_device_name(s->qdev.conf.bs), id_len); + memcpy(outbuf+buflen, str, id_len); buflen += id_len; break; } -- 1.7.3.2