[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 04 of 11] libxl: expand the libxl_{cpu, node}map API a bit



By adding copying and *_is_full/*_is_empty facilities.

Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>

diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -505,6 +505,35 @@ static int libxl_map_alloc(libxl_ctx *ct
     return 0;
 }
 
+static void libxl_map_copy(struct libxl_map *dptr,
+                           const struct libxl_map *sptr)
+{
+    int sz;
+
+    sz = dptr->size = sptr->size;
+    memcpy(dptr->map, sptr->map, sz * sizeof(*dptr->map));
+}
+
+int libxl_map_is_full(struct libxl_map *map)
+{
+    int i;
+
+    for (i = 0; i < map->size; i++)
+        if (map->map[i] != (uint8_t)-1)
+            return -1;
+    return 0;
+}
+
+int libxl_map_is_empty(struct libxl_map *map)
+{
+    int i;
+
+    for (i = 0; i < map->size; i++)
+        if (map->map[i])
+            return -1;
+    return 0;
+}
+
 int libxl_map_test(struct libxl_map *map, int elem)
 {
     if (elem >= map->size * 8)
@@ -548,6 +577,18 @@ int libxl_nodemap_alloc(libxl_ctx *ctx, 
     return libxl_map_alloc(ctx, nodemap, max_nodes);
 }
 
+void libxl_cpumap_copy(/*XXX libxl_ctx *ctx,*/ libxl_cpumap *dst,
+                       const libxl_cpumap *src)
+{
+    libxl_map_copy(dst, src);
+}
+
+void libxl_nodemap_copy(/*XXX libxl_ctx *ctx,*/ libxl_nodemap *dst,
+                       const libxl_nodemap *src)
+{
+   libxl_map_copy(dst, src);
+}
+
 int libxl_get_max_cpus(libxl_ctx *ctx)
 {
     return xc_get_max_cpus(ctx->xch);
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -63,6 +63,8 @@ int libxl_devid_to_device_nic(libxl_ctx 
 int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid, const char *vdev,
                                libxl_device_disk *disk);
 
+int libxl_map_is_full(struct libxl_map *map);
+int libxl_map_is_empty(struct libxl_map *map);
 int libxl_map_test(struct libxl_map *map, int elem);
 void libxl_map_set(struct libxl_map *map, int elem);
 void libxl_map_reset(struct libxl_map *map, int elem);
@@ -80,6 +82,16 @@ static inline int libxl_map_elem_valid(s
 }
 
 int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap);
+void libxl_cpumap_copy(/*XXX libxl_ctx *ctx, */ libxl_cpumap *dst,
+                       const libxl_cpumap *src);
+static inline int libxl_cpumap_is_full(libxl_cpumap *cpumap)
+{
+    return libxl_map_is_full(cpumap);
+}
+static inline int libxl_cpumap_is_empty(libxl_cpumap *cpumap)
+{
+    return libxl_map_is_empty(cpumap);
+}
 static inline int libxl_cpumap_test(libxl_cpumap *cpumap, int cpu)
 {
     return libxl_map_test(cpumap, cpu);
@@ -109,6 +121,16 @@ static inline int libxl_cpumap_cpu_valid
                                              if (libxl_cpumap_test(&(m), v))
 
 int libxl_nodemap_alloc(libxl_ctx *ctx, libxl_nodemap *nodemap);
+void libxl_nodemap_copy(/*XXX libxl_ctx *ctx, */ libxl_nodemap *dst,
+                       const libxl_nodemap *src);
+static inline int libxl_nodemap_is_full(libxl_nodemap *nodemap)
+{
+    return libxl_map_is_full(nodemap);
+}
+static inline int libxl_nodemap_is_empty(libxl_nodemap *nodemap)
+{
+    return libxl_map_is_empty(nodemap);
+}
 static inline int libxl_nodemap_test(libxl_nodemap *nodemap, int node)
 {
     return libxl_map_test(nodemap, node);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.