Skip to contentSkip to conversation

tools: IDL improvements and ocaml datatype generation

PATCH New Ian Campbell 1 participant 26 messages Apr 13, 2011 – Apr 15, 2011 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

#1 lore raw

PATCH 1/1 tools: libxl: move all enum values into the libxl namespace

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1302698151 -3600
# Node ID f5fb8d97a4b921e1afa9410fb3c75d12bd9e8d28 # Parent 715d0091ac49bb81e40bee5a6ba3420df7376725
tools: libxl: move all enum values into the libxl namespace

tools/libxl/libxl.c +35 -34
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl.c
@@ -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:
tools/libxl/libxl.h +16 -16
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl.h
@@ -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);
tools/libxl/libxl_device.c +8 -8
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl_device.c
@@ -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;
     }
 }
tools/libxl/libxl_dm.c +31 -23

150 lines not on this page · raw message

tools/libxl/libxl_utils.c +5 -5
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/libxl/libxl_utils.c
@@ -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:
tools/libxl/xl_cmdimpl.c +34 -32

135 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +2 -2
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/ocaml/libs/xl/xl_stubs.c
@@ -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();
tools/python/xen/lowlevel/xl/xl.c +16 -16
diff -r 715d0091ac49 -r f5fb8d97a4b9 tools/python/xen/lowlevel/xl/xl.c
@@ -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);
 }
#2 lore raw

PATCH 1/1 tools: libxl: generalize libxl_qemu_machine_type into libxl_domain_type

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

tools/libxl/libxl.h +3 -3
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl.h
@@ -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,
tools/libxl/libxl.idl +2 -2
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl.idl
@@ -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"),
tools/libxl/libxl_dm.c +10 -10
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/libxl_dm.c
@@ -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;
 }
 
tools/libxl/xl_cmdimpl.c +2 -2
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/libxl/xl_cmdimpl.c
@@ -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);
 }
tools/python/xen/lowlevel/xl/xl.c +2 -2
diff -r f5fb8d97a4b9 -r 624f293ec064 tools/python/xen/lowlevel/xl/xl.c
@@ -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);
#3 lore raw

PATCH 1/1 tools: libxl: namespace enum values within their type

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # 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.

tools/libxl/libxl.c +10 -10
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.c
@@ -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");
tools/libxl/libxl.h +17 -17
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.h
@@ -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
tools/libxl/libxl.idl +3 -3
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl.idl
@@ -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),
     ])
tools/libxl/libxl_create.c +2 -2
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl_create.c
@@ -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);
tools/libxl/libxl_dm.c +4 -4
diff -r 624f293ec064 -r b600101b951c tools/libxl/libxl_dm.c
@@ -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;
         }
tools/libxl/xl_cmdimpl.c +30 -30

142 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +2 -2
diff -r 624f293ec064 -r b600101b951c tools/ocaml/libs/xl/xl_stubs.c
@@ -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);
 }
tools/python/xen/lowlevel/xl/xl.c +8 -8
diff -r 624f293ec064 -r b600101b951c tools/python/xen/lowlevel/xl/xl.c
@@ -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);
#4 lore raw

PATCH 1/1 tools: libxl: add an Enumeration type to the IDL

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # 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.

tools/libxl/gentypes.py +22 -1
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/gentypes.py
@@ -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)
 
tools/libxl/idl.txt +24 -0
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/idl.txt
@@ -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
tools/libxl/libxl.h +0 -58

82 lines not on this page · raw message

tools/libxl/libxl.idl +62 -6

80 lines not on this page · raw message

tools/libxl/libxltypes.py +31 -0
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/libxltypes.py
@@ -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)
tools/libxl/xl_cmdimpl.c +2 -0
diff -r b600101b951c -r 1c34c37f3200 tools/libxl/xl_cmdimpl.c
@@ -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;
tools/python/genwrap.py +32 -21

87 lines not on this page · raw message

tools/python/xen/lowlevel/xl/xl.c +0 -29
diff -r b600101b951c -r 1c34c37f3200 tools/python/xen/lowlevel/xl/xl.c
@@ -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);
 }
#5 lore raw

PATCH 1/1 tools: libxl: add libxl_domid to IDL

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # 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.

tools/libxl/libxl.h +2 -0
diff -r 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxl.h
@@ -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;
tools/libxl/libxl.idl +9 -9
diff -r 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxl.idl
@@ -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),
tools/libxl/libxltypes.py +0 -2
diff -r 1c34c37f3200 -r 174d1c23adc2 tools/libxl/libxltypes.py
@@ -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):
tools/python/xen/lowlevel/xl/xl.c +10 -0
diff -r 1c34c37f3200 -r 174d1c23adc2 tools/python/xen/lowlevel/xl/xl.c
@@ -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");
#6 lore raw

PATCH 1/1 tools: libxl: remove BitField type class from IDL

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # 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).

tools/libxl/gentypes.py +1 -3
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/gentypes.py
@@ -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:
tools/libxl/idl.txt +0 -8
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/idl.txt
@@ -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
tools/libxl/libxl.idl +8 -8
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/libxl.idl
@@ -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"),
     ])
