|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 6/6] libxl: create path for advertisement of network attributes...
...at vif instantiation time.
The xenstore path ~attr/vif/$DEVID is documented for the purposes of
a frontend advertising network attributes.
This patch adds an extra bool argument to libxl__device_generic_add()
(the function which creates frontend and backend xenstore paths) which
will cause creation of guest writable xenstore path ~/attr/$DEVICE/$DEVID
if true. libxl__device_nic_add() (i.e. $DEVICE == 'vif') is modified
to pass true for this argument. All other callers pass false.
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/libxl/libxl.c | 18 ++++++++++++------
tools/libxl/libxl_device.c | 30 ++++++++++++++++++++++++------
tools/libxl/libxl_internal.h | 5 ++++-
tools/libxl/libxl_pci.c | 3 ++-
4 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index d7dd081..1689274 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2186,7 +2186,8 @@ void libxl__device_vtpm_add(libxl__egc *egc, uint32_t
domid,
back->count),
libxl__xs_kvs_of_flexarray(gc, front,
front->count),
- NULL);
+ NULL,
+ false);
rc = libxl__xs_transaction_commit(gc, &t);
if (!rc) break;
@@ -2628,7 +2629,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t
domid,
libxl__device_generic_add(gc, t, device,
libxl__xs_kvs_of_flexarray(gc, back,
back->count),
libxl__xs_kvs_of_flexarray(gc, front,
front->count),
- NULL);
+ NULL,
+ false);
rc = libxl__xs_transaction_commit(gc, &t);
if (!rc) break;
@@ -3442,7 +3444,8 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t
domid,
back->count),
libxl__xs_kvs_of_flexarray(gc, front,
front->count),
- NULL);
+ NULL,
+ true);
rc = libxl__xs_transaction_commit(gc, &t);
if (!rc) break;
@@ -3731,7 +3734,8 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t
domid,
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),
- libxl__xs_kvs_of_flexarray(gc, ro_front,
ro_front->count));
+ libxl__xs_kvs_of_flexarray(gc, ro_front,
ro_front->count),
+ false);
rc = 0;
out:
return rc;
@@ -4031,7 +4035,8 @@ int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,
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),
- NULL);
+ NULL,
+ false);
rc = 0;
out:
return rc;
@@ -4144,7 +4149,8 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid,
libxl_device_vfb *vfb)
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),
- NULL);
+ NULL,
+ false);
rc = 0;
out:
return rc;
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 8bb5e93..3b2cbcd 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -40,6 +40,15 @@ char *libxl__device_backend_path(libxl__gc *gc,
libxl__device *device)
device->domid, device->devid);
}
+char *libxl__device_attr_path(libxl__gc *gc, libxl__device *device)
+{
+ char *dom_path = libxl__xs_get_dompath(gc, device->domid);
+
+ return GCSPRINTF("%s/attr/%s/%d", dom_path,
+ libxl__device_kind_to_string(device->kind),
+ device->devid);
+}
+
/* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */
int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
libxl__device *device)
@@ -102,22 +111,25 @@ out:
}
int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
- libxl__device *device, char **bents, char **fents, char **ro_fents)
+ libxl__device *device, char **bents, char
**fents, char **ro_fents,
+ bool attr)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
- char *frontend_path, *backend_path;
+ char *frontend_path, *backend_path, *attr_path;
struct xs_permissions frontend_perms[2];
struct xs_permissions ro_frontend_perms[2];
struct xs_permissions backend_perms[2];
+ struct xs_permissions attr_perms[2];
int create_transaction = t == XBT_NULL;
frontend_path = libxl__device_frontend_path(gc, device);
backend_path = libxl__device_backend_path(gc, device);
+ attr_path = libxl__device_attr_path(gc, device);
- frontend_perms[0].id = device->domid;
- frontend_perms[0].perms = XS_PERM_NONE;
- frontend_perms[1].id = device->backend_domid;
- frontend_perms[1].perms = XS_PERM_READ;
+ attr_perms[0].id = frontend_perms[0].id = device->domid;
+ attr_perms[0].perms = frontend_perms[0].perms = XS_PERM_NONE;
+ attr_perms[1].id = frontend_perms[1].id = device->backend_domid;
+ attr_perms[1].perms = frontend_perms[1].perms = XS_PERM_READ;
ro_frontend_perms[0].id = backend_perms[0].id = device->backend_domid;
ro_frontend_perms[0].perms = backend_perms[0].perms = XS_PERM_NONE;
@@ -162,6 +174,12 @@ retry_transaction:
libxl__xs_writev(gc, t, backend_path, bents);
}
+ if (attr) {
+ xs_rm(ctx->xsh, t, attr_path);
+ xs_mkdir(ctx->xsh, t, attr_path);
+ xs_set_permissions(ctx->xsh, t, attr_path, attr_perms,
ARRAY_SIZE(attr_perms));
+ }
+
if (!create_transaction)
return 0;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index ab62e6f..89d893f 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1159,9 +1159,12 @@ _hidden int libxl__device_console_add(libxl__gc *gc,
uint32_t domid,
_hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
libxl__device *device);
_hidden int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
- libxl__device *device, char **bents, char **fents, char **ro_fents);
+ libxl__device *device, char **bents,
+ char **fents, char **ro_fents,
+ bool attr);
_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_attr_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_destroy(libxl__gc *gc, libxl__device *dev);
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index de3976b..c175939 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -111,7 +111,8 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
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),
- NULL);
+ NULL,
+ false);
return 0;
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |