mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Validate disk against domain def on coldplug
https://bugzilla.redhat.com/show_bug.cgi?id=1692296#c7
This is a counterpart for ddc72f9902
and implements the same
check for coldplug.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
7722606b36
commit
881686d4b1
@ -8066,6 +8066,21 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuCheckDiskConfigAgainstDomain(const virDomainDef *def,
|
||||||
|
const virDomainDiskDef *disk)
|
||||||
|
{
|
||||||
|
if (virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("Domain already contains a disk with that address"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
@ -8094,6 +8109,8 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
return -1;
|
return -1;
|
||||||
if (qemuCheckDiskConfig(disk, NULL) < 0)
|
if (qemuCheckDiskConfig(disk, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (qemuCheckDiskConfigAgainstDomain(vmdef, disk) < 0)
|
||||||
|
return -1;
|
||||||
if (virDomainDiskInsert(vmdef, disk) < 0)
|
if (virDomainDiskInsert(vmdef, disk) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
||||||
|
Loading…
Reference in New Issue
Block a user