From nobody Fri Dec 19 19:16:24 2025 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 1548692421453620.8447739989625; Mon, 28 Jan 2019 08:20:21 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BEECC0C4273; Mon, 28 Jan 2019 16:20:17 +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 47D0284016; Mon, 28 Jan 2019 16:20: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 E996C3F60B; Mon, 28 Jan 2019 16:20:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0SGJdHP018327 for ; Mon, 28 Jan 2019 11:19:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4A8A682EDC; Mon, 28 Jan 2019 16:19:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3E8F82ED8 for ; Mon, 28 Jan 2019 16:19:38 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 28 Jan 2019 17:19:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 31/32] qemu: Use the 'device_id' property of SCSI disks to avoid regressing 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 28 Jan 2019 16:20:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" QEMU accidentally exposed the id of -drive (or same value as disk serial, if provided) in one of the identifiers visible from the guest. To avoid regression in case when -blockdev will be used we need to always specify it ourselves. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 22 +++++++++++++++++++ .../controller-virtio-scsi.x86_64-latest.args | 20 ++++++++--------- .../disk-cache.x86_64-latest.args | 4 ++-- .../disk-scsi-device-auto.x86_64-latest.args | 3 ++- .../disk-scsi.x86_64-latest.args | 16 ++++++++------ .../disk-shared.x86_64-latest.args | 5 +++-- ...threads-virtio-scsi-pci.x86_64-latest.args | 4 ++-- 7 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0a62317a33..2036ae663c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1873,6 +1873,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, const char *bus =3D virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; char *backendAlias =3D NULL; + char *scsiVPDDeviceId =3D NULL; int controllerModel; if (qemuCheckDiskConfig(disk, qemuCaps) < 0) @@ -1962,6 +1963,21 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBufferAddLit(&opt, "scsi-cd"); else virBufferAddLit(&opt, "scsi-hd"); + + /* qemu historically used the name of -drive as one of the dev= ice + * ids in the Vital Product Data Device Identification page if + * disk serial was not set and the disk serial otherwise. + * To avoid a guest-visible regression we need to provide it + * ourselves especially for cases when -blockdev will be used = */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID)) { + if (disk->serial) { + if (VIR_STRDUP(scsiVPDDeviceId, disk->serial) < 0) + goto error; + } else { + if (!(scsiVPDDeviceId =3D qemuAliasDiskDriveFromDisk(d= isk))) + goto error; + } + } } if (!(contAlias =3D virDomainControllerAliasFind(def, VIR_DOMAIN_C= ONTROLLER_TYPE_SCSI, @@ -2004,6 +2020,12 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, disk->info.addr.drive.target, disk->info.addr.drive.unit); } + + if (scsiVPDDeviceId) { + virBufferAddLit(&opt, ",device_id=3D"); + virBufferEscape(&opt, '\\', " ", "%s", scsiVPDDeviceId); + } + break; case VIR_DOMAIN_DISK_BUS_SATA: diff --git a/tests/qemuxml2argvdata/controller-virtio-scsi.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/controller-virtio-scsi.x86_64-latest.args index cf8a497eb7..095b4724d3 100644 --- a/tests/qemuxml2argvdata/controller-virtio-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/controller-virtio-scsi.x86_64-latest.args @@ -30,20 +30,20 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device virtio-scsi-pci,id=3Dscsi3,max_sectors=3D512,bus=3Dpci.0,addr=3D0x= 5 \ -device virtio-scsi-pci,id=3Dscsi4,ioeventfd=3Don,bus=3Dpci.0,addr=3D0x6 \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-scs= i0-0-0-0 \ --device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi0-0-0-0,\ -id=3Dscsi0-0-0-0,bootindex=3D1 \ +-device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi0-0-0-0,drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0,b= ootindex=3D1 \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-scs= i1-0-0-0 \ --device scsi-hd,bus=3Dscsi1.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi1-0-0-0,\ -id=3Dscsi1-0-0-0 \ +-device scsi-hd,bus=3Dscsi1.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi1-0-0-0,drive=3Ddrive-scsi1-0-0-0,id=3Dscsi1-0-0-0 \ -drive file=3D/dev/HostVG/QEMUGuest3,format=3Draw,if=3Dnone,id=3Ddrive-scs= i2-0-0-0 \ --device scsi-hd,bus=3Dscsi2.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi2-0-0-0,\ -id=3Dscsi2-0-0-0 \ +-device scsi-hd,bus=3Dscsi2.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi2-0-0-0,drive=3Ddrive-scsi2-0-0-0,id=3Dscsi2-0-0-0 \ -drive file=3D/dev/HostVG/QEMUGuest4,format=3Draw,if=3Dnone,id=3Ddrive-scs= i3-0-0-0 \ --device scsi-hd,bus=3Dscsi3.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi3-0-0-0,\ -id=3Dscsi3-0-0-0 \ +-device scsi-hd,bus=3Dscsi3.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi3-0-0-0,drive=3Ddrive-scsi3-0-0-0,id=3Dscsi3-0-0-0 \ -drive file=3D/dev/HostVG/QEMUGuest5,format=3Draw,if=3Dnone,id=3Ddrive-scs= i4-0-0-0 \ --device scsi-hd,bus=3Dscsi4.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi4-0-0-0,\ -id=3Dscsi4-0-0-0 \ +-device scsi-hd,bus=3Dscsi4.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi4-0-0-0,drive=3Ddrive-scsi4-0-0-0,id=3Dscsi4-0-0-0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x7 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args b/tests/q= emuxml2argvdata/disk-cache.x86_64-latest.args index 9220e6bee9..7f703d0861 100644 --- a/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args @@ -35,8 +35,8 @@ cache=3Dunsafe \ write-cache=3Don \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Dqcow2,if=3Dnone,id=3Ddrive-s= csi0-0-0,\ cache=3Dnone \ --device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,drive=3Ddrive-scsi0-0-0,id=3Dscs= i0-0-0,\ -write-cache=3Don \ +-device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,device_id=3Ddrive-scsi0-0-0,\ +drive=3Ddrive-scsi0-0-0,id=3Dscsi0-0-0,write-cache=3Don \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Dqcow2,if=3Dnone,id=3Ddrive-v= irtio-disk0,\ cache=3Dwritethrough \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Ddrive-vir= tio-disk0,\ diff --git a/tests/qemuxml2argvdata/disk-scsi-device-auto.x86_64-latest.arg= s b/tests/qemuxml2argvdata/disk-scsi-device-auto.x86_64-latest.args index 549a162808..508daa0365 100644 --- a/tests/qemuxml2argvdata/disk-scsi-device-auto.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-scsi-device-auto.x86_64-latest.args @@ -28,7 +28,8 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -drive file=3D/tmp/scsidisk.img,format=3Draw,if=3Dnone,id=3Ddrive-scsi0-0-= 0 \ --device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,drive=3Ddrive-scsi0-0-0,id=3Dscs= i0-0-0 \ +-device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,device_id=3Ddrive-scsi0-0-0,\ +drive=3Ddrive-scsi0-0-0,id=3Dscsi0-0-0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args b/tests/qe= muxml2argvdata/disk-scsi.x86_64-latest.args index 68a8b2921d..e5b930a28a 100644 --- a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args @@ -31,16 +31,18 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -drive file=3D/tmp/scsidisk.img,format=3Draw,if=3Dnone,id=3Ddrive-scsi0-0-= 0 \ --device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,drive=3Ddrive-scsi0-0-0,id=3Dscs= i0-0-0 \ +-device scsi-hd,bus=3Dscsi0.0,scsi-id=3D0,device_id=3Ddrive-scsi0-0-0,\ +drive=3Ddrive-scsi0-0-0,id=3Dscsi0-0-0 \ -drive file=3D/tmp/scsidisk2.img,format=3Draw,if=3Dnone,id=3Ddrive-scsi1-0= -0-0 \ --device scsi-hd,bus=3Dscsi1.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi1-0-0-0,\ -id=3Dscsi1-0-0-0,serial=3Dabcdefghijklmn \ +-device scsi-hd,bus=3Dscsi1.0,channel=3D0,scsi-id=3D0,lun=3D0,device_id=3D= abcdefghijklmn,\ +drive=3Ddrive-scsi1-0-0-0,id=3Dscsi1-0-0-0,serial=3Dabcdefghijklmn \ -drive file=3D/tmp/scsidisk3.img,format=3Draw,if=3Dnone,id=3Ddrive-scsi2-0= -0-0 \ --device scsi-hd,bus=3Dscsi2.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi2-0-0-0,\ -id=3Dscsi2-0-0-0,wwn=3D0x5000c50015ea71ac \ +-device scsi-hd,bus=3Dscsi2.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi2-0-0-0,drive=3Ddrive-scsi2-0-0-0,id=3Dscsi2-0-0-0,\ +wwn=3D0x5000c50015ea71ac \ -drive file=3D/tmp/scsidisk4.img,format=3Draw,if=3Dnone,id=3Ddrive-scsi3-0= -0-0 \ --device scsi-hd,bus=3Dscsi3.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi3-0-0-0,\ -id=3Dscsi3-0-0-0 \ +-device scsi-hd,bus=3Dscsi3.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi3-0-0-0,drive=3Ddrive-scsi3-0-0-0,id=3Dscsi3-0-0-0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/disk-shared.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-shared.x86_64-latest.args index 4913d1ed20..141cf735a5 100644 --- a/tests/qemuxml2argvdata/disk-shared.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-shared.x86_64-latest.args @@ -33,8 +33,9 @@ bootindex=3D1,write-cache=3Don,serial=3DXYZXYZXYZYXXYZYZY= XYZY \ readonly=3Don \ -device ide-cd,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-0 \ -drive file=3D/dev/scsi,format=3Draw,if=3Dnone,id=3Ddrive-scsi0-0-0-0,cach= e=3Dnone \ --device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,share-rw=3Do= n,\ -drive=3Ddrive-scsi0-0-0-0,id=3Dscsi0-0-0-0,write-cache=3Don \ +-device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,\ +device_id=3Ddrive-scsi0-0-0-0,share-rw=3Don,drive=3Ddrive-scsi0-0-0-0,id= =3Dscsi0-0-0-0,\ +write-cache=3Don \ -drive file=3D/dev/virtio,format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk0,c= ache=3Dnone \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,share-rw=3Don,\ drive=3Ddrive-virtio-disk0,id=3Dvirtio-disk0,write-cache=3Don \ diff --git a/tests/qemuxml2argvdata/iothreads-virtio-scsi-pci.x86_64-latest= .args b/tests/qemuxml2argvdata/iothreads-virtio-scsi-pci.x86_64-latest.args index 4513edcdd0..cde42c7dd1 100644 --- a/tests/qemuxml2argvdata/iothreads-virtio-scsi-pci.x86_64-latest.args +++ b/tests/qemuxml2argvdata/iothreads-virtio-scsi-pci.x86_64-latest.args @@ -35,8 +35,8 @@ id=3Ddrive-virtio-disk1 \ drive=3Ddrive-virtio-disk1,id=3Dvirtio-disk1 \ -drive file=3D/var/lib/libvirt/images/iothrtest2.img,format=3Draw,if=3Dnon= e,\ id=3Ddrive-scsi0-0-0-3 \ --device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D3,drive=3Ddriv= e-scsi0-0-0-3,\ -id=3Dscsi0-0-0-3 \ +-device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D3,\ +device_id=3Ddrive-scsi0-0-0-3,drive=3Ddrive-scsi0-0-0-3,id=3Dscsi0-0-0-3 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ -msg timestamp=3Don --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list