[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: add function to remove usb controller xenstore entries
commit 0503cafe62e505f53c7af149521a17cfe92f9bb7 Author: Juergen Gross <jgross@xxxxxxxx> AuthorDate: Tue Sep 20 16:18:07 2016 +0200 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Sep 20 15:48:16 2016 +0100 libxl: add function to remove usb controller xenstore entries In case of failure when trying to add a new USB controller to a domain libxl might leak xenstore entries. Add a function to remove them and call this function in case of failure. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl_usb.c | 58 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 6b30e0f..2493464 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -194,6 +194,47 @@ out: return rc; } +static const char *vusb_be_from_xs_libxl(libxl__gc *gc, const char *libxl_path) +{ + const char *be_path; + int r; + + r = libxl__xs_read_checked(gc, XBT_NULL, + GCSPRINTF("%s/backend", libxl_path), + &be_path); + if (r || !be_path) return NULL; + + return be_path; +} + +static void libxl__device_usbctrl_del_xenstore(libxl__gc *gc, uint32_t domid, + libxl_device_usbctrl *usbctrl) +{ + const char *libxl_path, *be_path; + xs_transaction_t t = XBT_NULL; + int rc; + + libxl_path = GCSPRINTF("%s/device/vusb/%d", + libxl__xs_libxl_path(gc, domid), usbctrl->devid); + be_path = vusb_be_from_xs_libxl(gc, libxl_path); + + for (;;) { + rc = libxl__xs_transaction_start(gc, &t); + if (rc) goto out; + + libxl__xs_path_cleanup(gc, t, be_path); + + rc = libxl__xs_transaction_commit(gc, &t); + if (!rc) break; + if (rc < 0) goto out; + } + + return; + +out: + libxl__xs_transaction_abort(gc, &t); +} + static char *pvusb_get_device_type(libxl_usbctrl_type type) { switch (type) { @@ -250,13 +291,15 @@ static void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid, GCNEW(device); rc = libxl__device_from_usbctrl(gc, domid, usbctrl, device); - if (rc) goto out; + if (rc) goto outrm; aodev->dev = device; aodev->action = LIBXL__DEVICE_ACTION_ADD; libxl__wait_device_connection(egc, aodev); return; +outrm: + libxl__device_usbctrl_del_xenstore(gc, domid, usbctrl); out: aodev->rc = rc; aodev->callback(egc, aodev); @@ -340,19 +383,6 @@ out: return; } -static const char *vusb_be_from_xs_libxl(libxl__gc *gc, const char *libxl_path) -{ - const char *be_path; - int r; - - r = libxl__xs_read_checked(gc, XBT_NULL, - GCSPRINTF("%s/backend", libxl_path), - &be_path); - if (r || !be_path) return NULL; - - return be_path; -} - libxl_device_usbctrl * libxl_device_usbctrl_list(libxl_ctx *ctx, uint32_t domid, int *num) { -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |