提交 7aeb9794 编写于 作者: O Osier Yang 提交者: Eric Blake

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.
上级 6be610bf
......@@ -9244,6 +9244,7 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
{
struct qemud_driver *driver = dev->conn->privateData;
pciDevice *pci;
pciDevice *other;
unsigned domain, bus, slot, function;
int ret = -1;
......@@ -9254,6 +9255,20 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
if (!pci)
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);
qemuDriverLock(driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册