From: Andrea Bolognani Date: Thu, 17 Dec 2015 14:11:27 +0000 (+0100) Subject: hostdev: Only rollback detach of managed devices on error X-Git-Tag: v1.3.1-rc1~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e926df601d9ec420aa04e38fb74bfba93141aee2;p=thirdparty%2Flibvirt.git hostdev: Only rollback detach of managed devices on error Since we don't detach unmanaged devices before attaching them to a domain, we shouldn't reattach them to rollback an error either. --- diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index afacd4e9b9..c8da8e5afd 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -711,12 +711,14 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr, for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); - /* NB: This doesn't actually re-bind to original driver, just - * unbinds from the stub driver - */ - ignore_value(virPCIDeviceReattach(dev, - hostdev_mgr->activePCIHostdevs, - hostdev_mgr->inactivePCIHostdevs)); + if (virPCIDeviceGetManaged(dev)) { + /* NB: This doesn't actually re-bind to original driver, just + * unbinds from the stub driver + */ + ignore_value(virPCIDeviceReattach(dev, + hostdev_mgr->activePCIHostdevs, + hostdev_mgr->inactivePCIHostdevs)); + } } cleanup: