handcoded = ["libxl_cpumap", "libxl_key_value_list",
"libxl_cpuid_policy_list", "libxl_file_reference",
- "libxl_string_list", "libxl_cpuarray"]
+ "libxl_string_list"]
def gen_rand_init(ty, v, indent = " ", parent = None):
s = ""
l[i] = NULL;
*p = l;
}
-
-#if 0 /* To be remove in a subsequent patch */
-static void libxl_cpuarray_rand_init(libxl_cpuarray *p)
-{
- int i;
- /* Up to 16 VCPUs on 32 PCPUS */
- p->entries = rand() % 16;
- p->array = calloc(p->entries, sizeof(*p->array));
- for (i = 0; i < p->entries; i++) {
- int r = rand() % 32*1.5; /* 2:1 valid:invalid */
- if (r >= 32)
- p->array[i] = LIBXL_CPUARRAY_INVALID_ENTRY;
- else
- p->array[i] = r;
- }
-}
-#endif
""")
for ty in builtins + types:
if ty.typename not in handcoded:
} libxl_cpumap;
void libxl_cpumap_dispose(libxl_cpumap *map);
-typedef struct {
- uint32_t entries;
- uint32_t *array;
-} libxl_cpuarray;
-#define LIBXL_CPUARRAY_INVALID_ENTRY ~0
-void libxl_cpuarray_dispose(libxl_cpuarray *array);
-
typedef struct {
/*
* Path is always set if the file reference is valid. However if
return s;
}
-yajl_gen_status libxl_cpuarray_gen_json(yajl_gen hand,
- libxl_cpuarray *cpuarray)
-{
- yajl_gen_status s;
- int i;
-
- s = yajl_gen_array_open(hand);
- if (s != yajl_gen_status_ok) goto out;
-
- for(i=0; i<cpuarray->entries; i++) {
- if (cpuarray->array[i] == LIBXL_CPUARRAY_INVALID_ENTRY)
- s = yajl_gen_null(hand);
- else
- s = yajl_gen_integer(hand, cpuarray->array[i]);
- if (s != yajl_gen_status_ok) goto out;
- }
- s = yajl_gen_array_close(hand);
-out:
- return s;
-}
-
yajl_gen_status libxl_file_reference_gen_json(yajl_gen hand,
libxl_file_reference *p)
{
libxl_uuid = Builtin("uuid", passby=PASS_BY_REFERENCE)
libxl_mac = Builtin("mac", passby=PASS_BY_REFERENCE)
libxl_cpumap = Builtin("cpumap", dispose_fn="libxl_cpumap_dispose", passby=PASS_BY_REFERENCE)
-libxl_cpuarray = Builtin("cpuarray", dispose_fn="libxl_cpuarray_dispose", passby=PASS_BY_REFERENCE)
libxl_cpuid_policy_list = Builtin("cpuid_policy_list", dispose_fn="libxl_cpuid_dispose", passby=PASS_BY_REFERENCE)
libxl_string_list = Builtin("string_list", dispose_fn="libxl_string_list_dispose", passby=PASS_BY_REFERENCE)
cpumap->map[cpu / 8] &= ~(1 << (cpu & 7));
}
-int libxl_cpuarray_alloc(libxl_ctx *ctx, libxl_cpuarray *cpuarray)
-{
- int max_cpus;
- int i;
-
- max_cpus = libxl_get_max_cpus(ctx);
- if (max_cpus == 0)
- return ERROR_FAIL;
-
- cpuarray->array = calloc(max_cpus, sizeof(*cpuarray->array));
- if (!cpuarray->array)
- return ERROR_NOMEM;
- cpuarray->entries = max_cpus;
- for (i = 0; i < max_cpus; i++)
- cpuarray->array[i] = LIBXL_CPUARRAY_INVALID_ENTRY;
-
- return 0;
-}
-
-void libxl_cpuarray_dispose(libxl_cpuarray *array)
-{
- free(array->array);
-}
-
int libxl_get_max_cpus(libxl_ctx *ctx)
{
return xc_get_max_cpus(ctx->xch);
#define libxl_for_each_set_cpu(v, m) for (v = 0; v < (m).size * 8; v++) \
if (libxl_cpumap_test(&(m), v))
-int libxl_cpuarray_alloc(libxl_ctx *ctx, libxl_cpuarray *cpuarray);
-
static inline uint32_t libxl__sizekb_to_mb(uint32_t s) {
return (s + 1023) / 1024;
}
return 0;
}
-int attrib__libxl_cpuarray_set(PyObject *v, libxl_cpuarray *pptr)
-{
- return -1;
-}
-
int attrib__libxl_file_reference_set(PyObject *v, libxl_file_reference *pptr)
{
return genwrap__string_set(v, &pptr->path);
return cpulist;
}
-PyObject *attrib__libxl_cpuarray_get(libxl_cpuarray *pptr)
-{
- PyObject *list = NULL;
- int i;
-
- list = PyList_New(0);
- for (i = 0; i < pptr->entries; i++) {
- if (pptr->array[i] == LIBXL_CPUARRAY_INVALID_ENTRY) {
- PyList_Append(list, Py_None);
- } else {
- PyObject* pyint = PyInt_FromLong(pptr->array[i]);
-
- PyList_Append(list, pyint);
- Py_DECREF(pyint);
- }
- }
- return list;
-}
-
PyObject *attrib__libxl_file_reference_get(libxl_file_reference *pptr)
{
return genwrap__string_get(&pptr->path);