From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Pau Monne Subject: [PATCH v8 13/15] libxl: use libxl__xs_path_cleanup on device_destroy Date: Wed, 4 Jul 2012 12:59:34 +0100 Message-ID: <1341403176-50715-14-git-send-email-roger.pau@citrix.com> References: <1341403176-50715-1-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1341403176-50715-1-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian Jackson , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org 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 Acked-by: Ian Jackson Signed-off-by: Roger Pau Monne --- 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)