Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 00 of 24] tools: IDL improvements and ocaml datatype generation
The following series makes some improvements to the libxl IDL and then uses them to autogenerate the datatypes and datatype-conversion for the ocaml bindings. The series incorporates much of Dave Scott''s ocaml interface cleanup series but excludes the network QoS bits (patches 13..14/14 in his series) since there were outstanding questions around that stuff. I would appreciate some advice on the handling of the integer types and their conversion from someone who knows about ocaml C bindings. In particular the handling of >=32-bit integers (ocaml ints are 31 bits) is not clear and probably intcorrect. Not all of the datatypes are actually usable via the ocaml interfaces yet since the stub functions have not been implemented. I used -Wno-unused for now but this should go away as the set of stub functions is completed. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 01 of 24] tools: libxl: move all enum values into the libxl namespace
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID f5fb8d97a4b921e1afa9410fb3c75d12bd9e8d28
# Parent 715d0091ac49bb81e40bee5a6ba3420df7376725
tools: libxl: move all enum values into the libxl namespace
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.c Wed Apr 13 13:35:51 2011 +0100
@@ -695,15 +695,15 @@ int libxl_event_get_disk_eject_info(libx
"/local/domain/%d/backend/%"
TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d",
&disk->backend_domid, backend_type);
if (!strcmp(backend_type, "tap") || !strcmp(backend_type,
"vbd")) {
- disk->backend = DISK_BACKEND_TAP;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(backend_type, "qdisk")) {
- disk->backend = DISK_BACKEND_QDISK;
+ disk->backend = LIBXL_DISK_BACKEND_QDISK;
} else {
- disk->backend = DISK_BACKEND_UNKNOWN;
+ disk->backend = LIBXL_DISK_BACKEND_UNKNOWN;
}
disk->pdev_path = strdup("");
- disk->format = DISK_FORMAT_EMPTY;
+ disk->format = LIBXL_DISK_FORMAT_EMPTY;
/* this value is returned to the user: do not free right away */
disk->vdev = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc,
"%s/dev", backend), NULL);
disk->unpluggable = 1;
@@ -908,7 +908,7 @@ static int validate_virtual_disk(libxl__
struct stat stat_buf;
char *delimiter;
- if (disk->format == DISK_FORMAT_EMPTY) {
+ if (disk->format == LIBXL_DISK_FORMAT_EMPTY) {
if (disk->is_cdrom)
return 0;
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Empty disk %s is not a CDROM
device\n",
@@ -916,11 +916,11 @@ static int validate_virtual_disk(libxl__
return ERROR_INVAL;
}
- if (disk->format == DISK_FORMAT_RAW) {
+ if (disk->format == LIBXL_DISK_FORMAT_RAW) {
delimiter = strchr(file_name, '':'');
if (delimiter) {
if (!strncmp(file_name, "vhd:",
sizeof("vhd:")-1)) {
- disk->format = DISK_FORMAT_VHD;
+ disk->format = LIBXL_DISK_FORMAT_VHD;
file_name = ++delimiter;
}
}
@@ -930,7 +930,7 @@ static int validate_virtual_disk(libxl__
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s",
file_name);
return ERROR_INVAL;
}
- if (disk->backend == DISK_BACKEND_PHY) {
+ if (disk->backend == LIBXL_DISK_BACKEND_PHY) {
if ( !(S_ISBLK(stat_buf.st_mode)) ) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a
block device!\n",
file_name);
@@ -984,19 +984,20 @@ int libxl_device_disk_add(libxl_ctx *ctx
device.kind = DEVICE_VBD;
/* If blktap is not available then fallback to qdisk */
- if (disk->backend == DISK_BACKEND_TAP &&
!libxl__blktap_enabled(&gc))
- disk->backend = DISK_BACKEND_QDISK;
+ if (disk->backend == LIBXL_DISK_BACKEND_TAP &&
!libxl__blktap_enabled(&gc))
+ disk->backend = LIBXL_DISK_BACKEND_QDISK;
/*
* blktap cannot handle empty disks (aka cdroms). Fall back to
* qdisk because qemu-xen creates the disk based on the xenstore
* entries.
*/
- if (disk->backend == DISK_BACKEND_TAP && disk->format ==
DISK_FORMAT_EMPTY)
- disk->backend == DISK_BACKEND_QDISK;
+ if (disk->backend == LIBXL_DISK_BACKEND_TAP &&
+ disk->format == LIBXL_DISK_FORMAT_EMPTY)
+ disk->backend == LIBXL_DISK_BACKEND_QDISK;
switch (disk->backend) {
- case DISK_BACKEND_PHY:
+ case LIBXL_DISK_BACKEND_PHY:
dev = disk->pdev_path;
do_backend_phy:
libxl__device_physdisk_major_minor(dev, &major, &minor);
@@ -1008,7 +1009,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
device.backend_kind = DEVICE_VBD;
break;
- case DISK_BACKEND_TAP:
+ case LIBXL_DISK_BACKEND_TAP:
dev = libxl__blktap_devpath(&gc, disk->pdev_path,
disk->format);
if (!dev) {
rc = ERROR_FAIL;
@@ -1021,8 +1022,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
/* now create a phy device to export the device to the guest */
goto do_backend_phy;
-
- case DISK_BACKEND_QDISK:
+ case LIBXL_DISK_BACKEND_QDISK:
flexarray_append(back, "params");
flexarray_append(back, libxl__sprintf(&gc, "%s:%s",
libxl__device_disk_string_of_format(disk->format),
disk->pdev_path));
@@ -1091,13 +1091,13 @@ int libxl_device_disk_del(libxl_ctx *ctx
device.backend_devid = devid;
switch (disk->backend) {
- case DISK_BACKEND_PHY:
+ case LIBXL_DISK_BACKEND_PHY:
device.backend_kind = DEVICE_VBD;
break;
- case DISK_BACKEND_TAP:
+ case LIBXL_DISK_BACKEND_TAP:
device.backend_kind = DEVICE_VBD;
break;
- case DISK_BACKEND_QDISK:
+ case LIBXL_DISK_BACKEND_QDISK:
device.backend_kind = DEVICE_QDISK;
break;
default:
@@ -1124,8 +1124,8 @@ char * libxl_device_disk_local_attach(li
char *ret = NULL;
switch (disk->backend) {
- case DISK_BACKEND_PHY:
- if (disk->format != DISK_FORMAT_RAW) {
+ case LIBXL_DISK_BACKEND_PHY:
+ if (disk->format != LIBXL_DISK_FORMAT_RAW) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "physical block device
must"
" be raw");
break;
@@ -1134,13 +1134,14 @@ char * libxl_device_disk_local_attach(li
disk->pdev_path);
dev = disk->pdev_path;
break;
- case DISK_BACKEND_TAP:
- if (disk->format == DISK_FORMAT_VHD || disk->format ==
DISK_FORMAT_RAW)
+ case LIBXL_DISK_BACKEND_TAP:
+ if (disk->format == LIBXL_DISK_FORMAT_VHD ||
+ disk->format == LIBXL_DISK_FORMAT_RAW)
{
if (libxl__blktap_enabled(&gc))
dev = libxl__blktap_devpath(&gc, disk->pdev_path,
disk->format);
else {
- if (disk->format != DISK_FORMAT_RAW) {
+ if (disk->format != LIBXL_DISK_FORMAT_RAW) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "tapdisk2 is
required"
" to open a vhd disk");
break;
@@ -1152,8 +1153,8 @@ char * libxl_device_disk_local_attach(li
}
}
break;
- } else if (disk->format == DISK_FORMAT_QCOW ||
- disk->format == DISK_FORMAT_QCOW2) {
+ } else if (disk->format == LIBXL_DISK_FORMAT_QCOW ||
+ disk->format == LIBXL_DISK_FORMAT_QCOW2) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach a
qcow or qcow2 disk image");
break;
} else {
@@ -1161,8 +1162,8 @@ char * libxl_device_disk_local_attach(li
"type: %d", disk->backend);
break;
}
- case DISK_BACKEND_QDISK:
- if (disk->format != DISK_FORMAT_RAW) {
+ case LIBXL_DISK_BACKEND_QDISK:
+ if (disk->format != LIBXL_DISK_FORMAT_RAW) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach a
qdisk "
"image if the format is not raw");
break;
@@ -1171,7 +1172,7 @@ char * libxl_device_disk_local_attach(li
disk->pdev_path);
dev = disk->pdev_path;
break;
- case DISK_BACKEND_UNKNOWN:
+ case LIBXL_DISK_BACKEND_UNKNOWN:
default:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend
"
"type: %d", disk->backend);
@@ -1222,7 +1223,7 @@ int libxl_device_nic_init(libxl_device_n
if ( asprintf(&nic_info->script, "%s/vif-bridge",
libxl_xen_script_dir_path()) < 0 )
return ERROR_FAIL;
- nic_info->nictype = NICTYPE_IOEMU;
+ nic_info->nictype = LIBXL_NICTYPE_IOEMU;
return 0;
}
@@ -1585,7 +1586,7 @@ static unsigned int libxl__append_disk_l
pdisk->readwrite = 0;
type = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc,
"%s/device-type", libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc,
"%s/%s/frontend", be_path, *dir))));
pdisk->is_cdrom = !strcmp(type, "cdrom");
- pdisk->format = DISK_FORMAT_UNKNOWN;
+ pdisk->format = LIBXL_DISK_FORMAT_UNKNOWN;
}
}
@@ -1650,7 +1651,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
if (!disk->pdev_path) {
disk->pdev_path = strdup("");
- disk->format = DISK_FORMAT_EMPTY;
+ disk->format = LIBXL_DISK_FORMAT_EMPTY;
}
disks = libxl_device_disk_list(ctx, domid, &num);
for (i = 0; i < num; i++) {
@@ -2170,10 +2171,10 @@ int libxl_button_press(libxl_ctx *ctx, u
int rc = -1;
switch (button) {
- case POWER_BUTTON:
+ case LIBXL_BUTTON_POWER:
rc = xc_domain_send_trigger(ctx->xch, domid,
XEN_DOMCTL_SENDTRIGGER_POWER, 0);
break;
- case SLEEP_BUTTON:
+ case LIBXL_BUTTON_SLEEP:
rc = xc_domain_send_trigger(ctx->xch, domid,
XEN_DOMCTL_SENDTRIGGER_SLEEP, 0);
break;
default:
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
@@ -162,8 +162,8 @@ typedef struct {
void libxl_cpuarray_destroy(libxl_cpuarray *array);
typedef enum {
- XENFV = 1,
- XENPV,
+ LIBXL_QEMU_MACHINE_TYPE_FV = 1,
+ LIBXL_QEMU_MACHINE_TYPE_PV,
} libxl_qemu_machine_type;
typedef enum {
@@ -177,24 +177,24 @@ typedef enum {
} libxl_console_consback;
typedef enum {
- DISK_FORMAT_UNKNOWN = 0,
- DISK_FORMAT_QCOW,
- DISK_FORMAT_QCOW2,
- DISK_FORMAT_VHD,
- DISK_FORMAT_RAW,
- DISK_FORMAT_EMPTY,
+ LIBXL_DISK_FORMAT_UNKNOWN = 0,
+ LIBXL_DISK_FORMAT_QCOW,
+ LIBXL_DISK_FORMAT_QCOW2,
+ LIBXL_DISK_FORMAT_VHD,
+ LIBXL_DISK_FORMAT_RAW,
+ LIBXL_DISK_FORMAT_EMPTY,
} libxl_disk_format;
typedef enum {
- DISK_BACKEND_UNKNOWN = 0,
- DISK_BACKEND_PHY,
- DISK_BACKEND_TAP,
- DISK_BACKEND_QDISK,
+ LIBXL_DISK_BACKEND_UNKNOWN = 0,
+ LIBXL_DISK_BACKEND_PHY,
+ LIBXL_DISK_BACKEND_TAP,
+ LIBXL_DISK_BACKEND_QDISK,
} libxl_disk_backend;
typedef enum {
- NICTYPE_IOEMU = 1,
- NICTYPE_VIF,
+ LIBXL_NICTYPE_IOEMU = 1,
+ LIBXL_NICTYPE_VIF,
} libxl_nic_type;
typedef struct {
@@ -494,8 +494,8 @@ int libxl_userdata_retrieve(libxl_ctx *c
*/
typedef enum {
- POWER_BUTTON,
- SLEEP_BUTTON
+ LIBXL_BUTTON_POWER,
+ LIBXL_BUTTON_SLEEP
} libxl_button;
int libxl_button_press(libxl_ctx *ctx, uint32_t domid, libxl_button button);
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_device.c Wed Apr 13 13:35:51 2011 +0100
@@ -121,11 +121,11 @@ out:
char *libxl__device_disk_string_of_format(libxl_disk_format format)
{
switch (format) {
- case DISK_FORMAT_QCOW: return "qcow";
- case DISK_FORMAT_QCOW2: return "qcow2";
- case DISK_FORMAT_VHD: return "vhd";
- case DISK_FORMAT_RAW:
- case DISK_FORMAT_EMPTY: return "aio";
+ case LIBXL_DISK_FORMAT_QCOW: return "qcow";
+ case LIBXL_DISK_FORMAT_QCOW2: return "qcow2";
+ case LIBXL_DISK_FORMAT_VHD: return "vhd";
+ case LIBXL_DISK_FORMAT_RAW:
+ case LIBXL_DISK_FORMAT_EMPTY: return "aio";
default: return NULL;
}
}
@@ -133,9 +133,9 @@ char *libxl__device_disk_string_of_forma
char *libxl__device_disk_string_of_backend(libxl_disk_backend backend)
{
switch (backend) {
- case DISK_BACKEND_QDISK: return "qdisk";
- case DISK_BACKEND_TAP: return "phy";
- case DISK_BACKEND_PHY: return "phy";
+ case LIBXL_DISK_BACKEND_QDISK: return "qdisk";
+ case LIBXL_DISK_BACKEND_TAP: return "phy";
+ case LIBXL_DISK_BACKEND_PHY: return "phy";
default: return NULL;
}
}
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
@@ -137,7 +137,7 @@ static char ** libxl__build_device_model
if (info->serial) {
flexarray_vappend(dm_args, "-serial", info->serial, NULL);
}
- if (info->type == XENFV) {
+ if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
int ioemu_vifs = 0;
if (info->videoram) {
@@ -169,7 +169,7 @@ static char ** libxl__build_device_model
flexarray_vappend(dm_args, "-vcpu_avail",
libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL);
}
for (i = 0; i < num_vifs; i++) {
- if (vifs[i].nictype == NICTYPE_IOEMU) {
+ if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
@@ -201,10 +201,14 @@ static char ** libxl__build_device_model
for (i = 0; info->extra && info->extra[i] != NULL; i++)
flexarray_append(dm_args, info->extra[i]);
flexarray_append(dm_args, "-M");
- if (info->type == XENPV)
+ switch (info->type) {
+ case LIBXL_QEMU_MACHINE_TYPE_PV:
flexarray_append(dm_args, "xenpv");
- else
+ break;
+ case LIBXL_QEMU_MACHINE_TYPE_FV:
flexarray_append(dm_args, "xenfv");
+ break;
+ }
flexarray_append(dm_args, NULL);
return (char **) flexarray_contents(dm_args);
}
@@ -212,11 +216,11 @@ static char ** libxl__build_device_model
static const char *qemu_disk_format_string(libxl_disk_format format)
{
switch (format) {
- case DISK_FORMAT_QCOW: return "qcow";
- case DISK_FORMAT_QCOW2: return "qcow2";
- case DISK_FORMAT_VHD: return "vpc";
- case DISK_FORMAT_RAW: return "raw";
- case DISK_FORMAT_EMPTY: return NULL;
+ case LIBXL_DISK_FORMAT_QCOW: return "qcow";
+ case LIBXL_DISK_FORMAT_QCOW2: return "qcow2";
+ case LIBXL_DISK_FORMAT_VHD: return "vpc";
+ case LIBXL_DISK_FORMAT_RAW: return "raw";
+ case LIBXL_DISK_FORMAT_EMPTY: return NULL;
default: return NULL;
}
}
@@ -238,7 +242,7 @@ static char ** libxl__build_device_model
flexarray_vappend(dm_args, dm,
"-xen-domid", libxl__sprintf(gc,
"%d", info->domid), NULL);
- if (info->type == XENPV) {
+ if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV) {
flexarray_append(dm_args, "-xen-attach");
}
@@ -276,7 +280,7 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, "-sdl");
}
- if (info->type == XENPV && !info->nographic) {
+ if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV &&
!info->nographic) {
flexarray_vappend(dm_args, "-vga", "xenfb", NULL);
}
@@ -289,7 +293,7 @@ static char ** libxl__build_device_model
if (info->serial) {
flexarray_vappend(dm_args, "-serial", info->serial, NULL);
}
- if (info->type == XENFV) {
+ if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
int ioemu_vifs = 0;
if (info->stdvga) {
@@ -319,7 +323,7 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, libxl__sprintf(gc, "%d",
info->vcpus));
}
for (i = 0; i < num_vifs; i++) {
- if (vifs[i].nictype == NICTYPE_IOEMU) {
+ if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
@@ -354,16 +358,20 @@ static char ** libxl__build_device_model
for (i = 0; info->extra && info->extra[i] != NULL; i++)
flexarray_append(dm_args, info->extra[i]);
flexarray_append(dm_args, "-M");
- if (info->type == XENPV)
+ switch (info->type) {
+ case LIBXL_QEMU_MACHINE_TYPE_PV:
flexarray_append(dm_args, "xenpv");
- else
+ break;
+ case LIBXL_QEMU_MACHINE_TYPE_FV:
flexarray_append(dm_args, "xenfv");
+ break;
+ }
/* RAM Size */
flexarray_append(dm_args, "-m");
flexarray_append(dm_args, libxl__sprintf(gc, "%d",
info->target_ram));
- if (info->type == XENFV) {
+ if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
for (i; i < num_disks; i++) {
int disk, part;
int dev_number @@ -378,7 +386,7 @@ static char **
libxl__build_device_model
}
if (disks[i].is_cdrom) {
- if (disks[i].format == DISK_FORMAT_EMPTY)
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
drive = libxl__sprintf
(gc, "if=ide,index=%d,media=cdrom", disk);
else
@@ -386,7 +394,7 @@ static char ** libxl__build_device_model
(gc,
"file=%s,if=ide,index=%d,media=cdrom,format=%s",
disks[i].pdev_path, disk, format);
} else {
- if (disks[i].format == DISK_FORMAT_EMPTY) {
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot
support"
" empty disk format for %s",
disks[i].vdev);
continue;
@@ -913,7 +921,7 @@ static int libxl__build_xenpv_qemu_args(
info->dom_name = libxl_domid_to_name(ctx, domid);
info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_DEFAULT;
info->device_model = NULL;
- info->type = XENPV;
+ info->type = LIBXL_QEMU_MACHINE_TYPE_PV;
return 0;
}
@@ -945,7 +953,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc
int blktap_enabled = -1;
for (i = 0; i < nr_disks; i++) {
switch (disks[i].backend) {
- case DISK_BACKEND_TAP:
+ case LIBXL_DISK_BACKEND_TAP:
if (blktap_enabled == -1)
blktap_enabled = libxl__blktap_enabled(gc);
if (!blktap_enabled) {
@@ -954,12 +962,12 @@ int libxl__need_xenpv_qemu(libxl__gc *gc
}
break;
- case DISK_BACKEND_QDISK:
+ case LIBXL_DISK_BACKEND_QDISK:
ret = 1;
goto out;
- case DISK_BACKEND_PHY:
- case DISK_BACKEND_UNKNOWN:
+ case LIBXL_DISK_BACKEND_PHY:
+ case LIBXL_DISK_BACKEND_UNKNOWN:
break;
}
}
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_utils.c Wed Apr 13 13:35:51 2011 +0100
@@ -283,9 +283,9 @@ int libxl_string_to_backend(libxl_ctx *c
int rc = 0;
if (!strcmp(s, "phy")) {
- *backend = DISK_BACKEND_PHY;
+ *backend = LIBXL_DISK_BACKEND_PHY;
} else if (!strcmp(s, "file")) {
- *backend = DISK_BACKEND_TAP;
+ *backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(s, "tap")) {
p = strchr(s, '':'');
if (!p) {
@@ -294,11 +294,11 @@ int libxl_string_to_backend(libxl_ctx *c
}
p++;
if (!strcmp(p, "vhd")) {
- *backend = DISK_BACKEND_TAP;
+ *backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(p, "qcow")) {
- *backend = DISK_BACKEND_QDISK;
+ *backend = LIBXL_DISK_BACKEND_QDISK;
} else if (!strcmp(p, "qcow2")) {
- *backend = DISK_BACKEND_QDISK;
+ *backend = LIBXL_DISK_BACKEND_QDISK;
}
}
out:
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
@@ -481,12 +481,12 @@ static int parse_disk_config(libxl_devic
*p = ''\0'';
if ( !strcmp(tok, "phy") ) {
state = DSTATE_PHYSPATH;
- disk->format = DISK_FORMAT_RAW;
- disk->backend = DISK_BACKEND_PHY;
+ disk->format = LIBXL_DISK_FORMAT_RAW;
+ disk->backend = LIBXL_DISK_BACKEND_PHY;
}else if ( !strcmp(tok, "file") ) {
state = DSTATE_PHYSPATH;
- disk->format = DISK_FORMAT_RAW;
- disk->backend = DISK_BACKEND_TAP;
+ disk->format = LIBXL_DISK_FORMAT_RAW;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
}else if ((!strcmp(tok, "tap")) ||
(!strcmp(tok, "tap2"))) {
state = DSTATE_TAP;
@@ -497,16 +497,16 @@ static int parse_disk_config(libxl_devic
tok = p + 1;
} else if (*p == '','') {
state = DSTATE_VIRTPATH;
- disk->format = DISK_FORMAT_EMPTY;
- disk->backend = DISK_BACKEND_TAP;
+ disk->format = LIBXL_DISK_FORMAT_EMPTY;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
disk->pdev_path = strdup("");
tok = p + 1;
}
break;
case DSTATE_TAP:
if (*p == '','') {
- disk->format = DISK_FORMAT_RAW;
- disk->backend = DISK_BACKEND_TAP;
+ disk->format = LIBXL_DISK_FORMAT_RAW;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
state = DSTATE_PHYSPATH;
} else if ( *p == '':'' ) {
*p = ''\0'';
@@ -515,17 +515,17 @@ static int parse_disk_config(libxl_devic
break;
}
if (!strcmp(tok, "vhd")) {
- disk->format = DISK_FORMAT_VHD;
- disk->backend = DISK_BACKEND_TAP;
+ disk->format = LIBXL_DISK_FORMAT_VHD;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
}else if ( !strcmp(tok, "qcow") ) {
- disk->format = DISK_FORMAT_QCOW;
- disk->backend = DISK_BACKEND_QDISK;
+ disk->format = LIBXL_DISK_FORMAT_QCOW;
+ disk->backend = LIBXL_DISK_BACKEND_QDISK;
}else if ( !strcmp(tok, "qcow2") ) {
- disk->format = DISK_FORMAT_QCOW2;
- disk->backend = DISK_BACKEND_QDISK;
+ disk->format = LIBXL_DISK_FORMAT_QCOW2;
+ disk->backend = LIBXL_DISK_BACKEND_QDISK;
}else if (!strcmp(tok, "raw")) {
- disk->format = DISK_FORMAT_RAW;
- disk->backend = DISK_BACKEND_TAP;
+ disk->format = LIBXL_DISK_FORMAT_RAW;
+ disk->backend = LIBXL_DISK_BACKEND_TAP;
}
else {
fprintf(stderr, "Unknown tapdisk type: %s\n",
tok);
@@ -872,9 +872,9 @@ static void parse_config_data(const char
nic->bridge = strdup(p2 + 1);
} else if (!strcmp(p, "type")) {
if (!strcmp(p2 + 1, "ioemu"))
- nic->nictype = NICTYPE_IOEMU;
+ nic->nictype = LIBXL_NICTYPE_IOEMU;
else
- nic->nictype = NICTYPE_VIF;
+ nic->nictype = LIBXL_NICTYPE_VIF;
} else if (!strcmp(p, "ip")) {
free(nic->ip);
nic->ip = strdup(p2 + 1);
@@ -1130,7 +1130,9 @@ skip_vfb:
}
}
- dm_info->type = c_info->hvm ? XENFV : XENPV;
+ dm_info->type = c_info->hvm ?
+ LIBXL_QEMU_MACHINE_TYPE_FV :
+ LIBXL_QEMU_MACHINE_TYPE_PV;
xlu_cfg_destroy(config);
}
@@ -3319,9 +3321,9 @@ static void button_press(const char *p,
find_domain(p);
if (!strcmp(b, "power")) {
- button = POWER_BUTTON;
+ button = LIBXL_BUTTON_POWER;
} else if (!strcmp(b, "sleep")) {
- button = SLEEP_BUTTON;
+ button = LIBXL_BUTTON_SLEEP;
} else {
fprintf(stderr, "%s is an invalid button identifier\n", b);
exit(2);
@@ -4233,9 +4235,9 @@ int main_networkattach(int argc, char **
for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) {
if (!strncmp("type=", *argv, 5)) {
if (!strncmp("vif", (*argv) + 5, 4)) {
- nic.nictype = NICTYPE_VIF;
+ nic.nictype = LIBXL_NICTYPE_VIF;
} else if (!strncmp("ioemu", (*argv) + 5, 5)) {
- nic.nictype = NICTYPE_IOEMU;
+ nic.nictype = LIBXL_NICTYPE_IOEMU;
} else {
fprintf(stderr, "Invalid parameter
`type''.\n");
return 1;
@@ -4404,22 +4406,22 @@ int main_blockattach(int argc, char **ar
tok = strtok(argv[optind+1], ":");
if (!strcmp(tok, "phy")) {
- disk.backend = DISK_BACKEND_PHY;
+ disk.backend = LIBXL_DISK_BACKEND_PHY;
} else if (!strcmp(tok, "file")) {
- disk.backend = DISK_BACKEND_TAP;
+ disk.backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(tok, "tap")) {
tok = strtok(NULL, ":");
if (!strcmp(tok, "aio")) {
- disk.backend = DISK_BACKEND_TAP;
+ disk.backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(tok, "vhd")) {
- disk.format = DISK_FORMAT_VHD;
- disk.backend = DISK_BACKEND_TAP;
+ disk.format = LIBXL_DISK_FORMAT_VHD;
+ disk.backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(tok, "qcow")) {
- disk.format = DISK_FORMAT_QCOW;
- disk.backend = DISK_BACKEND_QDISK;
+ disk.format = LIBXL_DISK_FORMAT_QCOW;
+ disk.backend = LIBXL_DISK_BACKEND_QDISK;
} else if (!strcmp(tok, "qcow2")) {
- disk.format = DISK_FORMAT_QCOW2;
- disk.backend = DISK_BACKEND_QDISK;
+ disk.format = LIBXL_DISK_FORMAT_QCOW2;
+ disk.backend = LIBXL_DISK_BACKEND_QDISK;
} else {
fprintf(stderr, "Error: `%s'' is not a valid disk
image.\n", tok);
return 1;
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:51 2011 +0100
@@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l
c_val->bridge = dup_String_val(gc, Field(v, 5));
c_val->ifname = dup_String_val(gc, Field(v, 6));
c_val->script = dup_String_val(gc, Field(v, 7));
- c_val->nictype = (Int_val(Field(v, 8))) + NICTYPE_IOEMU;
+ c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU;
out:
CAMLreturn(ret);
@@ -610,7 +610,7 @@ value stub_xl_button_press(value domid,
INIT_STRUCT();
INIT_CTX();
- ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
+ ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) +
LIBXL_BUTTON_POWER);
if (ret != 0)
failwith_xl("button_press", &lg);
FREE_CTX();
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
@@ -769,8 +769,8 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST(m, SHUTDOWN_crash);
_INT_CONST(m, SHUTDOWN_watchdog);
- _INT_CONST(m, XENFV);
- _INT_CONST(m, XENPV);
+ _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_FV);
+ _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_PV);
_INT_CONST_LIBXL(m, CONSTYPE_SERIAL);
_INT_CONST_LIBXL(m, CONSTYPE_PV);
@@ -778,26 +778,26 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED);
_INT_CONST_LIBXL(m, CONSBACK_IOEMU);
- _INT_CONST(m, DISK_FORMAT_UNKNOWN);
- _INT_CONST(m, DISK_FORMAT_QCOW);
- _INT_CONST(m, DISK_FORMAT_QCOW2);
- _INT_CONST(m, DISK_FORMAT_VHD);
- _INT_CONST(m, DISK_FORMAT_RAW);
- _INT_CONST(m, DISK_FORMAT_EMPTY);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW2);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_VHD);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_RAW);
+ _INT_CONST_LIBXL(m, DISK_FORMAT_EMPTY);
- _INT_CONST(m, DISK_BACKEND_UNKNOWN);
- _INT_CONST(m, DISK_BACKEND_PHY);
- _INT_CONST(m, DISK_BACKEND_TAP);
- _INT_CONST(m, DISK_BACKEND_QDISK);
+ _INT_CONST_LIBXL(m, DISK_BACKEND_UNKNOWN);
+ _INT_CONST_LIBXL(m, DISK_BACKEND_PHY);
+ _INT_CONST_LIBXL(m, DISK_BACKEND_TAP);
+ _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK);
- _INT_CONST(m, NICTYPE_IOEMU);
- _INT_CONST(m, NICTYPE_VIF);
+ _INT_CONST_LIBXL(m, NICTYPE_IOEMU);
+ _INT_CONST_LIBXL(m, NICTYPE_VIF);
_INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH);
_INT_CONST_LIBXL(m, EVENT_DISK_EJECT);
- _INT_CONST(m, POWER_BUTTON);
- _INT_CONST(m, SLEEP_BUTTON);
+ _INT_CONST_LIBXL(m, BUTTON_POWER);
+ _INT_CONST_LIBXL(m, BUTTON_SLEEP);
genwrap__init(m);
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 02 of 24] tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID 624f293ec064968fed538177a910bf7479f6a879
# Parent f5fb8d97a4b921e1afa9410fb3c75d12bd9e8d28
tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type
The FV/PV distinction is not particular to the device model, although
that remains the only user for now.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
@@ -162,9 +162,9 @@ typedef struct {
void libxl_cpuarray_destroy(libxl_cpuarray *array);
typedef enum {
- LIBXL_QEMU_MACHINE_TYPE_FV = 1,
- LIBXL_QEMU_MACHINE_TYPE_PV,
-} libxl_qemu_machine_type;
+ LIBXL_DOMAIN_TYPE_FV = 1,
+ LIBXL_DOMAIN_TYPE_PV,
+} libxl_domain_type;
typedef enum {
LIBXL_CONSTYPE_SERIAL = 1,
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
@@ -8,7 +8,7 @@ libxl_uuid = Builtin("uuid")
libxl_mac = Builtin("mac")
libxl_cpumap = Builtin("cpumap",
destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
libxl_cpuarray = Builtin("cpuarray",
destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
-libxl_qemu_machine_type = Number("qemu_machine_type",
namespace="libxl_")
+libxl_domain_type = Number("domain_type",
namespace="libxl_")
libxl_console_consback = Number("console_consback",
namespace="libxl_")
libxl_console_constype = Number("console_constype",
namespace="libxl_")
libxl_disk_format = Number("disk_format",
namespace="libxl_")
@@ -143,7 +143,7 @@ libxl_device_model_info = Struct("device
("device_model_version", integer),
("device_model", string, False, "if you set this you
must set device_model_version too"),
("saved_state", string),
- ("type", libxl_qemu_machine_type),
+ ("type", libxl_domain_type),
("target_ram", uint32),
("videoram", integer, False, "size of the
videoram in MB"),
("stdvga", bool, False, "stdvga
enabled or disabled"),
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
@@ -137,7 +137,7 @@ static char ** libxl__build_device_model
if (info->serial) {
flexarray_vappend(dm_args, "-serial", info->serial, NULL);
}
- if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
+ if (info->type == LIBXL_DOMAIN_TYPE_FV) {
int ioemu_vifs = 0;
if (info->videoram) {
@@ -202,10 +202,10 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, info->extra[i]);
flexarray_append(dm_args, "-M");
switch (info->type) {
- case LIBXL_QEMU_MACHINE_TYPE_PV:
+ case LIBXL_DOMAIN_TYPE_PV:
flexarray_append(dm_args, "xenpv");
break;
- case LIBXL_QEMU_MACHINE_TYPE_FV:
+ case LIBXL_DOMAIN_TYPE_FV:
flexarray_append(dm_args, "xenfv");
break;
}
@@ -242,7 +242,7 @@ static char ** libxl__build_device_model
flexarray_vappend(dm_args, dm,
"-xen-domid", libxl__sprintf(gc,
"%d", info->domid), NULL);
- if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV) {
+ if (info->type == LIBXL_DOMAIN_TYPE_PV) {
flexarray_append(dm_args, "-xen-attach");
}
@@ -280,7 +280,7 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, "-sdl");
}
- if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV &&
!info->nographic) {
+ if (info->type == LIBXL_DOMAIN_TYPE_PV && !info->nographic) {
flexarray_vappend(dm_args, "-vga", "xenfb", NULL);
}
@@ -293,7 +293,7 @@ static char ** libxl__build_device_model
if (info->serial) {
flexarray_vappend(dm_args, "-serial", info->serial, NULL);
}
- if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
+ if (info->type == LIBXL_DOMAIN_TYPE_FV) {
int ioemu_vifs = 0;
if (info->stdvga) {
@@ -359,10 +359,10 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, info->extra[i]);
flexarray_append(dm_args, "-M");
switch (info->type) {
- case LIBXL_QEMU_MACHINE_TYPE_PV:
+ case LIBXL_DOMAIN_TYPE_PV:
flexarray_append(dm_args, "xenpv");
break;
- case LIBXL_QEMU_MACHINE_TYPE_FV:
+ case LIBXL_DOMAIN_TYPE_FV:
flexarray_append(dm_args, "xenfv");
break;
}
@@ -371,7 +371,7 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, "-m");
flexarray_append(dm_args, libxl__sprintf(gc, "%d",
info->target_ram));
- if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
+ if (info->type == LIBXL_DOMAIN_TYPE_FV) {
for (i; i < num_disks; i++) {
int disk, part;
int dev_number @@ -921,7 +921,7 @@ static int
libxl__build_xenpv_qemu_args(
info->dom_name = libxl_domid_to_name(ctx, domid);
info->device_model_version = LIBXL_DEVICE_MODEL_VERSION_DEFAULT;
info->device_model = NULL;
- info->type = LIBXL_QEMU_MACHINE_TYPE_PV;
+ info->type = LIBXL_DOMAIN_TYPE_PV;
return 0;
}
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
@@ -1131,8 +1131,8 @@ skip_vfb:
}
dm_info->type = c_info->hvm ?
- LIBXL_QEMU_MACHINE_TYPE_FV :
- LIBXL_QEMU_MACHINE_TYPE_PV;
+ LIBXL_DOMAIN_TYPE_FV :
+ LIBXL_DOMAIN_TYPE_PV;
xlu_cfg_destroy(config);
}
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
@@ -769,8 +769,8 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST(m, SHUTDOWN_crash);
_INT_CONST(m, SHUTDOWN_watchdog);
- _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_FV);
- _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_PV);
+ _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV);
+ _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV);
_INT_CONST_LIBXL(m, CONSTYPE_SERIAL);
_INT_CONST_LIBXL(m, CONSTYPE_PV);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 03 of 24] tools: libxl: namespace enum values within their type
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID b600101b951c259c101024ed1ab833481ae20acd
# Parent 624f293ec064968fed538177a910bf7479f6a879
tools: libxl: namespace enum values within their type.
In other words the values for an enum type libxl_foo always take the
form LIBXL_FOO_VALUE.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.c Wed Apr 13 13:35:51 2011 +0100
@@ -592,7 +592,7 @@ int libxl_get_wait_fd(libxl_ctx *ctx, in
int libxl_wait_for_domain_death(libxl_ctx *ctx, uint32_t domid, libxl_waiter
*waiter)
{
waiter->path = strdup("@releaseDomain");
- if (asprintf(&(waiter->token), "%d",
LIBXL_EVENT_DOMAIN_DEATH) < 0)
+ if (asprintf(&(waiter->token), "%d",
LIBXL_EVENT_TYPE_DOMAIN_DEATH) < 0)
return -1;
if (!xs_watch(ctx->xsh, waiter->path, waiter->token))
return -1;
@@ -614,7 +614,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx
libxl__device_disk_dev_number(disks[i].vdev,
NULL, NULL)) < 0)
goto out;
- if (asprintf(&(waiter[i].token), "%d",
LIBXL_EVENT_DISK_EJECT) < 0)
+ if (asprintf(&(waiter[i].token), "%d",
LIBXL_EVENT_TYPE_DISK_EJECT) < 0)
goto out;
xs_watch(ctx->xsh, waiter[i].path, waiter[i].token);
}
@@ -782,7 +782,7 @@ out:
return 0;
}
-int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
libxl_console_constype type)
+int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
libxl_console_type type)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
char *p = libxl__sprintf(&gc, "%s/xenconsole",
libxl_private_bindir_path());
@@ -791,10 +791,10 @@ int libxl_console_exec(libxl_ctx *ctx, u
char *cons_type_s;
switch (type) {
- case LIBXL_CONSTYPE_PV:
+ case LIBXL_CONSOLE_TYPE_PV:
cons_type_s = "pv";
break;
- case LIBXL_CONSTYPE_SERIAL:
+ case LIBXL_CONSOLE_TYPE_SERIAL:
cons_type_s = "serial";
break;
default:
@@ -815,12 +815,12 @@ int libxl_primary_console_exec(libxl_ctx
int rc;
if (stubdomid)
rc = libxl_console_exec(ctx, stubdomid,
- STUBDOM_CONSOLE_SERIAL, LIBXL_CONSTYPE_PV);
+ STUBDOM_CONSOLE_SERIAL, LIBXL_CONSOLE_TYPE_PV);
else {
if (libxl__domain_is_hvm(&gc, domid_vm))
- rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_SERIAL);
+ rc = libxl_console_exec(ctx, domid_vm, 0,
LIBXL_CONSOLE_TYPE_SERIAL);
else
- rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_PV);
+ rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV);
}
libxl__free_all(&gc);
return rc;
@@ -1223,7 +1223,7 @@ int libxl_device_nic_init(libxl_device_n
if ( asprintf(&nic_info->script, "%s/vif-bridge",
libxl_xen_script_dir_path()) < 0 )
return ERROR_FAIL;
- nic_info->nictype = LIBXL_NICTYPE_IOEMU;
+ nic_info->nictype = LIBXL_NIC_TYPE_IOEMU;
return 0;
}
@@ -1441,7 +1441,7 @@ int libxl_device_console_add(libxl_ctx *
flexarray_append(front, "limit");
flexarray_append(front, libxl__sprintf(&gc, "%d",
LIBXL_XENCONSOLE_LIMIT));
flexarray_append(front, "type");
- if (console->consback == LIBXL_CONSBACK_XENCONSOLED)
+ if (console->consback == LIBXL_CONSOLE_BACKEND_XENCONSOLED)
flexarray_append(front, "xenconsoled");
else
flexarray_append(front, "ioemu");
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
@@ -167,14 +167,14 @@ typedef enum {
} libxl_domain_type;
typedef enum {
- LIBXL_CONSTYPE_SERIAL = 1,
- LIBXL_CONSTYPE_PV,
-} libxl_console_constype;
+ LIBXL_CONSOLE_TYPE_SERIAL = 1,
+ LIBXL_CONSOLE_TYPE_PV,
+} libxl_console_type;
typedef enum {
- LIBXL_CONSBACK_XENCONSOLED,
- LIBXL_CONSBACK_IOEMU,
-} libxl_console_consback;
+ LIBXL_CONSOLE_BACKEND_XENCONSOLED,
+ LIBXL_CONSOLE_BACKEND_IOEMU,
+} libxl_console_backend;
typedef enum {
LIBXL_DISK_FORMAT_UNKNOWN = 0,
@@ -193,8 +193,8 @@ typedef enum {
} libxl_disk_backend;
typedef enum {
- LIBXL_NICTYPE_IOEMU = 1,
- LIBXL_NICTYPE_VIF,
+ LIBXL_NIC_TYPE_IOEMU = 1,
+ LIBXL_NIC_TYPE_VIF,
} libxl_nic_type;
typedef struct {
@@ -246,15 +246,15 @@ enum {
#define LIBXL_VERSION 0
typedef enum libxl_action_on_shutdown {
- LIBXL_ACTION_DESTROY,
+ LIBXL_ACTION_ON_SHUTDOWN_DESTROY,
- LIBXL_ACTION_RESTART,
- LIBXL_ACTION_RESTART_RENAME,
+ LIBXL_ACTION_ON_SHUTDOWN_RESTART,
+ LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME,
- LIBXL_ACTION_PRESERVE,
+ LIBXL_ACTION_ON_SHUTDOWN_PRESERVE,
- LIBXL_ACTION_COREDUMP_DESTROY,
- LIBXL_ACTION_COREDUMP_RESTART,
+ LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY,
+ LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART,
} libxl_action_on_shutdown;
/*
@@ -327,8 +327,8 @@ int libxl_run_bootloader(libxl_ctx *ctx,
/* events handling */
typedef enum {
- LIBXL_EVENT_DOMAIN_DEATH,
- LIBXL_EVENT_DISK_EJECT,
+ LIBXL_EVENT_TYPE_DOMAIN_DEATH,
+ LIBXL_EVENT_TYPE_DISK_EJECT,
} libxl_event_type;
typedef struct {
@@ -401,7 +401,7 @@ int libxl_wait_for_free_memory(libxl_ctx
int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int
wait_secs);
int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
-int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
libxl_console_constype type);
+int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
libxl_console_type type);
/* libxl_primary_console_exec finds the domid and console number
* corresponding to the primary console of the given vm, then calls
* libxl_console_exec with the right arguments (domid might be different
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
@@ -9,8 +9,8 @@ libxl_mac = Builtin("mac")
libxl_cpumap = Builtin("cpumap",
destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
libxl_cpuarray = Builtin("cpuarray",
destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
libxl_domain_type = Number("domain_type",
namespace="libxl_")
-libxl_console_consback = Number("console_consback",
namespace="libxl_")
-libxl_console_constype = Number("console_constype",
namespace="libxl_")
+libxl_console_backend = Number("console_backend",
namespace="libxl_")
+libxl_console_type = Number("console_type",
namespace="libxl_")
libxl_disk_format = Number("disk_format",
namespace="libxl_")
libxl_disk_backend = Number("disk_backend",
namespace="libxl_")
libxl_nic_type = Number("nic_type", namespace="libxl_")
@@ -196,7 +196,7 @@ libxl_device_vkb = Struct("device_vkb",
libxl_device_console = Struct("device_console", [
("backend_domid", uint32),
("devid", integer),
- ("consback", libxl_console_consback),
+ ("consback", libxl_console_backend),
("build_state", Reference(libxl_domain_build_state), True),
("output", string),
])
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_create.c Wed Apr 13 13:35:51 2011 +0100
@@ -136,7 +136,7 @@ static int init_console_info(libxl_devic
{
memset(console, 0x00, sizeof(libxl_device_console));
console->devid = dev_num;
- console->consback = LIBXL_CONSBACK_XENCONSOLED;
+ console->consback = LIBXL_CONSOLE_BACKEND_XENCONSOLED;
console->output = strdup("pty");
if ( NULL == console->output )
return ERROR_NOMEM;
@@ -497,7 +497,7 @@ static int do_domain_create(libxl__gc *g
d_config->num_disks, &d_config->disks[0]);
if (need_qemu)
- console.consback = LIBXL_CONSBACK_IOEMU;
+ console.consback = LIBXL_CONSOLE_BACKEND_IOEMU;
libxl_device_console_add(ctx, domid, &console);
libxl_device_console_destroy(&console);
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl_dm.c Wed Apr 13 13:35:51 2011 +0100
@@ -169,7 +169,7 @@ static char ** libxl__build_device_model
flexarray_vappend(dm_args, "-vcpu_avail",
libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL);
}
for (i = 0; i < num_vifs; i++) {
- if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
+ if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
@@ -323,7 +323,7 @@ static char ** libxl__build_device_model
flexarray_append(dm_args, libxl__sprintf(gc, "%d",
info->vcpus));
}
for (i = 0; i < num_vifs; i++) {
- if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
+ if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
char *smac = libxl__sprintf(gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
vifs[i].mac[0], vifs[i].mac[1],
vifs[i].mac[2],
vifs[i].mac[3], vifs[i].mac[4],
vifs[i].mac[5]);
@@ -665,7 +665,7 @@ retry_transaction:
for (i = 0; i < num_console; i++) {
console[i].devid = i;
- console[i].consback = LIBXL_CONSBACK_IOEMU;
+ console[i].consback = LIBXL_CONSOLE_BACKEND_IOEMU;
/* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging
* STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file
* STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file
@@ -938,7 +938,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc
}
for (i = 0; i < nr_consoles; i++) {
- if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) {
+ if (consoles[i].consback == LIBXL_CONSOLE_BACKEND_IOEMU) {
ret = 1;
goto out;
}
diff -r 624f293ec064 -r b600101b951c tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
@@ -101,15 +101,15 @@ struct save_file_header {
static const char *action_on_shutdown_names[] = {
- [LIBXL_ACTION_DESTROY] = "destroy",
-
- [LIBXL_ACTION_RESTART] = "restart",
- [LIBXL_ACTION_RESTART_RENAME] = "rename-restart",
-
- [LIBXL_ACTION_PRESERVE] = "preserve",
-
- [LIBXL_ACTION_COREDUMP_DESTROY] = "coredump-destroy",
- [LIBXL_ACTION_COREDUMP_RESTART] = "coredump-restart",
+ [LIBXL_ACTION_ON_SHUTDOWN_DESTROY] = "destroy",
+
+ [LIBXL_ACTION_ON_SHUTDOWN_RESTART] = "restart",
+ [LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME] = "rename-restart",
+
+ [LIBXL_ACTION_ON_SHUTDOWN_PRESERVE] = "preserve",
+
+ [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY] = "coredump-destroy",
+ [LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART] = "coredump-restart",
};
/* Optional data, in order:
@@ -872,9 +872,9 @@ static void parse_config_data(const char
nic->bridge = strdup(p2 + 1);
} else if (!strcmp(p, "type")) {
if (!strcmp(p2 + 1, "ioemu"))
- nic->nictype = LIBXL_NICTYPE_IOEMU;
+ nic->nictype = LIBXL_NIC_TYPE_IOEMU;
else
- nic->nictype = LIBXL_NICTYPE_VIF;
+ nic->nictype = LIBXL_NIC_TYPE_VIF;
} else if (!strcmp(p, "ip")) {
free(nic->ip);
nic->ip = strdup(p2 + 1);
@@ -1161,12 +1161,12 @@ static int handle_domain_death(libxl_ctx
break;
default:
LOG("Unknown shutdown reason code %d. Destroying domain.",
info->shutdown_reason);
- action = LIBXL_ACTION_DESTROY;
+ action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY;
}
LOG("Action for shutdown reason code %d is %s",
info->shutdown_reason, action_on_shutdown_names[action]);
- if (action == LIBXL_ACTION_COREDUMP_DESTROY || action ==
LIBXL_ACTION_COREDUMP_RESTART) {
+ if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY || action ==
LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) {
char *corefile;
int rc;
@@ -1179,30 +1179,30 @@ static int handle_domain_death(libxl_ctx
}
/* No point crying over spilled milk, continue on failure. */
- if (action == LIBXL_ACTION_COREDUMP_DESTROY)
- action = LIBXL_ACTION_DESTROY;
+ if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY)
+ action = LIBXL_ACTION_ON_SHUTDOWN_DESTROY;
else
- action = LIBXL_ACTION_RESTART;
+ action = LIBXL_ACTION_ON_SHUTDOWN_RESTART;
}
switch (action) {
- case LIBXL_ACTION_PRESERVE:
+ case LIBXL_ACTION_ON_SHUTDOWN_PRESERVE:
break;
- case LIBXL_ACTION_RESTART_RENAME:
+ case LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME:
restart = 2;
break;
- case LIBXL_ACTION_RESTART:
+ case LIBXL_ACTION_ON_SHUTDOWN_RESTART:
restart = 1;
/* fall-through */
- case LIBXL_ACTION_DESTROY:
+ case LIBXL_ACTION_ON_SHUTDOWN_DESTROY:
LOG("Domain %d needs to be cleaned up: destroying the
domain", domid);
libxl_domain_destroy(ctx, domid, 0);
break;
- case LIBXL_ACTION_COREDUMP_DESTROY:
- case LIBXL_ACTION_COREDUMP_RESTART:
+ case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY:
+ case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART:
/* Already handled these above. */
abort();
}
@@ -1600,7 +1600,7 @@ start:
continue;
libxl_get_event(ctx, &event);
switch (event.type) {
- case LIBXL_EVENT_DOMAIN_DEATH:
+ case LIBXL_EVENT_TYPE_DOMAIN_DEATH:
ret = libxl_event_get_domain_death_info(ctx, domid, &event,
&info);
if (ret < 0) {
@@ -1658,7 +1658,7 @@ start:
goto out;
}
break;
- case LIBXL_EVENT_DISK_EJECT:
+ case LIBXL_EVENT_TYPE_DISK_EJECT:
if (libxl_event_get_disk_eject_info(ctx, domid, &event,
&disk)) {
libxl_cdrom_insert(ctx, domid, &disk);
libxl_device_disk_destroy(&disk);
@@ -1926,7 +1926,7 @@ int main_cd_insert(int argc, char **argv
int main_console(int argc, char **argv)
{
int opt = 0, num = 0;
- libxl_console_constype type = 0;
+ libxl_console_type type = 0;
while ((opt = getopt(argc, argv, "hn:t:")) != -1) {
switch (opt) {
@@ -1935,9 +1935,9 @@ int main_console(int argc, char **argv)
return 0;
case ''t'':
if (!strcmp(optarg, "pv"))
- type = LIBXL_CONSTYPE_PV;
+ type = LIBXL_CONSOLE_TYPE_PV;
else if (!strcmp(optarg, "serial"))
- type = LIBXL_CONSTYPE_SERIAL;
+ type = LIBXL_CONSOLE_TYPE_SERIAL;
else {
fprintf(stderr, "console type supported are: pv,
serial\n");
return 2;
@@ -2232,7 +2232,7 @@ static void shutdown_domain(const char *
libxl_get_event(ctx, &event);
- if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
+ if (event.type == LIBXL_EVENT_TYPE_DOMAIN_DEATH) {
if (libxl_event_get_domain_death_info(ctx, domid, &event,
&info) < 0)
continue;
@@ -4235,9 +4235,9 @@ int main_networkattach(int argc, char **
for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) {
if (!strncmp("type=", *argv, 5)) {
if (!strncmp("vif", (*argv) + 5, 4)) {
- nic.nictype = LIBXL_NICTYPE_VIF;
+ nic.nictype = LIBXL_NIC_TYPE_VIF;
} else if (!strncmp("ioemu", (*argv) + 5, 5)) {
- nic.nictype = LIBXL_NICTYPE_IOEMU;
+ nic.nictype = LIBXL_NIC_TYPE_IOEMU;
} else {
fprintf(stderr, "Invalid parameter
`type''.\n");
return 1;
diff -r 624f293ec064 -r b600101b951c tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:51 2011 +0100
@@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l
c_val->bridge = dup_String_val(gc, Field(v, 5));
c_val->ifname = dup_String_val(gc, Field(v, 6));
c_val->script = dup_String_val(gc, Field(v, 7));
- c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU;
+ c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU;
out:
CAMLreturn(ret);
@@ -236,7 +236,7 @@ static int device_console_val(caml_gc *g
c_val->backend_domid = Int_val(Field(v, 0));
c_val->devid = Int_val(Field(v, 1));
- c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSBACK_XENCONSOLED;
+ c_val->consback = (Int_val(Field(v, 2))) +
LIBXL_CONSOLE_BACKEND_XENCONSOLED;
CAMLreturn(0);
}
diff -r 624f293ec064 -r b600101b951c tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
@@ -772,11 +772,11 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST_LIBXL(m, DOMAIN_TYPE_FV);
_INT_CONST_LIBXL(m, DOMAIN_TYPE_PV);
- _INT_CONST_LIBXL(m, CONSTYPE_SERIAL);
- _INT_CONST_LIBXL(m, CONSTYPE_PV);
+ _INT_CONST_LIBXL(m, CONSOLE_TYPE_SERIAL);
+ _INT_CONST_LIBXL(m, CONSOLE_TYPE_PV);
- _INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED);
- _INT_CONST_LIBXL(m, CONSBACK_IOEMU);
+ _INT_CONST_LIBXL(m, CONSOLE_BACKEND_XENCONSOLED);
+ _INT_CONST_LIBXL(m, CONSOLE_BACKEND_IOEMU);
_INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN);
_INT_CONST_LIBXL(m, DISK_FORMAT_QCOW);
@@ -790,11 +790,11 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST_LIBXL(m, DISK_BACKEND_TAP);
_INT_CONST_LIBXL(m, DISK_BACKEND_QDISK);
- _INT_CONST_LIBXL(m, NICTYPE_IOEMU);
- _INT_CONST_LIBXL(m, NICTYPE_VIF);
+ _INT_CONST_LIBXL(m, NIC_TYPE_IOEMU);
+ _INT_CONST_LIBXL(m, NIC_TYPE_VIF);
- _INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH);
- _INT_CONST_LIBXL(m, EVENT_DISK_EJECT);
+ _INT_CONST_LIBXL(m, EVENT_TYPE_DOMAIN_DEATH);
+ _INT_CONST_LIBXL(m, EVENT_TYPE_DISK_EJECT);
_INT_CONST_LIBXL(m, BUTTON_POWER);
_INT_CONST_LIBXL(m, BUTTON_SLEEP);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 04 of 24] tools: libxl: add an Enumeration type to the IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID 1c34c37f32002a16e9ae443cafab7c98ee827d8b
# Parent b600101b951c259c101024ed1ab833481ae20acd
tools: libxl: add an Enumeration type to the IDL
The IDL requires a specific value for each enumerate, this make it
much easier to avoid (or at least track) ABI changes since they must
now be explicit.
I believe I have used the same values as would have been chosen
previoulsy but have not confirmed.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/gentypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -34,7 +34,28 @@ def libxl_C_instance_of(ty, instancename
def libxl_C_type_define(ty, indent = ""):
s = ""
- if isinstance(ty, libxltypes.Aggregate):
+
+ if isinstance(ty, libxltypes.Enumeration):
+ if ty.comment is not None:
+ s += format_comment(0, ty.comment)
+
+ if ty.typename is None:
+ s += "enum {\n"
+ else:
+ s += "typedef enum %s {\n" % ty.typename
+
+ for v in ty.values:
+ if v.comment is not None:
+ s += format_comment(4, v.comment)
+ x = "%s = %d" % (v.name, v.value)
+ x = x.replace("\n", "\n ")
+ s += " " + x + ",\n"
+ if ty.typename is None:
+ s += "}"
+ else:
+ s += "} %s" % ty.typename
+
+ elif isinstance(ty, libxltypes.Aggregate):
if ty.comment is not None:
s += format_comment(0, ty.comment)
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/idl.txt
--- a/tools/libxl/idl.txt Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/idl.txt Wed Apr 13 13:35:51 2011 +0100
@@ -82,6 +82,30 @@ libxltype.Reference
Complex type-Classes
--------------------
+libxltype.Enumeration
+
+ A class representing an enumeration (named integer values).
+
+ The values are available in the list Enumeration.values. Each
+ element in the list is of type libxltype.EnumerationValue.
+
+ Each EnumerationValue has the following properties:
+
+ EnumerationValue.namespace Namespace, similar to Type.namespace
+ (e.g. "libxl_")
+ EnumerationValue.typename The name of the Enumeration which
+ includes this value, but excluding
+ any namespace (e.g. "fooenum")
+ EnumerationValue.rawname The name of this value, including the
+ name of the containing
+ Enumeration, but excluding any
+ namespace (e.g. "FOOENUM_VALUE")
+ EnumerationValue.name The fullname of this value, including
+ all namespace elements
+ (e.g. "LIBXL_FOOENUM_VALUE")
+ EnumerationValue.value The integer value associated with this name.
+ EnumerationValue.comment A free text comment which describes the member.
+
libxltype.Aggregate
Base class for type-Classes which contain a number of other types
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
@@ -161,42 +161,6 @@ typedef struct {
#define LIBXL_CPUARRAY_INVALID_ENTRY ~0
void libxl_cpuarray_destroy(libxl_cpuarray *array);
-typedef enum {
- LIBXL_DOMAIN_TYPE_FV = 1,
- LIBXL_DOMAIN_TYPE_PV,
-} libxl_domain_type;
-
-typedef enum {
- LIBXL_CONSOLE_TYPE_SERIAL = 1,
- LIBXL_CONSOLE_TYPE_PV,
-} libxl_console_type;
-
-typedef enum {
- LIBXL_CONSOLE_BACKEND_XENCONSOLED,
- LIBXL_CONSOLE_BACKEND_IOEMU,
-} libxl_console_backend;
-
-typedef enum {
- LIBXL_DISK_FORMAT_UNKNOWN = 0,
- LIBXL_DISK_FORMAT_QCOW,
- LIBXL_DISK_FORMAT_QCOW2,
- LIBXL_DISK_FORMAT_VHD,
- LIBXL_DISK_FORMAT_RAW,
- LIBXL_DISK_FORMAT_EMPTY,
-} libxl_disk_format;
-
-typedef enum {
- LIBXL_DISK_BACKEND_UNKNOWN = 0,
- LIBXL_DISK_BACKEND_PHY,
- LIBXL_DISK_BACKEND_TAP,
- LIBXL_DISK_BACKEND_QDISK,
-} libxl_disk_backend;
-
-typedef enum {
- LIBXL_NIC_TYPE_IOEMU = 1,
- LIBXL_NIC_TYPE_VIF,
-} libxl_nic_type;
-
typedef struct {
/*
* Path is always set if the file reference is valid. However if
@@ -245,18 +209,6 @@ enum {
#define LIBXL_VERSION 0
-typedef enum libxl_action_on_shutdown {
- LIBXL_ACTION_ON_SHUTDOWN_DESTROY,
-
- LIBXL_ACTION_ON_SHUTDOWN_RESTART,
- LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME,
-
- LIBXL_ACTION_ON_SHUTDOWN_PRESERVE,
-
- LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY,
- LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART,
-} libxl_action_on_shutdown;
-
/*
* 1 - Historical qemu-xen device model (qemu-dm)
* 2 - Upstream qemu
@@ -326,11 +278,6 @@ int libxl_run_bootloader(libxl_ctx *ctx,
/* events handling */
-typedef enum {
- LIBXL_EVENT_TYPE_DOMAIN_DEATH,
- LIBXL_EVENT_TYPE_DISK_EJECT,
-} libxl_event_type;
-
typedef struct {
/* event type */
libxl_event_type type;
@@ -493,11 +440,6 @@ int libxl_userdata_retrieve(libxl_ctx *c
* On error return, *data_r and *datalen_r are undefined.
*/
-typedef enum {
- LIBXL_BUTTON_POWER,
- LIBXL_BUTTON_SLEEP
-} libxl_button;
-
int libxl_button_press(libxl_ctx *ctx, uint32_t domid, libxl_button button);
int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
@@ -8,12 +8,6 @@ libxl_uuid = Builtin("uuid")
libxl_mac = Builtin("mac")
libxl_cpumap = Builtin("cpumap",
destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
libxl_cpuarray = Builtin("cpuarray",
destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
-libxl_domain_type = Number("domain_type",
namespace="libxl_")
-libxl_console_backend = Number("console_backend",
namespace="libxl_")
-libxl_console_type = Number("console_type",
namespace="libxl_")
-libxl_disk_format = Number("disk_format",
namespace="libxl_")
-libxl_disk_backend = Number("disk_backend",
namespace="libxl_")
-libxl_nic_type = Number("nic_type", namespace="libxl_")
libxl_cpuid_policy_list = Builtin("cpuid_policy_list",
destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE)
libxl_string_list = Builtin("string_list",
destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
@@ -23,6 +17,68 @@ libxl_file_reference = Builtin("file_ref
libxl_hwcap = Builtin("hwcap")
#
+# Constants / Enumerations
+#
+
+libxl_domain_type = Enumeration("domain_type", [
+ (1, "FV"),
+ (2, "PV"),
+ ])
+
+libxl_console_type = Enumeration("console_type", [
+ (1, "SERIAL"),
+ (2, "PV"),
+ ])
+
+libxl_console_backend = Enumeration("console_backend", [
+ (1, "XENCONSOLED"),
+ (2, "IOEMU"),
+ ])
+
+libxl_disk_format = Enumeration("disk_format", [
+ (0, "UNKNOWN"),
+ (1, "QCOW"),
+ (2, "QCOW2"),
+ (3, "VHD"),
+ (4, "RAW"),
+ (5, "EMPTY"),
+ ])
+
+libxl_disk_backend = Enumeration("disk_backend", [
+ (0, "UNKNOWN"),
+ (1, "PHY"),
+ (2, "TAP"),
+ (3, "QDISK"),
+ ])
+
+libxl_nic_type = Enumeration("nic_type", [
+ (1, "IOEMU"),
+ (2, "VIF"),
+ ])
+
+libxl_action_on_shutdown = Enumeration("action_on_shutdown", [
+ (1, "DESTROY"),
+
+ (2, "RESTART"),
+ (3, "RESTART_RENAME"),
+
+ (4, "PRESERVE"),
+
+ (5, "COREDUMP_DESTROY"),
+ (6, "COREDUMP_RESTART"),
+ ])
+
+libxl_event_type = Enumeration("event_type", [
+ (1, "DOMAIN_DEATH"),
+ (2, "DISK_EJECT"),
+ ])
+
+libxl_button = Enumeration("button", [
+ (1, "POWER"),
+ (2, "SLEEP"),
+ ])
+
+#
# Complex libxl types
#
libxl_dominfo = Struct("dominfo",[
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -52,6 +52,37 @@ class UInt(Number):
self.width = w
+class EnumerationValue(object):
+ def __init__(self, value, name, **kwargs):
+ kwargs.setdefault("namespace", None)
+ kwargs.setdefault("typename", None)
+
+ if kwargs["typename"]:
+ name = kwargs["typename"] + "_" + name
+
+ self.typename = kwargs["typename"]
+ self.rawname = str.upper(name)
+
+ if kwargs["namespace"]:
+ name = kwargs["namespace"] + name
+
+ self.name = str.upper(name)
+
+ self.value = value
+ self.comment = kwargs.setdefault("comment", None)
+
+class Enumeration(Type):
+ def __init__(self, typename, values, **kwargs):
+ kwargs.setdefault(''destructor_fn'', None)
+ Type.__init__(self, typename, **kwargs)
+
+ self.values = []
+ for v in values:
+ (num,name) = v
+ self.values.append(EnumerationValue(num, name,
+ namespace=self.namespace,
+ typename=self.rawname))
+
class BitField(Type):
def __init__(self, ty, w, **kwargs):
kwargs.setdefault(''namespace'', None)
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Apr 13 13:35:51 2011 +0100
@@ -451,6 +451,8 @@ static int parse_action_on_shutdown(cons
for (i = 0; i < sizeof(action_on_shutdown_names) /
sizeof(action_on_shutdown_names[0]); i++) {
n = action_on_shutdown_names[i];
+ if (!n) continue;
+
if (strcmp(buf, n) == 0) {
*a = i;
return 1;
diff -r b600101b951c -r 1c34c37f3200 tools/python/genwrap.py
--- a/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
@@ -9,6 +9,8 @@ import libxltypes
def py_type(ty):
if ty == libxltypes.bool or isinstance(ty, libxltypes.BitField) and
ty.width == 1:
return TYPE_BOOL
+ if isinstance(ty, libxltypes.Enumeration):
+ return TYPE_UINT
if isinstance(ty, libxltypes.Number):
if ty.signed:
return TYPE_INT
@@ -34,15 +36,16 @@ def fsanitize(name):
def py_decls(ty):
l = []
- l.append(''_hidden Py_%s *Py%s_New(void);\n''%(ty.rawname,
ty.rawname))
- l.append(''_hidden int Py%s_Check(PyObject
*self);\n''%ty.rawname)
- for f in ty.fields:
- if py_type(f.type) is not None:
- continue
- l.append(''_hidden PyObject *attrib__%s_get(%s
*%s);''%(\
- fsanitize(f.type.typename), f.type.typename, f.name))
- l.append(''_hidden int attrib__%s_set(PyObject *v, %s
*%s);''%(\
- fsanitize(f.type.typename), f.type.typename, f.name))
+ if isinstance(ty, libxltypes.Aggregate):
+ l.append(''_hidden Py_%s
*Py%s_New(void);\n''%(ty.rawname, ty.rawname))
+ l.append(''_hidden int Py%s_Check(PyObject
*self);\n''%ty.rawname)
+ for f in ty.fields:
+ if py_type(f.type) is not None:
+ continue
+ l.append(''_hidden PyObject *attrib__%s_get(%s
*%s);''%(\
+ fsanitize(f.type.typename), f.type.typename, f.name))
+ l.append(''_hidden int attrib__%s_set(PyObject *v, %s
*%s);''%(\
+ fsanitize(f.type.typename), f.type.typename, f.name))
return ''\n''.join(l) + "\n"
def py_attrib_get(ty, f):
@@ -189,16 +192,23 @@ def py_initfuncs(types):
l.append(''void genwrap__init(PyObject *m)'')
l.append(''{'')
for ty in types:
- l.append('' if (PyType_Ready(&Py%s_Type) >= 0)
{''%ty.rawname)
- l.append(''
Py_INCREF(&Py%s_Type);''%ty.rawname)
- l.append('' PyModule_AddObject(m, "%s",
(PyObject *)&Py%s_Type);''%(ty.rawname, ty.rawname))
- l.append('' }'')
+ if isinstance(ty, libxltypes.Enumeration):
+ for v in ty.values:
+ l.append('' PyModule_AddIntConstant(m,
"%s", %s);'' % (v.rawname, v.name))
+ elif isinstance(ty, libxltypes.Aggregate):
+ l.append('' if (PyType_Ready(&Py%s_Type) >= 0)
{''%ty.rawname)
+ l.append(''
Py_INCREF(&Py%s_Type);''%ty.rawname)
+ l.append('' PyModule_AddObject(m, "%s",
(PyObject *)&Py%s_Type);''%(ty.rawname, ty.rawname))
+ l.append('' }'')
+ else:
+ raise NotImplementedError("unknown type %s (%s)" %
(ty.typename, type(ty)))
+
l.append(''}'')
return ''\n''.join(l) + "\n\n"
def tree_frob(types):
ret = types[:]
- for ty in ret:
+ for ty in [ty for ty in ret if isinstance(ty, libxltypes.Aggregate)]:
ty.fields = filter(lambda f:f.name is not None and f.type.typename is
not None, ty.fields)
return ret
@@ -249,8 +259,8 @@ _hidden PyObject *genwrap__ll_get(long l
_hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask);
""" % " ".join(sys.argv))
- for ty in types:
- f.write(''/* Internal APU for %s wrapper
*/\n''%ty.typename)
+ for ty in [ty for ty in types if isinstance(ty, libxltypes.Aggregate)]:
+ f.write(''/* Internal API for %s wrapper
*/\n''%ty.typename)
f.write(py_wrapstruct(ty))
f.write(py_decls(ty))
f.write(''\n'')
@@ -276,10 +286,11 @@ _hidden int genwrap__ll_set(PyObject *v,
""" % tuple(('' ''.join(sys.argv),) +
(os.path.split(decls)[-1:]),))
for ty in types:
- f.write(''/* Attribute get/set functions for %s
*/\n''%ty.typename)
- for a in ty.fields:
- f.write(py_attrib_get(ty,a))
- f.write(py_attrib_set(ty,a))
- f.write(py_object_def(ty))
+ if isinstance(ty, libxltypes.Aggregate):
+ f.write(''/* Attribute get/set functions for %s
*/\n''%ty.typename)
+ for a in ty.fields:
+ f.write(py_attrib_get(ty,a))
+ f.write(py_attrib_set(ty,a))
+ f.write(py_object_def(ty))
f.write(py_initfuncs(types))
f.close()
diff -r b600101b951c -r 1c34c37f3200 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
@@ -769,35 +769,6 @@ PyMODINIT_FUNC initxl(void)
_INT_CONST(m, SHUTDOWN_crash);
_INT_CONST(m, SHUTDOWN_watchdog);
- _INT_CONST_LIBXL(m, DOMAIN_TYPE_FV);
- _INT_CONST_LIBXL(m, DOMAIN_TYPE_PV);
-
- _INT_CONST_LIBXL(m, CONSOLE_TYPE_SERIAL);
- _INT_CONST_LIBXL(m, CONSOLE_TYPE_PV);
-
- _INT_CONST_LIBXL(m, CONSOLE_BACKEND_XENCONSOLED);
- _INT_CONST_LIBXL(m, CONSOLE_BACKEND_IOEMU);
-
- _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN);
- _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW);
- _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW2);
- _INT_CONST_LIBXL(m, DISK_FORMAT_VHD);
- _INT_CONST_LIBXL(m, DISK_FORMAT_RAW);
- _INT_CONST_LIBXL(m, DISK_FORMAT_EMPTY);
-
- _INT_CONST_LIBXL(m, DISK_BACKEND_UNKNOWN);
- _INT_CONST_LIBXL(m, DISK_BACKEND_PHY);
- _INT_CONST_LIBXL(m, DISK_BACKEND_TAP);
- _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK);
-
- _INT_CONST_LIBXL(m, NIC_TYPE_IOEMU);
- _INT_CONST_LIBXL(m, NIC_TYPE_VIF);
-
- _INT_CONST_LIBXL(m, EVENT_TYPE_DOMAIN_DEATH);
- _INT_CONST_LIBXL(m, EVENT_TYPE_DISK_EJECT);
-
- _INT_CONST_LIBXL(m, BUTTON_POWER);
- _INT_CONST_LIBXL(m, BUTTON_SLEEP);
genwrap__init(m);
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 05 of 24] tools: libxl: add libxl_domid to IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID 174d1c23adc24747d03415b808b30dbb22cf1c07
# Parent 1c34c37f32002a16e9ae443cafab7c98ee827d8b
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 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 13 13:35:51 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 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 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)
@@ -83,7 +83,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)),
@@ -111,7 +111,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", [
@@ -193,7 +193,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", integer),
@@ -230,7 +230,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"),
@@ -245,12 +245,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),
@@ -258,7 +258,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),
@@ -269,7 +269,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 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -186,8 +186,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 1c34c37f3200 -r 174d1c23adc2 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Wed Apr 13 13:35:51 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
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 06 of 24] tools: libxl: remove BitField type class from IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID 10262be99780f9bdb7922c9475bd91020e86449b
# Parent 174d1c23adc24747d03415b808b30dbb22cf1c07
tools: libxl: remove BitField type class from IDL
All usages are single bit BitFields, AKA booleans.
In general we prefer to use simple structures (e.g. without packing or
specific layouts) in the libxl API and take care of any require
structure by marshalling within the library instead of expecting users
to do so (e.g. the PCI device BDF is unpacked in the libxl API).
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/gentypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -22,9 +22,7 @@ def libxl_C_type_of(ty):
return ty.typename
def libxl_C_instance_of(ty, instancename):
- if isinstance(ty, libxltypes.BitField):
- return libxl_C_type_of(ty) + " " + instancename +
":%d" % ty.width
- elif isinstance(ty, libxltypes.Aggregate) and ty.typename is None:
+ if isinstance(ty, libxltypes.Aggregate) and ty.typename is None:
if instancename is None:
return libxl_C_type_define(ty)
else:
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/idl.txt
--- a/tools/libxl/idl.txt Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/idl.txt Wed Apr 13 13:35:51 2011 +0100
@@ -64,14 +64,6 @@ libxltype.UInt
The <N> for a given instance must be passed to the constructor and is
then available in UInt.width
-libxltype.BitField
-
- Instances of this class represent bitfield type classes.
-
- The base type and desired width for a given instance must be passed
- to the contructor. The base type becomes the type of the instance and
- width is contained in BitField.width
-
libxltype.Reference
Instances of this type represent a reference to another type
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
@@ -84,11 +84,11 @@ libxl_button = Enumeration("button", [
libxl_dominfo = Struct("dominfo",[
("uuid", libxl_uuid),
("domid", libxl_domid),
- ("running", BitField(uint8, 1)),
- ("blocked", BitField(uint8, 1)),
- ("paused", BitField(uint8, 1)),
- ("shutdown", BitField(uint8, 1)),
- ("dying", BitField(uint8, 1)),
+ ("running", bool),
+ ("blocked", bool),
+ ("paused", bool),
+ ("shutdown", bool),
+ ("dying", bool),
("shutdown_reason", unsigned, False,
"""Valid SHUTDOWN_* value from xen/sched.h iff
(shutdown||dying).
@@ -320,9 +320,9 @@ libxl_nicinfo = Struct("nicinfo", [
libxl_vcpuinfo = Struct("vcpuinfo", [
("vcpuid", uint32, False, "vcpu''s
id"),
("cpu", uint32, False, "current
mapping"),
- ("online", BitField(uint8, 1), False, "currently online
(not hotplugged)?"),
- ("blocked", BitField(uint8, 1), False, "blocked waiting for
an event?"),
- ("running", BitField(uint8, 1), False, "currently scheduled
on its CPU?"),
+ ("online", bool, False, "currently online
(not hotplugged)?"),
+ ("blocked", bool, False, "blocked waiting for
an event?"),
+ ("running", bool, False, "currently scheduled
on its CPU?"),
("vcpu_time", uint64, False, "total vcpu time ran
(ns)"),
("cpumap", libxl_cpumap, False, "current
cpu''s affinities"),
])
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -83,14 +83,6 @@ class Enumeration(Type):
namespace=self.namespace,
typename=self.rawname))
-class BitField(Type):
- def __init__(self, ty, w, **kwargs):
- kwargs.setdefault(''namespace'', None)
- kwargs.setdefault(''destructor_fn'', None)
- Type.__init__(self, ty.typename, **kwargs)
-
- self.width = w
-
class Field(object):
"""An element of an Aggregate type"""
def __init__(self, type, name, **kwargs):
diff -r 174d1c23adc2 -r 10262be99780 tools/python/genwrap.py
--- a/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
@@ -7,7 +7,7 @@ import libxltypes
(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING) = range(4)
def py_type(ty):
- if ty == libxltypes.bool or isinstance(ty, libxltypes.BitField) and
ty.width == 1:
+ if ty == libxltypes.bool:
return TYPE_BOOL
if isinstance(ty, libxltypes.Enumeration):
return TYPE_UINT
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 07 of 24] tools: libxl: add concept of in- and out-put only data types to IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698151 -3600
# Node ID 0d0fcc0939066625e05668c96119cdbd927dadd6
# Parent 10262be99780f9bdb7922c9475bd91020e86449b
tools: libxl: add concept of in- and out-put only data types to IDL
This allow language bindings to only emit the relevant conversion functions.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 10262be99780 -r 0d0fcc093906 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 13 13:35:51 2011 +0100
@@ -342,7 +342,7 @@ libxl_physinfo = Struct("physinfo", [
("nr_nodes", uint32),
("hw_cap", libxl_hwcap),
("phys_cap", uint32),
- ], destructor_fn=None)
+ ], destructor_fn=None, dir=DIR_OUT)
libxl_topologyinfo = Struct("topologyinfo", [
("coremap", libxl_cpuarray, False, "cpu to core
map"),
diff -r 10262be99780 -r 0d0fcc093906 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/libxl/libxltypes.py Wed Apr 13 13:35:51 2011 +0100
@@ -3,10 +3,18 @@ import sys
PASS_BY_VALUE = 1
PASS_BY_REFERENCE = 2
+DIR_NONE = 0
+DIR_IN = 1
+DIR_OUT = 2
+DIR_BOTH = 3
+
class Type(object):
def __init__(self, typename, **kwargs):
self.comment = kwargs.setdefault(''comment'', None)
self.namespace = kwargs.setdefault(''namespace'',
"libxl_")
+ self.dir = kwargs.setdefault(''dir'', DIR_BOTH)
+ if self.dir not in [DIR_NONE, DIR_IN, DIR_OUT, DIR_BOTH]:
+ raise ValueError
self.passby = kwargs.setdefault(''passby'',
PASS_BY_VALUE)
if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE]:
@@ -29,6 +37,11 @@ class Type(object):
self.autogenerate_destructor =
kwargs.setdefault(''autogenerate_destructor'', True)
+ def marshal_in(self):
+ return self.dir in [DIR_IN, DIR_BOTH]
+ def marshal_out(self):
+ return self.dir in [DIR_OUT, DIR_BOTH]
+
class Builtin(Type):
"""Builtin type"""
def __init__(self, typename, **kwargs):
@@ -216,7 +229,8 @@ def parse(f):
globs[n] = t
elif isinstance(t,type(object)) and issubclass(t, Type):
globs[n] = t
- elif n in [''PASS_BY_REFERENCE'',
''PASS_BY_VALUE'']:
+ elif n in [''PASS_BY_REFERENCE'',
''PASS_BY_VALUE'',
+ ''DIR_NONE'', ''DIR_IN'',
''DIR_OUT'', ''DIR_BOTH'']:
globs[n] = t
try:
diff -r 10262be99780 -r 0d0fcc093906 tools/python/genwrap.py
--- a/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/python/genwrap.py Wed Apr 13 13:35:51 2011 +0100
@@ -42,10 +42,12 @@ def py_decls(ty):
for f in ty.fields:
if py_type(f.type) is not None:
continue
- l.append(''_hidden PyObject *attrib__%s_get(%s
*%s);''%(\
- fsanitize(f.type.typename), f.type.typename, f.name))
- l.append(''_hidden int attrib__%s_set(PyObject *v, %s
*%s);''%(\
- fsanitize(f.type.typename), f.type.typename, f.name))
+ if ty.marshal_out():
+ l.append(''_hidden PyObject *attrib__%s_get(%s
*%s);''%(\
+ fsanitize(f.type.typename), f.type.typename, f.name))
+ if ty.marshal_in():
+ l.append(''_hidden int attrib__%s_set(PyObject *v, %s
*%s);''%(\
+ fsanitize(f.type.typename), f.type.typename, f.name))
return ''\n''.join(l) + "\n"
def py_attrib_get(ty, f):
@@ -128,8 +130,15 @@ static PyObject *Py%(rawname)s_new(PyTyp
l.append(''static PyGetSetDef Py%s_getset[] =
{''%ty.rawname)
for f in ty.fields:
l.append('' { .name = "%s", ''%f.name)
- l.append('' .get = (getter)py_%s_%s_get,
''%(ty.rawname, f.name))
- l.append('' .set = (setter)py_%s_%s_set
},''%(ty.rawname, f.name))
+ if ty.marshal_out():
+ l.append('' .get = (getter)py_%s_%s_get,
''%(ty.rawname, f.name))
+ else:
+ l.append('' .get = (getter)NULL, '')
+ if ty.marshal_in():
+ l.append('' .set =
(setter)py_%s_%s_set,''%(ty.rawname, f.name))
+ else:
+ l.append('' .set = (setter)NULL,'')
+ l.append('' },'')
l.append('' { .name = NULL }'')
l.append(''};'')
struct="""
@@ -289,8 +298,10 @@ _hidden int genwrap__ll_set(PyObject *v,
if isinstance(ty, libxltypes.Aggregate):
f.write(''/* Attribute get/set functions for %s
*/\n''%ty.typename)
for a in ty.fields:
- f.write(py_attrib_get(ty,a))
- f.write(py_attrib_set(ty,a))
+ if ty.marshal_out():
+ f.write(py_attrib_get(ty,a))
+ if ty.marshal_in():
+ f.write(py_attrib_set(ty,a))
f.write(py_object_def(ty))
f.write(py_initfuncs(types))
f.close()
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 08 of 24] tools: ocaml: rename the device_nic types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID dad896f9bb67f417d2279fc34af867470206a6f0
# Parent 0d0fcc0939066625e05668c96119cdbd927dadd6
tools: ocaml: rename the device_nic types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -1,5 +1,5 @@
(*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
* Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -97,18 +97,22 @@ type nic_type | NICTYPE_IOEMU
| NICTYPE_VIF
-type nic_info -{
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
-}
+module Device_nic = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
type console_type | CONSOLETYPE_XENCONSOLED
@@ -190,9 +194,6 @@ external domain_build : build_info -> do
external disk_add : disk_info -> domid -> unit =
"stub_xl_disk_add"
external disk_remove : disk_info -> domid -> unit =
"stub_xl_disk_remove"
-external nic_add : nic_info -> domid -> unit =
"stub_xl_nic_add"
-external nic_remove : disk_info -> domid -> unit =
"stub_xl_nic_remove"
-
external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -1,5 +1,5 @@
(*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
* Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -97,18 +97,22 @@ type nic_type | NICTYPE_IOEMU
| NICTYPE_VIF
-type nic_info -{
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
-}
+module Device_nic : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
type console_type | CONSOLETYPE_XENCONSOLED
@@ -190,9 +194,6 @@ external domain_build : build_info -> do
external disk_add : disk_info -> domid -> unit =
"stub_xl_disk_add"
external disk_remove : disk_info -> domid -> unit =
"stub_xl_disk_remove"
-external nic_add : nic_info -> domid -> unit =
"stub_xl_nic_add"
-external nic_remove : disk_info -> domid -> unit =
"stub_xl_nic_remove"
-
external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:51 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
* Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -402,7 +402,7 @@ value stub_xl_disk_remove(value info, va
CAMLreturn(Val_unit);
}
-value stub_xl_nic_add(value info, value domid)
+value stub_xl_device_nic_add(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_nic c_info;
@@ -419,7 +419,7 @@ value stub_xl_nic_add(value info, value
CAMLreturn(Val_unit);
}
-value stub_xl_nic_remove(value info, value domid)
+value stub_xl_device_nic_del(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_nic c_info;
@@ -431,7 +431,7 @@ value stub_xl_nic_remove(value info, val
INIT_CTX();
ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0);
if (ret != 0)
- failwith_xl("nic_remove", &lg);
+ failwith_xl("nic_del", &lg);
FREE_CTX();
CAMLreturn(Val_unit);
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 09 of 24] tools: ocaml: rename the disk_info types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 7670cfb0da45bdb85bd949bd21eb2004d0989a41
# Parent dad896f9bb67f417d2279fc34af867470206a6f0
tools: ocaml: rename the disk_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -82,16 +82,21 @@ type disk_phystype | PHYSTYPE_FILE
| PHYSTYPE_PHY
-type disk_info -{
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
-}
+module Device_disk = struct
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
type nic_type | NICTYPE_IOEMU
@@ -191,9 +196,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external disk_add : disk_info -> domid -> unit =
"stub_xl_disk_add"
-external disk_remove : disk_info -> domid -> unit =
"stub_xl_disk_remove"
-
external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -82,16 +82,21 @@ type disk_phystype | PHYSTYPE_FILE
| PHYSTYPE_PHY
-type disk_info -{
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
-}
+module Device_disk : sig
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
type nic_type | NICTYPE_IOEMU
@@ -191,9 +196,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external disk_add : disk_info -> domid -> unit =
"stub_xl_disk_add"
-external disk_remove : disk_info -> domid -> unit =
"stub_xl_disk_remove"
-
external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
@@ -368,7 +368,7 @@ static value Val_topologyinfo(libxl_topo
CAMLreturn(topologyinfo);
}
-value stub_xl_disk_add(value info, value domid)
+value stub_xl_device_disk_add(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_disk c_info;
@@ -385,7 +385,7 @@ value stub_xl_disk_add(value info, value
CAMLreturn(Val_unit);
}
-value stub_xl_disk_remove(value info, value domid)
+value stub_xl_device_disk_del(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_disk c_info;
@@ -397,7 +397,7 @@ value stub_xl_disk_remove(value info, va
INIT_CTX();
ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0);
if (ret != 0)
- failwith_xl("disk_remove", &lg);
+ failwith_xl("disk_del", &lg);
FREE_CTX();
CAMLreturn(Val_unit);
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 10 of 24] tools: ocaml: rename the console types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 06caff5991c65f809ff3013d7d8b1bc2b893b28e
# Parent 7670cfb0da45bdb85bd949bd21eb2004d0989a41
tools: ocaml: rename the console types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -123,12 +123,16 @@ type console_type | CONSOLETYPE_XENCONSOLED
| CONSOLETYPE_IOEMU
-type console_info -{
- backend_domid : domid;
- devid : int;
- consoletype : console_type;
-}
+module Device_console = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ consoletype : console_type;
+ }
+
+ external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
+end
type vkb_info {
@@ -196,8 +200,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
-
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
external vkb_clean_shutdown : domid -> unit =
"stub_vkb_clean_shutdown"
external vkb_hard_shutdown : domid -> unit =
"stub_vkb_hard_shutdown"
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -123,12 +123,16 @@ type console_type | CONSOLETYPE_XENCONSOLED
| CONSOLETYPE_IOEMU
-type console_info -{
- backend_domid : domid;
- devid : int;
- consoletype : console_type;
-}
+module Device_console : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ consoletype : console_type;
+ }
+
+ external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
+end
type vkb_info {
@@ -196,8 +200,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external console_add : console_info -> build_state -> domid -> unit =
"stub_xl_console_add"
-
external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
external vkb_clean_shutdown : domid -> unit =
"stub_vkb_clean_shutdown"
external vkb_hard_shutdown : domid -> unit =
"stub_vkb_hard_shutdown"
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
@@ -436,7 +436,7 @@ value stub_xl_device_nic_del(value info,
CAMLreturn(Val_unit);
}
-value stub_xl_console_add(value info, value state, value domid)
+value stub_xl_device_console_add(value info, value state, value domid)
{
CAMLparam3(info, state, domid);
libxl_device_console c_info;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 11 of 24] tools: ocaml: rename the vkb types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 10db4482d72ad85ee2d92713435621ba6e1a8f0b
# Parent 06caff5991c65f809ff3013d7d8b1bc2b893b28e
tools: ocaml: rename the vkb types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 06caff5991c6 -r 10db4482d72a tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -134,27 +134,39 @@ module Device_console = struct
external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
end
-type vkb_info -{
- backend_domid : domid;
- devid : int;
-}
+module Device_vkb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
-type vfb_info -{
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
-}
+module Device_vfb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
+
type pci_info {
@@ -200,14 +212,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
-external vkb_clean_shutdown : domid -> unit =
"stub_vkb_clean_shutdown"
-external vkb_hard_shutdown : domid -> unit =
"stub_vkb_hard_shutdown"
-
-external vfb_add : vfb_info -> domid -> unit =
"stub_xl_vfb_add"
-external vfb_clean_shutdown : domid -> unit =
"stub_vfb_clean_shutdown"
-external vfb_hard_shutdown : domid -> unit =
"stub_vfb_hard_shutdown"
-
external pci_add : pci_info -> domid -> unit =
"stub_xl_pci_add"
external pci_remove : pci_info -> domid -> unit =
"stub_xl_pci_remove"
external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown"
diff -r 06caff5991c6 -r 10db4482d72a tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -134,27 +134,38 @@ module Device_console : sig
external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
end
-type vkb_info -{
- backend_domid : domid;
- devid : int;
-}
+module Device_vkb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
-type vfb_info -{
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
-}
+module Device_vfb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
type pci_info {
@@ -200,14 +211,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external vkb_add : vkb_info -> domid -> unit =
"stub_xl_vkb_add"
-external vkb_clean_shutdown : domid -> unit =
"stub_vkb_clean_shutdown"
-external vkb_hard_shutdown : domid -> unit =
"stub_vkb_hard_shutdown"
-
-external vfb_add : vfb_info -> domid -> unit =
"stub_xl_vfb_add"
-external vfb_clean_shutdown : domid -> unit =
"stub_vfb_clean_shutdown"
-external vfb_hard_shutdown : domid -> unit =
"stub_vfb_hard_shutdown"
-
external pci_add : pci_info -> domid -> unit =
"stub_xl_pci_add"
external pci_remove : pci_info -> domid -> unit =
"stub_xl_pci_remove"
external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown"
diff -r 06caff5991c6 -r 10db4482d72a tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
@@ -456,7 +456,7 @@ value stub_xl_device_console_add(value i
CAMLreturn(Val_unit);
}
-value stub_xl_vkb_add(value info, value domid)
+value stub_xl_device_vkb_add(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_vkb c_info;
@@ -474,7 +474,7 @@ value stub_xl_vkb_add(value info, value
CAMLreturn(Val_unit);
}
-value stub_xl_vkb_clean_shutdown(value domid)
+value stub_xl_device_vkb_clean_shutdown(value domid)
{
CAMLparam1(domid);
int ret;
@@ -489,7 +489,7 @@ value stub_xl_vkb_clean_shutdown(value d
CAMLreturn(Val_unit);
}
-value stub_xl_vkb_hard_shutdown(value domid)
+value stub_xl_device_vkb_hard_shutdown(value domid)
{
CAMLparam1(domid);
int ret;
@@ -504,7 +504,7 @@ value stub_xl_vkb_hard_shutdown(value do
CAMLreturn(Val_unit);
}
-value stub_xl_vfb_add(value info, value domid)
+value stub_xl_device_vfb_add(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_vfb c_info;
@@ -522,7 +522,7 @@ value stub_xl_vfb_add(value info, value
CAMLreturn(Val_unit);
}
-value stub_xl_vfb_clean_shutdown(value domid)
+value stub_xl_device_vfb_clean_shutdown(value domid)
{
CAMLparam1(domid);
int ret;
@@ -537,7 +537,7 @@ value stub_xl_vfb_clean_shutdown(value d
CAMLreturn(Val_unit);
}
-value stub_xl_vfb_hard_shutdown(value domid)
+value stub_xl_device_vfb_hard_shutdown(value domid)
{
CAMLparam1(domid);
int ret;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 12 of 24] tools: ocaml: rename the pci types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 8dfd508475fdaccd71a376ea02d8a0de49af0336
# Parent 10db4482d72ad85ee2d92713435621ba6e1a8f0b
tools: ocaml: rename the pci types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -167,17 +167,22 @@ module Device_vfb = struct
external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
end
+module Device_pci = struct
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
-type pci_info -{
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
-}
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
type physinfo {
@@ -212,10 +217,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external pci_add : pci_info -> domid -> unit =
"stub_xl_pci_add"
-external pci_remove : pci_info -> domid -> unit =
"stub_xl_pci_remove"
-external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown"
-
type button | Button_Power
| Button_Sleep
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -167,16 +167,22 @@ module Device_vfb : sig
external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
end
-type pci_info -{
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
-}
+module Device_pci : sig
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
type physinfo {
@@ -211,10 +217,6 @@ type sched_credit external domain_make : create_info ->
domid = "stub_xl_domain_make"
external domain_build : build_info -> domid -> build_state =
"stub_xl_domain_build"
-external pci_add : pci_info -> domid -> unit =
"stub_xl_pci_add"
-external pci_remove : pci_info -> domid -> unit =
"stub_xl_pci_remove"
-external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown"
-
type button | Button_Power
| Button_Sleep
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Mar 30 18:54:28 2011 +0100
@@ -552,7 +552,7 @@ value stub_xl_device_vfb_hard_shutdown(v
CAMLreturn(Val_unit);
}
-value stub_xl_pci_add(value info, value domid)
+value stub_xl_device_pci_add(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_pci c_info;
@@ -570,7 +570,7 @@ value stub_xl_pci_add(value info, value
CAMLreturn(Val_unit);
}
-value stub_xl_pci_remove(value info, value domid)
+value stub_xl_device_pci_remove(value info, value domid)
{
CAMLparam2(info, domid);
libxl_device_pci c_info;
@@ -588,7 +588,7 @@ value stub_xl_pci_remove(value info, val
CAMLreturn(Val_unit);
}
-value stub_xl_pci_shutdown(value domid)
+value stub_xl_device_pci_shutdown(value domid)
{
CAMLparam1(domid);
int ret;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 13 of 24] tools: ocaml: remove the domain_make and domain_build functions since they don''t work
# HG changeset patch # User David Scott <dave.scott@eu.citrix.com> # Date 1301507668 -3600 # Node ID 7c7094664ff1873d22b133094836654ae58b2de8 # Parent 8dfd508475fdaccd71a376ea02d8a0de49af0336 tools: ocaml: remove the domain_make and domain_build functions since they don''t work The actual stubs are missing so these are currently a trap for the unwary. Signed-off-by: David Scott <dave.scott@eu.citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 8dfd508475fd -r 7c7094664ff1 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100 @@ -214,9 +214,6 @@ type sched_credit cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button | Button_Power | Button_Sleep diff -r 8dfd508475fd -r 7c7094664ff1 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100 @@ -214,9 +214,6 @@ type sched_credit cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button | Button_Power | Button_Sleep _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 14 of 24] tools: ocaml: rename the create_info types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 21fe28c477f161c38c7073e2844d9cbca9add6ca
# Parent 7c7094664ff1873d22b133094836654ae58b2de8
tools: ocaml: rename the create_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 7c7094664ff1 -r 21fe28c477f1 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -15,19 +15,21 @@
exception Error of string
-type create_info -{
- hvm : bool;
- hap : bool;
- oos : bool;
- ssidref : int32;
- name : string;
- uuid : int array;
- xsdata : (string * string) list;
- platformdata : (string * string) list;
- poolid : int32;
- poolname : string;
-}
+module Domain_create_info = struct
+ type t + {
+ hvm : bool;
+ hap : bool;
+ oos : bool;
+ ssidref : int32;
+ name : string;
+ uuid : int array;
+ xsdata : (string * string) list;
+ platformdata : (string * string) list;
+ poolid : int32;
+ poolname : string;
+ }
+end
type build_pv_info {
diff -r 7c7094664ff1 -r 21fe28c477f1 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -15,19 +15,21 @@
exception Error of string
-type create_info -{
- hvm : bool;
- hap : bool;
- oos : bool;
- ssidref : int32;
- name : string;
- uuid : int array;
- xsdata : (string * string) list;
- platformdata : (string * string) list;
- poolid : int32;
- poolname : string;
-}
+module Domain_create_info : sig
+ type t + {
+ hvm : bool;
+ hap : bool;
+ oos : bool;
+ ssidref : int32;
+ name : string;
+ uuid : int array;
+ xsdata : (string * string) list;
+ platformdata : (string * string) list;
+ poolid : int32;
+ poolname : string;
+ }
+end
type build_pv_info {
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 15 of 24] tools: ocaml: rename the build_info types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID d4357ab0e6b41ac8b89e5ec658c464ace23534b6
# Parent 21fe28c477f161c38c7073e2844d9cbca9add6ca
tools: ocaml: rename the build_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 21fe28c477f1 -r d4357ab0e6b4 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -31,40 +31,44 @@ module Domain_create_info = struct
}
end
-type build_pv_info -{
- slack_memkb : int64;
- cmdline : string;
- ramdisk : string;
- features : string;
-}
+module Domain_build_info = struct
+ module Hvm = struct
+ type t + {
+ pae : bool;
+ apic : bool;
+ acpi : bool;
+ nx : bool;
+ viridian : bool;
+ timeoffset : string;
+ timer_mode : int;
+ hpet : int;
+ vpt_align : int;
+ }
+ end
-type build_hvm_info -{
- pae : bool;
- apic : bool;
- acpi : bool;
- nx : bool;
- viridian : bool;
- timeoffset : string;
- timer_mode : int;
- hpet : int;
- vpt_align : int;
-}
+ module Pv = struct
+ type t + {
+ slack_memkb : int64;
+ cmdline : string;
+ ramdisk : string;
+ features : string;
+ }
+ end
-type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info
-
-type build_info -{
- max_vcpus : int;
- cur_vcpus : int;
- max_memkb : int64;
- target_memkb : int64;
- video_memkb : int64;
- shadow_memkb : int64;
- kernel : string;
- priv: build_spec;
-}
+ type t + {
+ max_vcpus : int;
+ cur_vcpus : int;
+ max_memkb : int64;
+ target_memkb : int64;
+ video_memkb : int64;
+ shadow_memkb : int64;
+ kernel : string;
+ u : [ `HVM of Hvm.t | `PV of Pv.t ];
+ }
+end
type build_state {
diff -r 21fe28c477f1 -r d4357ab0e6b4 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -31,40 +31,44 @@ module Domain_create_info : sig
}
end
-type build_pv_info -{
- slack_memkb : int64;
- cmdline : string;
- ramdisk : string;
- features : string;
-}
+module Domain_build_info : sig
+ module Hvm : sig
+ type t + {
+ pae : bool;
+ apic : bool;
+ acpi : bool;
+ nx : bool;
+ viridian : bool;
+ timeoffset : string;
+ timer_mode : int;
+ hpet : int;
+ vpt_align : int;
+ }
+ end
-type build_hvm_info -{
- pae : bool;
- apic : bool;
- acpi : bool;
- nx : bool;
- viridian : bool;
- timeoffset : string;
- timer_mode : int;
- hpet : int;
- vpt_align : int;
-}
+ module Pv : sig
+ type t + {
+ slack_memkb : int64;
+ cmdline : string;
+ ramdisk : string;
+ features : string;
+ }
+ end
-type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info
-
-type build_info -{
- max_vcpus : int;
- cur_vcpus : int;
- max_memkb : int64;
- target_memkb : int64;
- video_memkb : int64;
- shadow_memkb : int64;
- kernel : string;
- priv: build_spec;
-}
+ type t + {
+ max_vcpus : int;
+ cur_vcpus : int;
+ max_memkb : int64;
+ target_memkb : int64;
+ video_memkb : int64;
+ shadow_memkb : int64;
+ kernel : string;
+ u : [ `HVM of Hvm.t | `PV of Pv.t ];
+ }
+end
type build_state {
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 16 of 24] tools: ocaml: rename the device_build_state types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 27ae89234b2a3eb2f5da96b1efd8578bef608fdb
# Parent d4357ab0e6b41ac8b89e5ec658c464ace23534b6
tools: ocaml: rename the device_build_state types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r d4357ab0e6b4 -r 27ae89234b2a tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -70,13 +70,15 @@ module Domain_build_info = struct
}
end
-type build_state -{
- store_port : int;
- store_mfn : int64;
- console_port : int;
- console_mfn : int64;
-}
+module Device_build_state = struct
+ type t + {
+ store_port : int;
+ store_mfn : int64;
+ console_port : int;
+ console_mfn : int64;
+ }
+end
type domid = int
@@ -137,7 +139,7 @@ module Device_console = struct
consoletype : console_type;
}
- external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
+ external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
end
module Device_vkb = struct
diff -r d4357ab0e6b4 -r 27ae89234b2a tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -70,13 +70,15 @@ module Domain_build_info : sig
}
end
-type build_state -{
- store_port : int;
- store_mfn : int64;
- console_port : int;
- console_mfn : int64;
-}
+module Device_build_state : sig
+ type t + {
+ store_port : int;
+ store_mfn : int64;
+ console_port : int;
+ console_mfn : int64;
+ }
+end
type domid = int
@@ -137,7 +139,7 @@ module Device_console : sig
consoletype : console_type;
}
- external add : t -> build_state -> domid -> unit =
"stub_xl_device_console_add"
+ external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
end
module Device_vkb : sig
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 17 of 24] tools: ocaml: rename the physinfo types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 5c73eaa9e09a8099d26b75eacf1c931a43afa2a6
# Parent 27ae89234b2a3eb2f5da96b1efd8578bef608fdb
tools: ocaml: rename the physinfo types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 27ae89234b2a -r 5c73eaa9e09a tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -192,20 +192,24 @@ module Device_pci = struct
external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
end
-type physinfo -{
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
-}
+module Physinfo = struct
+ type t + {
+ threads_per_core: int;
+ cores_per_socket: int;
+ max_cpu_id: int;
+ nr_cpus: int;
+ cpu_khz: int;
+ total_pages: int64;
+ free_pages: int64;
+ scrub_pages: int64;
+ nr_nodes: int;
+ hwcap: int32 array;
+ physcap: int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+
+end
type topology =
{
@@ -227,7 +231,6 @@ type button | Button_Sleep
external button_press : domid -> button -> unit =
"stub_xl_button_press"
-external physinfo : unit -> physinfo = "stub_xl_physinfo"
external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
diff -r 27ae89234b2a -r 5c73eaa9e09a tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -192,20 +192,24 @@ module Device_pci : sig
external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
end
-type physinfo -{
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
-}
+module Physinfo : sig
+ type t + {
+ threads_per_core: int;
+ cores_per_socket: int;
+ max_cpu_id: int;
+ nr_cpus: int;
+ cpu_khz: int;
+ total_pages: int64;
+ free_pages: int64;
+ scrub_pages: int64;
+ nr_nodes: int;
+ hwcap: int32 array;
+ physcap: int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+
+end
type topology =
{
@@ -227,7 +231,6 @@ type button | Button_Sleep
external button_press : domid -> button -> unit =
"stub_xl_button_press"
-external physinfo : unit -> physinfo = "stub_xl_physinfo"
external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:36 UTC
[Xen-devel] [PATCH 18 of 24] tools: ocaml: rename the sched_credit types and functions
# HG changeset patch
# User David Scott <dave.scott@eu.citrix.com>
# Date 1301507668 -3600
# Node ID 7202919ef85649078c4369726b7cc2441d118a9a
# Parent 5c73eaa9e09a8099d26b75eacf1c931a43afa2a6
tools: ocaml: rename the sched_credit types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 5c73eaa9e09a -r 7202919ef856 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
@@ -220,11 +220,15 @@ type topology
type topologyinfo = topology option array
-type sched_credit -{
- weight: int;
- cap: int;
-}
+module Sched_credit = struct
+ type t + {
+ weight: int;
+ cap: int;
+ }
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
type button | Button_Power
@@ -234,9 +238,6 @@ external button_press : domid -> button
external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
-external domain_sched_credit_get : domid -> sched_credit =
"stub_xl_sched_credit_domain_get"
-external domain_sched_credit_set : domid -> sched_credit -> unit =
"stub_xl_sched_credit_domain_set"
-
external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
diff -r 5c73eaa9e09a -r 7202919ef856 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
@@ -220,11 +220,16 @@ type topology
type topologyinfo = topology option array
-type sched_credit -{
- weight: int;
- cap: int;
-}
+module Sched_credit : sig
+ type t + {
+ weight: int;
+ cap: int;
+ }
+
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
type button | Button_Power
@@ -234,9 +239,6 @@ external button_press : domid -> button
external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
-external domain_sched_credit_get : domid -> sched_credit =
"stub_xl_sched_credit_domain_get"
-external domain_sched_credit_set : domid -> sched_credit -> unit =
"stub_xl_sched_credit_domain_set"
-
external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 19 of 24] tools: ocaml: rename the topology types and functions
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID cdf5d9feb563b274235953579d8c991f38b7ca22
# Parent 7202919ef85649078c4369726b7cc2441d118a9a
tools: ocaml: rename the topology types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: David Scott <dave.scott@eu.citrix.com>
diff -r 7202919ef856 -r cdf5d9feb563 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
@@ -211,14 +211,15 @@ module Physinfo = struct
end
-type topology =
-{
- core: int;
- socket: int;
- node: int;
-}
-
-type topologyinfo = topology option array
+module Topologyinfo = struct
+ type t + {
+ core: int;
+ socket: int;
+ node: int;
+ }
+ external get: unit -> t = "stub_xl_topologyinfo"
+end
module Sched_credit = struct
type t @@ -236,7 +237,6 @@ type button
external button_press : domid -> button -> unit =
"stub_xl_button_press"
-external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
diff -r 7202919ef856 -r cdf5d9feb563 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Mar 30 18:54:28 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
@@ -211,14 +211,15 @@ module Physinfo : sig
end
-type topology =
-{
- core: int;
- socket: int;
- node: int;
-}
-
-type topologyinfo = topology option array
+module Topologyinfo : sig
+ type t + {
+ core: int;
+ socket: int;
+ node: int;
+ }
+ external get : unit -> t = "stub_xl_topologyinfo"
+end
module Sched_credit : sig
type t @@ -237,8 +238,6 @@ type button
external button_press : domid -> button -> unit =
"stub_xl_button_press"
-external topologyinfo: unit -> topologyinfo =
"stub_xl_topologyinfo"
-
external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 20 of 24] tools: ocaml: reorder xl bindings type and function definitions to match IDL
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID 91209ee048a9b7f3eed4ec42c00fe22dcb06ad51
# Parent cdf5d9feb563b274235953579d8c991f38b7ca22
tools: ocaml: reorder xl bindings type and function definitions to match IDL
Reduces the churn when comparing the before and after auto-generation
versions of the patch. (in practice the ocaml pre-autogeneration
bindings are so out of date that there isn''t all that much benefit to
this though...)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r cdf5d9feb563 -r 91209ee048a9 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
@@ -15,6 +15,28 @@
exception Error of string
+type domid = int
+
+type console_type + | CONSOLETYPE_XENCONSOLED
+ | CONSOLETYPE_IOEMU
+
+type disk_phystype + | PHYSTYPE_QCOW
+ | PHYSTYPE_QCOW2
+ | PHYSTYPE_VHD
+ | PHYSTYPE_AIO
+ | PHYSTYPE_FILE
+ | PHYSTYPE_PHY
+
+type nic_type + | NICTYPE_IOEMU
+ | NICTYPE_VIF
+
+type button + | Button_Power
+ | Button_Sleep
+
module Domain_create_info = struct
type t {
@@ -31,6 +53,118 @@ module Domain_create_info = struct
}
end
+module Device_vfb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk = struct
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci = struct
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo = struct
+ type t + {
+ threads_per_core: int;
+ cores_per_socket: int;
+ max_cpu_id: int;
+ nr_cpus: int;
+ cpu_khz: int;
+ total_pages: int64;
+ free_pages: int64;
+ scrub_pages: int64;
+ nr_nodes: int;
+ hwcap: int32 array;
+ physcap: int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+
+end
+
+module Sched_credit = struct
+ type t + {
+ weight: int;
+ cap: int;
+ }
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
+
module Domain_build_info = struct
module Hvm = struct
type t @@ -80,57 +214,6 @@ module Device_build_state = struct
}
end
-type domid = int
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-module Device_disk = struct
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-module Device_nic = struct
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
module Device_console = struct
type t {
@@ -142,75 +225,6 @@ module Device_console = struct
external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
end
-module Device_vkb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_vfb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_pci = struct
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo = struct
- type t - {
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-
-end
-
module Topologyinfo = struct
type t {
@@ -221,20 +235,6 @@ module Topologyinfo = struct
external get: unit -> t = "stub_xl_topologyinfo"
end
-module Sched_credit = struct
- type t - {
- weight: int;
- cap: int;
- }
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
-type button - | Button_Power
- | Button_Sleep
-
external button_press : domid -> button -> unit =
"stub_xl_button_press"
diff -r cdf5d9feb563 -r 91209ee048a9 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
@@ -15,6 +15,28 @@
exception Error of string
+type domid = int
+
+type console_type + | CONSOLETYPE_XENCONSOLED
+ | CONSOLETYPE_IOEMU
+
+type disk_phystype + | PHYSTYPE_QCOW
+ | PHYSTYPE_QCOW2
+ | PHYSTYPE_VHD
+ | PHYSTYPE_AIO
+ | PHYSTYPE_FILE
+ | PHYSTYPE_PHY
+
+type nic_type + | NICTYPE_IOEMU
+ | NICTYPE_VIF
+
+type button + | Button_Power
+ | Button_Sleep
+
module Domain_create_info : sig
type t {
@@ -31,6 +53,119 @@ module Domain_create_info : sig
}
end
+module Device_vfb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk : sig
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci : sig
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
+
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo : sig
+ type t + {
+ threads_per_core: int;
+ cores_per_socket: int;
+ max_cpu_id: int;
+ nr_cpus: int;
+ cpu_khz: int;
+ total_pages: int64;
+ free_pages: int64;
+ scrub_pages: int64;
+ nr_nodes: int;
+ hwcap: int32 array;
+ physcap: int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+
+end
+
+module Sched_credit : sig
+ type t + {
+ weight: int;
+ cap: int;
+ }
+
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
+
module Domain_build_info : sig
module Hvm : sig
type t @@ -80,57 +215,6 @@ module Device_build_state : sig
}
end
-type domid = int
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-module Device_disk : sig
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-module Device_nic : sig
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
module Device_console : sig
type t {
@@ -142,75 +226,6 @@ module Device_console : sig
external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
end
-module Device_vkb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_vfb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_pci : sig
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
-
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo : sig
- type t - {
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-
-end
-
module Topologyinfo : sig
type t {
@@ -221,21 +236,6 @@ module Topologyinfo : sig
external get : unit -> t = "stub_xl_topologyinfo"
end
-module Sched_credit : sig
- type t - {
- weight: int;
- cap: int;
- }
-
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
-type button - | Button_Power
- | Button_Sleep
-
external button_press : domid -> button -> unit =
"stub_xl_button_press"
external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 21 of 24] tools: ocaml: remove create_info and build_info data types from xl bindings
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID a5704e01a60669dbc6d07416f936d330614d28a1
# Parent 91209ee048a9b7f3eed4ec42c00fe22dcb06ad51
tools: ocaml: remove create_info and build_info data types from xl bindings
There are currently no stub functions which use these datatypes. The
existing definitions are out of date wrt the C API (and the conversion
routines are commented out anyway) and are complex from the IDL point
of view (and so will be skipped in the first round of
autogeneration). Remove them to keep things simple for now.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 91209ee048a9 -r a5704e01a606 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
@@ -37,22 +37,6 @@ type button | Button_Power
| Button_Sleep
-module Domain_create_info = struct
- type t - {
- hvm : bool;
- hap : bool;
- oos : bool;
- ssidref : int32;
- name : string;
- uuid : int array;
- xsdata : (string * string) list;
- platformdata : (string * string) list;
- poolid : int32;
- poolname : string;
- }
-end
-
module Device_vfb = struct
type t {
@@ -165,45 +149,6 @@ module Sched_credit = struct
external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
end
-module Domain_build_info = struct
- module Hvm = struct
- type t - {
- pae : bool;
- apic : bool;
- acpi : bool;
- nx : bool;
- viridian : bool;
- timeoffset : string;
- timer_mode : int;
- hpet : int;
- vpt_align : int;
- }
- end
-
- module Pv = struct
- type t - {
- slack_memkb : int64;
- cmdline : string;
- ramdisk : string;
- features : string;
- }
- end
-
- type t - {
- max_vcpus : int;
- cur_vcpus : int;
- max_memkb : int64;
- target_memkb : int64;
- video_memkb : int64;
- shadow_memkb : int64;
- kernel : string;
- u : [ `HVM of Hvm.t | `PV of Pv.t ];
- }
-end
-
module Device_build_state = struct
type t {
diff -r 91209ee048a9 -r a5704e01a606 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
@@ -37,22 +37,6 @@ type button | Button_Power
| Button_Sleep
-module Domain_create_info : sig
- type t - {
- hvm : bool;
- hap : bool;
- oos : bool;
- ssidref : int32;
- name : string;
- uuid : int array;
- xsdata : (string * string) list;
- platformdata : (string * string) list;
- poolid : int32;
- poolname : string;
- }
-end
-
module Device_vfb : sig
type t {
@@ -166,45 +150,6 @@ module Sched_credit : sig
external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
end
-module Domain_build_info : sig
- module Hvm : sig
- type t - {
- pae : bool;
- apic : bool;
- acpi : bool;
- nx : bool;
- viridian : bool;
- timeoffset : string;
- timer_mode : int;
- hpet : int;
- vpt_align : int;
- }
- end
-
- module Pv : sig
- type t - {
- slack_memkb : int64;
- cmdline : string;
- ramdisk : string;
- features : string;
- }
- end
-
- type t - {
- max_vcpus : int;
- cur_vcpus : int;
- max_memkb : int64;
- target_memkb : int64;
- video_memkb : int64;
- shadow_memkb : int64;
- kernel : string;
- u : [ `HVM of Hvm.t | `PV of Pv.t ];
- }
-end
-
module Device_build_state : sig
type t {
diff -r 91209ee048a9 -r a5704e01a606 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
@@ -128,63 +128,6 @@ static int string_string_tuple_array_val
CAMLreturn(0);
}
-static int domain_create_info_val (caml_gc *gc, libxl_domain_create_info
*c_val, value v)
-{
- CAMLparam1(v);
- CAMLlocal1(a);
- uint8_t *uuid = libxl_uuid_bytearray(&c_val->uuid);
- int i;
-
- c_val->hvm = Bool_val(Field(v, 0));
- c_val->hap = Bool_val(Field(v, 1));
- c_val->oos = Bool_val(Field(v, 2));
- c_val->ssidref = Int32_val(Field(v, 3));
- c_val->name = dup_String_val(gc, Field(v, 4));
- a = Field(v, 5);
- for (i = 0; i < 16; i++)
- uuid[i] = Int_val(Field(a, i));
- string_string_tuple_array_val(gc, &(c_val->xsdata), Field(v, 6));
- string_string_tuple_array_val(gc, &(c_val->platformdata), Field(v, 7));
-
- c_val->poolid = Int32_val(Field(v, 8));
- c_val->poolname = dup_String_val(gc, Field(v, 9));
-
- CAMLreturn(0);
-}
-
-static int domain_build_info_val (caml_gc *gc, libxl_domain_build_info *c_val,
value v)
-{
- CAMLparam1(v);
- CAMLlocal1(infopriv);
-
- c_val->max_vcpus = Int_val(Field(v, 0));
- c_val->cur_vcpus = Int_val(Field(v, 1));
- c_val->max_memkb = Int64_val(Field(v, 2));
- c_val->target_memkb = Int64_val(Field(v, 3));
- c_val->video_memkb = Int64_val(Field(v, 4));
- c_val->shadow_memkb = Int64_val(Field(v, 5));
- c_val->kernel.path = dup_String_val(gc, Field(v, 6));
- c_val->is_hvm = Tag_val(Field(v, 7)) == 0;
- infopriv = Field(Field(v, 7), 0);
- if (c_val->hvm) {
- c_val->u.hvm.pae = Bool_val(Field(infopriv, 0));
- c_val->u.hvm.apic = Bool_val(Field(infopriv, 1));
- c_val->u.hvm.acpi = Bool_val(Field(infopriv, 2));
- c_val->u.hvm.nx = Bool_val(Field(infopriv, 3));
- c_val->u.hvm.viridian = Bool_val(Field(infopriv, 4));
- c_val->u.hvm.timeoffset = dup_String_val(gc, Field(infopriv, 5));
- c_val->u.hvm.timer_mode = Int_val(Field(infopriv, 6));
- c_val->u.hvm.hpet = Int_val(Field(infopriv, 7));
- c_val->u.hvm.vpt_align = Int_val(Field(infopriv, 8));
- } else {
- c_val->u.pv.slack_memkb = Int64_val(Field(infopriv, 0));
- c_val->u.pv.cmdline = dup_String_val(gc, Field(infopriv, 1));
- c_val->u.pv.ramdisk.path = dup_String_val(gc, Field(infopriv, 2));
- c_val->u.pv.features = dup_String_val(gc, Field(infopriv, 3));
- }
-
- CAMLreturn(0);
-}
#endif
static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 22 of 24] tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID 3c51e7bfe28948bcd354cfc2ab2083d2ddb94d22
# Parent a5704e01a60669dbc6d07416f936d330614d28a1
tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings
Reduces the diff of existing vs auto-generated code.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
@@ -64,7 +64,6 @@ module Device_vkb = struct
backend_domid : domid;
devid : int;
}
-
external add : t -> domid -> unit = "stub_xl_device_vkb_add"
external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
@@ -81,7 +80,6 @@ module Device_disk = struct
readwrite : bool;
is_cdrom : bool;
}
-
external add : t -> domid -> unit = "stub_xl_device_disk_add"
external del : t -> domid -> unit = "stub_xl_device_disk_del"
end
@@ -114,7 +112,6 @@ module Device_pci = struct
msitranslate : bool;
power_mgmt : bool;
}
-
external add : t -> domid -> unit = "stub_xl_device_pci_add"
external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
@@ -123,17 +120,17 @@ end
module Physinfo = struct
type t {
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
+ threads_per_core : int;
+ cores_per_socket : int;
+ max_cpu_id : int;
+ nr_cpus : int;
+ cpu_khz : int;
+ total_pages : int64;
+ free_pages : int64;
+ scrub_pages : int64;
+ nr_nodes : int;
+ hwcap : int32 array;
+ physcap : int32;
}
external get : unit -> t = "stub_xl_physinfo"
@@ -142,8 +139,8 @@ end
module Sched_credit = struct
type t {
- weight: int;
- cap: int;
+ weight : int;
+ cap : int;
}
external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
@@ -166,18 +163,17 @@ module Device_console = struct
devid : int;
consoletype : console_type;
}
-
external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
end
module Topologyinfo = struct
type t {
- core: int;
- socket: int;
- node: int;
+ core : int;
+ socket : int;
+ node : int;
}
- external get: unit -> t = "stub_xl_topologyinfo"
+ external get : unit -> t = "stub_xl_topologyinfo"
end
external button_press : domid -> button -> unit =
"stub_xl_button_press"
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
@@ -64,7 +64,6 @@ module Device_vkb : sig
backend_domid : domid;
devid : int;
}
-
external add : t -> domid -> unit = "stub_xl_device_vkb_add"
external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
@@ -81,7 +80,6 @@ module Device_disk : sig
readwrite : bool;
is_cdrom : bool;
}
-
external add : t -> domid -> unit = "stub_xl_device_disk_add"
external del : t -> domid -> unit = "stub_xl_device_disk_del"
end
@@ -114,7 +112,6 @@ module Device_pci : sig
msitranslate : bool;
power_mgmt : bool;
}
-
external add : t -> domid -> unit = "stub_xl_device_pci_add"
external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
@@ -123,29 +120,27 @@ end
module Physinfo : sig
type t {
- threads_per_core: int;
- cores_per_socket: int;
- max_cpu_id: int;
- nr_cpus: int;
- cpu_khz: int;
- total_pages: int64;
- free_pages: int64;
- scrub_pages: int64;
- nr_nodes: int;
- hwcap: int32 array;
- physcap: int32;
+ threads_per_core : int;
+ cores_per_socket : int;
+ max_cpu_id : int;
+ nr_cpus : int;
+ cpu_khz : int;
+ total_pages : int64;
+ free_pages : int64;
+ scrub_pages : int64;
+ nr_nodes : int;
+ hwcap : int32 array;
+ physcap : int32;
}
external get : unit -> t = "stub_xl_physinfo"
-
end
module Sched_credit : sig
type t {
- weight: int;
- cap: int;
+ weight : int;
+ cap : int;
}
-
external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
end
@@ -174,9 +169,9 @@ end
module Topologyinfo : sig
type t {
- core: int;
- socket: int;
- node: int;
+ core : int;
+ socket : int;
+ node : int;
}
external get : unit -> t = "stub_xl_topologyinfo"
end
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
@@ -245,7 +245,7 @@ static int domain_build_state_val(caml_g
c_val->store_mfn = Int64_val(Field(v, 1));
c_val->console_port = Int_val(Field(v, 2));
c_val->console_mfn = Int64_val(Field(v, 3));
-
+
CAMLreturn(0);
}
@@ -295,7 +295,7 @@ static value Val_topologyinfo(libxl_topo
int i;
topologyinfo = caml_alloc_tuple(c_val->coremap.entries);
- for (i = 0; i < c_val->coremap.entries; i++) {
+ for (i = 0; i < c_val->coremap.entries; i++) {
v = Val_int(0); /* None */
if (c_val->coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY) {
topology = caml_alloc_tuple(3);
@@ -413,7 +413,7 @@ value stub_xl_device_vkb_add(value info,
if (ret != 0)
failwith_xl("vkb_add", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -428,7 +428,7 @@ value stub_xl_device_vkb_clean_shutdown(
if (ret != 0)
failwith_xl("vkb_clean_shutdown", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -443,7 +443,7 @@ value stub_xl_device_vkb_hard_shutdown(v
if (ret != 0)
failwith_xl("vkb_hard_shutdown", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -461,7 +461,7 @@ value stub_xl_device_vfb_add(value info,
if (ret != 0)
failwith_xl("vfb_add", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -476,7 +476,7 @@ value stub_xl_device_vfb_clean_shutdown(
if (ret != 0)
failwith_xl("vfb_clean_shutdown", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -491,7 +491,7 @@ value stub_xl_device_vfb_hard_shutdown(v
if (ret != 0)
failwith_xl("vfb_hard_shutdown", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -509,7 +509,7 @@ value stub_xl_device_pci_add(value info,
if (ret != 0)
failwith_xl("pci_add", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -527,7 +527,7 @@ value stub_xl_device_pci_remove(value in
if (ret != 0)
failwith_xl("pci_remove", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -542,7 +542,7 @@ value stub_xl_device_pci_shutdown(value
if (ret != 0)
failwith_xl("pci_shutdown", &lg);
FREE_CTX();
-
+
CAMLreturn(Val_unit);
}
@@ -551,7 +551,7 @@ value stub_xl_button_press(value domid,
CAMLparam2(domid, button);
int ret;
INIT_STRUCT();
-
+
INIT_CTX();
ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) +
LIBXL_BUTTON_POWER);
if (ret != 0)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 23 of 24] tools: ocaml: lay ground work for auto generating xl datatypes
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID 5bbea737a0dc092bf377129a057b01b15944b041
# Parent 3c51e7bfe28948bcd354cfc2ab2083d2ddb94d22
tools: ocaml: lay ground work for auto generating xl datatypes.
Doesn''t actually generate anything yet but puts all the moving parts
into place. In particular sets up the
xl.ml.in+_libxl_types.ml.in->xl.ml transformation using sed. This
appears to be the only/best way to do this for ocaml due to the lack
of a preprocessor and/or an include mechanism which has an inmpact on
namespacing.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 3c51e7bfe289 -r 5bbea737a0dc .hgignore
--- a/.hgignore Wed Apr 13 13:35:52 2011 +0100
+++ b/.hgignore Wed Apr 13 13:35:52 2011 +0100
@@ -295,6 +295,11 @@
^tools/ocaml/.*/.*\.cmx?a$
^tools/ocaml/.*/META$
^tools/ocaml/.*/\.ocamldep\.make$
+^tools/ocaml/libs/xl/_libxl_types\.ml\.in$
+^tools/ocaml/libs/xl/_libxl_types\.mli\.in$
+^tools/ocaml/libs/xl/_libxl_types\.inc$
+^tools/ocaml/libs/xl/xl\.ml$
+^tools/ocaml/libs/xl/xl\.mli$
^tools/ocaml/xenstored/oxenstored$
^xen/\.banner.*$
^xen/BLOG$
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/Makefile
--- a/tools/ocaml/libs/xl/Makefile Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/Makefile Wed Apr 13 13:35:52 2011 +0100
@@ -15,8 +15,36 @@ xl_C_OBJS = xl_stubs
OCAML_LIBRARY = xl
+GENERATED_FILES += xl.ml xl.mli
+GENERATED_FILES += _libxl_types.ml.in _libxl_types.mli.in
+GENERATED_FILES += _libxl_types.inc
+
all: $(INTF) $(LIBS)
+xl.ml: xl.ml.in _libxl_types.ml.in
+ $(Q)sed -e ''1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.ml.in and _libxl_types.ml.in\
+ *)\
+'' \
+ -e ''/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.ml.in'' \
+ < xl.ml.in > xl.ml
+
+xl.mli: xl.mli.in _libxl_types.mli.in
+ $(Q)sed -e ''1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.mli.in and _libxl_types.mli.in\
+ *)\
+'' \
+ -e ''/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.mli.in'' \
+ < xl.mli.in > xl.mli
+
+_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py
$(XEN_ROOT)/tools/libxl/libxl.idl \
+ $(XEN_ROOT)/tools/libxl/libxltypes.py
+ PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \
+ $(XEN_ROOT)/tools/libxl/libxl.idl \
+ _libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc
+
libs: $(LIBS)
.PHONY: install
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/genwrap.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import sys,os
+
+import libxltypes
+
+def autogen_header(open_comment, close_comment):
+ s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " +
close_comment + "\n"
+ s += open_comment + " autogenerated by \n"
+ s += reduce(lambda x,y: x + " ", range(len(open_comment + "
")), "")
+ s += "%s" % " ".join(sys.argv)
+ s += "\n " + close_comment + "\n\n"
+ return s
+
+if __name__ == ''__main__'':
+ if len(sys.argv) < 4:
+ print >>sys.stderr, "Usage: genwrap.py <idl>
<mli> <ml> <c-inc>"
+ sys.exit(1)
+
+ idl = sys.argv[1]
+ (_,types) = libxltypes.parse(idl)
+
+
+ _ml = sys.argv[3]
+ ml = open(_ml, ''w'')
+ ml.write(autogen_header("(*", "*)"))
+
+ _mli = sys.argv[2]
+ mli = open(_mli, ''w'')
+ mli.write(autogen_header("(*", "*)"))
+
+ _cinc = sys.argv[4]
+ cinc = open(_cinc, ''w'')
+ cinc.write(autogen_header("/*", "*/"))
+
+ # TODO: autogenerate something
+
+ ml.write("(* END OF AUTO-GENERATED CODE *)\n")
+ ml.close()
+ mli.write("(* END OF AUTO-GENERATED CODE *)\n")
+ mli.close()
+ cinc.close()
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-(*
- * Copyright (C) 2009-2011 Citrix Ltd.
- * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *)
-
-exception Error of string
-
-type domid = int
-
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-type button - | Button_Power
- | Button_Sleep
-
-module Device_vfb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- }
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk = struct
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic = struct
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci = struct
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo = struct
- type t - {
- threads_per_core : int;
- cores_per_socket : int;
- max_cpu_id : int;
- nr_cpus : int;
- cpu_khz : int;
- total_pages : int64;
- free_pages : int64;
- scrub_pages : int64;
- nr_nodes : int;
- hwcap : int32 array;
- physcap : int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-
-end
-
-module Sched_credit = struct
- type t - {
- weight : int;
- cap : int;
- }
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
-module Device_build_state = struct
- type t - {
- store_port : int;
- store_mfn : int64;
- console_port : int;
- console_mfn : int64;
- }
-end
-
-module Device_console = struct
- type t - {
- backend_domid : domid;
- devid : int;
- consoletype : console_type;
- }
- external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
-end
-
-module Topologyinfo = struct
- type t - {
- core : int;
- socket : int;
- node : int;
- }
- external get : unit -> t = "stub_xl_topologyinfo"
-end
-
-external button_press : domid -> button -> unit =
"stub_xl_button_press"
-
-
-external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
-external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
-external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
-
-let _ = Callback.register_exception "xl.error" (Error
"register_callback")
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.ml.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/xl.ml.in Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,188 @@
+(*
+ * Copyright (C) 2009-2011 Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *)
+
+exception Error of string
+
+type domid = int
+
+(* @@LIBXL_TYPES@@ *)
+
+type console_type + | CONSOLETYPE_XENCONSOLED
+ | CONSOLETYPE_IOEMU
+
+type disk_phystype + | PHYSTYPE_QCOW
+ | PHYSTYPE_QCOW2
+ | PHYSTYPE_VHD
+ | PHYSTYPE_AIO
+ | PHYSTYPE_FILE
+ | PHYSTYPE_PHY
+
+type nic_type + | NICTYPE_IOEMU
+ | NICTYPE_VIF
+
+type button + | Button_Power
+ | Button_Sleep
+
+module Device_vfb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk = struct
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci = struct
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo = struct
+ type t + {
+ threads_per_core : int;
+ cores_per_socket : int;
+ max_cpu_id : int;
+ nr_cpus : int;
+ cpu_khz : int;
+ total_pages : int64;
+ free_pages : int64;
+ scrub_pages : int64;
+ nr_nodes : int;
+ hwcap : int32 array;
+ physcap : int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+
+end
+
+module Sched_credit = struct
+ type t + {
+ weight : int;
+ cap : int;
+ }
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
+
+module Device_build_state = struct
+ type t + {
+ store_port : int;
+ store_mfn : int64;
+ console_port : int;
+ console_mfn : int64;
+ }
+end
+
+module Device_console = struct
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ consoletype : console_type;
+ }
+ external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
+end
+
+module Topologyinfo = struct
+ type t + {
+ core : int;
+ socket : int;
+ node : int;
+ }
+ external get : unit -> t = "stub_xl_topologyinfo"
+end
+
+external button_press : domid -> button -> unit =
"stub_xl_button_press"
+
+
+external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
+external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
+external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
+
+let _ = Callback.register_exception "xl.error" (Error
"register_callback")
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli Wed Apr 13 13:35:52 2011 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-(*
- * Copyright (C) 2009-2011 Citrix Ltd.
- * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *)
-
-exception Error of string
-
-type domid = int
-
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-type button - | Button_Power
- | Button_Sleep
-
-module Device_vfb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- }
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk : sig
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic : sig
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci : sig
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo : sig
- type t - {
- threads_per_core : int;
- cores_per_socket : int;
- max_cpu_id : int;
- nr_cpus : int;
- cpu_khz : int;
- total_pages : int64;
- free_pages : int64;
- scrub_pages : int64;
- nr_nodes : int;
- hwcap : int32 array;
- physcap : int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-end
-
-module Sched_credit : sig
- type t - {
- weight : int;
- cap : int;
- }
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
-module Device_build_state : sig
- type t - {
- store_port : int;
- store_mfn : int64;
- console_port : int;
- console_mfn : int64;
- }
-end
-
-module Device_console : sig
- type t - {
- backend_domid : domid;
- devid : int;
- consoletype : console_type;
- }
-
- external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
-end
-
-module Topologyinfo : sig
- type t - {
- core : int;
- socket : int;
- node : int;
- }
- external get : unit -> t = "stub_xl_topologyinfo"
-end
-
-external button_press : domid -> button -> unit =
"stub_xl_button_press"
-
-external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
-external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
-external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.mli.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/xl.mli.in Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,185 @@
+(*
+ * Copyright (C) 2009-2011 Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *)
+
+exception Error of string
+
+type domid = int
+
+(* @@LIBXL_TYPES@@ *)
+
+type console_type + | CONSOLETYPE_XENCONSOLED
+ | CONSOLETYPE_IOEMU
+
+type disk_phystype + | PHYSTYPE_QCOW
+ | PHYSTYPE_QCOW2
+ | PHYSTYPE_VHD
+ | PHYSTYPE_AIO
+ | PHYSTYPE_FILE
+ | PHYSTYPE_PHY
+
+type nic_type + | NICTYPE_IOEMU
+ | NICTYPE_VIF
+
+type button + | Button_Power
+ | Button_Sleep
+
+module Device_vfb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ vnc : bool;
+ vnclisten : string;
+ vncpasswd : string;
+ vncdisplay : int;
+ vncunused : bool;
+ keymap : string;
+ sdl : bool;
+ opengl : bool;
+ display : string;
+ xauthority : string;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+ external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
+ external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk : sig
+ type t + {
+ backend_domid : domid;
+ physpath : string;
+ phystype : disk_phystype;
+ virtpath : string;
+ unpluggable : bool;
+ readwrite : bool;
+ is_cdrom : bool;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_disk_add"
+ external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ mtu : int;
+ model : string;
+ mac : int array;
+ bridge : string;
+ ifname : string;
+ script : string;
+ nictype : nic_type;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_nic_add"
+ external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci : sig
+ type t + {
+ func : int;
+ dev : int;
+ bus : int;
+ domain : int;
+ vdevfn : int;
+ msitranslate : bool;
+ power_mgmt : bool;
+ }
+ external add : t -> domid -> unit = "stub_xl_device_pci_add"
+ external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
+ external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo : sig
+ type t + {
+ threads_per_core : int;
+ cores_per_socket : int;
+ max_cpu_id : int;
+ nr_cpus : int;
+ cpu_khz : int;
+ total_pages : int64;
+ free_pages : int64;
+ scrub_pages : int64;
+ nr_nodes : int;
+ hwcap : int32 array;
+ physcap : int32;
+ }
+ external get : unit -> t = "stub_xl_physinfo"
+end
+
+module Sched_credit : sig
+ type t + {
+ weight : int;
+ cap : int;
+ }
+ external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
+ external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
+end
+
+module Device_build_state : sig
+ type t + {
+ store_port : int;
+ store_mfn : int64;
+ console_port : int;
+ console_mfn : int64;
+ }
+end
+
+module Device_console : sig
+ type t + {
+ backend_domid : domid;
+ devid : int;
+ consoletype : console_type;
+ }
+
+ external add : t -> Device_build_state.t -> domid -> unit =
"stub_xl_device_console_add"
+end
+
+module Topologyinfo : sig
+ type t + {
+ core : int;
+ socket : int;
+ node : int;
+ }
+ external get : unit -> t = "stub_xl_topologyinfo"
+end
+
+external button_press : domid -> button -> unit =
"stub_xl_button_press"
+
+external send_trigger : domid -> string -> int -> unit =
"stub_xl_send_trigger"
+external send_sysrq : domid -> char -> unit =
"stub_xl_send_sysrq"
+external send_debug_keys : domid -> string -> unit =
"stub_xl_send_debug_keys"
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <string.h>
-#include "libxl.h"
+#include <libxl.h>
struct caml_logger {
struct xentoollog_logger logger;
@@ -130,6 +130,8 @@ static int string_string_tuple_array_val
#endif
+#include "_libxl_types.inc"
+
static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
{
CAMLparam1(v);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-13 14:37 UTC
[Xen-devel] [PATCH 24 of 24] tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1302698152 -3600
# Node ID 12c05af7227399ac7f2f7897b4fdf0b972a42892
# Parent 5bbea737a0dc092bf377129a057b01b15944b041
tools: ocaml: autogenerate xl datatype definitions and ocaml<->C
conversion
The method by which ocaml converts between ocaml types and C
datastructures is based around explicit matching of field indexes
within the ocaml data type to C structure members which is error prone
to write and fragile to maintain (as evidenced by the difference
between the existing hand coded support and the autogenerated code
which shows how out of date the ocaml bindings have
become). Autogenerating these types should reduce these problems.
There is a short list of types which are blacklisted and not
autogenerated because I expect them to change significantly in the
future due to changes to the IDL type (fixing up the TaggedUnion
class).
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/Makefile
--- a/tools/ocaml/libs/xl/Makefile Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/Makefile Wed Apr 13 13:35:52 2011 +0100
@@ -2,6 +2,8 @@ TOPLEVEL=$(CURDIR)/../..
XEN_ROOT=$(TOPLEVEL)/../..
include $(TOPLEVEL)/common.make
+# ignore unused generated functions
+CFLAGS += -Wno-unused
CFLAGS += $(CFLAGS_libxenlight)
OBJS = xl
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/genwrap.py Wed Apr 13 13:35:52 2011 +0100
@@ -4,6 +4,218 @@ import sys,os
import libxltypes
+# typename -> ( ocaml_type, c_from_ocaml, ocaml_from_c )
+builtins = {
+ "bool": ("bool",
"%(c)s = Bool_val(%(o)s)", "Val_bool(%(c)s)" ),
+ "int": ("int",
"%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "long": ("int",
"%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "unsigned int": ("int",
"%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "unsigned long": ("int",
"%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "char *": ("string",
"%(c)s = dup_String_val(gc, %(o)s)",
"caml_copy_string(%(c)s)"),
+ "libxl_domid": ("domid",
"%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ),
+ "libxl_uuid": ("int array",
"Uuid_val(gc, lg, &%(c)s, %(o)s)",
"Val_uuid(&%(c)s)"),
+ "libxl_key_value_list": ("(string * string) list",
None, None),
+ "libxl_mac": ("int array",
"Mac_val(gc, lg, &%(c)s, %(o)s)",
"Val_mac(&%(c)s)"),
+ "libxl_hwcap": ("int32 array",
None, "Val_hwcap(&%(c)s)"),
+ }
+
+functions = {
+ "device_disk": [ "external add : t -> domid -> unit
= \"stub_xl_device_disk_add\"",
+ "external del : t -> domid -> unit =
\"stub_xl_device_disk_del\"",
+ ],
+ "device_nic": [ "external add : t -> domid -> unit
= \"stub_xl_device_nic_add\"",
+ "external del : t -> domid -> unit =
\"stub_xl_device_nic_del\"",
+ ],
+ "device_vfb": [ "external add : t -> domid -> unit
= \"stub_xl_device_vfb_add\"",
+ "external clean_shutdown : domid -> unit =
\"stub_xl_device_vfb_clean_shutdown\"",
+ "external hard_shutdown : domid -> unit =
\"stub_xl_device_vfb_hard_shutdown\"",
+ ],
+ "device_vkb": [ "external add : t -> domid -> unit
= \"stub_xl_device_vkb_add\"",
+ "external clean_shutdown : domid -> unit =
\"stub_xl_device_vkb_clean_shutdown\"",
+ "external hard_shutdown : domid -> unit =
\"stub_xl_device_vkb_hard_shutdown\"",
+ ],
+ "device_pci": [ "external add : t -> domid -> unit
= \"stub_xl_device_pci_add\"",
+ "external remove : t -> domid -> unit =
\"stub_xl_device_pci_remove\"",
+ "external shutdown : domid -> unit =
\"stub_xl_device_pci_shutdown\"",
+ ],
+ "physinfo": [ "external get : unit -> t =
\"stub_xl_physinfo\"",
+ ],
+ "sched_credit": [ "external domain_get : domid -> t =
\"stub_xl_sched_credit_domain_get\"",
+ "external domain_set : domid -> t -> unit =
\"stub_xl_sched_credit_domain_set\"",
+ ],
+}
+
+def ocaml_type_of(ty):
+ if ty.rawname == "domid":
+ return "domid"
+ elif isinstance(ty,libxltypes.UInt):
+ # standard ocaml "int" type is 31-bit signed.
+ if ty.width > 64:
+ raise NotImplementedError("Cannot handle %d-bit int" %
ty.width)
+ elif ty.width > 32:
+ return "int64"
+ else:
+ return "int32"
+ elif isinstance(ty,libxltypes.Builtin):
+ if not builtins.has_key(ty.typename):
+ raise NotImplementedError("Unknown Builtin %s (%s)" %
(ty.typename, type(ty)))
+ typename,_,_ = builtins[ty.typename]
+ if not typename:
+ raise NotImplementedError("No typename for Builtin %s
(%s)" % (ty.typename, type(ty)))
+ return typename
+ else:
+ return ty.rawname
+
+def ocaml_instance_of(type, name):
+ return "%s : %s" % (name, ocaml_type_of(type))
+
+def gen_ocaml_ml(ty, interface, indent=""):
+
+ if interface:
+ s = ("""(* %s interface *)\n""" %
ty.typename)
+ else:
+ s = ("""(* %s implementation *)\n""" %
ty.typename)
+ if isinstance(ty, libxltypes.Enumeration):
+ s = "type %s = \n" % ty.rawname
+ for v in ty.values:
+ s += "\t | %s\n" % v.rawname
+ elif isinstance(ty, libxltypes.Aggregate):
+ s = ""
+ if ty.typename is None:
+ raise NotImplementedError("%s has no typename" %
type(ty))
+ else:
+
+ module_name = ty.rawname[0].upper() + ty.rawname[1:]
+
+ if interface:
+ s += "module %s : sig\n" % module_name
+ else:
+ s += "module %s = struct\n" % module_name
+ s += "\ttype t =\n"
+ s += "\t{\n"
+
+ for f in ty.fields:
+ x = ocaml_instance_of(f.type, f.name)
+ x = x.replace("\n", "\n\t\t")
+ s += "\t\t" + x + ";\n"
+
+ s += "\t}\n"
+
+ if functions.has_key(ty.rawname):
+ for fn in functions[ty.rawname]:
+ s += "\t%s\n" % fn
+
+ s += "end\n"
+
+ else:
+ raise NotImplementedError("%s" % type(ty))
+ return s.replace("\n", "\n%s" % indent)
+
+def c_val(ty, c, o, indent="", parent = None):
+ if ty.passby == libxltypes.PASS_BY_REFERENCE:
+ makeref = ""
+ else:
+ makeref = "&"
+
+ s = indent
+ if isinstance(ty,libxltypes.UInt):
+ s += "%s = Int_val(%s);" % (c, o)
+ elif isinstance(ty,libxltypes.Builtin):
+ if not builtins.has_key(ty.typename):
+ raise NotImplementedError("Unknown Builtin %s (%s)" %
(ty.typename, type(ty)))
+ _,fn,_ = builtins[ty.typename]
+ if not fn:
+ raise NotImplementedError("No c_val fn for Builtin %s
(%s)" % (ty.typename, type(ty)))
+ s += "%s;" % (fn % { "o": o, "c": c })
+ elif isinstance(ty,libxltypes.Enumeration) and (parent is None):
+ n = 0
+ s += "switch(Int_val(%s)) {\n" % o
+ for e in ty.values:
+ s += " case %d: *%s = %s; break;\n" % (n, c, e.name)
+ n += 1
+ s += " default: failwith_xl(\"cannot convert value to
%s\", lg); break;\n" % ty.typename
+ s += "}"
+ elif isinstance(ty, libxltypes.Aggregate) and (parent is None):
+ n = 0
+ for f in ty.fields:
+ s += "%s\n" % c_val(f.type, "%s->%s" % (c,
f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c))
+ n = n + 1
+ else:
+ s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, makeref + c, o)
+
+ return s.replace("\n", "\n%s" % indent)
+
+def gen_c_val(ty, indent=""):
+ s = ""
+
+ s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s
*c_val, value v)\n" % (ty.rawname, ty.typename)
+ s += "{\n"
+ s += "\tCAMLparam1(v);\n"
+ s += "\n"
+
+ s += c_val(ty, "c_val", "v", indent="\t") +
"\n"
+
+ s += "\tCAMLreturn(0);\n"
+ s += "}\n"
+
+ return s.replace("\n", "\n%s" % indent)
+
+def ocaml_Val(ty, o, c, indent="", parent = None):
+ if ty.passby == libxltypes.PASS_BY_REFERENCE:
+ makeref = ""
+ else:
+ makeref = "&"
+
+ s = indent
+ if isinstance(ty,libxltypes.UInt):
+ s += "%s = Val_int(%s);" % (o, c)
+ elif isinstance(ty,libxltypes.Builtin):
+ if not builtins.has_key(ty.typename):
+ raise NotImplementedError("Unknown Builtin %s (%s)" %
(ty.typename, type(ty)))
+ _,_,fn = builtins[ty.typename]
+ if not fn:
+ raise NotImplementedError("No ocaml_Val fn for Builtin %s
(%s)" % (ty.typename, type(ty)))
+ s += "%s = %s;" % (o, fn % { "c": c })
+ elif isinstance(ty,libxltypes.Enumeration) and (parent is None):
+ n = 0
+ s += "switch(*%s) {\n" % c
+ for e in ty.values:
+ s += " case %s: %s = Int_val(%d); break;\n" % (e.name,
o, n)
+ n += 1
+ s += " default: failwith_xl(\"cannot convert value from
%s\", lg); break;\n" % ty.typename
+ s += "}"
+ elif isinstance(ty,libxltypes.Aggregate) and (parent is None):
+ s += "{\n"
+ s += "\tvalue %s_field;\n" % ty.rawname
+ s += "\n"
+ s += "\t%s = caml_alloc_tuple(%d);\n" % (o, len(ty.fields))
+
+ n = 0
+ for f in ty.fields:
+ s += "\n"
+ s += "\t%s\n" % ocaml_Val(f.type, "%s_field" %
ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c)
+ s += "\tStore_field(%s, %d, %s);\n" % (o, n,
"%s_field" % ty.rawname)
+ n = n + 1
+ s += "}"
+ else:
+ s += "%s = Val_%s(gc, lg, %s);" % (o, ty.rawname, makeref +
c)
+
+ return s.replace("\n", "\n%s" % indent).rstrip(indent)
+
+def gen_Val_ocaml(ty, indent=""):
+ s = ""
+
+ s += "static value Val_%s (caml_gc *gc, struct caml_logger *lg, %s
*%s_c)\n" % (ty.rawname, ty.typename, ty.rawname)
+ s += "{\n"
+ s += "\tCAMLparam0();\n"
+ s += "\tCAMLlocal1(%s_ocaml);\n" % ty.rawname
+
+ s += ocaml_Val(ty, "%s_ocaml" % ty.rawname, "%s_c" %
ty.rawname, indent="\t") + "\n"
+
+ s += "\tCAMLreturn(%s_ocaml);\n" % ty.rawname
+ s += "}\n"
+ return s.replace("\n", "\n%s" % indent)
+
def autogen_header(open_comment, close_comment):
s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " +
close_comment + "\n"
s += open_comment + " autogenerated by \n"
@@ -20,6 +232,19 @@ if __name__ == ''__main__'':
idl = sys.argv[1]
(_,types) = libxltypes.parse(idl)
+ # Do not generate these yet.
+ blacklist = [
+ "cpupoolinfo",
+ "domain_create_info",
+ "domain_build_info",
+ "domain_build_state",
+ "device_model_info",
+ "device_console",
+ "vcpuinfo",
+ "topologyinfo",
+ ]
+
+ types = [ty for ty in types if not ty.rawname in blacklist]
_ml = sys.argv[3]
ml = open(_ml, ''w'')
@@ -33,8 +258,22 @@ if __name__ == ''__main__'':
cinc = open(_cinc, ''w'')
cinc.write(autogen_header("/*", "*/"))
- # TODO: autogenerate something
+ for ty in types:
+ #sys.stdout.write(" TYPE %-20s " % ty.rawname)
+ ml.write(gen_ocaml_ml(ty, False))
+ ml.write("\n")
+ mli.write(gen_ocaml_ml(ty, True))
+ mli.write("\n")
+
+ if ty.marshal_in():
+ cinc.write(gen_c_val(ty))
+ cinc.write("\n")
+ if ty.marshal_out():
+ cinc.write(gen_Val_ocaml(ty))
+ cinc.write("\n")
+ #sys.stdout.write("\n")
+
ml.write("(* END OF AUTO-GENERATED CODE *)\n")
ml.close()
mli.write("(* END OF AUTO-GENERATED CODE *)\n")
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/xl.ml.in
--- a/tools/ocaml/libs/xl/xl.ml.in Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.ml.in Wed Apr 13 13:35:52 2011 +0100
@@ -19,135 +19,6 @@ type domid = int
(* @@LIBXL_TYPES@@ *)
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-type button - | Button_Power
- | Button_Sleep
-
-module Device_vfb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb = struct
- type t - {
- backend_domid : domid;
- devid : int;
- }
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk = struct
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic = struct
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci = struct
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo = struct
- type t - {
- threads_per_core : int;
- cores_per_socket : int;
- max_cpu_id : int;
- nr_cpus : int;
- cpu_khz : int;
- total_pages : int64;
- free_pages : int64;
- scrub_pages : int64;
- nr_nodes : int;
- hwcap : int32 array;
- physcap : int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-
-end
-
-module Sched_credit = struct
- type t - {
- weight : int;
- cap : int;
- }
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
module Device_build_state = struct
type t {
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/xl.mli.in
--- a/tools/ocaml/libs/xl/xl.mli.in Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl.mli.in Wed Apr 13 13:35:52 2011 +0100
@@ -19,134 +19,6 @@ type domid = int
(* @@LIBXL_TYPES@@ *)
-type console_type - | CONSOLETYPE_XENCONSOLED
- | CONSOLETYPE_IOEMU
-
-type disk_phystype - | PHYSTYPE_QCOW
- | PHYSTYPE_QCOW2
- | PHYSTYPE_VHD
- | PHYSTYPE_AIO
- | PHYSTYPE_FILE
- | PHYSTYPE_PHY
-
-type nic_type - | NICTYPE_IOEMU
- | NICTYPE_VIF
-
-type button - | Button_Power
- | Button_Sleep
-
-module Device_vfb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- vnc : bool;
- vnclisten : string;
- vncpasswd : string;
- vncdisplay : int;
- vncunused : bool;
- keymap : string;
- sdl : bool;
- opengl : bool;
- display : string;
- xauthority : string;
- }
- external add : t -> domid -> unit = "stub_xl_device_vfb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vfb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb : sig
- type t - {
- backend_domid : domid;
- devid : int;
- }
- external add : t -> domid -> unit = "stub_xl_device_vkb_add"
- external clean_shutdown : domid -> unit =
"stub_xl_device_vkb_clean_shutdown"
- external hard_shutdown : domid -> unit =
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk : sig
- type t - {
- backend_domid : domid;
- physpath : string;
- phystype : disk_phystype;
- virtpath : string;
- unpluggable : bool;
- readwrite : bool;
- is_cdrom : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_disk_add"
- external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic : sig
- type t - {
- backend_domid : domid;
- devid : int;
- mtu : int;
- model : string;
- mac : int array;
- bridge : string;
- ifname : string;
- script : string;
- nictype : nic_type;
- }
- external add : t -> domid -> unit = "stub_xl_device_nic_add"
- external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci : sig
- type t - {
- func : int;
- dev : int;
- bus : int;
- domain : int;
- vdevfn : int;
- msitranslate : bool;
- power_mgmt : bool;
- }
- external add : t -> domid -> unit = "stub_xl_device_pci_add"
- external remove : t -> domid -> unit =
"stub_xl_device_pci_remove"
- external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo : sig
- type t - {
- threads_per_core : int;
- cores_per_socket : int;
- max_cpu_id : int;
- nr_cpus : int;
- cpu_khz : int;
- total_pages : int64;
- free_pages : int64;
- scrub_pages : int64;
- nr_nodes : int;
- hwcap : int32 array;
- physcap : int32;
- }
- external get : unit -> t = "stub_xl_physinfo"
-end
-
-module Sched_credit : sig
- type t - {
- weight : int;
- cap : int;
- }
- external domain_get : domid -> t =
"stub_xl_sched_credit_domain_get"
- external domain_set : domid -> t -> unit =
"stub_xl_sched_credit_domain_set"
-end
-
module Device_build_state : sig
type t {
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c Wed Apr 13 13:35:52 2011 +0100
@@ -130,55 +130,76 @@ static int string_string_tuple_array_val
#endif
-#include "_libxl_types.inc"
+static value Val_mac (libxl_mac *c_val)
+{
+ CAMLparam0();
+ CAMLlocal1(v);
+ int i;
-static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
+ v = caml_alloc_tuple(6);
+
+ for(i=0; i<6; i++)
+ Store_field(v, i, Val_int((*c_val)[i]));
+
+ CAMLreturn(v);
+}
+
+static int Mac_val(caml_gc *gc, struct caml_logger *lg, libxl_mac *c_val, value
v)
{
CAMLparam1(v);
+ int i;
- c_val->backend_domid = Int_val(Field(v, 0));
- c_val->pdev_path = dup_String_val(gc, Field(v, 1));
- c_val->vdev = dup_String_val(gc, Field(v, 2));
- c_val->backend = (Int_val(Field(v, 3)));
- c_val->format = (Int_val(Field(v, 4)));
- c_val->unpluggable = Bool_val(Field(v, 5));
- c_val->readwrite = Bool_val(Field(v, 6));
- c_val->is_cdrom = Bool_val(Field(v, 7));
+ for(i=0; i<6; i++)
+ (*c_val)[i] = Int_val(Field(v, i));
CAMLreturn(0);
}
-static int device_nic_val(caml_gc *gc, libxl_device_nic *c_val, value v)
+static value Val_uuid (libxl_uuid *c_val)
+{
+ CAMLparam0();
+ CAMLlocal1(v);
+ uint8_t *uuid = libxl_uuid_bytearray(c_val);
+ int i;
+
+ v = caml_alloc_tuple(16);
+
+ for(i=0; i<16; i++)
+ Store_field(v, i, Val_int(uuid[i]));
+
+ CAMLreturn(v);
+}
+
+static int Uuid_val(caml_gc *gc, struct caml_logger *lg, libxl_uuid *c_val,
value v)
{
CAMLparam1(v);
int i;
- int ret = 0;
- c_val->backend_domid = Int_val(Field(v, 0));
- c_val->devid = Int_val(Field(v, 1));
- c_val->mtu = Int_val(Field(v, 2));
- c_val->model = dup_String_val(gc, Field(v, 3));
+ uint8_t *uuid = libxl_uuid_bytearray(c_val);
- if (Wosize_val(Field(v, 4)) != 6) {
- ret = 1;
- goto out;
- }
- for (i = 0; i < 6; i++)
- c_val->mac[i] = Int_val(Field(Field(v, 4), i));
+ for(i=0; i<16; i++)
+ uuid[i] = Int_val(Field(v, i));
- /* not handling c_val->ip */
- c_val->bridge = dup_String_val(gc, Field(v, 5));
- c_val->ifname = dup_String_val(gc, Field(v, 6));
- c_val->script = dup_String_val(gc, Field(v, 7));
- c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU;
+ CAMLreturn(0);
+}
-out:
- CAMLreturn(ret);
+static value Val_hwcap(libxl_hwcap *c_val)
+{
+ CAMLparam0();
+ CAMLlocal1(hwcap);
+ int i;
+
+ hwcap = caml_alloc_tuple(8);
+ for (i = 0; i < 8; i++)
+ Store_field(hwcap, i, caml_copy_int32((*c_val)[i]));
+
+ CAMLreturn(hwcap);
}
+#include "_libxl_types.inc"
+
static int device_console_val(caml_gc *gc, libxl_device_console *c_val, value
v)
{
CAMLparam1(v);
-
c_val->backend_domid = Int_val(Field(v, 0));
c_val->devid = Int_val(Field(v, 1));
c_val->consback = (Int_val(Field(v, 2))) +
LIBXL_CONSOLE_BACKEND_XENCONSOLED;
@@ -186,59 +207,6 @@ static int device_console_val(caml_gc *g
CAMLreturn(0);
}
-static int device_vkb_val(caml_gc *gc, libxl_device_vkb *c_val, value v)
-{
- CAMLparam1(v);
-
- c_val->backend_domid = Int_val(Field(v, 0));
- c_val->devid = Int_val(Field(v, 1));
-
- CAMLreturn(0);
-}
-
-static int device_vfb_val(caml_gc *gc, libxl_device_vfb *c_val, value v)
-{
- CAMLparam1(v);
-
- c_val->backend_domid = Int_val(Field(v, 0));
- c_val->devid = Int_val(Field(v, 1));
- c_val->vnc = Bool_val(Field(v, 2));
- c_val->vnclisten = dup_String_val(gc, Field(v, 3));
- c_val->vncpasswd = dup_String_val(gc, Field(v, 4));
- c_val->vncdisplay = Int_val(Field(v, 5));
- c_val->keymap = dup_String_val(gc, Field(v, 6));
- c_val->sdl = Bool_val(Field(v, 7));
- c_val->opengl = Bool_val(Field(v, 8));
- c_val->display = dup_String_val(gc, Field(v, 9));
- c_val->xauthority = dup_String_val(gc, Field(v, 10));
-
- CAMLreturn(0);
-}
-
-static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v)
-{
- CAMLparam1(v);
-
- c_val->func = Int_val(Field(v, 0));
- c_val->dev = Int_val(Field(v, 1));
- c_val->bus = Int_val(Field(v, 2));
-
- c_val->domain = Int_val(Field(v, 3));
- c_val->vdevfn = Int_val(Field(v, 4));
- c_val->msitranslate = Bool_val(Field(v, 5));
- c_val->power_mgmt = Bool_val(Field(v, 6));
-
- CAMLreturn(0);
-}
-
-static int sched_credit_val(caml_gc *gc, libxl_sched_credit *c_val, value v)
-{
- CAMLparam1(v);
- c_val->weight = Int_val(Field(v, 0));
- c_val->cap = Int_val(Field(v, 1));
- CAMLreturn(0);
-}
-
static int domain_build_state_val(caml_gc *gc, libxl_domain_build_state *c_val,
value v)
{
CAMLparam1(v);
@@ -251,45 +219,6 @@ static int domain_build_state_val(caml_g
CAMLreturn(0);
}
-static value Val_sched_credit(libxl_sched_credit *c_val)
-{
- CAMLparam0();
- CAMLlocal1(v);
-
- v = caml_alloc_tuple(2);
-
- Store_field(v, 0, Val_int(c_val->weight));
- Store_field(v, 1, Val_int(c_val->cap));
-
- CAMLreturn(v);
-}
-
-static value Val_physinfo(libxl_physinfo *c_val)
-{
- CAMLparam0();
- CAMLlocal2(v, hwcap);
- int i;
-
- hwcap = caml_alloc_tuple(8);
- for (i = 0; i < 8; i++)
- Store_field(hwcap, i, caml_copy_int32(c_val->hw_cap[i]));
-
- v = caml_alloc_tuple(11);
- Store_field(v, 0, Val_int(c_val->threads_per_core));
- Store_field(v, 1, Val_int(c_val->cores_per_socket));
- Store_field(v, 2, Val_int(c_val->max_cpu_id));
- Store_field(v, 3, Val_int(c_val->nr_cpus));
- Store_field(v, 4, Val_int(c_val->cpu_khz));
- Store_field(v, 5, caml_copy_int64(c_val->total_pages));
- Store_field(v, 6, caml_copy_int64(c_val->free_pages));
- Store_field(v, 7, caml_copy_int64(c_val->scrub_pages));
- Store_field(v, 8, Val_int(c_val->nr_nodes));
- Store_field(v, 9, hwcap);
- Store_field(v, 10, caml_copy_int32(c_val->phys_cap));
-
- CAMLreturn(v);
-}
-
static value Val_topologyinfo(libxl_topologyinfo *c_val)
{
CAMLparam0();
@@ -320,7 +249,7 @@ value stub_xl_device_disk_add(value info
int ret;
INIT_STRUCT();
- device_disk_val(&gc, &c_info, info);
+ device_disk_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info);
@@ -337,7 +266,7 @@ value stub_xl_device_disk_del(value info
int ret;
INIT_STRUCT();
- device_disk_val(&gc, &c_info, info);
+ device_disk_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0);
@@ -354,7 +283,7 @@ value stub_xl_device_nic_add(value info,
int ret;
INIT_STRUCT();
- device_nic_val(&gc, &c_info, info);
+ device_nic_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info);
@@ -371,7 +300,7 @@ value stub_xl_device_nic_del(value info,
int ret;
INIT_STRUCT();
- device_nic_val(&gc, &c_info, info);
+ device_nic_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0);
@@ -408,7 +337,7 @@ value stub_xl_device_vkb_add(value info,
int ret;
INIT_STRUCT();
- device_vkb_val(&gc, &c_info, info);
+ device_vkb_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info);
@@ -456,7 +385,7 @@ value stub_xl_device_vfb_add(value info,
int ret;
INIT_STRUCT();
- device_vfb_val(&gc, &c_info, info);
+ device_vfb_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
@@ -504,7 +433,7 @@ value stub_xl_device_pci_add(value info,
int ret;
INIT_STRUCT();
- device_pci_val(&gc, &c_info, info);
+ device_pci_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info);
@@ -522,7 +451,7 @@ value stub_xl_device_pci_remove(value in
int ret;
INIT_STRUCT();
- device_pci_val(&gc, &c_info, info);
+ device_pci_val(&gc, &lg, &c_info, info);
INIT_CTX();
ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0);
@@ -577,7 +506,7 @@ value stub_xl_physinfo(value unit)
failwith_xl("physinfo", &lg);
FREE_CTX();
- physinfo = Val_physinfo(&c_physinfo);
+ physinfo = Val_physinfo(&gc, &lg, &c_physinfo);
CAMLreturn(physinfo);
}
@@ -613,7 +542,7 @@ value stub_xl_sched_credit_domain_get(va
failwith_xl("sched_credit_domain_get", &lg);
FREE_CTX();
- scinfo = Val_sched_credit(&c_scinfo);
+ scinfo = Val_sched_credit(&gc, &lg, &c_scinfo);
CAMLreturn(scinfo);
}
@@ -624,7 +553,7 @@ value stub_xl_sched_credit_domain_set(va
int ret;
INIT_STRUCT();
- sched_credit_val(&gc, &c_scinfo, scinfo);
+ sched_credit_val(&gc, &lg, &c_scinfo, scinfo);
INIT_CTX();
ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Apr-15 09:27 UTC
Re: [Xen-devel] [PATCH 24 of 24] tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion
On Wed, 2011-04-13 at 15:37 +0100, Ian Campbell wrote:> tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversionThis updated version has improved handling of integer types (although I still don''t think it is quite correct wrt signedness for uint32 and uint64). The other change is to autogenerate a prototype for each function, this will hopefully catch cases of parameter mismatch. Ian. # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1302859303 -3600 # Node ID 4244d6a3fa3a843aa109481b88e55a34d894d22f # Parent 2a93903c97f09b06965066ac30b0f9711ae3fe7c tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion The method by which ocaml converts between ocaml types and C datastructures is based around explicit matching of field indexes within the ocaml data type to C structure members which is error prone to write and fragile to maintain (as evidenced by the difference between the existing hand coded support and the autogenerated code which shows how out of date the ocaml bindings have become). Autogenerating these types should reduce these problems. There is a short list of types which are blacklisted and not autogenerated because I expect them to change significantly in the future due to changes to the IDL type (fixing up the TaggedUnion class). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> * * * tools: ocaml: add structure to ocaml stub function definitions This allows us to generate a C prototype as well and therefore lets the C compiler catch errors with the stub function implementation. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/Makefile --- a/tools/ocaml/libs/xl/Makefile Fri Apr 15 09:34:19 2011 +0100 +++ b/tools/ocaml/libs/xl/Makefile Fri Apr 15 10:21:43 2011 +0100 @@ -2,6 +2,8 @@ TOPLEVEL=$(CURDIR)/../.. XEN_ROOT=$(TOPLEVEL)/../.. include $(TOPLEVEL)/common.make +# ignore unused generated functions +CFLAGS += -Wno-unused CFLAGS += $(CFLAGS_libxenlight) OBJS = xl diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/genwrap.py --- a/tools/ocaml/libs/xl/genwrap.py Fri Apr 15 09:34:19 2011 +0100 +++ b/tools/ocaml/libs/xl/genwrap.py Fri Apr 15 10:21:43 2011 +0100 @@ -4,6 +4,256 @@ import sys,os import libxltypes +# typename -> ( ocaml_type, c_from_ocaml, ocaml_from_c ) +builtins = { + "bool": ("bool", "%(c)s = Bool_val(%(o)s)", "Val_bool(%(c)s)" ), + "int": ("int", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "long": ("int", "%(c)s = Long_val(%(o)s)", "Val_int(%(c)s)" ), + "unsigned int": ("int", "%(c)s = Unsigned_int_val(%(o)s)", "Val_int(%(c)s)" ), + "unsigned long": ("int", "%(c)s = Unsigned_long_val(%(o)s)", "Val_int(%(c)s)" ), + "char *": ("string", "%(c)s = dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"), + "libxl_domid": ("domid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "libxl_uuid": ("int array", "Uuid_val(gc, lg, &%(c)s, %(o)s)", "Val_uuid(&%(c)s)"), + "libxl_key_value_list": ("(string * string) list", None, None), + "libxl_mac": ("int array", "Mac_val(gc, lg, &%(c)s, %(o)s)", "Val_mac(&%(c)s)"), + "libxl_hwcap": ("int32 array", None, "Val_hwcap(&%(c)s)"), + } + +functions = { # ( name , [type1,type2,....] ) + "device_disk": [ ("add", ["t", "domid", "unit"]), + ("del", ["t", "domid", "unit"]), + ], + "device_nic": [ ("add", ["t", "domid", "unit"]), + ("del", ["t", "domid", "unit"]), + ], + "device_vfb": [ ("add", ["t", "domid", "unit"]), + ("clean_shutdown", ["domid", "unit"]), + ("hard_shutdown", ["domid", "unit"]), + ], + "device_vkb": [ ("add", ["t", "domid", "unit"]), + ("clean_shutdown", ["domid", "unit"]), + ("hard_shutdown", ["domid", "unit"]), + ], + "device_pci": [ ("add", ["t", "domid", "unit"]), + ("remove", ["t", "domid", "unit"]), + ("shutdown", ["domid", "unit"]), + ], + "physinfo": [ ("get", ["unit", "t"]), + ], + "sched_credit": [ ("domain_get", ["domid", "t"]), + ("domain_set", ["domid", "t", "unit"]), + ], +} +def stub_fn_name(ty, name): + return "stub_xl_%s_%s" % (ty.rawname,name) + +def ocaml_type_of(ty): + if ty.rawname == "domid": + return "domid" + elif isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + return "int%d" % ty.width + else: + return "int" + + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + typename,_,_ = builtins[ty.typename] + if not typename: + raise NotImplementedError("No typename for Builtin %s (%s)" % (ty.typename, type(ty))) + return typename + else: + return ty.rawname + +def ocaml_instance_of(type, name): + return "%s : %s" % (name, ocaml_type_of(type)) + +def gen_ocaml_ml(ty, interface, indent=""): + + if interface: + s = ("""(* %s interface *)\n""" % ty.typename) + else: + s = ("""(* %s implementation *)\n""" % ty.typename) + if isinstance(ty, libxltypes.Enumeration): + s = "type %s = \n" % ty.rawname + for v in ty.values: + s += "\t | %s\n" % v.rawname + elif isinstance(ty, libxltypes.Aggregate): + s = "" + if ty.typename is None: + raise NotImplementedError("%s has no typename" % type(ty)) + else: + + module_name = ty.rawname[0].upper() + ty.rawname[1:] + + if interface: + s += "module %s : sig\n" % module_name + else: + s += "module %s = struct\n" % module_name + s += "\ttype t =\n" + s += "\t{\n" + + for f in ty.fields: + x = ocaml_instance_of(f.type, f.name) + x = x.replace("\n", "\n\t\t") + s += "\t\t" + x + ";\n" + + s += "\t}\n" + + if functions.has_key(ty.rawname): + for name,args in functions[ty.rawname]: + s += "\texternal %s : " % name + s += " -> ".join(args) + s += " = \"%s\"\n" % stub_fn_name(ty,name) + + s += "end\n" + + else: + raise NotImplementedError("%s" % type(ty)) + return s.replace("\n", "\n%s" % indent) + +def c_val(ty, c, o, indent="", parent = None): + if ty.passby == libxltypes.PASS_BY_REFERENCE: + makeref = "" + else: + makeref = "&" + + s = indent + if isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + s += "%s = Int%d_val(%s);" % (c, width, o) + else: + s += "%s = Int_val(%s);" % (c, o) + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + _,fn,_ = builtins[ty.typename] + if not fn: + raise NotImplementedError("No c_val fn for Builtin %s (%s)" % (ty.typename, type(ty))) + s += "%s;" % (fn % { "o": o, "c": c }) + elif isinstance(ty,libxltypes.Enumeration) and (parent is None): + n = 0 + s += "switch(Int_val(%s)) {\n" % o + for e in ty.values: + s += " case %d: *%s = %s; break;\n" % (n, c, e.name) + n += 1 + s += " default: failwith_xl(\"cannot convert value to %s\", lg); break;\n" % ty.typename + s += "}" + elif isinstance(ty, libxltypes.Aggregate) and (parent is None): + n = 0 + for f in ty.fields: + s += "%s\n" % c_val(f.type, "%s->%s" % (c, f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c)) + n = n + 1 + else: + s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, makeref + c, o) + + return s.replace("\n", "\n%s" % indent) + +def gen_c_val(ty, indent=""): + s = "/* Convert caml value to %s */\n" % ty.rawname + + s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s *c_val, value v)\n" % (ty.rawname, ty.typename) + s += "{\n" + s += "\tCAMLparam1(v);\n" + s += "\n" + + s += c_val(ty, "c_val", "v", indent="\t") + "\n" + + s += "\tCAMLreturn(0);\n" + s += "}\n" + + return s.replace("\n", "\n%s" % indent) + +def ocaml_Val(ty, o, c, indent="", parent = None): + if ty.passby == libxltypes.PASS_BY_REFERENCE: + makeref = "" + else: + makeref = "&" + + s = indent + if isinstance(ty,libxltypes.UInt): + if ty.width in [8, 16]: + # handle as ints + width = None + elif ty.width in [32, 64]: + width = ty.width + else: + raise NotImplementedError("Cannot handle %d-bit int" % ty.width) + if width: + s += "%s = caml_copy_int%d(%s);" % (o, width, c) + else: + s += "%s = Val_int(%s);" % (o, c) + elif isinstance(ty,libxltypes.Builtin): + if not builtins.has_key(ty.typename): + raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) + _,_,fn = builtins[ty.typename] + if not fn: + raise NotImplementedError("No ocaml Val fn for Builtin %s (%s)" % (ty.typename, type(ty))) + s += "%s = %s;" % (o, fn % { "c": c }) + elif isinstance(ty,libxltypes.Enumeration) and (parent is None): + n = 0 + s += "switch(*%s) {\n" % c + for e in ty.values: + s += " case %s: %s = Int_val(%d); break;\n" % (e.name, o, n) + n += 1 + s += " default: failwith_xl(\"cannot convert value from %s\", lg); break;\n" % ty.typename + s += "}" + elif isinstance(ty,libxltypes.Aggregate) and (parent is None): + s += "{\n" + s += "\tvalue %s_field;\n" % ty.rawname + s += "\n" + s += "\t%s = caml_alloc_tuple(%d);\n" % (o, len(ty.fields)) + + n = 0 + for f in ty.fields: + s += "\n" + s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c) + s += "\tStore_field(%s, %d, %s);\n" % (o, n, "%s_field" % ty.rawname) + n = n + 1 + s += "}" + else: + s += "%s = Val_%s(gc, lg, %s);" % (o, ty.rawname, makeref + c) + + return s.replace("\n", "\n%s" % indent).rstrip(indent) + +def gen_Val_ocaml(ty, indent=""): + s = "/* Convert %s to a caml value */\n" % ty.rawname + + s += "static value Val_%s (caml_gc *gc, struct caml_logger *lg, %s *%s_c)\n" % (ty.rawname, ty.typename, ty.rawname) + s += "{\n" + s += "\tCAMLparam0();\n" + s += "\tCAMLlocal1(%s_ocaml);\n" % ty.rawname + + s += ocaml_Val(ty, "%s_ocaml" % ty.rawname, "%s_c" % ty.rawname, indent="\t") + "\n" + + s += "\tCAMLreturn(%s_ocaml);\n" % ty.rawname + s += "}\n" + return s.replace("\n", "\n%s" % indent) + +def gen_c_stub_prototype(ty, fns): + s = "/* Stubs for %s */\n" % ty.rawname + for name,args in fns: + # For N args we return one value and take N-1 values as parameters + s += "value %s(" % stub_fn_name(ty, name) + s += ", ".join(["value v%d" % v for v in range(1,len(args))]) + s += ");\n" + return s + def autogen_header(open_comment, close_comment): s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + "\n" s += open_comment + " autogenerated by \n" @@ -20,6 +270,19 @@ if __name__ == ''__main__'': idl = sys.argv[1] (_,types) = libxltypes.parse(idl) + # Do not generate these yet. + blacklist = [ + "cpupoolinfo", + "domain_create_info", + "domain_build_info", + "domain_build_state", + "device_model_info", + "device_console", + "vcpuinfo", + "topologyinfo", + ] + + types = [ty for ty in types if not ty.rawname in blacklist] _ml = sys.argv[3] ml = open(_ml, ''w'') @@ -33,8 +296,25 @@ if __name__ == ''__main__'': cinc = open(_cinc, ''w'') cinc.write(autogen_header("/*", "*/")) - # TODO: autogenerate something + for ty in types: + #sys.stdout.write(" TYPE %-20s " % ty.rawname) + ml.write(gen_ocaml_ml(ty, False)) + ml.write("\n") + mli.write(gen_ocaml_ml(ty, True)) + mli.write("\n") + + if ty.marshal_in(): + cinc.write(gen_c_val(ty)) + cinc.write("\n") + if ty.marshal_out(): + cinc.write(gen_Val_ocaml(ty)) + cinc.write("\n") + if functions.has_key(ty.rawname): + cinc.write(gen_c_stub_prototype(ty, functions[ty.rawname])) + cinc.write("\n") + #sys.stdout.write("\n") + ml.write("(* END OF AUTO-GENERATED CODE *)\n") ml.close() mli.write("(* END OF AUTO-GENERATED CODE *)\n") diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/xl.ml.in --- a/tools/ocaml/libs/xl/xl.ml.in Fri Apr 15 09:34:19 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.ml.in Fri Apr 15 10:21:43 2011 +0100 @@ -19,135 +19,6 @@ type domid = int (* @@LIBXL_TYPES@@ *) -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb = struct - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb = struct - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_disk = struct - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic = struct - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci = struct - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo = struct - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" - -end - -module Sched_credit = struct - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - module Device_build_state = struct type t { diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/xl.mli.in --- a/tools/ocaml/libs/xl/xl.mli.in Fri Apr 15 09:34:19 2011 +0100 +++ b/tools/ocaml/libs/xl/xl.mli.in Fri Apr 15 10:21:43 2011 +0100 @@ -19,134 +19,6 @@ type domid = int (* @@LIBXL_TYPES@@ *) -type console_type - | CONSOLETYPE_XENCONSOLED - | CONSOLETYPE_IOEMU - -type disk_phystype - | PHYSTYPE_QCOW - | PHYSTYPE_QCOW2 - | PHYSTYPE_VHD - | PHYSTYPE_AIO - | PHYSTYPE_FILE - | PHYSTYPE_PHY - -type nic_type - | NICTYPE_IOEMU - | NICTYPE_VIF - -type button - | Button_Power - | Button_Sleep - -module Device_vfb : sig - type t - { - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; - } - external add : t -> domid -> unit = "stub_xl_device_vfb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" -end - -module Device_vkb : sig - type t - { - backend_domid : domid; - devid : int; - } - external add : t -> domid -> unit = "stub_xl_device_vkb_add" - external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" - external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" -end - -module Device_disk : sig - type t - { - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; - } - external add : t -> domid -> unit = "stub_xl_device_disk_add" - external del : t -> domid -> unit = "stub_xl_device_disk_del" -end - -module Device_nic : sig - type t - { - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; - } - external add : t -> domid -> unit = "stub_xl_device_nic_add" - external del : t -> domid -> unit = "stub_xl_device_nic_del" -end - -module Device_pci : sig - type t - { - func : int; - dev : int; - bus : int; - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; - } - external add : t -> domid -> unit = "stub_xl_device_pci_add" - external remove : t -> domid -> unit = "stub_xl_device_pci_remove" - external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" -end - -module Physinfo : sig - type t - { - threads_per_core : int; - cores_per_socket : int; - max_cpu_id : int; - nr_cpus : int; - cpu_khz : int; - total_pages : int64; - free_pages : int64; - scrub_pages : int64; - nr_nodes : int; - hwcap : int32 array; - physcap : int32; - } - external get : unit -> t = "stub_xl_physinfo" -end - -module Sched_credit : sig - type t - { - weight : int; - cap : int; - } - external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" - external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" -end - module Device_build_state : sig type t { diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Fri Apr 15 09:34:19 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Fri Apr 15 10:21:43 2011 +0100 @@ -39,7 +39,7 @@ typedef struct caml_gc { void *ptrs[64]; } caml_gc; -void log_vmessage(struct xentoollog_logger *logger, xentoollog_level level, +static void log_vmessage(struct xentoollog_logger *logger, xentoollog_level level, int errnoval, const char *context, const char *format, va_list al) { struct caml_logger *ologger = (struct caml_logger *) logger; @@ -48,7 +48,7 @@ void log_vmessage(struct xentoollog_logg 2048 - ologger->log_offset, format, al); } -void log_destroy(struct xentoollog_logger *logger) +static void log_destroy(struct xentoollog_logger *logger) { } @@ -89,7 +89,7 @@ static void gc_free(caml_gc *gc) } } -void failwith_xl(char *fname, struct caml_logger *lg) +static void failwith_xl(char *fname, struct caml_logger *lg) { char *s; s = (lg) ? lg->log_buf : fname; @@ -130,55 +130,76 @@ static int string_string_tuple_array_val #endif -#include "_libxl_types.inc" +static value Val_mac (libxl_mac *c_val) +{ + CAMLparam0(); + CAMLlocal1(v); + int i; -static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v) + v = caml_alloc_tuple(6); + + for(i=0; i<6; i++) + Store_field(v, i, Val_int((*c_val)[i])); + + CAMLreturn(v); +} + +static int Mac_val(caml_gc *gc, struct caml_logger *lg, libxl_mac *c_val, value v) { CAMLparam1(v); + int i; - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->pdev_path = dup_String_val(gc, Field(v, 1)); - c_val->vdev = dup_String_val(gc, Field(v, 2)); - c_val->backend = (Int_val(Field(v, 3))); - c_val->format = (Int_val(Field(v, 4))); - c_val->unpluggable = Bool_val(Field(v, 5)); - c_val->readwrite = Bool_val(Field(v, 6)); - c_val->is_cdrom = Bool_val(Field(v, 7)); + for(i=0; i<6; i++) + (*c_val)[i] = Int_val(Field(v, i)); CAMLreturn(0); } -static int device_nic_val(caml_gc *gc, libxl_device_nic *c_val, value v) +static value Val_uuid (libxl_uuid *c_val) +{ + CAMLparam0(); + CAMLlocal1(v); + uint8_t *uuid = libxl_uuid_bytearray(c_val); + int i; + + v = caml_alloc_tuple(16); + + for(i=0; i<16; i++) + Store_field(v, i, Val_int(uuid[i])); + + CAMLreturn(v); +} + +static int Uuid_val(caml_gc *gc, struct caml_logger *lg, libxl_uuid *c_val, value v) { CAMLparam1(v); int i; - int ret = 0; - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - c_val->mtu = Int_val(Field(v, 2)); - c_val->model = dup_String_val(gc, Field(v, 3)); + uint8_t *uuid = libxl_uuid_bytearray(c_val); - if (Wosize_val(Field(v, 4)) != 6) { - ret = 1; - goto out; - } - for (i = 0; i < 6; i++) - c_val->mac[i] = Int_val(Field(Field(v, 4), i)); + for(i=0; i<16; i++) + uuid[i] = Int_val(Field(v, i)); - /* not handling c_val->ip */ - c_val->bridge = dup_String_val(gc, Field(v, 5)); - c_val->ifname = dup_String_val(gc, Field(v, 6)); - c_val->script = dup_String_val(gc, Field(v, 7)); - c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NIC_TYPE_IOEMU; + CAMLreturn(0); +} -out: - CAMLreturn(ret); +static value Val_hwcap(libxl_hwcap *c_val) +{ + CAMLparam0(); + CAMLlocal1(hwcap); + int i; + + hwcap = caml_alloc_tuple(8); + for (i = 0; i < 8; i++) + Store_field(hwcap, i, caml_copy_int32((*c_val)[i])); + + CAMLreturn(hwcap); } +#include "_libxl_types.inc" + static int device_console_val(caml_gc *gc, libxl_device_console *c_val, value v) { CAMLparam1(v); - c_val->backend_domid = Int_val(Field(v, 0)); c_val->devid = Int_val(Field(v, 1)); c_val->consback = (Int_val(Field(v, 2))) + LIBXL_CONSOLE_BACKEND_XENCONSOLED; @@ -186,59 +207,6 @@ static int device_console_val(caml_gc *g CAMLreturn(0); } -static int device_vkb_val(caml_gc *gc, libxl_device_vkb *c_val, value v) -{ - CAMLparam1(v); - - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - - CAMLreturn(0); -} - -static int device_vfb_val(caml_gc *gc, libxl_device_vfb *c_val, value v) -{ - CAMLparam1(v); - - c_val->backend_domid = Int_val(Field(v, 0)); - c_val->devid = Int_val(Field(v, 1)); - c_val->vnc = Bool_val(Field(v, 2)); - c_val->vnclisten = dup_String_val(gc, Field(v, 3)); - c_val->vncpasswd = dup_String_val(gc, Field(v, 4)); - c_val->vncdisplay = Int_val(Field(v, 5)); - c_val->keymap = dup_String_val(gc, Field(v, 6)); - c_val->sdl = Bool_val(Field(v, 7)); - c_val->opengl = Bool_val(Field(v, 8)); - c_val->display = dup_String_val(gc, Field(v, 9)); - c_val->xauthority = dup_String_val(gc, Field(v, 10)); - - CAMLreturn(0); -} - -static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v) -{ - CAMLparam1(v); - - c_val->func = Int_val(Field(v, 0)); - c_val->dev = Int_val(Field(v, 1)); - c_val->bus = Int_val(Field(v, 2)); - - c_val->domain = Int_val(Field(v, 3)); - c_val->vdevfn = Int_val(Field(v, 4)); - c_val->msitranslate = Bool_val(Field(v, 5)); - c_val->power_mgmt = Bool_val(Field(v, 6)); - - CAMLreturn(0); -} - -static int sched_credit_val(caml_gc *gc, libxl_sched_credit *c_val, value v) -{ - CAMLparam1(v); - c_val->weight = Int_val(Field(v, 0)); - c_val->cap = Int_val(Field(v, 1)); - CAMLreturn(0); -} - static int domain_build_state_val(caml_gc *gc, libxl_domain_build_state *c_val, value v) { CAMLparam1(v); @@ -251,45 +219,6 @@ static int domain_build_state_val(caml_g CAMLreturn(0); } -static value Val_sched_credit(libxl_sched_credit *c_val) -{ - CAMLparam0(); - CAMLlocal1(v); - - v = caml_alloc_tuple(2); - - Store_field(v, 0, Val_int(c_val->weight)); - Store_field(v, 1, Val_int(c_val->cap)); - - CAMLreturn(v); -} - -static value Val_physinfo(libxl_physinfo *c_val) -{ - CAMLparam0(); - CAMLlocal2(v, hwcap); - int i; - - hwcap = caml_alloc_tuple(8); - for (i = 0; i < 8; i++) - Store_field(hwcap, i, caml_copy_int32(c_val->hw_cap[i])); - - v = caml_alloc_tuple(11); - Store_field(v, 0, Val_int(c_val->threads_per_core)); - Store_field(v, 1, Val_int(c_val->cores_per_socket)); - Store_field(v, 2, Val_int(c_val->max_cpu_id)); - Store_field(v, 3, Val_int(c_val->nr_cpus)); - Store_field(v, 4, Val_int(c_val->cpu_khz)); - Store_field(v, 5, caml_copy_int64(c_val->total_pages)); - Store_field(v, 6, caml_copy_int64(c_val->free_pages)); - Store_field(v, 7, caml_copy_int64(c_val->scrub_pages)); - Store_field(v, 8, Val_int(c_val->nr_nodes)); - Store_field(v, 9, hwcap); - Store_field(v, 10, caml_copy_int32(c_val->phys_cap)); - - CAMLreturn(v); -} - static value Val_topologyinfo(libxl_topologyinfo *c_val) { CAMLparam0(); @@ -320,7 +249,7 @@ value stub_xl_device_disk_add(value info int ret; INIT_STRUCT(); - device_disk_val(&gc, &c_info, info); + device_disk_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info); @@ -337,7 +266,7 @@ value stub_xl_device_disk_del(value info int ret; INIT_STRUCT(); - device_disk_val(&gc, &c_info, info); + device_disk_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_disk_del(ctx, Int_val(domid), &c_info, 0); @@ -354,7 +283,7 @@ value stub_xl_device_nic_add(value info, int ret; INIT_STRUCT(); - device_nic_val(&gc, &c_info, info); + device_nic_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info); @@ -371,7 +300,7 @@ value stub_xl_device_nic_del(value info, int ret; INIT_STRUCT(); - device_nic_val(&gc, &c_info, info); + device_nic_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_nic_del(ctx, Int_val(domid), &c_info, 0); @@ -408,7 +337,7 @@ value stub_xl_device_vkb_add(value info, int ret; INIT_STRUCT(); - device_vkb_val(&gc, &c_info, info); + device_vkb_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info); @@ -456,7 +385,7 @@ value stub_xl_device_vfb_add(value info, int ret; INIT_STRUCT(); - device_vfb_val(&gc, &c_info, info); + device_vfb_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info); @@ -504,7 +433,7 @@ value stub_xl_device_pci_add(value info, int ret; INIT_STRUCT(); - device_pci_val(&gc, &c_info, info); + device_pci_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info); @@ -522,7 +451,7 @@ value stub_xl_device_pci_remove(value in int ret; INIT_STRUCT(); - device_pci_val(&gc, &c_info, info); + device_pci_val(&gc, &lg, &c_info, info); INIT_CTX(); ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0); @@ -563,7 +492,7 @@ value stub_xl_button_press(value domid, CAMLreturn(Val_unit); } -value stub_xl_physinfo(value unit) +value stub_xl_physinfo_get(value unit) { CAMLparam1(unit); CAMLlocal1(physinfo); @@ -576,8 +505,8 @@ value stub_xl_physinfo(value unit) if (ret != 0) failwith_xl("physinfo", &lg); FREE_CTX(); - - physinfo = Val_physinfo(&c_physinfo); + + physinfo = Val_physinfo(&gc, &lg, &c_physinfo); CAMLreturn(physinfo); } @@ -594,7 +523,7 @@ value stub_xl_topologyinfo(value unit) if (ret != 0) failwith_xl("topologyinfo", &lg); FREE_CTX(); - + topologyinfo = Val_topologyinfo(&c_topologyinfo); CAMLreturn(topologyinfo); } @@ -612,8 +541,8 @@ value stub_xl_sched_credit_domain_get(va if (ret != 0) failwith_xl("sched_credit_domain_get", &lg); FREE_CTX(); - - scinfo = Val_sched_credit(&c_scinfo); + + scinfo = Val_sched_credit(&gc, &lg, &c_scinfo); CAMLreturn(scinfo); } @@ -624,14 +553,14 @@ value stub_xl_sched_credit_domain_set(va int ret; INIT_STRUCT(); - sched_credit_val(&gc, &c_scinfo, scinfo); + sched_credit_val(&gc, &lg, &c_scinfo, scinfo); INIT_CTX(); ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo); if (ret != 0) failwith_xl("sched_credit_domain_set", &lg); FREE_CTX(); - + CAMLreturn(Val_unit); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel