From de4aace4b0908f2c66f0530e2c35b31be1013a41 Mon Sep 17 00:00:00 2001 From: Chunyan Liu Date: Thu, 6 Mar 2014 15:14:44 +0800 Subject: [PATCH] extract general code of NodeDeviceReset --- src/qemu/qemu_driver.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 97da6b4b22..8756329ce5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11450,6 +11450,25 @@ cleanup: return ret; } +static int +virHostdevPciNodeDeviceReset(virHostdevManagerPtr hostdev_mgr, + virPCIDevicePtr pci) +{ + int ret = -1; + + virObjectLock(hostdev_mgr->activePciHostdevs); + virObjectLock(hostdev_mgr->inactivePciHostdevs); + if (virPCIDeviceReset(pci, hostdev_mgr->activePciHostdevs, + hostdev_mgr->inactivePciHostdevs) < 0) + goto out; + + ret = 0; +out: + virObjectUnlock(hostdev_mgr->inactivePciHostdevs); + virObjectUnlock(hostdev_mgr->activePciHostdevs); + return ret; +} + static int qemuNodeDeviceReset(virNodeDevicePtr dev) { @@ -11479,16 +11498,8 @@ qemuNodeDeviceReset(virNodeDevicePtr dev) if (!pci) goto cleanup; - virObjectLock(hostdev_mgr->activePciHostdevs); - virObjectLock(hostdev_mgr->inactivePciHostdevs); - if (virPCIDeviceReset(pci, hostdev_mgr->activePciHostdevs, - hostdev_mgr->inactivePciHostdevs) < 0) - goto out; + ret = virHostdevPciNodeDeviceReset(hostdev_mgr, pci); - ret = 0; -out: - virObjectUnlock(hostdev_mgr->inactivePciHostdevs); - virObjectUnlock(hostdev_mgr->activePciHostdevs); virPCIDeviceFree(pci); cleanup: virNodeDeviceDefFree(def); -- GitLab