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

Re: [Xen-devel] [PATCH] libxl: add a new Array type to the IDL



> Since there are currently no uses of this type there is no change to
> the generated code.

But for reference if I add Dario's numa info type:

diff -r 03b641aa89f9 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Wed Jun 27 11:05:57 2012 +0100
+++ b/tools/libxl/libxl_types.idl       Wed Jun 27 11:13:44 2012 +0100
@@ -423,6 +423,12 @@ libxl_physinfo = Struct("physinfo", [
     ("cap_hvm_directio", bool),
     ], dir=DIR_OUT)
 
+libxl_numainfo = Struct("numainfo", [
+    ("size", uint64),
+    ("free", uint64),
+    ("dists", Array(uint32, "num_dists")),
+    ], dir=DIR_OUT)
+
 libxl_cputopology = Struct("cputopology", [
     ("core", uint32),
     ("socket", uint32),

then I get the following diff to the generated files:

--- tools/libxl/_libxl_types.c.baseline 2012-06-27 10:08:58.000000000 +0100
+++ tools/libxl/_libxl_types.c  2012-06-27 11:12:06.000000000 +0100
@@ -176,6 +176,12 @@ void libxl_physinfo_dispose(libxl_physin
     memset(p, LIBXL_DTOR_POISON, sizeof(*p));
 }
 
+void libxl_numainfo_dispose(libxl_numainfo *p)
+{
+    free(p->dists);
+    memset(p, LIBXL_DTOR_POISON, sizeof(*p));
+}
+
 void libxl_cputopology_dispose(libxl_cputopology *p)
 {
     memset(p, LIBXL_DTOR_POISON, sizeof(*p));
@@ -337,6 +343,11 @@ void libxl_physinfo_init(libxl_physinfo
     memset(p, '\0', sizeof(*p));
 }
 
+void libxl_numainfo_init(libxl_numainfo *p)
+{
+    memset(p, '\0', sizeof(*p));
+}
+
 void libxl_cputopology_init(libxl_cputopology *p)
 {
     memset(p, '\0', sizeof(*p));
@@ -2554,6 +2565,53 @@ char *libxl_physinfo_to_json(libxl_ctx *
     return libxl__object_to_json(ctx, "libxl_physinfo", 
(libxl__gen_json_callback)&libxl_physinfo_gen_json, (void *)p);
 }
 
+yajl_gen_status libxl_numainfo_gen_json(yajl_gen hand, libxl_numainfo *p)
+{
+    yajl_gen_status s;
+    s = yajl_gen_map_open(hand);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    s = yajl_gen_string(hand, (const unsigned char *)"size", sizeof("size")-1);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    s = yajl_gen_integer(hand, p->size);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    s = yajl_gen_string(hand, (const unsigned char *)"free", sizeof("free")-1);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    s = yajl_gen_integer(hand, p->free);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    s = yajl_gen_string(hand, (const unsigned char *)"dists", 
sizeof("dists")-1);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    {
+        int i;
+        s = yajl_gen_array_open(hand);
+        if (s != yajl_gen_status_ok)
+            goto out;
+        for (i=0; i<p->num_dists; i++) {
+            s = yajl_gen_integer(hand, p->dists[i]);
+            if (s != yajl_gen_status_ok)
+                goto out;
+        }
+        s = yajl_gen_array_close(hand);
+        if (s != yajl_gen_status_ok)
+            goto out;
+    }
+    s = yajl_gen_map_close(hand);
+    if (s != yajl_gen_status_ok)
+        goto out;
+    out:
+    return s;
+}
+
+char *libxl_numainfo_to_json(libxl_ctx *ctx, libxl_numainfo *p)
+{
+    return libxl__object_to_json(ctx, "libxl_numainfo", 
(libxl__gen_json_callback)&libxl_numainfo_gen_json, (void *)p);
+}
+
 yajl_gen_status libxl_cputopology_gen_json(yajl_gen hand, libxl_cputopology *p)
 {
     yajl_gen_status s;
--- tools/libxl/_libxl_types.h.baseline 2012-06-27 10:08:58.000000000 +0100
+++ tools/libxl/_libxl_types.h  2012-06-27 11:12:06.000000000 +0100
@@ -475,6 +475,16 @@ void libxl_physinfo_dispose(libxl_physin
 void libxl_physinfo_init(libxl_physinfo *p);
 char *libxl_physinfo_to_json(libxl_ctx *ctx, libxl_physinfo *p);
 
+typedef struct libxl_numainfo {
+    uint64_t size;
+    uint64_t free;
+    int num_dists;
+    uint32_t * dists;
+} libxl_numainfo;
+void libxl_numainfo_dispose(libxl_numainfo *p);
+void libxl_numainfo_init(libxl_numainfo *p);
+char *libxl_numainfo_to_json(libxl_ctx *ctx, libxl_numainfo *p);
+
 typedef struct libxl_cputopology {
     uint32_t core;
     uint32_t socket;
--- tools/libxl/_libxl_types_json.h.baseline    2012-06-27 10:08:58.000000000 
+0100
+++ tools/libxl/_libxl_types_json.h     2012-06-27 11:12:06.000000000 +0100
@@ -40,6 +40,7 @@ yajl_gen_status libxl_diskinfo_gen_json(
 yajl_gen_status libxl_nicinfo_gen_json(yajl_gen hand, libxl_nicinfo *p);
 yajl_gen_status libxl_vcpuinfo_gen_json(yajl_gen hand, libxl_vcpuinfo *p);
 yajl_gen_status libxl_physinfo_gen_json(yajl_gen hand, libxl_physinfo *p);
+yajl_gen_status libxl_numainfo_gen_json(yajl_gen hand, libxl_numainfo *p);
 yajl_gen_status libxl_cputopology_gen_json(yajl_gen hand, libxl_cputopology 
*p);
 yajl_gen_status libxl_sched_credit_params_gen_json(yajl_gen hand, 
libxl_sched_credit_params *p);
 yajl_gen_status libxl_domain_remus_info_gen_json(yajl_gen hand, 
libxl_domain_remus_info *p);
--- tools/python/xen/lowlevel/xl/_pyxl_types.h.baseline 2012-06-27 
10:08:58.000000000 +0100
+++ tools/python/xen/lowlevel/xl/_pyxl_types.h  2012-06-27 11:12:09.000000000 
+0100
@@ -268,6 +268,17 @@ _hidden int Pyphysinfo_Check(PyObject *s
 
 _hidden PyObject *attrib__libxl_hwcap_get(libxl_hwcap *hw_cap);
 
+/* Internal API for libxl_numainfo wrapper */
+typedef struct {
+    PyObject_HEAD;
+    libxl_numainfo obj;
+}Py_numainfo;
+
+_hidden Py_numainfo *Pynumainfo_New(void);
+
+_hidden int Pynumainfo_Check(PyObject *self);
+
+
 /* Internal API for libxl_cputopology wrapper */
 typedef struct {
     PyObject_HEAD;
--- tools/python/xen/lowlevel/xl/_pyxl_types.c.baseline 2012-06-27 
10:08:58.000000000 +0100
+++ tools/python/xen/lowlevel/xl/_pyxl_types.c  2012-06-27 11:12:09.000000000 
+0100
@@ -3495,6 +3495,111 @@ int Pyphysinfo_Check(PyObject *self)
 {
     return (self->ob_type == &Pyphysinfo_Type);
 }
+/* Attribute get/set functions for libxl_numainfo */
+static PyObject *py_numainfo_size_get(Py_numainfo *self, void *priv)
+{
+    return genwrap__ull_get(self->obj.size);
+}
+
+static PyObject *py_numainfo_free_get(Py_numainfo *self, void *priv)
+{
+    return genwrap__ull_get(self->obj.free);
+}
+
+static PyObject *py_numainfo_dists_get(Py_numainfo *self, void *priv)
+{
+    PyErr_SetString(PyExc_NotImplementedError, "Getting libxl_numainfo");
+    return NULL;
+}
+
+static void Pynumainfo_dealloc(Py_numainfo *self)
+{
+    libxl_numainfo_dispose(&self->obj);
+    self->ob_type->tp_free((PyObject *)self);
+}
+
+static int Pynumainfo_init(Py_numainfo *self, PyObject *args, PyObject *kwds)
+{
+    memset(&self->obj, 0, sizeof(self->obj));
+    return genwrap__obj_init((PyObject *)self, args, kwds);
+}
+
+static PyObject *Pynumainfo_new(PyTypeObject *type, PyObject *args, PyObject 
*kwds)
+{
+    Py_numainfo *self = (Py_numainfo *)type->tp_alloc(type, 0);
+    if (self == NULL)
+        return NULL;
+    memset(&self->obj, 0, sizeof(self->obj));
+    return (PyObject *)self;
+}
+
+static PyGetSetDef Pynumainfo_getset[] = {
+    { .name = "size", 
+      .get = (getter)py_numainfo_size_get, 
+      .set = (setter)NULL,
+    },
+    { .name = "free", 
+      .get = (getter)py_numainfo_free_get, 
+      .set = (setter)NULL,
+    },
+    { .name = "dists", 
+      .get = (getter)py_numainfo_dists_get, 
+      .set = (setter)NULL,
+    },
+    { .name = NULL }
+};
+
+static PyTypeObject Pynumainfo_Type= {
+    PyObject_HEAD_INIT(NULL)
+    0,
+    PKG ".numainfo",
+    sizeof(Py_numainfo),
+    0,
+    (destructor)Pynumainfo_dealloc,     /* tp_dealloc        */
+    NULL,                         /* tp_print          */
+    NULL,                         /* tp_getattr        */
+    NULL,                         /* tp_setattr        */
+    NULL,                         /* tp_compare        */
+    NULL,                         /* tp_repr           */
+    NULL,                         /* tp_as_number      */
+    NULL,                         /* tp_as_sequence    */
+    NULL,                         /* tp_as_mapping     */
+    NULL,                         /* tp_hash           */
+    NULL,                         /* tp_call           */
+    NULL,                         /* tp_str            */
+    NULL,                         /* tp_getattro       */
+    NULL,                         /* tp_setattro       */
+    NULL,                         /* tp_as_buffer      */
+    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags          */
+    "numainfo",                         /* tp_doc            */
+    NULL,                         /* tp_traverse       */
+    NULL,                         /* tp_clear          */
+    NULL,                         /* tp_richcompare    */
+    0,                            /* tp_weaklistoffset */
+    NULL,                         /* tp_iter           */
+    NULL,                         /* tp_iternext       */
+    NULL,                         /* tp_methods        */
+    NULL,                         /* tp_members        */
+    Pynumainfo_getset,                  /* tp_getset         */
+    NULL,                         /* tp_base           */
+    NULL,                         /* tp_dict           */
+    NULL,                         /* tp_descr_get      */
+    NULL,                         /* tp_descr_set      */
+    0,                            /* tp_dictoffset     */
+    (initproc)Pynumainfo_init,          /* tp_init           */
+    NULL,                         /* tp_alloc          */
+    Pynumainfo_new,                     /* tp_new            */
+};
+
+Py_numainfo *Pynumainfo_New(void)
+{
+    return (Py_numainfo *)Pynumainfo_new(&Pynumainfo_Type, NULL, NULL);
+}
+
+int Pynumainfo_Check(PyObject *self)
+{
+    return (self->ob_type == &Pynumainfo_Type);
+}
 /* Attribute get/set functions for libxl_cputopology */
 static PyObject *py_cputopology_core_get(Py_cputopology *self, void *priv)
 {
@@ -4100,6 +4205,10 @@ void genwrap__init(PyObject *m)
         Py_INCREF(&Pyphysinfo_Type);
         PyModule_AddObject(m, "physinfo", (PyObject *)&Pyphysinfo_Type);
     }
+    if (PyType_Ready(&Pynumainfo_Type) >= 0) {
+        Py_INCREF(&Pynumainfo_Type);
+        PyModule_AddObject(m, "numainfo", (PyObject *)&Pynumainfo_Type);
+    }
     if (PyType_Ready(&Pycputopology_Type) >= 0) {
         Py_INCREF(&Pycputopology_Type);
         PyModule_AddObject(m, "cputopology", (PyObject *)&Pycputopology_Type);
--- tools/ocaml/libs/xl/_libxl_types.inc.baseline       2012-06-27 
10:08:58.000000000 +0100
+++ tools/ocaml/libs/xl/_libxl_types.inc        2012-06-27 11:12:11.000000000 
+0100
@@ -1129,6 +1129,36 @@ static value Val_physinfo (caml_gc *gc,
 /* Stubs for physinfo */
 value stub_xl_physinfo_get(value v1);
 
+/* Convert numainfo to a caml value */
+static value Val_numainfo (caml_gc *gc, struct caml_logger *lg, libxl_numainfo 
*numainfo_c)
+{
+       CAMLparam0();
+       CAMLlocal1(numainfo_ocaml);
+       {
+               value numainfo_field;
+       
+               numainfo_ocaml = caml_alloc_tuple(3);
+       
+               numainfo_field = caml_copy_int64(numainfo_c->size);
+               Store_field(numainfo_ocaml, 0, numainfo_field);
+       
+               numainfo_field = caml_copy_int64(numainfo_c->free);
+               Store_field(numainfo_ocaml, 1, numainfo_field);
+       
+               {
+                   int i;
+                   value array_elem;
+                   numainfo_field = caml_alloc(numainfo_c->num_dists,0);
+                   for(i=0; i<numainfo_c->num_dists; i++) {
+                       array_elem = caml_copy_int32(numainfo_c->dists[i]);
+                       Store_field(numainfo_field, i, array_elem);
+                   }
+               }
+               Store_field(numainfo_ocaml, 2, numainfo_field);
+       }
+       CAMLreturn(numainfo_ocaml);
+}
+
 /* Convert cputopology to a caml value */
 static value Val_cputopology (caml_gc *gc, struct caml_logger *lg, 
libxl_cputopology *cputopology_c)
 {
--- tools/ocaml/libs/xl/_libxl_types.mli.in.baseline    2012-06-27 
10:08:58.000000000 +0100
+++ tools/ocaml/libs/xl/_libxl_types.mli.in     2012-06-27 11:12:11.000000000 
+0100
@@ -312,6 +312,15 @@ module Physinfo : sig
        external get : unit -> t = "stub_xl_physinfo_get"
 end
 
+module Numainfo : sig
+       type t =
+       {
+               size : int64;
+               free : int64;
+               dists : int32 array;
+       }
+end
+
 module Cputopology : sig
        type t =
        {
--- tools/ocaml/libs/xl/_libxl_types.ml.in.baseline     2012-06-27 
10:08:58.000000000 +0100
+++ tools/ocaml/libs/xl/_libxl_types.ml.in      2012-06-27 11:12:11.000000000 
+0100
@@ -312,6 +312,15 @@ module Physinfo = struct
        external get : unit -> t = "stub_xl_physinfo_get"
 end
 
+module Numainfo = struct
+       type t =
+       {
+               size : int64;
+               free : int64;
+               dists : int32 array;
+       }
+end
+
 module Cputopology = struct
        type t =
        {
--- tools/libxl/testidl.c.baseline      2012-06-27 10:08:58.000000000 +0100
+++ tools/libxl/testidl.c       2012-06-27 11:12:06.000000000 +0100
@@ -521,6 +521,20 @@ static void libxl_physinfo_rand_init(lib
     p->cap_hvm_directio = rand() % 2;
 }
 
+static void libxl_numainfo_rand_init(libxl_numainfo *p);
+static void libxl_numainfo_rand_init(libxl_numainfo *p)
+{
+    p->size = rand() % (sizeof(p->size)*8);
+    p->free = rand() % (sizeof(p->free)*8);
+    p->num_dists = rand()%8;
+    p->dists = calloc(p->num_dists, sizeof(*p->dists));
+    {
+        int i;
+        for (i=0; i<p->num_dists; i++)
+            p->dists[i] = rand() % (sizeof(p->dists[i])*8);
+    }
+}
+
 static void libxl_cputopology_rand_init(libxl_cputopology *p);
 static void libxl_cputopology_rand_init(libxl_cputopology *p)
 {
@@ -610,6 +624,7 @@ int main(int argc, char **argv)
     libxl_nicinfo libxl_nicinfo_val;
     libxl_vcpuinfo libxl_vcpuinfo_val;
     libxl_physinfo libxl_physinfo_val;
+    libxl_numainfo libxl_numainfo_val;
     libxl_cputopology libxl_cputopology_val;
     libxl_sched_credit_params libxl_sched_credit_params_val;
     libxl_domain_remus_info libxl_domain_remus_info_val;
@@ -842,6 +857,13 @@ int main(int argc, char **argv)
     free(s);
     libxl_physinfo_dispose(&libxl_physinfo_val);
 
+    libxl_numainfo_rand_init(&libxl_numainfo_val);
+    s = libxl_numainfo_to_json(ctx, &libxl_numainfo_val);
+    printf("%s: %s\n", "libxl_numainfo", s);
+    if (s == NULL) abort();
+    free(s);
+    libxl_numainfo_dispose(&libxl_numainfo_val);
+
     libxl_cputopology_rand_init(&libxl_cputopology_val);
     s = libxl_cputopology_to_json(ctx, &libxl_cputopology_val);
     printf("%s: %s\n", "libxl_cputopology", s);





_______________________________________________
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®.