From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org
Cc: Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 2/5] libxl: add libxl__xs_path_cleanup
Date: Tue, 17 Apr 2012 16:51:13 +0100 [thread overview]
Message-ID: <1334677876-17704-3-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1334677876-17704-1-git-send-email-roger.pau@citrix.com>
Add a function which behaves like "xenstore-rm -t", and which will be used to
clean xenstore after unplug since we will be no longer executing
xen-hotplug-cleanup script, that used to do that for us.
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
tools/libxl/libxl_device.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index c7e057d..fe4bcc6 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -356,6 +356,27 @@ int libxl__device_disk_dev_number(const char *virtpath, int *pdisk,
return -1;
}
+static int libxl__xs_path_cleanup(libxl__gc *gc, char *path)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ unsigned int nb = 0;
+ char *last;
+
+ if (!path)
+ return 0;
+
+ xs_rm(ctx->xsh, XBT_NULL, path);
+
+ for (last = strrchr(path, '/'); last != NULL; last = strrchr(path, '/')) {
+ *last = '\0';
+ if (!libxl__xs_directory(gc, XBT_NULL, path, &nb))
+ continue;
+ if (nb == 0) {
+ xs_rm(ctx->xsh, XBT_NULL, path);
+ }
+ }
+ return 0;
+}
typedef struct {
libxl__ao *ao;
--
1.7.7.5 (Apple Git-26)
next prev parent reply other threads:[~2012-04-17 15:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-17 15:51 [PATCH v2 0/5] libxl: call hotplug scripts from libxl Roger Pau Monne
2012-04-17 15:51 ` [PATCH v2 1/5] libxl: allow libxl__exec to take a parameter containing the env variables Roger Pau Monne
2012-04-17 15:51 ` Roger Pau Monne [this message]
2012-04-18 8:51 ` [PATCH v2 2/5] libxl: add libxl__xs_path_cleanup Ian Campbell
2012-04-17 15:51 ` [PATCH v2 3/5] libxl: call hotplug scripts from libxl for vbd Roger Pau Monne
2012-04-18 9:25 ` Ian Campbell
2012-04-17 15:51 ` [PATCH v2 4/5] libxl: call hotplug scripts from libxl for vif Roger Pau Monne
2012-04-18 9:54 ` Ian Campbell
2012-04-18 11:22 ` Roger Pau Monne
2012-04-18 12:31 ` Ian Campbell
2012-04-18 13:28 ` Roger Pau Monne
2012-04-18 13:31 ` Ian Campbell
2012-04-18 13:48 ` Roger Pau Monne
2012-04-18 15:30 ` Ian Campbell
2012-04-18 15:40 ` Roger Pau Monne
2012-04-20 12:47 ` Ian Campbell
2012-04-18 16:24 ` Roger Pau Monne
2012-04-18 17:22 ` Ian Campbell
2012-04-18 11:58 ` Roger Pau Monne
2012-04-18 12:34 ` Ian Campbell
2012-04-17 15:51 ` [PATCH v2 5/5] libxl: add "downscript=no" to Qemu call Roger Pau Monne
2012-04-18 9:56 ` Ian Campbell
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=1334677876-17704-3-git-send-email-roger.pau@citrix.com \
--to=roger.pau@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).