diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-05-29 16:36:47 +0100 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-05-29 16:36:47 +0100 |
commit | 4f3798dba22c28706d824a5329b9ddd07471fafe (patch) | |
tree | d6cd52d78994889bddea8d247d7186c53575d1d6 /tools/libxl/libxl_device.c | |
parent | 6ae77f8afd24bf68a325bbba8a6cf8e09bd4d2ca (diff) | |
download | xen-4f3798dba22c28706d824a5329b9ddd07471fafe.tar.gz xen-4f3798dba22c28706d824a5329b9ddd07471fafe.tar.bz2 xen-4f3798dba22c28706d824a5329b9ddd07471fafe.zip |
libxl: add a transaction parameter to libxl__device_generic_add
Add a xs_transaction_t parameter to libxl__device_generic_add, if it is
XBT_NULL, allocate a proper one.
Update all the callers.
This patch contains a large number of unchecked xenstore operations, we
might want to fix this in the future.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_device.c')
-rw-r--r-- | tools/libxl/libxl_device.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 2006406bd5..3da60e17a0 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; } |