|
|
7711c0 |
From 4907989f1e3ccfa465a919c3a66e7f5a460bffe1 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Date: Wed, 6 Feb 2019 15:58:29 +0100
|
|
|
7711c0 |
Subject: [PATCH 09/33] scsi-disk: Add device_id property
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-id: <20190206155829.14641-3-kwolf@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 84254
|
|
|
7711c0 |
O-Subject: [RHEL-7.7/8.0-AV qemu-kvm-rhev PATCH 2/2] scsi-disk: Add device_id property
|
|
|
7711c0 |
Bugzilla: 1673080
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
The new device_id property specifies which value to use for the vendor
|
|
|
7711c0 |
specific designator in the Device Identification VPD page.
|
|
|
7711c0 |
|
|
|
7711c0 |
In particular, this is necessary for libvirt to maintain guest ABI
|
|
|
7711c0 |
compatibility when no serial number is given and a VM is switched from
|
|
|
7711c0 |
-drive (where the BlockBackend name is used) to -blockdev (where the
|
|
|
7711c0 |
vendor specific designator is left out by default).
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 7471a649fc3a391dd497297013fb2525ca9821ba)
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
hw/scsi/scsi-disk.c | 24 ++++++++++++++++--------
|
|
|
7711c0 |
1 file changed, 16 insertions(+), 8 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
|
|
|
7711c0 |
index de6c7bc..8033d7e 100644
|
|
|
7711c0 |
--- a/hw/scsi/scsi-disk.c
|
|
|
7711c0 |
+++ b/hw/scsi/scsi-disk.c
|
|
|
7711c0 |
@@ -103,6 +103,7 @@ typedef struct SCSIDiskState
|
|
|
7711c0 |
char *serial;
|
|
|
7711c0 |
char *vendor;
|
|
|
7711c0 |
char *product;
|
|
|
7711c0 |
+ char *device_id;
|
|
|
7711c0 |
bool tray_open;
|
|
|
7711c0 |
bool tray_locked;
|
|
|
7711c0 |
/*
|
|
|
7711c0 |
@@ -638,13 +639,8 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
|
|
|
7711c0 |
|
|
|
7711c0 |
case 0x83: /* Device identification page, mandatory */
|
|
|
7711c0 |
{
|
|
|
7711c0 |
- const char *str = s->serial ?: blk_name(s->qdev.conf.blk);
|
|
|
7711c0 |
- int max_len = s->serial ? 20 : 255 - 8;
|
|
|
7711c0 |
- int id_len = strlen(str);
|
|
|
7711c0 |
+ int id_len = s->device_id ? MIN(strlen(s->device_id), 255 - 8) : 0;
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (id_len > max_len) {
|
|
|
7711c0 |
- id_len = max_len;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
DPRINTF("Inquiry EVPD[Device identification] "
|
|
|
7711c0 |
"buffer size %zd\n", req->cmd.xfer);
|
|
|
7711c0 |
|
|
|
7711c0 |
@@ -653,7 +649,7 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
|
|
|
7711c0 |
outbuf[buflen++] = 0; /* not officially assigned */
|
|
|
7711c0 |
outbuf[buflen++] = 0; /* reserved */
|
|
|
7711c0 |
outbuf[buflen++] = id_len; /* length of data following */
|
|
|
7711c0 |
- memcpy(outbuf + buflen, str, id_len);
|
|
|
7711c0 |
+ memcpy(outbuf + buflen, s->device_id, id_len);
|
|
|
7711c0 |
buflen += id_len;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
@@ -2360,6 +2356,16 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
|
|
|
7711c0 |
if (!s->vendor) {
|
|
|
7711c0 |
s->vendor = g_strdup("QEMU");
|
|
|
7711c0 |
}
|
|
|
7711c0 |
+ if (!s->device_id) {
|
|
|
7711c0 |
+ if (s->serial) {
|
|
|
7711c0 |
+ s->device_id = g_strdup_printf("%.20s", s->serial);
|
|
|
7711c0 |
+ } else {
|
|
|
7711c0 |
+ const char *str = blk_name(s->qdev.conf.blk);
|
|
|
7711c0 |
+ if (str && *str) {
|
|
|
7711c0 |
+ s->device_id = g_strdup(str);
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
|
|
|
7711c0 |
if (blk_is_sg(s->qdev.conf.blk)) {
|
|
|
7711c0 |
error_setg(errp, "unwanted /dev/sg*");
|
|
|
7711c0 |
@@ -2895,7 +2901,9 @@ static const TypeInfo scsi_disk_base_info = {
|
|
|
7711c0 |
DEFINE_PROP_STRING("ver", SCSIDiskState, version), \
|
|
|
7711c0 |
DEFINE_PROP_STRING("serial", SCSIDiskState, serial), \
|
|
|
7711c0 |
DEFINE_PROP_STRING("vendor", SCSIDiskState, vendor), \
|
|
|
7711c0 |
- DEFINE_PROP_STRING("product", SCSIDiskState, product)
|
|
|
7711c0 |
+ DEFINE_PROP_STRING("product", SCSIDiskState, product), \
|
|
|
7711c0 |
+ DEFINE_PROP_STRING("device_id", SCSIDiskState, device_id)
|
|
|
7711c0 |
+
|
|
|
7711c0 |
|
|
|
7711c0 |
static Property scsi_hd_properties[] = {
|
|
|
7711c0 |
DEFINE_SCSI_DISK_PROPERTIES(),
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|