From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: Re: [PATCH V8 3/7] libxl: add pvusb API Date: Tue, 27 Oct 2015 12:31:03 +0100 Message-ID: <562F6077.7000209@suse.com> References: <1445418510-19614-1-git-send-email-cyliu@suse.com> <1445418510-19614-4-git-send-email-cyliu@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1445418510-19614-4-git-send-email-cyliu@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chunyan Liu , xen-devel@lists.xen.org Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, george.dunlap@eu.citrix.com, Ian.Jackson@eu.citrix.com, jfehlig@suse.com, Simon Cao List-Id: xen-devel@lists.xenproject.org On 10/21/2015 11:08 AM, Chunyan Liu wrote: > Add pvusb APIs, including: > - attach/detach (create/destroy) virtual usb controller. > - attach/detach usb device > - list usb controller and usb devices > - some other helper functions > > Signed-off-by: Chunyan Liu > Signed-off-by: Simon Cao > > --- > changes: > - update COMPARE_USB to compare ctrl and port > - add check in usb_add/remove to disable non-Dom0 backend so that > not worring about codes which are effective on Dom0 but not > compatible on non-Dom0 backend. > - define READ_SUBPATH macro within functions > - do not initialize rc but give it value in each return case > - libxl__strdup gc or NOGC update, internal function using gc, > external using NOGC. > - address other comments from George and Ian J. > > tools/libxl/Makefile | 2 +- > tools/libxl/libxl.c | 53 ++ > tools/libxl/libxl.h | 74 ++ > tools/libxl/libxl_device.c | 5 +- > tools/libxl/libxl_internal.h | 18 + > tools/libxl/libxl_osdeps.h | 13 + > tools/libxl/libxl_pvusb.c | 1451 ++++++++++++++++++++++++++++++++++ > tools/libxl/libxl_types.idl | 57 ++ > tools/libxl/libxl_types_internal.idl | 1 + > tools/libxl/libxl_utils.c | 16 + > tools/libxl/libxl_utils.h | 5 + > 11 files changed, 1693 insertions(+), 2 deletions(-) > create mode 100644 tools/libxl/libxl_pvusb.c ... > diff --git a/tools/libxl/libxl_pvusb.c b/tools/libxl/libxl_pvusb.c > new file mode 100644 > index 0000000..aa1a653 > --- /dev/null > +++ b/tools/libxl/libxl_pvusb.c > @@ -0,0 +1,1451 @@ > +/* > + * Copyright (C) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. Hmm, shouldn't this be just "SUSE LINUX GmbH, ..."? > + * Author Chunyan Liu > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU Lesser General Public License as published > + * by the Free Software Foundation; version 2.1 only. with the special > + * exception on linking described in file LICENSE. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU Lesser General Public License for more details. > + */ ... > +/* Encode usb interface so that it could be written to xenstore as a key. > + * > + * Since xenstore key cannot include '.' or ':', we'll change '.' to '_', > + * change ':' to '-'. For example, 3-1:2.1 will be encoded to 3-1-2_1. > + * This will be used to save original driver of USB device to xenstore. > + */ > +static char *usb_interface_xenstore_encode(char *busid) > +{ > + char *str = strdup(busid); > + int i, len = strlen(str); > + > + for (i = 0; i < len; i++) { > + if (str[i] == '.') > + str[i] = '_'; > + if (str[i] == ':') Indentation. > + str[i] = '-'; > + } > + return str; > +} ... > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c > index 9c5c4d0..706a0c1 100644 > --- a/tools/libxl/libxl_utils.c > +++ b/tools/libxl/libxl_utils.c > @@ -1270,6 +1270,22 @@ int libxl__random_bytes(libxl__gc *gc, uint8_t *buf, size_t len) > return ret; > } > > +void libxl_device_usbctrl_list_free(libxl_device_usbctrl *list, int nr) > +{ > + int i; Blank line. > + for (i = 0; i < nr; i++) > + libxl_device_usbctrl_dispose(&list[i]); > + free(list); > +} > + > +void libxl_device_usb_list_free(libxl_device_usb *list, int nr) > +{ > + int i; Blank line. > + for (i = 0; i < nr; i++) > + libxl_device_usb_dispose(&list[i]); > + free(list); > +} Juergen