From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9fKN-0000Yk-OA for qemu-devel@nongnu.org; Mon, 19 Mar 2012 12:21:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9fK2-0008QD-H7 for qemu-devel@nongnu.org; Mon, 19 Mar 2012 12:20:59 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:50082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9fK2-0008P9-8e for qemu-devel@nongnu.org; Mon, 19 Mar 2012 12:20:38 -0400 Received: by mail-pz0-f45.google.com with SMTP id p14so11232567dad.4 for ; Mon, 19 Mar 2012 09:20:37 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 19 Mar 2012 17:19:33 +0100 Message-Id: <1332173975-29099-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332173975-29099-1-git-send-email-pbonzini@redhat.com> References: <1332173975-29099-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] scsi: copy serial number into VPD page 0x83 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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 7846f45..9949786 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -471,8 +471,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; @@ -486,7 +487,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.7.6