On Fri, Sep 13, 2013 at 11:34:36AM +0800, Chunyan Liu wrote: > Change qemu driver to use hostdev common library instead of APIs in > qemu_hostdev.[ch] > > Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> > --- > po/POTFILES.in | 1 - > src/Makefile.am | 1 - > src/qemu/qemu_command.c | 1 - > src/qemu/qemu_conf.h | 9 +- > src/qemu/qemu_driver.c | 72 +--- > src/qemu/qemu_hostdev.c | 1289 ----------------------------------------------- > src/qemu/qemu_hostdev.h | 72 --- > src/qemu/qemu_hotplug.c | 126 ++--- > src/qemu/qemu_process.c | 34 +- > 9 files changed, 87 insertions(+), 1518 deletions(-) > delete mode 100644 src/qemu/qemu_hostdev.c > delete mode 100644 src/qemu/qemu_hostdev.h > > diff --git a/po/POTFILES.in b/po/POTFILES.in > index d01cb99..2fc7e67 100644 > --- a/po/POTFILES.in > +++ b/po/POTFILES.in > @@ -99,7 +99,6 @@ src/qemu/qemu_command.c > src/qemu/qemu_conf.c > src/qemu/qemu_domain.c > src/qemu/qemu_driver.c > -src/qemu/qemu_hostdev.c > src/qemu/qemu_hotplug.c > src/qemu/qemu_migration.c > src/qemu/qemu_monitor.c > diff --git a/src/Makefile.am b/src/Makefile.am > index e563960..c3a8ba0 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -654,7 +654,6 @@ QEMU_DRIVER_SOURCES = \ > qemu/qemu_command.c qemu/qemu_command.h \ > qemu/qemu_domain.c qemu/qemu_domain.h \ > qemu/qemu_cgroup.c qemu/qemu_cgroup.h \ > - qemu/qemu_hostdev.c qemu/qemu_hostdev.h \ > qemu/qemu_hotplug.c qemu/qemu_hotplug.h \ > qemu/qemu_hotplugpriv.h \ > qemu/qemu_conf.c qemu/qemu_conf.h \ > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index 1521431..3abb88d 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -24,7 +24,6 @@ > #include <config.h> > > #include "qemu_command.h" > -#include "qemu_hostdev.h" > #include "qemu_capabilities.h" > #include "qemu_bridge_filter.h" > #include "cpu/cpu.h" > diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h > index 206f2c6..97c8501 100644 > --- a/src/qemu/qemu_conf.h > +++ b/src/qemu/qemu_conf.h > @@ -52,6 +52,7 @@ > # error "Port me" > # endif > > +# define QEMU_DRIVER_NAME "QEMU" > typedef struct _virQEMUDriver virQEMUDriver; > typedef virQEMUDriver *virQEMUDriverPtr; > > @@ -204,14 +205,6 @@ struct _virQEMUDriver { > /* Immutable pointer. self-locking APIs */ > virSecurityManagerPtr securityManager; > > - /* Immutable pointers. Requires locks to be held before > - * calling APIs. activePciHostdevs must be locked before > - * inactivePciHostdevs */ > - virPCIDeviceListPtr activePciHostdevs; > - virPCIDeviceListPtr inactivePciHostdevs; > - virUSBDeviceListPtr activeUsbHostdevs; > - virSCSIDeviceListPtr activeScsiHostdevs; > - > /* Immutable pointer. Unsafe APIs. XXX */ > virHashTablePtr sharedDevices; > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index bbf2d23..b289a30 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -50,7 +50,6 @@ > #include "qemu_capabilities.h" > #include "qemu_command.h" > #include "qemu_cgroup.h" > -#include "qemu_hostdev.h" > #include "qemu_hotplug.h" > #include "qemu_monitor.h" > #include "qemu_bridge_filter.h" > @@ -94,11 +93,10 @@ > #include "virstring.h" > #include "viraccessapicheck.h" > #include "viraccessapicheckqemu.h" > +#include "virhostdev.h" > > #define VIR_FROM_THIS VIR_FROM_QEMU > > -#define QEMU_DRIVER_NAME "QEMU" > - > #define QEMU_NB_MEM_PARAM 3 > > #define QEMU_NB_BLOCK_IO_TUNE_PARAM 6 > @@ -691,18 +689,6 @@ qemuStateInitialize(bool privileged, > if (qemuSecurityInit(qemu_driver) < 0) > goto error; > > - if ((qemu_driver->activePciHostdevs = virPCIDeviceListNew()) == NULL) > - goto error; > - > - if ((qemu_driver->activeUsbHostdevs = virUSBDeviceListNew()) == NULL) > - goto error; > - > - if ((qemu_driver->inactivePciHostdevs = virPCIDeviceListNew()) == NULL) > - goto error; > - > - if ((qemu_driver->activeScsiHostdevs = virSCSIDeviceListNew()) == NULL) > - goto error; > - > if (!(qemu_driver->sharedDevices = virHashCreate(30, qemuSharedDeviceEntryFree))) > goto error; > > @@ -983,9 +969,6 @@ qemuStateCleanup(void) { > > virNWFilterUnRegisterCallbackDriver(&qemuCallbackDriver); > virObjectUnref(qemu_driver->config); > - virObjectUnref(qemu_driver->activePciHostdevs); > - virObjectUnref(qemu_driver->inactivePciHostdevs); > - virObjectUnref(qemu_driver->activeUsbHostdevs); > virHashFree(qemu_driver->sharedDevices); > virObjectUnref(qemu_driver->caps); > virQEMUCapsCacheFree(qemu_driver->qemuCapsCache); > @@ -10689,12 +10672,12 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, > const char *driverName, > unsigned int flags) > { > - virQEMUDriverPtr driver = dev->conn->privateData; > virPCIDevicePtr pci = NULL; > unsigned domain = 0, bus = 0, slot = 0, function = 0; > int ret = -1; > virNodeDeviceDefPtr def = NULL; > char *xml = NULL; > + virHostdevManagerPtr hostdev_mgr; > > virCheckFlags(0, -1); > > @@ -10728,18 +10711,12 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, > goto cleanup; > } > > - virObjectLock(driver->activePciHostdevs); > - virObjectLock(driver->inactivePciHostdevs); > - > - if (virPCIDeviceDetach(pci, driver->activePciHostdevs, > - driver->inactivePciHostdevs) < 0) { > - goto out; > + hostdev_mgr = virHostdevManagerGetDefault(); Check for NULL, and other places throughout the file > + if (virHostdevPciNodeDeviceDetach(hostdev_mgr, pci) < 0) { > + goto cleanup; > } While you're changing this, remove the {} since they are not wanted for single-line blocks. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list