[libvirt] [PATCH v13 04/49] add virhostdev files to maintain global state of host devices
Daniel P. Berrange
berrange at redhat.com
Tue Mar 4 12:28:29 UTC 2014
On Sat, Mar 01, 2014 at 02:28:59PM +0800, Chunyan Liu wrote:
>
> Signed-off-by: Chunyan Liu <cyliu at suse.com>
> ---
> 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 :|
More information about the libvir-list
mailing list