Mailing List Archive

[PATCH 09 of 32] tools: libxl: add libxl_domid to IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1303133983 -3600
# Node ID c68e419be515d97aa9cad9575183845caf7fd3a0
# Parent 131f78406e7ea77c387aa988bae21bcb4fe50416
tools: libxl: add libxl_domid to IDL

Language bindings would like to strongly type the domid as a separate
type so make it a defined type.

This patch only impacts the datatypes and autogenerated destructors, I
didn't think the churn of switching the uint32_t's through the code
was worth it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 131f78406e7e -r c68e419be515 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Mon Apr 18 14:39:14 2011 +0100
+++ b/tools/libxl/libxl.h Mon Apr 18 14:39:43 2011 +0100
@@ -183,6 +183,8 @@ void libxl_cpuid_destroy(libxl_cpuid_pol

#define LIBXL_PCI_FUNC_ALL (~0U)

+typedef uint32_t libxl_domid;
+
#include "_libxl_types.h"

typedef struct libxl__ctx libxl_ctx;
diff -r 131f78406e7e -r c68e419be515 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Mon Apr 18 14:39:14 2011 +0100
+++ b/tools/libxl/libxl.idl Mon Apr 18 14:39:43 2011 +0100
@@ -3,7 +3,7 @@
# Builtin libxl types
#

-libxl_ctx = Builtin("ctx")
+libxl_domid = Builtin("domid")
libxl_uuid = Builtin("uuid")
libxl_mac = Builtin("mac")
libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
@@ -88,7 +88,7 @@ libxl_button = Enumeration("button", [
#
libxl_dominfo = Struct("dominfo",[.
("uuid", libxl_uuid),
- ("domid", domid),
+ ("domid", libxl_domid),
("running", BitField(uint8, 1)),
("blocked", BitField(uint8, 1)),
("paused", BitField(uint8, 1)),
@@ -116,7 +116,7 @@ libxl_cpupoolinfo = Struct("cpupoolinfo"

libxl_vminfo = Struct("vminfo", [
("uuid", libxl_uuid),
- ("domid", domid),
+ ("domid", libxl_domid),
], destructor_fn=None)

libxl_version_info = Struct("version_info", [
@@ -198,7 +198,7 @@ libxl_domain_build_state = Struct("domai
], destructor_fn=None)

libxl_device_model_info = Struct("device_model_info",[.
- ("domid", integer),
+ ("domid", libxl_domid),
("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"),
("dom_name", string),
("device_model_version", libxl_device_model_version),
@@ -236,7 +236,7 @@ libxl_device_model_info = Struct("device
Network is missing""")

libxl_device_vfb = Struct("device_vfb", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("vnc", bool, False, "vnc enabled or disabled"),
("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"),
@@ -251,12 +251,12 @@ libxl_device_vfb = Struct("device_vfb",
])

libxl_device_vkb = Struct("device_vkb", [
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
])

libxl_device_console = Struct("device_console", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("consback", libxl_console_backend),
("build_state", Reference(libxl_domain_build_state), True),
@@ -264,7 +264,7 @@ libxl_device_console = Struct("device_co
])

libxl_device_disk = Struct("device_disk", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("pdev_path", string),
("vdev", string),
("backend", libxl_disk_backend),
@@ -275,7 +275,7 @@ libxl_device_disk = Struct("device_disk"
])

libxl_device_nic = Struct("device_nic", [
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("mtu", integer),
("model", string),
diff -r 131f78406e7e -r c68e419be515 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Mon Apr 18 14:39:14 2011 +0100
+++ b/tools/libxl/libxltypes.py Mon Apr 18 14:39:43 2011 +0100
@@ -194,8 +194,6 @@ uint16 = UInt(16)
uint32 = UInt(32)
uint64 = UInt(64)

-domid = UInt(32)
-
string = Builtin("char *", namespace = None, destructor_fn = "free")

class OrderedDict(dict):
diff -r 131f78406e7e -r c68e419be515 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:39:14 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Mon Apr 18 14:39:43 2011 +0100
@@ -155,6 +155,7 @@ int genwrap__ll_set(PyObject *v, long lo
*val = tmp;
return 0;
}
+
static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len)
{
char *tmp;
@@ -275,6 +276,11 @@ int attrib__libxl_uuid_set(PyObject *v,
return fixed_bytearray_set(v, libxl_uuid_bytearray(pptr), 16);
}

+int attrib__libxl_domid_set(PyObject *v, libxl_domid *domid) {
+ *domid = PyInt_AsLong(v);
+ return 0;
+}
+
int attrib__struct_in_addr_set(PyObject *v, struct in_addr *pptr)
{
PyErr_SetString(PyExc_NotImplementedError, "Setting in_addr");
@@ -362,6 +368,10 @@ PyObject *attrib__libxl_uuid_get(libxl_u
return fixed_bytearray_get(libxl_uuid_bytearray(pptr), 16);
}

+PyObject *attrib__libxl_domid_get(libxl_domid *domid) {
+ return PyInt_FromLong(*domid);
+}
+
PyObject *attrib__struct_in_addr_get(struct in_addr *pptr)
{
PyErr_SetString(PyExc_NotImplementedError, "Getting in_addr");

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
[PATCH 09 of 32] tools: libxl: add libxl_domid to IDL [ In reply to ]
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1303315987 -3600
# Node ID e19934c3d1c1c5daff74ea2f3b304fd873b3094c
# Parent 7b8cf10806a14c913e659a5e8fe804b9c9b44f1a
tools: libxl: add libxl_domid to IDL

Language bindings would like to strongly type the domid as a separate
type so make it a defined type.

This patch only impacts the datatypes and autogenerated destructors, I
didn't think the churn of switching the uint32_t's through the code
was worth it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 20 17:13:07 2011 +0100
@@ -183,6 +183,8 @@ void libxl_cpuid_destroy(libxl_cpuid_pol

#define LIBXL_PCI_FUNC_ALL (~0U)

+typedef uint32_t libxl_domid;
+
#include "_libxl_types.h"

typedef struct libxl__ctx libxl_ctx;
diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 20 17:13:07 2011 +0100
@@ -3,7 +3,7 @@
# Builtin libxl types
#

-libxl_ctx = Builtin("ctx")
+libxl_domid = Builtin("domid")
libxl_uuid = Builtin("uuid")
libxl_mac = Builtin("mac")
libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
@@ -88,7 +88,7 @@ libxl_button = Enumeration("button", [
#
libxl_dominfo = Struct("dominfo",[.
("uuid", libxl_uuid),
- ("domid", domid),
+ ("domid", libxl_domid),
("running", BitField(uint8, 1)),
("blocked", BitField(uint8, 1)),
("paused", BitField(uint8, 1)),
@@ -116,7 +116,7 @@ libxl_cpupoolinfo = Struct("cpupoolinfo"

libxl_vminfo = Struct("vminfo", [
("uuid", libxl_uuid),
- ("domid", domid),
+ ("domid", libxl_domid),
], destructor_fn=None)

libxl_version_info = Struct("version_info", [
@@ -198,7 +198,7 @@ libxl_domain_build_state = Struct("domai
], destructor_fn=None)

libxl_device_model_info = Struct("device_model_info",[.
- ("domid", integer),
+ ("domid", libxl_domid),
("uuid", libxl_uuid, False, "this is use only with stubdom, and must be different from the domain uuid"),
("dom_name", string),
("device_model_version", libxl_device_model_version),
@@ -236,7 +236,7 @@ libxl_device_model_info = Struct("device
Network is missing""")

libxl_device_vfb = Struct("device_vfb", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("vnc", bool, False, "vnc enabled or disabled"),
("vnclisten", string, False, "address:port that should be listened on for the VNC server if vnc is set"),
@@ -251,12 +251,12 @@ libxl_device_vfb = Struct("device_vfb",
])

libxl_device_vkb = Struct("device_vkb", [
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
])

libxl_device_console = Struct("device_console", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("consback", libxl_console_backend),
("build_state", Reference(libxl_domain_build_state), True),
@@ -264,7 +264,7 @@ libxl_device_console = Struct("device_co
])

libxl_device_disk = Struct("device_disk", [.
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("pdev_path", string),
("vdev", string),
("backend", libxl_disk_backend),
@@ -275,7 +275,7 @@ libxl_device_disk = Struct("device_disk"
])

libxl_device_nic = Struct("device_nic", [
- ("backend_domid", uint32),
+ ("backend_domid", libxl_domid),
("devid", integer),
("mtu", integer),
("model", string),
diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100
+++ b/tools/libxl/libxltypes.py Wed Apr 20 17:13:07 2011 +0100
@@ -184,8 +184,6 @@ uint16 = UInt(16)
uint32 = UInt(32)
uint64 = UInt(64)

-domid = UInt(32)
-
string = Builtin("char *", namespace = None, destructor_fn = "free")

class OrderedDict(dict):
diff -r 7b8cf10806a1 -r e19934c3d1c1 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 20 17:13:07 2011 +0100
@@ -155,6 +155,7 @@ int genwrap__ll_set(PyObject *v, long lo
*val = tmp;
return 0;
}
+
static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len)
{
char *tmp;
@@ -275,6 +276,11 @@ int attrib__libxl_uuid_set(PyObject *v,
return fixed_bytearray_set(v, libxl_uuid_bytearray(pptr), 16);
}

+int attrib__libxl_domid_set(PyObject *v, libxl_domid *domid) {
+ *domid = PyInt_AsLong(v);
+ return 0;
+}
+
int attrib__struct_in_addr_set(PyObject *v, struct in_addr *pptr)
{
PyErr_SetString(PyExc_NotImplementedError, "Setting in_addr");
@@ -362,6 +368,10 @@ PyObject *attrib__libxl_uuid_get(libxl_u
return fixed_bytearray_get(libxl_uuid_bytearray(pptr), 16);
}

+PyObject *attrib__libxl_domid_get(libxl_domid *domid) {
+ return PyInt_FromLong(*domid);
+}
+
PyObject *attrib__struct_in_addr_get(struct in_addr *pptr)
{
PyErr_SetString(PyExc_NotImplementedError, "Getting in_addr");

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel