All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <Ian.Jackson@eu.citrix.com>
To: Chunyan Liu <cyliu@suse.com>
Cc: george.dunlap@eu.citrix.com, Simon Cao <caobosimon@gmail.com>,
	wei.liu2@citrix.com, ian.campbell@citrix.com,
	xen-devel@lists.xen.org
Subject: Re: [PATCH V4 3/7] libxl: add pvusb API
Date: Thu, 11 Jun 2015 17:42:03 +0100	[thread overview]
Message-ID: <21881.47707.526863.158586@mariner.uk.xensource.com> (raw)
In-Reply-To: <1433906441-3280-4-git-send-email-cyliu@suse.com>

Chunyan Liu writes ("[Xen-devel] [PATCH V4 3/7] libxl: add pvusb API"):
> Add pvusb APIs, including:
...

Thanks for your contribution.  I'm afraid I haven't had time to
completely finish my review this, but here's what I have:

> --- /dev/null
> +++ b/docs/misc/pvusb.txt
> @@ -0,0 +1,243 @@
> +1. Overview

It's good that you have provided documentation.  But I think this
document is a bit confused about its audience.

Information about design choices should be removed from this user- and
application-facing document, and put in comments in the code, or
commit messages, I think.


> +int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid,
> +                                libxl_device_usbctrl *usbctrl,
> +                                libxl_usbctrlinfo *usbctrlinfo)
> +                                LIBXL_EXTERNAL_CALLERS_ONLY;

Why is this function marked LIBXL_EXTERNAL_CALLERS_ONLY ?

> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index ef7aa1d..89a9f07 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -2439,6 +2439,18 @@ _hidden void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,
...
> +/* AO operation to connect a PVUSB controller.
> + * Adding a PVUSB controller will add a 'vusb' device entry in xenstore,
> + * and will wait for device connection.

In this context I think "will wait for device connection" is
misleading.  What you mean is that the vusb is available for adding
devices to, but won't have any yet.  Nothing in libxl is "waiting".

> diff --git a/tools/libxl/libxl_pvusb.c b/tools/libxl/libxl_pvusb.c
> new file mode 100644
> index 0000000..a6e1aa1
> --- /dev/null
> +++ b/tools/libxl/libxl_pvusb.c
> @@ -0,0 +1,1249 @@
...
> +void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid,
> +                               libxl_device_usbctrl *usbctrl,
> +                               libxl__ao_device *aodev)
> +{
> +    STATE_AO_GC(aodev->ao);
...
> +    libxl_domain_config_init(&d_config);
> +    libxl_device_usbctrl_init(&usbctrl_saved);
> +    libxl_device_usbctrl_copy(CTX, &usbctrl_saved, usbctrl);

Wei will need to review the saved/live saved device info handling, and
the json, etc.

> +static int
> +libxl_device_usbctrl_remove_common(libxl_ctx *ctx, uint32_t domid,
> +                                   libxl_device_usbctrl *usbctrl,
> +                                   const libxl_asyncop_how *ao_how,
> +                                   int force)

As discussed, you mustn't call this within libxl.  If you need to, you
need to break it out into an internal function
(libxl__initiate_device_usbctrl_remove, maybe) which makes a callback
when done.

> +libxl_device_usbctrl *
> +libxl_device_usbctrl_list(libxl_ctx *ctx, uint32_t domid, int *num)
> +{
> +    GC_INIT(ctx);
> +    libxl_device_usbctrl *usbctrls = NULL;
> +    char *fe_path = NULL;
> +    char **dir = NULL;
> +    unsigned int ndirs = 0;
> +
> +    *num = 0;
> +
> +    fe_path = GCSPRINTF("%s/device/vusb",
> +                        libxl__xs_get_dompath(gc, domid));
> +    dir = libxl__xs_directory(gc, XBT_NULL, fe_path, &ndirs);
> +
> +    if (dir && ndirs) {
> +        usbctrls = malloc(sizeof(*usbctrls) * ndirs);

Please use libxl__calloc with NOGC.

> +        libxl_device_usbctrl* usbctrl;
> +        libxl_device_usbctrl* end = usbctrls + ndirs;
> +        for (usbctrl = usbctrls; usbctrl < end; usbctrl++, dir++, (*num)++) {
> +            char *tmp;
> +            const char *be_path = libxl__xs_read(gc, XBT_NULL,
> +                                    GCSPRINTF("%s/%s/backend", fe_path, *dir));
> +
> +            libxl_device_usbctrl_init(usbctrl);
> +            usbctrl->devid = atoi(*dir);

This function (and the corresponding writing code) is quite formulaic.
Perhaps a macro or something could be used.

I would make a similar criticism of libxl_device_usbctrl_getinfo.

> +/* check if USB device is already assigned to a domain */
> +static bool is_usb_assigned(libxl__gc *gc, libxl_device_usb *usb)
> +{
> +    libxl_device_usb *usbs;
> +    int rc, num;
> +
> +    rc = libxl__device_usb_assigned_list(gc, &usbs, &num);
> +    if (rc) {
> +        LOG(ERROR, "Fail to get assigned usb list");
> +        return true;

I don't think this is proper error handling.  You need to either
encode the boolean return value in the error code, or have the boolean
result be a reference parameter.


Thanks,
Ian.

  parent reply	other threads:[~2015-06-11 16:42 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10  3:20 [PATCH V4 0/7] xen pvusb toolstack work Chunyan Liu
2015-06-10  3:20 ` [PATCH V4 1/7] libxl: export some functions for pvusb use Chunyan Liu
2015-06-11 16:08   ` Ian Jackson
2015-06-11 16:28     ` Wei Liu
2015-06-12 15:14       ` Ian Jackson
2015-06-10  3:20 ` [PATCH V4 2/7] libxl_read_file_contents: add new entry to read sysfs file Chunyan Liu
2015-06-11 16:16   ` Ian Jackson
2015-06-12  7:00     ` Chun Yan Liu
2015-06-12 15:11       ` Ian Jackson
2015-06-10  3:20 ` [PATCH V4 3/7] libxl: add pvusb API Chunyan Liu
2015-06-11 15:00   ` Juergen Gross
2015-06-11 16:07     ` Ian Jackson
2015-06-11 16:42   ` Ian Jackson [this message]
2015-06-12  7:39     ` Chun Yan Liu
2015-06-12  8:06       ` Chun Yan Liu
2015-06-12 11:22       ` Ian Jackson
2015-06-15 14:17   ` George Dunlap
2015-06-15 14:25     ` Jürgen Groß
2015-06-15 14:34       ` George Dunlap
2015-06-15 18:26         ` Juergen Gross
2015-06-16 10:30           ` George Dunlap
2015-06-16 10:51             ` Juergen Gross
2015-06-16 11:11               ` George Dunlap
2015-06-16 11:19                 ` Juergen Gross
2015-06-16 11:23                   ` George Dunlap
2015-06-16 11:44                     ` Ian Jackson
2015-06-17 11:24                       ` Ian Campbell
2015-06-18 11:50                         ` George Dunlap
2015-06-18 12:08                         ` George Dunlap
2015-06-18 13:03                           ` Juergen Gross
2015-06-22 13:29                           ` Proposed plan for libxl USB interface (was Re: [PATCH V4 3/7] libxl: add pvusb API) George Dunlap
2015-06-22 14:14                             ` Juergen Gross
2015-06-22 14:22                             ` Ian Jackson
2015-06-23  2:42                             ` Chun Yan Liu
2015-06-23  2:43                             ` Chun Yan Liu
2015-06-23  2:44                             ` Chun Yan Liu
2015-06-16 10:41     ` [PATCH V4 3/7] libxl: add pvusb API Ian Jackson
2015-06-16 10:56       ` Jürgen Groß
2015-06-16 11:03         ` George Dunlap
2015-06-16 11:10         ` Ian Jackson
2015-06-16 11:25           ` Juergen Gross
2015-06-16 11:45             ` George Dunlap
2015-06-16 12:02               ` Ian Jackson
2015-06-16 13:19                 ` George Dunlap
2015-06-16 13:32                   ` Juergen Gross
2015-06-16 13:37                   ` [PATCH V4 3/7] libxl: add pvusb API [and 1 more messages] Ian Jackson
2015-06-16 14:41                     ` George Dunlap
2015-06-16 15:58                       ` Sander Eikelenboom
2015-06-16 15:59                       ` Ian Jackson
2015-06-16 16:34                         ` George Dunlap
2015-06-17  3:59                           ` Juergen Gross
2015-06-17 10:27                             ` George Dunlap
2015-06-18  6:24                               ` Chun Yan Liu
2015-06-16 11:45             ` [PATCH V4 3/7] libxl: add pvusb API Ian Jackson
2015-06-16 13:06               ` Juergen Gross
2015-06-16 13:09                 ` George Dunlap
2015-06-16 13:23                   ` Juergen Gross
2015-06-16 13:29                     ` George Dunlap
2015-06-16 13:49                       ` Juergen Gross
2015-06-16 14:06                         ` George Dunlap
2015-06-16 14:20                           ` Juergen Gross
2015-06-16 14:37                             ` George Dunlap
2015-06-17 11:34                             ` Ian Campbell
2015-06-17 11:40                               ` Juergen Gross
2015-06-18  6:20                               ` Chun Yan Liu
2015-06-18  7:02                                 ` Juergen Gross
2015-06-18  8:50                                   ` Ian Campbell
2015-06-18 13:02                                     ` Juergen Gross
2015-06-16 15:38             ` George Dunlap
2015-06-16 11:01       ` George Dunlap
2015-06-16 11:12         ` Ian Jackson
2015-06-16 11:21           ` George Dunlap
2015-06-16 16:32             ` Ian Jackson
2015-06-16 16:39               ` George Dunlap
2015-06-16 16:51                 ` Ross Philipson
2015-06-17  4:03                   ` Jürgen Groß
2015-06-17 13:48                     ` Ross Philipson
2015-06-15 17:47   ` George Dunlap
2015-06-23 10:18     ` Chun Yan Liu
2015-06-23 11:29       ` George Dunlap
2015-06-24  2:26         ` Chun Yan Liu
2015-06-10  3:20 ` [PATCH V4 4/7] libxl: add libxl_device_usb_assignable_list API Chunyan Liu
2015-06-10  3:20 ` [PATCH V4 5/7] xl: add pvusb commands Chunyan Liu
2015-06-12  7:37   ` Juergen Gross
2015-06-12  8:03     ` Chun Yan Liu
2015-06-12  8:22       ` Juergen Gross
2015-06-10  3:20 ` [PATCH V4 6/7] xl: add usb-assignable-list command Chunyan Liu
2015-06-10  3:20 ` [PATCH V4 7/7] domcreate: support pvusb in configuration file Chunyan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21881.47707.526863.158586@mariner.uk.xensource.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=caobosimon@gmail.com \
    --cc=cyliu@suse.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.