On Tue, Jun 15, 2010 at 08:03:11AM -0400, Chris Lalancette wrote:
In the current libvirt PCI code, there is no checking whether
a PCI device is in use by a guest when doing node device
detach or reattach. This causes problems when a device is
assigned to a guest, and the administrator starts issuing
nodedevice commands. Make it so that we check the list
of active devices when trying to detach/reattach, and only
allow the operation if the device is not assigned to a guest.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 20 +++++++++++---------
src/util/pci.c | 16 ++++++++++++++--
src/util/pci.h | 4 ++--
src/xen/xen_driver.c | 4 ++--
4 files changed, 29 insertions(+), 15 deletions(-)
@@ -11179,6 +11179,7 @@ out:
static int
qemudNodeDeviceDettach (virNodeDevicePtr dev)
{
+ struct qemud_driver *driver = dev->conn->privateData;
pciDevice *pci;
unsigned domain, bus, slot, function;
int ret = -1;
@@ -11190,7 +11191,7 @@ qemudNodeDeviceDettach (virNodeDevicePtr dev)
if (!pci)
return -1;
- if (pciDettachDevice(pci) < 0)
+ if (pciDettachDevice(pci, driver->activePciHostdevs) < 0)
goto out;
ret = 0;
@@ -11202,6 +11203,7 @@ out:
static int
qemudNodeDeviceReAttach (virNodeDevicePtr dev)
{
+ struct qemud_driver *driver = dev->conn->privateData;
pciDevice *pci;
unsigned domain, bus, slot, function;
int ret = -1;
@@ -11213,7 +11215,7 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev)
if (!pci)
return -1;
- if (pciReAttachDevice(pci) < 0)
+ if (pciReAttachDevice(pci, driver->activePciHostdevs) < 0)
goto out;
ret = 0;
You're accessing 'driver' here without first locking it
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://deltacloud.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|