On Sat, Mar 01, 2014 at 02:28:59PM +0800, Chunyan Liu wrote: > > Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> > --- > po/POTFILES.in | 1 + > src/Makefile.am | 1 + > src/libvirt_private.syms | 4 ++ > src/util/virhostdev.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++ > src/util/virhostdev.h | 44 +++++++++++++++++++ > 5 files changed, 153 insertions(+), 0 deletions(-) > create mode 100644 src/util/virhostdev.c > create mode 100644 src/util/virhostdev.h > > +static void > +virHostdevManagerCleanup(void) > +{ > + if (!hostdevMgr) > + return; > + > + virObjectUnref(hostdevMgr->activePciHostdevs); > + virObjectUnref(hostdevMgr->inactivePciHostdevs); > + virObjectUnref(hostdevMgr->activeUsbHostdevs); Missing unref of activeScsiHostdevs that I'll push before pushing > + VIR_FREE(hostdevMgr->stateDir); > + > + VIR_FREE(hostdevMgr); > +} > + > +static int > +virHostdevOnceInit(void) > +{ > + if (VIR_ALLOC(hostdevMgr) < 0) > + goto error; > + > + if ((hostdevMgr->activePciHostdevs = virPCIDeviceListNew()) == NULL) > + goto error; > + > + if ((hostdevMgr->activeUsbHostdevs = virUSBDeviceListNew()) == NULL) > + goto error; > + > + if ((hostdevMgr->inactivePciHostdevs = virPCIDeviceListNew()) == NULL) > + goto error; > + > + if ((hostdevMgr->activeScsiHostdevs = virSCSIDeviceListNew()) == NULL) > + goto error; > + > + if (VIR_STRDUP(hostdevMgr->stateDir, HOSTDEV_STATE_DIR) < 0) > + goto error; > + > + if (virFileMakePath(hostdevMgr->stateDir) < 0) { > + virReportError(VIR_ERR_OPERATION_FAILED, > + _("Failed to create state dir '%s'"), > + hostdevMgr->stateDir); > + goto error; > + } > + > + return 0; > + > +error: > + virHostdevManagerCleanup(); > + return -1; > +} Regards, 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