提交 fd930791 编写于 作者: P Paolo Bonzini

scsi: copy serial number into VPD page 0x83

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: NPaolo Bonzini <pbonzini@redhat.com>
上级 9bcaf4fe
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册