[libvirt] [PATCH 1/6] Add helper module for dealing with USB host devices

Daniel Veillard veillard at redhat.com
Wed Sep 2 09:12:17 UTC 2009


On Tue, Sep 01, 2009 at 04:28:54PM +0100, Daniel P. Berrange wrote:
> * src/Makefile.am: Add usb.h and usb.h to libvirt_util.la
> * src/libvirt_private.syms: Export symbols
> * src/usb.c, src/usb.h: Helper APIs for USB host devices
> ---
>  src/Makefile.am          |    1 +
>  src/hostusb.c            |  103 ++++++++++++++++++++++++++++++++++++++++++++++
>  src/hostusb.h            |   45 ++++++++++++++++++++
>  src/libvirt_private.syms |    4 ++
>  4 files changed, 153 insertions(+), 0 deletions(-)
>  create mode 100644 src/hostusb.c
>  create mode 100644 src/hostusb.h

  Sounds good

[...]
> +/* For virReportOOMError()  and virReportSystemError() */
> +#define VIR_FROM_THIS VIR_FROM_NONE

   VIR_FROM_STORAGE might be a bit more precise

> +usbDevice *
> +usbGetDevice(virConnectPtr conn,
> +             unsigned bus,
> +             unsigned devno)
> +{

 The function code should probably be #ifdef linux

> +    usbDevice *dev;
> +
> +    if (VIR_ALLOC(dev) < 0) {
> +        virReportOOMError(conn);
> +        return NULL;
> +    }
> +
> +    dev->bus     = bus;
> +    dev->dev     = devno;
> +
> +    snprintf(dev->name, sizeof(dev->name), "%.3o:%.3o",
> +             dev->bus, dev->dev);
> +    snprintf(dev->path, sizeof(dev->path),
> +             USB_DEVFS "%03o/%03o", dev->bus, dev->dev);
> +
> +    /* XXX fixme. this should be product/vendor */
> +    snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus, dev->dev);
> +
> +    VIR_DEBUG("%s %s: initialized", dev->id, dev->name);
> +
> +    return dev;

  with a #else emitting an error

   Those tiny things apart, ACK, looks fine !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list