From nobody Wed May 1 18:23:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548438443409647.1864010512057; Fri, 25 Jan 2019 09:47:23 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C4DBC0C0FB0; Fri, 25 Jan 2019 17:47:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37A7760565; Fri, 25 Jan 2019 17:47:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 748C4180339F; Fri, 25 Jan 2019 17:47:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0PHlE98012365 for ; Fri, 25 Jan 2019 12:47:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3E7F71054FDF; Fri, 25 Jan 2019 17:47:14 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-226.ams2.redhat.com [10.36.117.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F8841001F4A; Fri, 25 Jan 2019 17:47:12 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 25 Jan 2019 18:46:51 +0100 Message-Id: <20190125174653.4604-2-kwolf@redhat.com> In-Reply-To: <20190125174653.4604-1-kwolf@redhat.com> References: <20190125174653.4604-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Subject: [libvirt] [PATCH 1/3] scsi-disk: Don't use empty string as device id X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 25 Jan 2019 17:47:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" scsi-disk includes in the Device Identification VPD page, depending on configuration amongst others, a vendor specific designator that consists either of the serial number if given or the BlockBackend name (which is a host detail that better shouldn't have been leaked to the guest, but now we have to maintain it for compatibility). With anonymous BlockBackends, i.e. scsi-disk devices constructed with drive=3D, and no serial number explicitly specified, this ends up as an empty string. If this happens to more than one disk, we have accidentally signalled to the OS that this is a multipath setup, which is obviously not what was intended. Instead of using an empty string for the vendor specific designator, simply leave out that designator, which makes Linux detect such setups as separate disks again. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/scsi-disk.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 0e9027c8f3..93eef40b87 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -652,12 +652,14 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *re= q, uint8_t *outbuf) DPRINTF("Inquiry EVPD[Device identification] " "buffer size %zd\n", req->cmd.xfer); =20 - outbuf[buflen++] =3D 0x2; /* ASCII */ - outbuf[buflen++] =3D 0; /* not officially assigned */ - outbuf[buflen++] =3D 0; /* reserved */ - outbuf[buflen++] =3D id_len; /* length of data following */ - memcpy(outbuf + buflen, str, id_len); - buflen +=3D id_len; + if (id_len) { + outbuf[buflen++] =3D 0x2; /* ASCII */ + outbuf[buflen++] =3D 0; /* not officially assigned */ + outbuf[buflen++] =3D 0; /* reserved */ + outbuf[buflen++] =3D id_len; /* length of data following */ + memcpy(outbuf + buflen, str, id_len); + buflen +=3D id_len; + } =20 if (s->qdev.wwn) { outbuf[buflen++] =3D 0x1; /* Binary */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 18:23:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548438460637411.5366187690545; Fri, 25 Jan 2019 09:47:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D13EDA8F4; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9579C1054FDB; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4E1F718033A3; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0PHlGun012524 for ; Fri, 25 Jan 2019 12:47:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E705105706C; Fri, 25 Jan 2019 17:47:16 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-226.ams2.redhat.com [10.36.117.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DFDE1001F4A; Fri, 25 Jan 2019 17:47:14 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 25 Jan 2019 18:46:52 +0100 Message-Id: <20190125174653.4604-3-kwolf@redhat.com> In-Reply-To: <20190125174653.4604-1-kwolf@redhat.com> References: <20190125174653.4604-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Subject: [libvirt] [PATCH 2/3] scsi-disk: Add device_id property X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 25 Jan 2019 17:47:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The new device_id property specifies which value to use for the vendor specific designator in the Device Identification VPD page. In particular, this is necessary for libvirt to maintain guest ABI compatibility when no serial number is given and a VM is switched from -drive (where the BlockBackend name is used) to -blockdev (where the vendor specific designator is left out by default). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- hw/scsi/scsi-disk.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 93eef40b87..e74e1e7c48 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -104,6 +104,7 @@ typedef struct SCSIDiskState char *serial; char *vendor; char *product; + char *device_id; bool tray_open; bool tray_locked; /* @@ -642,13 +643,8 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req= , uint8_t *outbuf) =20 case 0x83: /* Device identification page, mandatory */ { - const char *str =3D s->serial ?: blk_name(s->qdev.conf.blk); - int max_len =3D s->serial ? 20 : 255 - 8; - int id_len =3D strlen(str); + int id_len =3D s->device_id ? MIN(strlen(s->device_id), 255 - 8) := 0; =20 - if (id_len > max_len) { - id_len =3D max_len; - } DPRINTF("Inquiry EVPD[Device identification] " "buffer size %zd\n", req->cmd.xfer); =20 @@ -657,7 +653,7 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req,= uint8_t *outbuf) outbuf[buflen++] =3D 0; /* not officially assigned */ outbuf[buflen++] =3D 0; /* reserved */ outbuf[buflen++] =3D id_len; /* length of data following */ - memcpy(outbuf + buflen, str, id_len); + memcpy(outbuf + buflen, s->device_id, id_len); buflen +=3D id_len; } =20 @@ -2363,6 +2359,16 @@ static void scsi_realize(SCSIDevice *dev, Error **er= rp) if (!s->vendor) { s->vendor =3D g_strdup("QEMU"); } + if (!s->device_id) { + if (s->serial) { + s->device_id =3D g_strdup_printf("%.20s", s->serial); + } else { + const char *str =3D blk_name(s->qdev.conf.blk); + if (str && *str) { + s->device_id =3D g_strdup(str); + } + } + } =20 if (blk_is_sg(s->qdev.conf.blk)) { error_setg(errp, "unwanted /dev/sg*"); @@ -2904,7 +2910,9 @@ static const TypeInfo scsi_disk_base_info =3D { 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) + =20 static Property scsi_hd_properties[] =3D { DEFINE_SCSI_DISK_PROPERTIES(), --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 18:23:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548438461071826.365237284053; Fri, 25 Jan 2019 09:47:41 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1F84C0BEAA4; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9509A1054FD8; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4C3DC3F605; Fri, 25 Jan 2019 17:47:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0PHlIh7012916 for ; Fri, 25 Jan 2019 12:47:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id BD1501057072; Fri, 25 Jan 2019 17:47:18 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-226.ams2.redhat.com [10.36.117.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF5181001F4A; Fri, 25 Jan 2019 17:47:16 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 25 Jan 2019 18:46:53 +0100 Message-Id: <20190125174653.4604-4-kwolf@redhat.com> In-Reply-To: <20190125174653.4604-1-kwolf@redhat.com> References: <20190125174653.4604-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Subject: [libvirt] [PATCH 3/3] scsi-disk: Deprecate device_id fallback to BlockBackend name X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 25 Jan 2019 17:47:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We should never have exposed BlockBackend names to the guest, it's a host detail. Deprecate this behaviour. Users who need to maintain the guest ABI can explicitly set the value with the device_id property. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- hw/scsi/scsi-disk.c | 5 +++++ qemu-deprecated.texi | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e74e1e7c48..38f1fe2570 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2366,6 +2366,11 @@ static void scsi_realize(SCSIDevice *dev, Error **er= rp) const char *str =3D blk_name(s->qdev.conf.blk); if (str && *str) { s->device_id =3D g_strdup(str); + warn_report("Using the backend drive ID for the Device " + "Identification VPD page is deprecated. " + "Please specify the serial or device_id option= s " + "explicitly to avoid guest-visible changes in " + "future QEMU versions."); } } } diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 219206a836..a426d8245d 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -146,7 +146,7 @@ This machine type uses an unmaintained firmware, broken= in lots of ways, and unable to start post-2004 operating systems. 40p machine type should be used instead. =20 -@section Device options +@section Devices =20 @subsection Block device options =20 @@ -170,6 +170,26 @@ The above, converted to the current supported format: =20 @code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}} =20 +@subsection scsi-disk device identification (since 4.0.0) + +The Device Identification VPD page of ``scsi-disk'' devices contains a ven= dor +specific designator that can be explicitly specified using the ``device_id= '' +property since 4.0.0. + +If ``device_id'' is not given, the implementation falls back to reusing any +specified serial number for this field. If the serial number is not given +either and ``drive=3DX'' was used where ``X'' is a drive ID, this drive ID= is +given to the guest instead. This is backend information that should not +to be exposed to guests. + +Therefore, this behaviour is deprecated and future versions will change the +guest-visible behaviour (e.g. by leaving out the vendor specific designato= r) +for the case that neither ``device_id'' nor a serial number are given, but= a +drive ID is used to create the device. + +If you need the guest-visible information to stay unchanged, add an explic= it +``device_id'' option to your QEMU invocation. + @subsection vio-spapr-device device options =20 @subsubsection "irq": "" (since 3.0.0) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list