From: Michal Privoznik Date: Thu, 11 Apr 2019 13:45:27 +0000 (+0200) Subject: qemu_hotplug: Check for duplicate drive addresses X-Git-Tag: v5.3.0-rc1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddc72f99027b063feaf34e5fda89916b6b2c8943;p=thirdparty%2Flibvirt.git qemu_hotplug: Check for duplicate drive addresses This tries to fix the same problem as f1d65853000 but it's doing so in a less invasive way. Signed-off-by: Michal Privoznik Tested-by: Daniel Henrique Barboza Reviewed-by: Jim Fehlig --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 16da2b95fd..630be12d54 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1183,6 +1183,12 @@ qemuDomainAttachSCSIDisk(virQEMUDriverPtr driver, return -1; } + if (virDomainSCSIDriveAddressIsUsed(vm->def, &disk->info.addr.drive)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Domain already contains a disk with that address")); + return -1; + } + /* Let's make sure the disk has a controller defined and loaded before * trying to add it. The controller used by the disk must exist before a * qemu command line string is generated.