From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH v1 07/12] libxl: remove the Qemu bodge for driver domain devices
Date: Wed, 2 Oct 2013 10:45:51 +0100 [thread overview]
Message-ID: <524BEB4F.5000208@citrix.com> (raw)
In-Reply-To: <1380705874-58491-8-git-send-email-roger.pau@citrix.com>
On 02/10/13 10:24, Roger Pau Monne wrote:
> When Qemu is launched from a driver domain to act as a PV disk
> backend we can make sure that Qemu is running before detaching
> devices, so there's no need for the bodge there.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> ---
> tools/libxl/libxl_device.c | 71 ++++++++++++++++++++++++++++++++-----------
> 1 files changed, 53 insertions(+), 18 deletions(-)
>
> diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
> index fbab0d5..0404f8d 100644
> --- a/tools/libxl/libxl_device.c
> +++ b/tools/libxl/libxl_device.c
> @@ -780,30 +780,38 @@ void libxl__initiate_device_remove(libxl__egc *egc,
> char *online_path = GCSPRINTF("%s/online", be_path);
> const char *state;
> libxl_dominfo info;
> - uint32_t domid = aodev->dev->domid;
> + uint32_t my_domid, domid = aodev->dev->domid;
> int rc = 0;
>
> - libxl_dominfo_init(&info);
> - rc = libxl_domain_info(CTX, &info, domid);
> + rc = libxl__get_domid(gc, &my_domid);
> if (rc) {
> - LOG(ERROR, "unable to get info for domain %d", domid);
> + LOG(ERROR, "unable to get my domid");
> goto out;
> }
> - if (QEMU_BACKEND(aodev->dev) &&
> - (info.paused || info.dying || info.shutdown)) {
> - /*
> - * TODO: 4.2 Bodge due to QEMU, see comment on top of
> - * libxl__initiate_device_remove in libxl_internal.h
> - */
> - rc = libxl__ev_time_register_rel(gc, &aodev->timeout,
> - device_qemu_timeout,
> - LIBXL_QEMU_BODGE_TIMEOUT * 1000);
> +
> + if (my_domid == LIBXL_TOOLSTACK_DOMID) {
> + libxl_dominfo_init(&info);
> + rc = libxl_domain_info(CTX, &info, domid);
> if (rc) {
> - LOG(ERROR, "unable to register timeout for Qemu device %s",
> - be_path);
> + LOG(ERROR, "unable to get info for domain %d", domid);
> goto out;
> }
> - return;
> + if (QEMU_BACKEND(aodev->dev) &&
> + (info.paused || info.dying || info.shutdown)) {
> + /*
> + * TODO: 4.2 Bodge due to QEMU, see comment on top of
> + * libxl__initiate_device_remove in libxl_internal.h
> + */
> + rc = libxl__ev_time_register_rel(gc, &aodev->timeout,
> + device_qemu_timeout,
> + LIBXL_QEMU_BODGE_TIMEOUT * 1000);
> + if (rc) {
> + LOG(ERROR, "unable to register timeout for Qemu device %s",
> + be_path);
> + goto out;
> + }
> + return;
> + }
> }
>
> for (;;) {
> @@ -872,19 +880,46 @@ static void device_qemu_timeout(libxl__egc *egc, libxl__ev_time *ev,
> STATE_AO_GC(aodev->ao);
> char *be_path = libxl__device_backend_path(gc, aodev->dev);
> char *state_path = GCSPRINTF("%s/state", be_path);
> + const char *xs_state;
> + xs_transaction_t t = 0;
> int rc = 0;
>
> libxl__ev_time_deregister(gc, &aodev->timeout);
>
> - rc = libxl__xs_write_checked(gc, XBT_NULL, state_path, "6");
> - if (rc) goto out;
> + for (;;) {
> + rc = libxl__xs_transaction_start(gc, &t);
> + if (rc) {
> + LOG(ERROR, "unable to start transaction");
> + goto out;
> + }
> +
> + /*
> + * Check that the state path exists and is actually different than
> + * 6 before unconditionally setting it. If Qemu runs on a driver
> + * domain it is possible that the driver domain has already cleaned
> + * the backend path if the device has reached state 6.
> + */
> + rc = libxl__xs_read_checked(gc, XBT_NULL, state_path, &xs_state);
> + if (rc) goto out;
> +
> + if (xs_state && atoi(xs_state) != XenbusStateClosed) {
> + rc = libxl__xs_write_checked(gc, XBT_NULL, state_path, "6");
> + if (rc) goto out;
> + }
> +
> + rc = libxl__xs_transaction_commit(gc, &t);
> + if (!rc) break;
> + if (rc < 0) goto out;
> + }
>
> device_hotplug(egc, aodev);
> return;
>
> out:
> + libxl__xs_transaction_abort(gc, &t);
> aodev->rc = rc;
> device_hotplug_done(egc, aodev);
> + return;
This is a void function. The return here is completely superfluous.
~Andrew
> }
>
> static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds,
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-10-02 9:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 9:24 [PATCH v1 00/12] libxl: add driver domain backend daemon Roger Pau Monne
2013-10-02 9:24 ` [PATCH v1 01/12] libxl/hotplug: add support for getting domid Roger Pau Monne
2013-10-02 9:36 ` Andrew Cooper
2013-10-10 11:32 ` Ian Campbell
2013-11-01 18:42 ` Ian Jackson
2013-11-05 13:49 ` Ian Campbell
2013-10-02 9:24 ` [PATCH v1 02/12] libxl: remove unneeded libxl_domain_info in wait_device_connection Roger Pau Monne
2013-11-01 18:43 ` Ian Jackson
2013-10-02 9:24 ` [PATCH v1 03/12] libxl: make hotplug execution conditional on backend_domid == domid Roger Pau Monne
2013-11-01 18:43 ` Ian Jackson
2013-11-05 13:49 ` Ian Campbell
2013-10-02 9:24 ` [PATCH v1 04/12] libxl: create a local xenstore libxl and device-model dir for guests Roger Pau Monne
2013-10-10 11:37 ` Ian Campbell
2013-10-30 9:14 ` Roger Pau Monné
2013-10-30 11:53 ` Ian Jackson
2013-10-31 16:09 ` Ian Campbell
2013-10-02 9:24 ` [PATCH v1 05/12] libxl: don't remove device frontend path from driver domains Roger Pau Monne
2013-11-01 18:45 ` Ian Jackson
2013-10-02 9:24 ` [PATCH v1 06/12] libxl: synchronize device removal when using " Roger Pau Monne
2013-11-01 18:48 ` Ian Jackson
2013-10-02 9:24 ` [PATCH v1 07/12] libxl: remove the Qemu bodge for driver domain devices Roger Pau Monne
2013-10-02 9:45 ` Andrew Cooper [this message]
2013-10-02 9:24 ` [PATCH v1 08/12] libxl: don't launch Qemu on Dom0 for Qdisk devices on driver domains Roger Pau Monne
2013-10-02 9:24 ` [PATCH v1 09/12] libxl: add Qdisk backend launch helper Roger Pau Monne
2013-10-02 9:24 ` [PATCH v1 10/12] xl: put daemonize code in it's own function Roger Pau Monne
2013-10-02 9:24 ` [PATCH v1 11/12] libxl: revert 326a7b74 Roger Pau Monne
2013-10-02 9:24 ` [PATCH v1 12/12] libxl: add device backend listener in order to launch backends Roger Pau Monne
2013-10-30 17:00 ` Ian Jackson
2013-11-04 17:03 ` Roger Pau Monné
2013-11-04 17:20 ` Ian Jackson
2013-11-04 17:59 ` Ian Jackson
2013-11-06 12:15 ` Roger Pau Monné
2013-11-06 14:46 ` Ian Jackson
2013-11-07 10:22 ` Ian Campbell
2013-11-07 16:35 ` Ian Jackson
2013-11-07 19:11 ` Shriram Rajagopalan
2013-11-08 11:41 ` Ian Jackson
2013-11-11 17:59 ` Shriram Rajagopalan
2013-11-12 15:29 ` Ian Campbell
2013-11-06 9:41 ` Roger Pau Monné
2013-11-11 11:37 ` Ian Jackson
2013-11-06 13:02 ` Roger Pau Monné
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=524BEB4F.5000208@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).