From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Jim Fehlig <jfehlig@novell.com>,
Mike McClurg <mike.mcclurg@citrix.com>,
Dave Scott <Dave.Scott@eu.citrix.com>,
Jonathan Ludlam <Jonathan.Ludlam@eu.citrix.com>
Subject: [PATCH 15 of 23] libxl: merge libxl__device_del into libxl__device_remove
Date: Fri, 30 Sep 2011 14:33:28 +0100 [thread overview]
Message-ID: <7a8cd032b63cf91d3fe0.1317389608@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1317389593@localhost.localdomain>
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1317389248 -3600
# Node ID 7a8cd032b63cf91d3fe04501997405d53cf5d8b3
# Parent ec28ee6dace513c3d009d498341f9537a19b2d98
libxl: merge libxl__device_del into libxl__device_remove
Note that the "wait" parameter added to libxl_device_remove is different to the
wait paramter previously used by similar functions. In the past not-wait meant
forced whereas now in means wait for a graceful shutdown, as opposed to setting
off a graceful shutdown but not waiting.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r ec28ee6dace5 -r 7a8cd032b63c tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/libxl.c Fri Sep 30 14:27:28 2011 +0100
@@ -1072,7 +1072,7 @@ int libxl_device_disk_del(libxl_ctx *ctx
device.devid = devid;
device.kind = LIBXL__DEVICE_KIND_VBD;
if (wait)
- rc = libxl__device_del(&gc, &device);
+ rc = libxl__device_remove(&gc, &device, wait);
else
rc = libxl__device_force_remove(&gc, &device);
out_free:
@@ -1287,7 +1287,7 @@ int libxl_device_nic_del(libxl_ctx *ctx,
device.kind = LIBXL__DEVICE_KIND_VIF;
if (wait)
- rc = libxl__device_del(&gc, &device);
+ rc = libxl__device_remove(&gc, &device, wait);
else
rc = libxl__device_force_remove(&gc, &device);
diff -r ec28ee6dace5 -r 7a8cd032b63c tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100
@@ -367,57 +367,6 @@ int libxl__device_disk_dev_number(const
return -1;
}
-int libxl__device_remove(libxl__gc *gc, libxl__device *dev)
-{
- libxl_ctx *ctx = libxl__gc_owner(gc);
- xs_transaction_t t;
- char *be_path = libxl__device_backend_path(gc, dev);
- char *state_path = libxl__sprintf(gc, "%s/state", be_path);
- char *state = libxl__xs_read(gc, XBT_NULL, state_path);
- int rc = 0;
-
- if (!state)
- goto out;
- if (atoi(state) != 4) {
- libxl__device_destroy_tapdisk(gc, be_path);
- xs_rm(ctx->xsh, XBT_NULL, be_path);
- goto out;
- }
-
-retry_transaction:
- t = xs_transaction_start(ctx->xsh);
- xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/online", be_path), "0", strlen("0"));
- xs_write(ctx->xsh, t, state_path, "5", strlen("5"));
- if (!xs_transaction_end(ctx->xsh, t, 0)) {
- if (errno == EAGAIN)
- goto retry_transaction;
- else {
- rc = -1;
- goto out;
- }
- }
-
- xs_watch(ctx->xsh, state_path, be_path);
- libxl__device_destroy_tapdisk(gc, be_path);
- rc = 1;
-out:
- return rc;
-}
-
-int libxl__device_force_remove(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_rm(ctx->xsh, XBT_NULL, be_path);
- xs_rm(ctx->xsh, XBT_NULL, fe_path);
-
- libxl__device_destroy_tapdisk(gc, be_path);
-
- return 0;
-}
-
static int wait_for_dev_destroy(libxl__gc *gc, struct timeval *tv)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -446,6 +395,67 @@ static int wait_for_dev_destroy(libxl__g
return rc;
}
+/* Returns 0 on success, ERROR_* on fail */
+int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ xs_transaction_t t;
+ char *be_path = libxl__device_backend_path(gc, dev);
+ char *state_path = libxl__sprintf(gc, "%s/state", be_path);
+ char *state = libxl__xs_read(gc, XBT_NULL, state_path);
+ int rc = 0;
+
+ if (!state)
+ goto out;
+ if (atoi(state) != 4) {
+ libxl__device_destroy_tapdisk(gc, be_path);
+ xs_rm(ctx->xsh, XBT_NULL, be_path);
+ goto out;
+ }
+
+retry_transaction:
+ t = xs_transaction_start(ctx->xsh);
+ xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/online", be_path), "0", strlen("0"));
+ xs_write(ctx->xsh, t, state_path, "5", strlen("5"));
+ if (!xs_transaction_end(ctx->xsh, t, 0)) {
+ if (errno == EAGAIN)
+ goto retry_transaction;
+ else {
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ }
+
+ xs_watch(ctx->xsh, state_path, be_path);
+ libxl__device_destroy_tapdisk(gc, be_path);
+
+ if (wait) {
+ struct timeval tv;
+ tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
+ tv.tv_usec = 0;
+ (void)wait_for_dev_destroy(gc, &tv);
+ xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev));
+ }
+
+ rc = 0;
+out:
+ return rc;
+}
+
+int libxl__device_force_remove(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_rm(ctx->xsh, XBT_NULL, be_path);
+ xs_rm(ctx->xsh, XBT_NULL, fe_path);
+
+ libxl__device_destroy_tapdisk(gc, be_path);
+
+ return 0;
+}
+
int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -487,7 +497,7 @@ int libxl__devices_destroy(libxl__gc *gc
if (force) {
libxl__device_force_remove(gc, &dev);
} else {
- if (libxl__device_remove(gc, &dev) > 0)
+ if (libxl__device_remove(gc, &dev, 0) == 0)
n_watches++;
}
}
@@ -506,7 +516,7 @@ int libxl__devices_destroy(libxl__gc *gc
if (force) {
libxl__device_force_remove(gc, &dev);
} else {
- if (libxl__device_remove(gc, &dev) > 0)
+ if (libxl__device_remove(gc, &dev, 0) == 0)
n_watches++;
}
}
@@ -532,29 +542,6 @@ out:
return 0;
}
-int libxl__device_del(libxl__gc *gc, libxl__device *dev)
-{
- libxl_ctx *ctx = libxl__gc_owner(gc);
- struct timeval tv;
- int rc;
-
- rc = libxl__device_remove(gc, dev);
- if (rc == -1) {
- rc = ERROR_FAIL;
- goto out;
- }
-
- tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
- tv.tv_usec = 0;
- (void)wait_for_dev_destroy(gc, &tv);
-
- xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev));
- rc = 0;
-
-out:
- return rc;
-}
-
int libxl__wait_for_device_model(libxl__gc *gc,
uint32_t domid, char *state,
libxl__spawn_starting *spawning,
diff -r ec28ee6dace5 -r 7a8cd032b63c tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:27:28 2011 +0100
@@ -242,8 +242,7 @@ _hidden char *libxl__device_backend_path
_hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device);
_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
libxl__device *dev);
-_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev);
-_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev);
+_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait);
_hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev);
_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force);
_hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
next prev parent reply other threads:[~2011-09-30 13:33 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 13:33 [PATCH 00 of 23] libxl: rationalise libxl_device_* APIs Ian Campbell
2011-09-30 13:33 ` [PATCH 01 of 23] libxl: remove hard tabs from non-generated *.[ch] Ian Campbell
2011-10-06 16:34 ` Ian Jackson
2011-10-07 8:37 ` Ian Campbell
2011-10-07 14:08 ` [PATCH 0 of 3] libxl: fixup hard tabs and indentation Ian Campbell
2011-10-07 14:08 ` [PATCH 1 of 3] libxl: expand hard tabs stops Ian Campbell
2011-10-07 14:08 ` [PATCH 2 of 3] libxl: fixup incorrect indentation Ian Campbell
2011-10-12 15:23 ` Ian Jackson
2011-10-07 14:08 ` [PATCH 3 of 3] libxl: add emacs local variables block to turn on four space indentation Ian Campbell
2011-10-10 11:09 ` Ian Jackson
2011-09-30 13:33 ` [PATCH 02 of 23] libxl: add a comment describing the device interfaces Ian Campbell
2011-10-04 8:53 ` Dave Scott
2011-10-04 9:38 ` Ian Campbell
2011-10-11 12:59 ` Roger Pau Monné
2011-10-12 15:27 ` Ian Campbell
2011-09-30 13:33 ` [PATCH 03 of 23] libxl: various fixes to libxl_device_disk_list (and internals) Ian Campbell
2011-09-30 13:33 ` [PATCH 04 of 23] libxl: refactor code to construct disk from xenstore backend Ian Campbell
2011-09-30 13:33 ` [PATCH 05 of 23] libxl: do not read f.e. xenstore dir in disk list function Ian Campbell
2011-09-30 13:33 ` [PATCH 06 of 23] libxl: update nic list API to use common device API style Ian Campbell
2011-10-05 12:48 ` [PATCH] " Roger Pau Monne
2011-10-05 13:10 ` Ian Campbell
2011-10-05 13:22 ` Roger Pau Monné
2011-10-05 13:42 ` Ian Campbell
2011-09-30 13:33 ` [PATCH 07 of 23] libxl: reimplement devid->nic in terms of from_xs_be function Ian Campbell
2011-09-30 13:33 ` [PATCH 08 of 23] libxl: reimplement devid->disk " Ian Campbell
2011-09-30 13:33 ` [PATCH 09 of 23] libxl: libxl_devid_to_* should take an integer device id Ian Campbell
2011-09-30 13:33 ` [PATCH 10 of 23] libxl: separate forced and non-forced device remove Ian Campbell
2011-10-06 16:38 ` Ian Jackson
2011-10-07 8:44 ` Ian Campbell
2011-10-07 13:08 ` Ian Jackson
2011-09-30 13:33 ` [PATCH 11 of 23] libxl: split forced and non-forced uses of libxl__device_del Ian Campbell
2011-09-30 13:33 ` [PATCH 12 of 23] libxl: use IDL to define device front- and back-end kinds Ian Campbell
2011-09-30 13:33 ` [PATCH 13 of 23] libxl: do not remove unidentified frontend paths in libxl__devices_destroy Ian Campbell
2011-09-30 13:33 ` [PATCH 14 of 23] libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore Ian Campbell
2011-10-07 12:18 ` Roger Pau Monné
2011-10-07 12:24 ` Ian Campbell
2011-10-07 12:26 ` Ian Campbell
2011-09-30 13:33 ` Ian Campbell [this message]
2011-09-30 13:33 ` [PATCH 16 of 23] libxl: use more descriptive variable names in libxl__devices_destroy Ian Campbell
2011-09-30 13:33 ` [PATCH 17 of 23] libxl: convert disk handling to device API Ian Campbell
2011-09-30 13:33 ` [PATCH 18 of 23] libxl: convert NIC " Ian Campbell
2011-09-30 13:33 ` [PATCH 19 of 23] libxl: remove libxl_device_console_add Ian Campbell
2011-09-30 13:33 ` [PATCH 20 of 23] libxl: convert VKB handling to device API Ian Campbell
2011-09-30 13:33 ` [PATCH 21 " Ian Campbell
2011-09-30 13:33 ` [PATCH 22 of 23] libxl: reorder device functions to put functions for each device together Ian Campbell
2011-09-30 13:33 ` [PATCH 23 of 23] libxl: convert PCI device handling to device API Ian Campbell
2011-10-04 7:32 ` [PATCH 00 of 23] libxl: rationalise libxl_device_* APIs Roger Pau Monné
2011-10-04 8:12 ` Ian Campbell
2011-10-04 8:32 ` Ian Campbell
2011-10-05 9:04 ` Roger Pau Monné
2011-10-05 9:33 ` Ian Campbell
2011-10-05 11:59 ` Roger Pau Monné
2011-10-05 13:08 ` Ian Campbell
2011-10-05 13:15 ` Roger Pau Monné
2011-10-06 16:43 ` Ian Jackson
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=7a8cd032b63cf91d3fe0.1317389608@localhost.localdomain \
--to=ian.campbell@citrix.com \
--cc=Dave.Scott@eu.citrix.com \
--cc=Jonathan.Ludlam@eu.citrix.com \
--cc=jfehlig@novell.com \
--cc=mike.mcclurg@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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.