xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v7 13/15] libxl: use libxl__xs_path_cleanup on device_destroy
Date: Wed, 4 Jul 2012 11:16:10 +0100	[thread overview]
Message-ID: <1341396972-49704-13-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1341396972-49704-1-git-send-email-roger.pau@citrix.com>

Since the hotplug script that was in charge of cleaning the backend is
no longer launched, we need to clean the backend by ourselves, so use
libxl__xs_path_cleanup instead of xs_rm.

Changes sinve v2:

 * Changed the goto construction to a do-while loop.

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
 tools/libxl/libxl_device.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 13f9ecb..2f6e427 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -479,16 +479,26 @@ DEFINE_DEVICES_ADD(nic)
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *be_path = libxl__device_backend_path(gc, dev);
     char *fe_path = libxl__device_frontend_path(gc, dev);
+    xs_transaction_t t = 0;
+    int rc = 0;
 
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    do {
+        t = xs_transaction_start(CTX->xsh);
+        libxl__xs_path_cleanup(gc, t, fe_path);
+        libxl__xs_path_cleanup(gc, t, be_path);
+        rc = !xs_transaction_end(CTX->xsh, t, 0);
+    } while (rc && errno == EAGAIN);
+    if (rc) {
+        LOGE(ERROR, "unable to finish transaction");
+        goto out;
+    }
 
     libxl__device_destroy_tapdisk(gc, be_path);
 
-    return 0;
+out:
+    return rc;
 }
 
 /* Callback for device destruction */
-- 
1.7.7.5 (Apple Git-26)

  parent reply	other threads:[~2012-07-04 10:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04 10:15 [PATCH v7 01/15] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-04 10:15 ` [PATCH v7 02/15] libxl: move device model creation prototypes Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 03/15] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 04/15] libxl: move bootloader data strucutres and prototypes Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 05/15] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 06/15] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 07/15] libxl: rename vifs to nics Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 08/15] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 09/15] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 10/15] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 11/15] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 12/15] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-04 10:16 ` Roger Pau Monne [this message]
2012-07-04 10:16 ` [PATCH v7 14/15] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-04 10:16 ` [PATCH v7 15/15] libxl: call hotplug scripts for nic " Roger Pau Monne

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=1341396972-49704-13-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=ian.jackson@eu.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 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).