From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v4 3/8] libxl: add a transaction parameter to libxl__device_generic_add
Date: Tue, 24 Apr 2012 11:45:53 +0100 [thread overview]
Message-ID: <1335264358-20182-3-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1204231810140.26786@kaball-desktop>
Add a xs_transaction_t parameter to libxl__device_generic_add, if it is
XBT_NULL, allocate a proper one.
Update all the callers.
Changes in v4:
- libxl__device_generic_add: do not end the transaction is the caller
provided it;
- libxl__device_generic_add: fix success exit path.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/libxl/libxl.c | 10 +++++-----
tools/libxl/libxl_device.c | 17 +++++++++++------
tools/libxl/libxl_internal.h | 4 ++--
tools/libxl/libxl_pci.c | 2 +-
4 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index e645d2a..85082eb 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1401,7 +1401,7 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
flexarray_append(front, "device-type");
flexarray_append(front, disk->is_cdrom ? "cdrom" : "disk");
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
@@ -1795,7 +1795,7 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
flexarray_append(front, "mac");
flexarray_append(front, libxl__sprintf(gc,
LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
@@ -2073,7 +2073,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
flexarray_append(front, LIBXL_XENCONSOLE_PROTOCOL);
}
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
rc = 0;
@@ -2144,7 +2144,7 @@ int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb)
flexarray_append(front, "state");
flexarray_append(front, libxl__sprintf(gc, "%d", 1));
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
rc = 0;
@@ -2277,7 +2277,7 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
libxl__sprintf(gc, "%d", vfb->backend_domid));
flexarray_append_pair(front, "state", libxl__sprintf(gc, "%d", 1));
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
rc = 0;
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index c7e057d..88cdc7d 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -58,14 +58,14 @@ int libxl__parse_backend_path(libxl__gc *gc,
return libxl__device_kind_from_string(strkind, &dev->backend_kind);
}
-int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
- char **bents, char **fents)
+int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
+ libxl__device *device, char **bents, char **fents)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
char *frontend_path, *backend_path;
- xs_transaction_t t;
struct xs_permissions frontend_perms[2];
struct xs_permissions backend_perms[2];
+ int create_transaction = t == XBT_NULL;
frontend_path = libxl__device_frontend_path(gc, device);
backend_path = libxl__device_backend_path(gc, device);
@@ -81,7 +81,8 @@ int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
backend_perms[1].perms = XS_PERM_READ;
retry_transaction:
- t = xs_transaction_start(ctx->xsh);
+ if (create_transaction)
+ t = xs_transaction_start(ctx->xsh);
/* FIXME: read frontend_path and check state before removing stuff */
if (fents) {
@@ -100,13 +101,17 @@ retry_transaction:
libxl__xs_writev(gc, t, backend_path, bents);
}
+ if (!create_transaction)
+ return 0;
+
if (!xs_transaction_end(ctx->xsh, t, 0)) {
if (errno == EAGAIN)
goto retry_transaction;
- else
+ else {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs transaction failed");
+ return ERROR_FAIL;
+ }
}
-
return 0;
}
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 2f1cf0f..00856e0 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -681,8 +681,8 @@ _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
libxl__device_console *console,
libxl__domain_build_state *state);
-_hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
- char **bents, char **fents);
+_hidden int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
+ libxl__device *device, char **bents, char **fents);
_hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device);
_hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device);
_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index e8b8839..202a101 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -102,7 +102,7 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
flexarray_append_pair(front, "backend-id", libxl__sprintf(gc, "%d", 0));
flexarray_append_pair(front, "state", libxl__sprintf(gc, "%d", 1));
- libxl__device_generic_add(gc, &device,
+ libxl__device_generic_add(gc, XBT_NULL, &device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
--
1.7.2.5
next prev parent reply other threads:[~2012-04-24 10:45 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 11:12 [PATCH v5 0/8] qdisk local attach Stefano Stabellini
2012-05-04 11:13 ` [PATCH v5 1/8] libxl: make libxl_device_disk_local_attach/detach internal functions Stefano Stabellini
2012-05-04 11:13 ` [PATCH v5 2/8] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-05-04 14:40 ` Ian Campbell
2012-05-04 16:27 ` Ian Jackson
2012-05-14 13:04 ` Stefano Stabellini
2012-05-14 13:06 ` Ian Campbell
2012-05-14 14:15 ` Ian Jackson
2012-05-04 11:13 ` [PATCH v5 3/8] libxl: add a transaction parameter to libxl__device_generic_add Stefano Stabellini
2012-05-04 14:41 ` Ian Campbell
2012-05-04 11:13 ` [PATCH v5 4/8] libxl: introduce libxl__device_disk_add Stefano Stabellini
2012-04-24 10:45 ` [PATCH v4 0/8] qdisk local attach Stefano Stabellini
2012-04-24 10:45 ` [PATCH v4 1/8] libxl: make libxl_device_disk_local_attach/detach internal functions Stefano Stabellini
2012-04-24 15:16 ` Ian Campbell
2012-04-24 10:45 ` [PATCH v4 2/8] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-04-24 15:02 ` Ian Jackson
2012-04-24 15:25 ` Ian Campbell
2012-04-24 10:45 ` Stefano Stabellini [this message]
2012-04-24 15:34 ` [PATCH v4 3/8] libxl: add a transaction parameter to libxl__device_generic_add Ian Jackson
2012-04-24 10:45 ` [PATCH v4 4/8] libxl: introduce libxl__device_disk_add_t Stefano Stabellini
2012-04-24 15:42 ` Ian Jackson
2012-04-24 16:02 ` Ian Jackson
2012-05-04 16:30 ` [PATCH v4 4/8] libxl: introduce libxl__device_disk_add_t [and 1 more messages] Ian Jackson
2012-04-24 10:45 ` [PATCH v4 5/8] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-04-24 14:52 ` Ian Jackson
2012-04-24 10:45 ` [PATCH v4 6/8] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-04-24 14:58 ` Ian Jackson
2012-04-24 15:04 ` Ian Campbell
2012-04-24 15:16 ` Ian Jackson
2012-04-24 10:45 ` [PATCH v4 7/8] xl/libxl: implement QDISK libxl_device_disk_local_attach Stefano Stabellini
2012-04-24 15:39 ` Ian Jackson
2012-04-24 10:45 ` [PATCH v4 8/8] libxl__device_disk_local_attach: wait for state "connected" Stefano Stabellini
2012-04-24 15:18 ` Ian Jackson
2012-05-04 14:49 ` [PATCH v5 4/8] libxl: introduce libxl__device_disk_add Ian Campbell
2012-05-04 11:13 ` [PATCH v5 5/8] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-05-04 14:54 ` Ian Campbell
2012-05-04 16:32 ` Ian Jackson
2012-05-04 11:13 ` [PATCH v5 6/8] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-05-04 14:59 ` Ian Campbell
2012-05-04 16:46 ` Ian Jackson
2012-05-04 17:08 ` Ian Campbell
2012-05-04 17:16 ` Ian Jackson
2012-05-04 17:20 ` Ian Campbell
2012-05-14 13:48 ` Stefano Stabellini
2012-05-14 13:56 ` Ian Campbell
2012-05-04 16:39 ` Ian Jackson
2012-05-14 14:10 ` Stefano Stabellini
2012-05-14 14:22 ` Ian Jackson
2012-05-14 14:43 ` Stefano Stabellini
2012-05-04 11:13 ` [PATCH v5 7/8] xl/libxl: implement QDISK libxl_device_disk_local_attach Stefano Stabellini
2012-05-04 15:11 ` Ian Campbell
2012-05-04 16:42 ` Ian Jackson
2012-05-14 14:13 ` Stefano Stabellini
2012-05-14 14:23 ` Ian Jackson
2012-05-14 14:45 ` Stefano Stabellini
2012-05-14 14:46 ` Ian Jackson
2012-05-14 14:52 ` Stefano Stabellini
2012-05-04 11:13 ` [PATCH v5 8/8] libxl__device_disk_local_attach: wait for state "connected" Stefano Stabellini
2012-05-04 15:13 ` Ian Campbell
2012-05-14 14:16 ` Stefano Stabellini
2012-05-10 13:07 ` [PATCH v5 0/8] qdisk local attach Jan Beulich
2012-05-11 15:57 ` Stefano Stabellini
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=1335264358-20182-3-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.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 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).