mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
qemu: Use the 'device_id' property of SCSI disks to avoid regressing
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 <pkrempa@redhat.com>
This commit is contained in:
parent
85a8e364f3
commit
a1dce96236
@ -1890,6 +1890,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
||||
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
||||
const char *contAlias;
|
||||
char *backendAlias = NULL;
|
||||
char *scsiVPDDeviceId = NULL;
|
||||
int controllerModel;
|
||||
|
||||
if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
|
||||
@ -1979,6 +1980,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 device
|
||||
* 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 = qemuAliasDiskDriveFromDisk(disk)))
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
|
||||
@ -2021,6 +2037,10 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
||||
disk->info.addr.drive.target,
|
||||
disk->info.addr.drive.unit);
|
||||
}
|
||||
|
||||
if (scsiVPDDeviceId)
|
||||
virBufferStrcat(&opt, ",device_id=", scsiVPDDeviceId, NULL);
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
|
@ -30,20 +30,20 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
||||
-device virtio-scsi-pci,id=scsi3,max_sectors=512,bus=pci.0,addr=0x5 \
|
||||
-device virtio-scsi-pci,id=scsi4,ioeventfd=on,bus=pci.0,addr=0x6 \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,\
|
||||
id=scsi0-0-0-0,bootindex=1 \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi0-0-0-0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 \
|
||||
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-scsi1-0-0-0 \
|
||||
-device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,\
|
||||
id=scsi1-0-0-0 \
|
||||
-device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi1-0-0-0,drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \
|
||||
-drive file=/dev/HostVG/QEMUGuest3,format=raw,if=none,id=drive-scsi2-0-0-0 \
|
||||
-device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi2-0-0-0,\
|
||||
id=scsi2-0-0-0 \
|
||||
-device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi2-0-0-0,drive=drive-scsi2-0-0-0,id=scsi2-0-0-0 \
|
||||
-drive file=/dev/HostVG/QEMUGuest4,format=raw,if=none,id=drive-scsi3-0-0-0 \
|
||||
-device scsi-hd,bus=scsi3.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi3-0-0-0,\
|
||||
id=scsi3-0-0-0 \
|
||||
-device scsi-hd,bus=scsi3.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi3-0-0-0,drive=drive-scsi3-0-0-0,id=scsi3-0-0-0 \
|
||||
-drive file=/dev/HostVG/QEMUGuest5,format=raw,if=none,id=drive-scsi4-0-0-0 \
|
||||
-device scsi-hd,bus=scsi4.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi4-0-0-0,\
|
||||
id=scsi4-0-0-0 \
|
||||
-device scsi-hd,bus=scsi4.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi4-0-0-0,drive=drive-scsi4-0-0-0,id=scsi4-0-0-0 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
|
@ -35,8 +35,8 @@ cache=unsafe \
|
||||
write-cache=on \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\
|
||||
cache=none \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,\
|
||||
write-cache=on \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,device_id=drive-scsi0-0-0,\
|
||||
drive=drive-scsi0-0-0,id=scsi0-0-0,write-cache=on \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\
|
||||
cache=writethrough \
|
||||
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
|
||||
|
@ -28,7 +28,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
||||
-drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi0-0-0 \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,device_id=drive-scsi0-0-0,\
|
||||
drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
|
@ -31,16 +31,18 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
||||
-drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi0-0-0 \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
||||
-device scsi-hd,bus=scsi0.0,scsi-id=0,device_id=drive-scsi0-0-0,\
|
||||
drive=drive-scsi0-0-0,id=scsi0-0-0 \
|
||||
-drive file=/tmp/scsidisk2.img,format=raw,if=none,id=drive-scsi1-0-0-0 \
|
||||
-device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,\
|
||||
id=scsi1-0-0-0,serial=abcdefghijklmn \
|
||||
-device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,device_id=abcdefghijklmn,\
|
||||
drive=drive-scsi1-0-0-0,id=scsi1-0-0-0,serial=abcdefghijklmn \
|
||||
-drive file=/tmp/scsidisk3.img,format=raw,if=none,id=drive-scsi2-0-0-0 \
|
||||
-device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi2-0-0-0,\
|
||||
id=scsi2-0-0-0,wwn=0x5000c50015ea71ac \
|
||||
-device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi2-0-0-0,drive=drive-scsi2-0-0-0,id=scsi2-0-0-0,\
|
||||
wwn=0x5000c50015ea71ac \
|
||||
-drive file=/tmp/scsidisk4.img,format=raw,if=none,id=drive-scsi3-0-0-0 \
|
||||
-device scsi-hd,bus=scsi3.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi3-0-0-0,\
|
||||
id=scsi3-0-0-0 \
|
||||
-device scsi-hd,bus=scsi3.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi3-0-0-0,drive=drive-scsi3-0-0-0,id=scsi3-0-0-0 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
|
@ -33,8 +33,9 @@ bootindex=1,write-cache=on,serial=XYZXYZXYZYXXYZYZYXYZY \
|
||||
readonly=on \
|
||||
-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
|
||||
-drive file=/dev/scsi,format=raw,if=none,id=drive-scsi0-0-0-0,cache=none \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,share-rw=on,\
|
||||
drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,write-cache=on \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
|
||||
device_id=drive-scsi0-0-0-0,share-rw=on,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,\
|
||||
write-cache=on \
|
||||
-drive file=/dev/virtio,format=raw,if=none,id=drive-virtio-disk0,cache=none \
|
||||
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,share-rw=on,\
|
||||
drive=drive-virtio-disk0,id=virtio-disk0,write-cache=on \
|
||||
|
@ -35,8 +35,8 @@ id=drive-virtio-disk1 \
|
||||
drive=drive-virtio-disk1,id=virtio-disk1 \
|
||||
-drive file=/var/lib/libvirt/images/iothrtest2.img,format=raw,if=none,\
|
||||
id=drive-scsi0-0-0-3 \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=3,drive=drive-scsi0-0-0-3,\
|
||||
id=scsi0-0-0-3 \
|
||||
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=3,\
|
||||
device_id=drive-scsi0-0-0-3,drive=drive-scsi0-0-0-3,id=scsi0-0-0-3 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
-msg timestamp=on
|
||||
|
Loading…
Reference in New Issue
Block a user