[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 18 of 29 RFC] libxl: introduce libxl__device_generic_hotplug_add
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1328178447 -3600 # Node ID 94733bc9cc2fbeaa08a660ec90dcd9c5ad924e1b # Parent 6a6e7a195412935609c18bc7d52767f41521875b libxl: introduce libxl__device_generic_hotplug_add Add an array of xenstore entries for the given libxl__device to xenstore. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> diff -r 6a6e7a195412 -r 94733bc9cc2f tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Thu Feb 02 11:24:27 2012 +0100 +++ b/tools/libxl/libxl_device.c Thu Feb 02 11:27:27 2012 +0100 @@ -118,6 +118,42 @@ retry_transaction: return 0; } +int libxl__device_generic_hotplug_add(libxl__gc *gc, libxl__device *device, + char **hents) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + char *hotplug_path; + xs_transaction_t t; + struct xs_permissions hotplug_perms[2]; + + hotplug_path = libxl__device_hotplug_path(gc, device); + + hotplug_perms[0].id = 0; + hotplug_perms[0].perms = XS_PERM_NONE; + hotplug_perms[1].id = device->backend_domid; + hotplug_perms[1].perms = XS_PERM_NONE; + +retry_transaction: + t = xs_transaction_start(ctx->xsh); + + if (hents) { + xs_rm(ctx->xsh, t, hotplug_path); + xs_mkdir(ctx->xsh, t, hotplug_path); + xs_set_permissions(ctx->xsh, t, hotplug_path, hotplug_perms, + ARRAY_SIZE(hotplug_perms)); + libxl__xs_writev(gc, t, hotplug_path, hents); + } + + if (!xs_transaction_end(ctx->xsh, t, 0)) { + if (errno == EAGAIN) + goto retry_transaction; + else + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs transaction failed"); + } + + return 0; +} + typedef struct { libxl__gc *gc; libxl_device_disk *disk; diff -r 6a6e7a195412 -r 94733bc9cc2f tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu Feb 02 11:24:27 2012 +0100 +++ b/tools/libxl/libxl_internal.h Thu Feb 02 11:27:27 2012 +0100 @@ -299,6 +299,9 @@ typedef struct { _hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device, char **bents, char **fents); +_hidden int libxl__device_generic_hotplug_add(libxl__gc *gc, + libxl__device *device, + char **hents); _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 char *libxl__device_hotplug_path(libxl__gc *gc, libxl__device *device); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |