From: Juergen Gross <jgross@suse.com>
To: Chunyan Liu <cyliu@suse.com>, xen-devel@lists.xen.org
Cc: george.dunlap@eu.citrix.com, lars.kurth@citrix.com,
caobosimon@gmail.com, ian.campbell@citrix.com,
ian.jackson@citrix.com
Subject: Re: [PATCH RFC V2 3/5] libxl: add pvusb API
Date: Tue, 17 Mar 2015 15:03:34 +0100 [thread overview]
Message-ID: <55083436.3080902@suse.com> (raw)
In-Reply-To: <1421656131-19366-4-git-send-email-cyliu@suse.com>
Hi Chunyan,
I've found another problem while trying to write a qemu based pvUSB
backend.
On 01/19/2015 09:28 AM, Chunyan Liu wrote:
> Add pvusb APIs, including:
> - attach/detach (create/destroy) virtual usb controller.
> - attach/detach usb device
> - list assignable usb devices in host
> - some other helper functions
>
> Signed-off-by: Chunyan Liu <cyliu@suse.com>
> Signed-off-by: Simon Cao <caobosimon@gmail.com>
> ---
...
> diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
> new file mode 100644
> index 0000000..830a846
> --- /dev/null
> +++ b/tools/libxl/libxl_usb.c
...
> +/* xenstore usb data */
> +static int libxl__device_usb_add_xenstore(libxl__gc *gc, uint32_t domid,
> + libxl_device_usb *usb)
> +{
> + libxl_ctx *ctx = CTX;
> + char *be_path;
> + int rc;
> + libxl_domain_config d_config;
> + libxl_device_usb usb_saved;
> + libxl__domain_userdata_lock *lock = NULL;
> +
> + libxl_domain_config_init(&d_config);
> + libxl_device_usb_init(&usb_saved);
> + libxl_device_usb_copy(CTX, &usb_saved, usb);
> +
> + be_path = libxl__sprintf(gc, "%s/backend/vusb/%d/%d",
> + libxl__xs_get_dompath(gc, 0), domid, usb->ctrl);
> + if (libxl__wait_for_backend(gc, be_path, "4") < 0) {
Don't do this! That's the reason I had to change my backend driver in
order to support assignment of a usb device via config file. Normally
the backend will witch to state 4 only after the frontend is started.
You can just remove waiting for the backend here. The backend has to
check all ports when it is changing is state to 4 ("connected").
> + rc = ERROR_FAIL;
> + goto out;
> + }
> +
> + lock = libxl__lock_domain_userdata(gc, domid);
> + if (!lock) {
> + rc = ERROR_LOCK_FAIL;
> + goto out;
> + }
> +
> + rc = libxl__get_domain_configuration(gc, domid, &d_config);
> + if (rc) goto out;
> +
> + DEVICE_ADD(usb, usbs, domid, &usb_saved, COMPARE_USB, &d_config);
> +
> + rc = libxl__set_domain_configuration(gc, domid, &d_config);
> + if (rc) goto out;
> +
> + be_path = libxl__sprintf(gc, "%s/port/%d", be_path, usb->port);
> + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Adding new usb device to xenstore");
> + if (libxl__xs_write_checked(gc, XBT_NULL, be_path, usb->intf)) {
> + rc = ERROR_FAIL;
> + goto out;
> + }
> +
> + rc = 0;
> +
> +out:
> + if (lock) libxl__unlock_domain_userdata(lock);
> + libxl_device_usb_dispose(&usb_saved);
> + libxl_domain_config_dispose(&d_config);
> + return rc;
> +
> +}
> +
> +static int libxl__device_usb_remove_xenstore(libxl__gc *gc, uint32_t domid,
> + libxl_device_usb *usb)
> +{
> + libxl_ctx *ctx = CTX;
> + char *be_path;
> +
> + be_path = libxl__sprintf(gc, "%s/backend/vusb/%d/%d",
> + libxl__xs_get_dompath(gc, 0), domid, usb->ctrl);
> + if (libxl__wait_for_backend(gc, be_path, "4") < 0)
Remove this one, too.
Juergen
next prev parent reply other threads:[~2015-03-17 14:03 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 8:28 [PATCH RFC V2 0/5] pvusb toolstack work Chunyan Liu
2015-01-19 8:28 ` [PATCH RFC V2 1/5] libxl: add pvusb definitions Chunyan Liu
2015-03-03 11:10 ` Ian Campbell
2015-03-03 16:45 ` George Dunlap
2015-03-04 7:26 ` Chun Yan Liu
2015-03-04 10:00 ` Ian Campbell
2015-03-04 12:26 ` George Dunlap
2015-03-04 12:33 ` Ian Campbell
2015-03-05 5:04 ` Chun Yan Liu
2015-03-03 17:15 ` George Dunlap
2015-03-04 8:28 ` Chun Yan Liu
2015-03-04 14:41 ` George Dunlap
2015-03-05 6:07 ` Chun Yan Liu
2015-01-19 8:28 ` [PATCH RFC V2 2/5] libxl: export some functions for pvusb use Chunyan Liu
2015-03-03 11:10 ` Ian Campbell
2015-01-19 8:28 ` [PATCH RFC V2 3/5] libxl: add pvusb API Chunyan Liu
2015-01-28 15:54 ` Ian Campbell
2015-01-29 3:24 ` Chun Yan Liu
2015-02-10 10:08 ` Jürgen Groß
2015-02-10 16:01 ` Jürgen Groß
2015-03-03 11:38 ` Ian Campbell
2015-03-04 7:47 ` Chun Yan Liu
2015-03-06 16:50 ` George Dunlap
2015-03-09 9:39 ` Ian Campbell
2015-03-09 10:17 ` George Dunlap
2015-03-09 10:41 ` Ian Campbell
2015-03-20 9:37 ` Chun Yan Liu
2015-03-17 14:03 ` Juergen Gross [this message]
2015-01-19 8:28 ` [PATCH RFC V2 4/5] xl: add pvusb commands Chunyan Liu
2015-02-10 6:25 ` Jürgen Groß
2015-03-03 11:43 ` Ian Campbell
2015-03-04 7:48 ` Chun Yan Liu
2015-03-06 17:25 ` George Dunlap
2015-03-20 9:02 ` Chun Yan Liu
2015-01-19 8:28 ` [PATCH RFC V2 5/5] domcreate: support pvusb in configuration file Chunyan Liu
2015-03-03 11:44 ` Ian Campbell
2015-01-28 15:51 ` [PATCH RFC V2 0/5] pvusb toolstack work Ian Campbell
2015-01-28 16:07 ` Pasi Kärkkäinen
2015-01-28 16:17 ` Ian Campbell
2015-01-29 3:22 ` Chun Yan 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=55083436.3080902@suse.com \
--to=jgross@suse.com \
--cc=caobosimon@gmail.com \
--cc=cyliu@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=lars.kurth@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.