tools/libxl/libxltypes.py +0 -8
diff -r 174d1c23adc2 -r 10262be99780 tools/libxl/libxltypes.py
@@ -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):
tools/python/genwrap.py +1 -1
diff -r 174d1c23adc2 -r 10262be99780 tools/python/genwrap.py
@@ -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
#7 lore raw

PATCH 1/1 tools: libxl: add concept of in- and out-put only data types to IDL

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

tools/libxl/libxl.idl +1 -1
diff -r 10262be99780 -r 0d0fcc093906 tools/libxl/libxl.idl
@@ -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"),
tools/libxl/libxltypes.py +15 -1
diff -r 10262be99780 -r 0d0fcc093906 tools/libxl/libxltypes.py
@@ -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:
tools/python/genwrap.py +19 -8
diff -r 10262be99780 -r 0d0fcc093906 tools/python/genwrap.py
@@ -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()
#8 lore raw

PATCH 1/1 tools: ocaml: rename the device_nic types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +17 -16
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl.ml
@@ -1,5 +1,5 @@
 (*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
  * Author Vincent Hanquez <[email protected]>
  *
  * 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"
tools/ocaml/libs/xl/xl.mli +17 -16
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl.mli
@@ -1,5 +1,5 @@
 (*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
  * Author Vincent Hanquez <[email protected]>
  *
  * 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"
tools/ocaml/libs/xl/xl_stubs.c +4 -4
diff -r 0d0fcc093906 -r dad896f9bb67 tools/ocaml/libs/xl/xl_stubs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Citrix Ltd.
+ * Copyright (C) 2009-2011 Citrix Ltd.
  * Author Vincent Hanquez <[email protected]>
  *
  * 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);
 }
#9 lore raw

PATCH 1/1 tools: ocaml: rename the disk_info types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +15 -13
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +15 -13
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl.mli
@@ -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"
tools/ocaml/libs/xl/xl_stubs.c +3 -3
diff -r dad896f9bb67 -r 7670cfb0da45 tools/ocaml/libs/xl/xl_stubs.c
@@ -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);
 }
#10 lore raw

PATCH 1/1 tools: ocaml: rename the console types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +10 -8
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +10 -8
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl.mli
@@ -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"
tools/ocaml/libs/xl/xl_stubs.c +1 -1
diff -r 7670cfb0da45 -r 06caff5991c6 tools/ocaml/libs/xl/xl_stubs.c
@@ -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;
#11 lore raw

PATCH 1/1 tools: ocaml: rename the vkb types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +32 -28
diff -r 06caff5991c6 -r 10db4482d72a tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +31 -28

72 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +6 -6
diff -r 06caff5991c6 -r 10db4482d72a tools/ocaml/libs/xl/xl_stubs.c
@@ -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;
#12 lore raw

PATCH 1/1 tools: ocaml: rename the pci types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +15 -14
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl.ml
@@ -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
tools/ocaml/libs/xl/xl.mli +16 -14
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl.mli
@@ -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
tools/ocaml/libs/xl/xl_stubs.c +3 -3
diff -r 10db4482d72a -r 8dfd508475fd tools/ocaml/libs/xl/xl_stubs.c
@@ -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;
#13 lore raw

PATCH 1/1 tools: ocaml: remove the domain_make and domain_build functions since they don't work

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]>
# 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.

tools/ocaml/libs/xl/xl.ml +0 -3
diff -r 8dfd508475fd -r 7c7094664ff1 tools/ocaml/libs/xl/xl.ml
@@ -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
tools/ocaml/libs/xl/xl.mli +0 -3
diff -r 8dfd508475fd -r 7c7094664ff1 tools/ocaml/libs/xl/xl.mli
@@ -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
#14 lore raw

PATCH 1/1 tools: ocaml: rename the create_info types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]>
# 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

