mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: Prohibit reattaching node device if it is in use
It doesn't make sense to reattach a device to host while it's still in use, e.g, by a domain.
This commit is contained in:
parent
6be610bfaa
commit
7aeb9794d2
@ -9244,6 +9244,7 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
|
|||||||
{
|
{
|
||||||
struct qemud_driver *driver = dev->conn->privateData;
|
struct qemud_driver *driver = dev->conn->privateData;
|
||||||
pciDevice *pci;
|
pciDevice *pci;
|
||||||
|
pciDevice *other;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -9254,6 +9255,20 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
other = pciDeviceListFind(driver->activePciHostdevs, pci);
|
||||||
|
if (other) {
|
||||||
|
const char *other_name = pciDeviceGetUsedBy(other);
|
||||||
|
|
||||||
|
if (other_name)
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("PCI device %s is still in use by domain %s"),
|
||||||
|
pciDeviceGetName(pci), other_name);
|
||||||
|
else
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("PCI device %s is still in use"),
|
||||||
|
pciDeviceGetName(pci));
|
||||||
|
}
|
||||||
|
|
||||||
pciDeviceReAttachInit(pci);
|
pciDeviceReAttachInit(pci);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user