char *serial;
char *vendor;
char *product;
+ char *device_id;
bool tray_open;
bool tray_locked;
/*
case 0x83: /* Device identification page, mandatory */
{
- const char *str = s->serial ?: blk_name(s->qdev.conf.blk);
- int max_len = s->serial ? 20 : 255 - 8;
- int id_len = strlen(str);
+ int id_len = s->device_id ? MIN(strlen(s->device_id), 255 - 8) : 0;
- if (id_len > max_len) {
- id_len = max_len;
- }
DPRINTF("Inquiry EVPD[Device identification] "
"buffer size %zd\n", req->cmd.xfer);
outbuf[buflen++] = 0; /* not officially assigned */
outbuf[buflen++] = 0; /* reserved */
outbuf[buflen++] = id_len; /* length of data following */
- memcpy(outbuf + buflen, str, id_len);
+ memcpy(outbuf + buflen, s->device_id, id_len);
buflen += id_len;
}
if (!s->vendor) {
s->vendor = g_strdup("QEMU");
}
+ if (!s->device_id) {
+ if (s->serial) {
+ s->device_id = g_strdup_printf("%.20s", s->serial);
+ } else {
+ const char *str = blk_name(s->qdev.conf.blk);
+ if (str && *str) {
+ s->device_id = g_strdup(str);
+ }
+ }
+ }
if (blk_is_sg(s->qdev.conf.blk)) {
error_setg(errp, "unwanted /dev/sg*");
DEFINE_PROP_STRING("ver", SCSIDiskState, version), \
DEFINE_PROP_STRING("serial", SCSIDiskState, serial), \
DEFINE_PROP_STRING("vendor", SCSIDiskState, vendor), \
- DEFINE_PROP_STRING("product", SCSIDiskState, product)
+ DEFINE_PROP_STRING("product", SCSIDiskState, product), \
+ DEFINE_PROP_STRING("device_id", SCSIDiskState, device_id)
+
static Property scsi_hd_properties[] = {
DEFINE_SCSI_DISK_PROPERTIES(),