tools/ocaml/libs/xl/xl.ml +15 -13
diff -r 7c7094664ff1 -r 21fe28c477f1 tools/ocaml/libs/xl/xl.ml
@@ -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 =
 {
tools/ocaml/libs/xl/xl.mli +15 -13
diff -r 7c7094664ff1 -r 21fe28c477f1 tools/ocaml/libs/xl/xl.mli
@@ -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 =
 {
#15 lore raw

PATCH 1/1 tools: ocaml: rename the build_info types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +36 -32
diff -r 21fe28c477f1 -r d4357ab0e6b4 tools/ocaml/libs/xl/xl.ml
@@ -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 =
 {
tools/ocaml/libs/xl/xl.mli +36 -32

76 lines not on this page · raw message

#16 lore raw

PATCH 1/1 tools: ocaml: rename the device_build_state types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]>
# 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

tools/ocaml/libs/xl/xl.ml +10 -8
diff -r d4357ab0e6b4 -r 27ae89234b2a tools/ocaml/libs/xl/xl.ml
@@ -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
tools/ocaml/libs/xl/xl.mli +10 -8
diff -r d4357ab0e6b4 -r 27ae89234b2a tools/ocaml/libs/xl/xl.mli
@@ -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
#17 lore raw

PATCH 1/1 tools: ocaml: rename the physinfo types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +18 -15
diff -r 27ae89234b2a -r 5c73eaa9e09a tools/ocaml/libs/xl/xl.ml
@@ -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"
 
tools/ocaml/libs/xl/xl.mli +18 -15
diff -r 27ae89234b2a -r 5c73eaa9e09a tools/ocaml/libs/xl/xl.mli
@@ -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"
#18 lore raw

PATCH 1/1 tools: ocaml: rename the sched_credit types and functions

In reply to Ian Campbell

# HG changeset patch
# User David Scott <[email protected]>
# 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

tools/ocaml/libs/xl/xl.ml +9 -8
diff -r 5c73eaa9e09a -r 7202919ef856 tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +10 -8
diff -r 5c73eaa9e09a -r 7202919ef856 tools/ocaml/libs/xl/xl.mli
@@ -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"
#19 lore raw

PATCH 1/1 tools: ocaml: rename the topology types and functions

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # 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

tools/ocaml/libs/xl/xl.ml +9 -9
diff -r 7202919ef856 -r cdf5d9feb563 tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +9 -10
diff -r 7202919ef856 -r cdf5d9feb563 tools/ocaml/libs/xl/xl.mli
@@ -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"
#20 lore raw

PATCH 1/1 tools: ocaml: reorder xl bindings type and function definitions to match IDL

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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...)

tools/ocaml/libs/xl/xl.ml +134 -134
diff -r cdf5d9feb563 -r 91209ee048a9 tools/ocaml/libs/xl/xl.ml
@@ -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"
 
 
tools/ocaml/libs/xl/xl.mli +135 -135

300 lines not on this page · raw message

#21 lore raw

PATCH 1/1 tools: ocaml: remove create_info and build_info data types from xl bindings

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

tools/ocaml/libs/xl/xl.ml +0 -55
diff -r 91209ee048a9 -r a5704e01a606 tools/ocaml/libs/xl/xl.ml
@@ -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 =
 	{
tools/ocaml/libs/xl/xl.mli +0 -55

67 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +0 -57

63 lines not on this page · raw message

#22 lore raw

PATCH 1/1 tools: ocaml: tweak whitespace in preparation for autogenerating xl bindings

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

tools/ocaml/libs/xl/xl.ml +17 -21
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl.ml
@@ -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"
tools/ocaml/libs/xl/xl.mli +16 -21
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl.mli
@@ -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
tools/ocaml/libs/xl/xl_stubs.c +12 -12
diff -r a5704e01a606 -r 3c51e7bfe289 tools/ocaml/libs/xl/xl_stubs.c
@@ -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)
#23 lore raw

PATCH 1/1 tools: ocaml: lay ground work for auto generating xl datatypes

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

.hgignore +5 -0
diff -r 3c51e7bfe289 -r 5bbea737a0dc .hgignore
@@ -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$
tools/ocaml/libs/xl/Makefile +28 -0
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/Makefile
@@ -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
tools/ocaml/libs/xl/genwrap.py new file +42 -0

42 lines not on this page · raw message

tools/ocaml/libs/xl/xl.ml deleted +0 -186

186 lines not on this page · raw message

tools/ocaml/libs/xl/xl.ml.in new file +188 -0

188 lines not on this page · raw message

tools/ocaml/libs/xl/xl.mli deleted +0 -183

183 lines not on this page · raw message

tools/ocaml/libs/xl/xl.mli.in new file +185 -0

185 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +3 -1
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl_stubs.c
@@ -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);
#24 lore raw

PATCH 1/1 tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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).

tools/ocaml/libs/xl/Makefile +2 -0
diff -r 5bbea737a0dc -r 12c05af72273 tools/ocaml/libs/xl/Makefile
@@ -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
tools/ocaml/libs/xl/genwrap.py +240 -1

260 lines not on this page · raw message

tools/ocaml/libs/xl/xl.ml.in +0 -129

135 lines not on this page · raw message

tools/ocaml/libs/xl/xl.mli.in +0 -128

134 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +62 -133

298 lines not on this page · raw message

#25 lore raw

Re: [PATCH 24 of 24] tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion

Quoted 1 line · Ian Campbell

tools: ocaml: autogenerate xl datatype definitions and ocaml<->C conversion

This 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 <[email protected]>
# 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).

* * *
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.

tools/ocaml/libs/xl/Makefile +2 -0
diff -r 2a93903c97f0 -r 4244d6a3fa3a tools/ocaml/libs/xl/Makefile
@@ -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
tools/ocaml/libs/xl/genwrap.py +281 -1

301 lines not on this page · raw message

tools/ocaml/libs/xl/xl.ml.in +0 -129

135 lines not on this page · raw message

tools/ocaml/libs/xl/xl.mli.in +0 -128

134 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +70 -141

349 lines not on this page · raw message