[libvirt] [PATCH] qemu: Prohibit reattaching node device if it is in use
Eric Blake
eblake at redhat.com
Wed Jan 18 00:19:18 UTC 2012
On 01/17/2012 01:31 PM, Osier Yang wrote:
> It doesn't make sense to reattach a device to host while it's
> still in use, e.g, by a domain.
> ---
> src/qemu/qemu_driver.c | 15 +++++++++++++++
> 1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 47e2380..c920bfd 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -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));
> + }
ACK and pushed.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120117/e564a9d1/attachment-0001.sig>
More information about the libvir-list
mailing list