pvusb fixes
cover pvusb fixes
Patch series of pvusb fixes.
Chunyan Liu (4):
a fix in libxl_device_usbdev_list
correct libxl_write_exactly sizeof
cleanup redundant lstat in libxl_pvusb.c
fix a pvusb type check
tools/libxl/libxl_pvusb.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 1/4 a fix in libxl_device_usbdev_list
In testing with libvirt pvusb functionality, found a rc check error in libxl_device_usbdev_list. Correct it. This function is not used by xl.
--- tools/libxl/libxl_pvusb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/libxl/libxl_pvusb.c +3 -3
@@ -701,13 +701,13 @@ libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num) usbctrls =libxl__xs_directory (gc,XBT_NULL , path, &nc);for (i =0 ; i < nc; i++) { -int r, nd =0 ; +int rc, nd =0 ;libxl_device_usbdev *tmp =NULL ; - r =libxl__device_usbdev_list_for_usbctrl (gc, domid, + rc =libxl__device_usbdev_list_for_usbctrl (gc, domid,atoi (usbctrls[i]), &tmp, &nd); -if (!r || !nd)continue ; +if (rc || !nd)continue ; usbdevs =libxl__realloc (NOGC , usbdevs,sizeof (*usbdevs) * (*num + nd));
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 1/4] a fix in libxl_device_usbdev_list
Chunyan Liu writes ("[PATCH 1/4] a fix in libxl_device_usbdev_list"):
Quoted 2 lines
In testing with libvirt pvusb functionality, found a rc check error in
libxl_device_usbdev_list. Correct it.
Thanks. But now that I look at this code I'm not sure your fix is complete.
Quoted 8 lines
tools/libxl/libxl_pvusb.c +0
-0@@ -701,13 +701,13 @@ libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num) usbctrls =libxl__xs_directory (gc,XBT_NULL , path, &nc);for (i =0 ; i < nc; i++) {
tools/libxl/libxl_pvusb.c libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num) · line 710
Quoted 10 lines
tools/libxl/libxl_pvusb.c +3
-3-int r, nd =0 ; +int rc, nd =0 ;libxl_device_usbdev *tmp =NULL ; - r =libxl__device_usbdev_list_for_usbctrl (gc, domid, + rc =libxl__device_usbdev_list_for_usbctrl (gc, domid,atoi (usbctrls[i]), &tmp, &nd); -if (!r || !nd)continue ; +if (rc || !nd)continue ;
If libxl__device_usbdev_list_for_usbctrl fails, shouldn't libxl_device_usbdev_list fail too ?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/4] a fix in libxl_device_usbdev_list
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 4/8/2016 at 12:45 AM, in message
<[email protected]>, Ian Jackson
Quoted 27 lines · <[email protected]> wrote:
Chunyan Liu writes ("[PATCH 1/4] a fix in
libxl_device_usbdev_list"):Quoted 2 lines
In testing with libvirt pvusb functionality, found a rc check error in
libxl_device_usbdev_list. Correct it.Thanks. But now that I look at this code I'm not sure your fix is complete.
tools/libxl/libxl_pvusb.c libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t
Quoted 5 lines
tools/libxl/libxl_pvusb.c +0
-0@@ -701,13 +701,13 @@ libxl_device_usbdev_list(libxl_ctx *ctx, uint32_tdomid, int *num)
tools/libxl/libxl_pvusb.c libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num) · line 710
Quoted 13 lines
tools/libxl/libxl_pvusb.c +3
-3usbctrls =libxl__xs_directory (gc,XBT_NULL , path, &nc);for (i =0 ; i < nc; i++) { -int r, nd =0 ; +int rc, nd =0 ;libxl_device_usbdev *tmp =NULL ; - r =libxl__device_usbdev_list_for_usbctrl (gc, domid, + rc =libxl__device_usbdev_list_for_usbctrl (gc, domid,atoi (usbctrls[i]), &tmp, &nd); -if (!r || !nd)continue ; +if (rc || !nd)continue ;
Quoted 2 lines
If
libxl__device_usbdev_list_for_usbctrlfails, shouldn'tlibxl_device_usbdev_listfail too ?
Following the similar definitions of other device types, the return value of this function is "libxl_device_usbdev *", to treat the above case as failure, it cannot be reflected through return value, we can only set return value to NULL, but that will be confusing with a real no-device case.
- Chunyan
Quoted 4 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ian Jackson
Acked-byRe: [PATCH 1/4] a fix in libxl_device_usbdev_list
Chun Yan Liu writes ("Re: [PATCH 1/4] a fix in libxl_device_usbdev_list"):
Quoted 10 lines
Quoted 2 lines · Ian Jackson
If
libxl__device_usbdev_list_for_usbctrlfails, shouldn'tlibxl_device_usbdev_listfail too ?Following the similar definitions of other device types, the return value of this function is "
libxl_device_usbdev*", to treat the above case as failure, it cannot be reflected through return value, we can only set return value to NULL, but that will be confusing with a real no-device case.
Urk. Yes, you're right. *sigh*
We won't fix that bad API pattern for 4.7. So
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/4] a fix in libxl_device_usbdev_list
Ian Jackson writes ("Re: [PATCH 1/4] a fix in libxl_device_usbdev_list"):
Quoted 3 lines
We won't fix that bad API pattern for 4.7. So
Acked-by Ian Jackson <[email protected]>
Queued.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/4] a fix in libxl_device_usbdev_list
In reply to Chunyan LiuChunyan Liu writes ("[PATCH 1/4] a fix in libxl_device_usbdev_list"):
Quoted 3 lines
In testing with libvirt pvusb functionality, found a rc check error in
libxl_device_usbdev_list. Correct it. This function is not used by xl.
Thanks for these. I have applied 2,3, and 4. But not 1, as I had comments on it.
Regards,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/4 correct libxl_write_exactly sizeof
In reply to Chunyan Liusizeof is wrongly used in libxl_write_exactly function, using strlen instead.
CID: 1358110
CID: 1358109
--- tools/libxl/libxl_pvusb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_pvusb.c +2 -2
@@ -1025,7 +1025,7 @@ static int unbind_usbintf(libxl__gc *gc, const char *intf) goto out; } -if (libxl_write_exactly (CTX , fd, intf,sizeof (intf), path, intf)) { +if (libxl_write_exactly (CTX , fd, intf,strlen (intf), path, intf)) { rc =ERROR_FAIL ; goto out; }
@@ -1065,7 +1065,7 @@ static int bind_usbintf(libxl__gc *gc, const char *intf, const char *drvpath) goto out; } -if (libxl_write_exactly (CTX , fd, intf,sizeof (intf), path, intf)) { +if (libxl_write_exactly (CTX , fd, intf,strlen (intf), path, intf)) { rc =ERROR_FAIL ; goto out; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 2/4] correct libxl_write_exactly sizeof
Chunyan Liu writes ("[PATCH 2/4] correct libxl_write_exactly sizeof"):
Quoted 2 lines
sizeof is wrongly used in
libxl_write_exactlyfunction, using strlen instead.
thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 3/4 cleanup redundant lstat in libxl_pvusb.c
In reply to Chunyan LiuCID: 1358112
--- tools/libxl/libxl_pvusb.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
tools/libxl/libxl_pvusb.c +5 -16
@@ -983,25 +983,14 @@ static char *usbdev_busid_from_ctrlport(libxl__gc *gc, uint32_t domid,static int usbintf_get_drvpath (libxl__gc *gc,const char *intf,char **drvpath) {char *spath, *dp =NULL ; -struct stat st; -int r; spath =GCSPRINTF (SYSFS_USB_DEV "/%s/driver" , intf); - r =lstat (spath, &st); -if (r ==0 ) { -/* Find the canonical path to the driver. */ - dp =libxl__zalloc (gc,PATH_MAX ); - dp =realpath (spath, dp); -if (!dp) { -LOGE (ERROR ,"get realpath failed: '%s'" , spath); -return ERROR_FAIL ; - } - }else if (errno ==ENOENT ) { -/* driver path doesn't exist */ - dp =NULL ; - }else { -LOGE (ERROR ,"lstat failed: '%s'" , spath); +/* Find the canonical path to the driver. */ + dp =libxl__zalloc (gc,PATH_MAX ); + dp =realpath (spath, dp); +if (!dp && errno !=ENOENT ) { +LOGE (ERROR ,"get realpath failed: '%s'" , spath);return ERROR_FAIL ; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c
Chunyan Liu writes ("[PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c"):
Quoted 6 lines
CID: 1358112
Signed-off-by Chunyan Liu <[email protected]>CC Simon Cao <[email protected]>CC George Dunlap <[email protected]>CC Ian Jackson <[email protected]>
Although for this and the previous patch, it would have been better to add "libxl:" to the start of the Subject.
I will fix that up as I commit.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 4/4 fix a pvusb type check
In reply to Chunyan LiuMissing a check of controller type.
---
This affects Juergen's qusb patch too. Fix that together. This patch could be applied on top of Juergen's qusb backend patch.
tools/libxl/libxl_pvusb.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/libxl/libxl_pvusb.c +7 -0
@@ -811,6 +811,13 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc, } } +if (usbctrl->type !=LIBXL_USBCTRL_TYPE_PV && + usbctrl->type !=LIBXL_USBCTRL_TYPE_QUSB ) { +LOG (ERROR ,"Unsupported USB controller type" ); + rc =ERROR_FAIL ; + goto out; + } + rc =libxl__device_usbctrl_add_xenstore (gc, domid, usbctrl, update_json);if (rc) goto out;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 4/4] fix a pvusb type check
Quoted 7 lines · Chunyan Liu
Missing a check of controller type.
Signed-off-by Chunyan Liu <[email protected]>CC Simon Cao <[email protected]>CC George Dunlap <[email protected]>CC Ian Jackson <[email protected]>CC Juergen Gross <[email protected]>
Quoted 16 lines
---
This affects Juergen's qusb patch too. Fix that together. This patch could be applied on top of Juergen's qusb backend patch.tools/libxl/libxl_pvusb.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/libxl/libxl_pvusb.c +0
-0@@ -811,6 +811,13 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc, } }
tools/libxl/libxl_pvusb.c static int libxl__device_usbdev_setdefault(libxl__gc *gc, · line 823
Quoted 10 lines
tools/libxl/libxl_pvusb.c +7
-0+if (usbctrl->type !=LIBXL_USBCTRL_TYPE_PV && + usbctrl->type !=LIBXL_USBCTRL_TYPE_QUSB ) { +LOG (ERROR ,"Unsupported USB controller type" ); + rc =ERROR_FAIL ; + goto out; + } + rc =libxl__device_usbctrl_add_xenstore (gc, domid, usbctrl, update_json);if (rc) goto out;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel