Skip to contentSkip to conversation

libxl: Add enumeration type to IDL

PATCH New Ian Campbell 3 participants 9 messages Mar 31, 2011 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libxl: Add enumeration type to IDL

As part of this I namespace some enum values, firstly within the LIBXL_ namespace (which is clearly a good idea) but secondly to namespace the values to within their respective typename, which is less clearly of benefit. It makes the IDL for enumerations somewhat cleaner but I'm not totally wedded to it -- opinions welcome.

Changes since first version:

- Use typedef enum FOO { } FOO idiom which allows existing users of "enum FOO xxx;" to continue working.

- Add libxl_compat.h which defines the old names in an attempt to retain API (but not ABI) compatibility. By default all previous APIs will be exposed. Not sure if it makes more sense to require users to specify which they want.

#1 lore raw

PATCH 1/1 libxl: typedef libxl_action_on_shutdown

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1301571102 -3600
# Node ID e307b27c955b1fb0f0ef5e391fa9e37976d43d84 # Parent d0dd569bfcb0f5f8e2d903c8b6f9999ff1290e96
libxl: typedef libxl_action_on_shutdown

This is the libxl convention. By using the "typedef enum foo { } foo;" syntax we can retain backwards compatibility with existing users.

tools/libxl/libxl.h +6 -6
diff -r d0dd569bfcb0 -r e307b27c955b tools/libxl/libxl.h
@@ -245,7 +245,7 @@ enum {
 
 #define LIBXL_VERSION 0
 
-enum libxl_action_on_shutdown {
+typedef enum libxl_action_on_shutdown {
     LIBXL_ACTION_DESTROY,
 
     LIBXL_ACTION_RESTART,
@@ -255,7 +255,7 @@ enum libxl_action_on_shutdown {
 
     LIBXL_ACTION_COREDUMP_DESTROY,
     LIBXL_ACTION_COREDUMP_RESTART,
-};
+} libxl_action_on_shutdown;
 
 typedef struct {
     libxl_domain_create_info c_info;
@@ -271,10 +271,10 @@ typedef struct {
     libxl_device_vfb *vfbs;
     libxl_device_vkb *vkbs;
 
-    enum libxl_action_on_shutdown on_poweroff;
-    enum libxl_action_on_shutdown on_reboot;
-    enum libxl_action_on_shutdown on_watchdog;
-    enum libxl_action_on_shutdown on_crash;
+    libxl_action_on_shutdown on_poweroff;
+    libxl_action_on_shutdown on_reboot;
+    libxl_action_on_shutdown on_watchdog;
+    libxl_action_on_shutdown on_crash;
 } libxl_domain_config;
 
 /* context functions */
tools/libxl/xl_cmdimpl.c +2 -2
diff -r d0dd569bfcb0 -r e307b27c955b tools/libxl/xl_cmdimpl.c
@@ -442,7 +442,7 @@ static void printf_info(int domid,
        printf(")\n");
 }
 
-static int parse_action_on_shutdown(const char *buf, enum libxl_action_on_shutdown *a)
+static int parse_action_on_shutdown(const char *buf, libxl_action_on_shutdown *a)
 {
     int i;
     const char *n;
@@ -1166,7 +1166,7 @@ static int handle_domain_death(libxl_ctx
                                libxl_domain_config *d_config, libxl_dominfo *info)
 {
     int restart = 0;
-    enum libxl_action_on_shutdown action;
+    libxl_action_on_shutdown action;
 
     switch (info->shutdown_reason) {
     case SHUTDOWN_poweroff:
#3 lore raw

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

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1301571142 -3600
# Node ID f4bbcbd0417f7e4a4a167f385d6408494ed78e22 # Parent e307b27c955b1fb0f0ef5e391fa9e37976d43d84
libxl: move all enum values into the libxl namespace

Add libxl_compat.h to define the previous values so as not to break existing users.

tools/libxl/Makefile +1 -1
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/Makefile
@@ -124,7 +124,7 @@ install: all
 	ln -sf libxlutil.so.$(XLUMAJOR).$(XLUMINOR) $(DESTDIR)$(LIBDIR)/libxlutil.so.$(XLUMAJOR)
 	ln -sf libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(LIBDIR)/libxlutil.so
 	$(INSTALL_DATA) libxlutil.a $(DESTDIR)$(LIBDIR)
-	$(INSTALL_DATA) libxl.h _libxl_types.h libxl_uuid.h $(DESTDIR)$(INCLUDEDIR)
+	$(INSTALL_DATA) libxl.h _libxl_types.h libxl_uuid.h libxl_compat.h $(DESTDIR)$(INCLUDEDIR)
 	$(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
 
 .PHONY: clean
tools/libxl/libxl.c +28 -28

168 lines not on this page · raw message

tools/libxl/libxl.h +16 -16
diff -r e307b27c955b -r f4bbcbd0417f 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 {
@@ -487,8 +487,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_compat.h new file +58 -0

58 lines not on this page · raw message

tools/libxl/libxl_device.c +8 -8
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_device.c
@@ -123,11 +123,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; 
     }
 }
@@ -135,9 +135,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 "tap";
-        case DISK_BACKEND_PHY: return "phy";
+        case LIBXL_DISK_BACKEND_QDISK: return "qdisk";
+        case LIBXL_DISK_BACKEND_TAP: return "tap";
+        case LIBXL_DISK_BACKEND_PHY: return "phy";
         default: return NULL;
     }
 }
tools/libxl/libxl_dm.c +24 -16
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_dm.c
@@ -98,7 +98,7 @@ static char ** libxl__build_device_model
     if (info->serial) {
         flexarray_vappend(dm_args, "-serial", info->serial, NULL);
     }
-    if (info->type == XENFV) {
+    if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
         int ioemu_vifs = 0;
 
         if (info->videoram) {
@@ -130,7 +130,7 @@ static char ** libxl__build_device_model
             flexarray_vappend(dm_args, "-vcpu_avail", libxl__sprintf(gc, "0x%x", info->vcpu_avail), NULL);
         }
         for (i = 0; i < num_vifs; i++) {
-            if (vifs[i].nictype == NICTYPE_IOEMU) {
+            if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
                 char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                            vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2],
                                            vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]);
@@ -162,10 +162,14 @@ static char ** libxl__build_device_model
     for (i = 0; info->extra && info->extra[i] != NULL; i++)
         flexarray_append(dm_args, info->extra[i]);
     flexarray_append(dm_args, "-M");
-    if (info->type == XENPV)
+    switch (info->type) {
+    case LIBXL_QEMU_MACHINE_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-    else
+        break;
+    case LIBXL_QEMU_MACHINE_TYPE_FV:
         flexarray_append(dm_args, "xenfv");
+        break;
+    }
     flexarray_append(dm_args, NULL);
     return (char **) flexarray_contents(dm_args);
 }
@@ -187,7 +191,7 @@ static char ** libxl__build_device_model
     flexarray_vappend(dm_args, libxl__strdup(gc, info->device_model),
                         "-xen-domid", libxl__sprintf(gc, "%d", info->domid), NULL);
 
-    if (info->type == XENPV) {
+    if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV) {
         flexarray_append(dm_args, "-xen-attach");
     }
 
@@ -225,7 +229,7 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-sdl");
     }
 
-    if (info->type == XENPV && !info->nographic) {
+    if (info->type == LIBXL_QEMU_MACHINE_TYPE_PV && !info->nographic) {
         flexarray_vappend(dm_args, "-vga", "xenfb", NULL);
     }
 
@@ -238,7 +242,7 @@ static char ** libxl__build_device_model
     if (info->serial) {
         flexarray_vappend(dm_args, "-serial", info->serial, NULL);
     }
-    if (info->type == XENFV) {
+    if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
         int ioemu_vifs = 0;
 
         if (info->stdvga) {
@@ -268,7 +272,7 @@ static char ** libxl__build_device_model
                 flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->vcpus));
         }
         for (i = 0; i < num_vifs; i++) {
-            if (vifs[i].nictype == NICTYPE_IOEMU) {
+            if (vifs[i].nictype == LIBXL_NICTYPE_IOEMU) {
                 char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                            vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2],
                                            vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]);
@@ -303,16 +307,20 @@ static char ** libxl__build_device_model
     for (i = 0; info->extra && info->extra[i] != NULL; i++)
         flexarray_append(dm_args, info->extra[i]);
     flexarray_append(dm_args, "-M");
-    if (info->type == XENPV)
+    switch (info->type) {
+    case LIBXL_QEMU_MACHINE_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-    else
+        break;
+    case LIBXL_QEMU_MACHINE_TYPE_FV:
         flexarray_append(dm_args, "xenfv");
+        break;
+    }
 
     /* RAM Size */
     flexarray_append(dm_args, "-m");
     flexarray_append(dm_args, libxl__sprintf(gc, "%d", info->target_ram));
 
-    if (info->type == XENFV) {
+    if (info->type == LIBXL_QEMU_MACHINE_TYPE_FV) {
         disks = libxl_device_disk_list(libxl__gc_owner(gc), info->domid, &nb);
         for (i; i < nb; i++) {
             if (disks[i].is_cdrom) {
@@ -813,7 +821,7 @@ static int libxl__build_xenpv_qemu_args(
     info->domid = domid;
     info->dom_name = libxl_domid_to_name(ctx, domid);
     info->device_model = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path());
-    info->type = XENPV;
+    info->type = LIBXL_QEMU_MACHINE_TYPE_PV;
     return 0;
 }
 
@@ -845,7 +853,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc
         int blktap_enabled = -1;
         for (i = 0; i < nr_disks; i++) {
             switch (disks[i].backend) {
-            case DISK_BACKEND_TAP:
+            case LIBXL_DISK_BACKEND_TAP:
                 if (blktap_enabled == -1)
                     blktap_enabled = libxl__blktap_enabled(gc);
                 if (!blktap_enabled) {
@@ -854,12 +862,12 @@ int libxl__need_xenpv_qemu(libxl__gc *gc
                 }
                 break;
 
-            case DISK_BACKEND_QDISK:
+            case LIBXL_DISK_BACKEND_QDISK:
                 ret = 1;
                 goto out;
 
-            case DISK_BACKEND_PHY:
-            case DISK_BACKEND_UNKNOWN:
+            case LIBXL_DISK_BACKEND_PHY:
+            case LIBXL_DISK_BACKEND_UNKNOWN:
                 break;
             }
         }
tools/libxl/libxl_utils.c +5 -5
diff -r e307b27c955b -r f4bbcbd0417f 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 +32 -32

133 lines not on this page · raw message

tools/ocaml/libs/xl/xl_stubs.c +2 -2
diff -r e307b27c955b -r f4bbcbd0417f 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);
@@ -594,7 +594,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 e307b27c955b -r f4bbcbd0417f 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);
 }
#4 lore raw

Re: [PATCH 2 of 4] libxl: move all enum values into the libxl namespace

Ian Campbell writes ("[Xen-devel] [PATCH 2 of 4] libxl: move all enum values into the libxl namespace"):

Quoted 1 line

libxl: move all enum values into the libxl namespace

I'm afraid this one needs to be refreshed ...

Ian.

#5 lore raw

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

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1301571234 -3600
# Node ID 6a72a608fe9e8d3639038697fcea0197c59156fe # Parent f4bbcbd0417f7e4a4a167f385d6408494ed78e22
libxl: namespace enum values within their type.

tools/libxl/libxl.c +10 -10
diff -r f4bbcbd0417f -r 6a72a608fe9e 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;
@@ -613,7 +613,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx
                      libxl__xs_get_dompath(&gc, domid),
                      libxl__device_disk_dev_number(disks[i].vdev)) < 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;
@@ -1202,7 +1202,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;
 }
 
@@ -1641,7 +1641,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 f4bbcbd0417f -r 6a72a608fe9e tools/libxl/libxl.h
@@ -167,14 +167,14 @@ typedef enum {
 } libxl_qemu_machine_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;
 
 typedef struct {
@@ -322,8 +322,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 {
@@ -396,7 +396,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 f4bbcbd0417f -r 6a72a608fe9e 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_qemu_machine_type = Number("qemu_machine_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_console = Struct("device_co
     ("backend_domid", uint32),
     ("domid", domid),
     ("devid", integer),
-    ("consback", libxl_console_consback),
+    ("consback", libxl_console_backend),
     ("build_state", Reference(libxl_domain_build_state), True),
     ("output", string),
     ])
tools/libxl/libxl_compat.h +21 -2
diff -r f4bbcbd0417f -r 6a72a608fe9e tools/libxl/libxl_compat.h
@@ -35,6 +35,14 @@
 #define XENFV LIBXL_QEMU_MACHINE_TYPE_FV
 #define XENPV LIBXL_QEMU_MACHINE_TYPE_PV
 
+#define libxl_console_constype	libxl_console_type
+#define LIBXL_CONSTYPE_SERIAL	LIBXL_CONSOLE_TYPE_SERIAL
+#define LIBXL_CONSTYPE_PV	LIBXL_CONSOLE_TYPE_PV
+
+#define LIBXL_CONSBACK_XENCONSOLED	LIBXL_CONSOLE_BACKEND_XENCONSOLED
+#define LIBXL_CONSBACK_IOEMU		LIBXL_CONSOLE_BACKEND_IOEMU
+#define libxl_console_consback		libxl_console_backend
+
 #define DISK_FORMAT_UNKNOWN	LIBXL_DISK_FORMAT_UNKNOWN
 #define DISK_FORMAT_QCOW	LIBXL_DISK_FORMAT_QCOW
 #define DISK_FORMAT_QCOW2	LIBXL_DISK_FORMAT_QCOW2
@@ -47,12 +55,23 @@
 #define DISK_BACKEND_TAP	LIBXL_DISK_BACKEND_TAP
 #define DISK_BACKEND_QDISK	LIBXL_DISK_BACKEND_QDISK
 
-#define NICTYPE_IOEMU		LIBXL_NICTYPE_IOEMU
-#define NICTYPE_VIF		LIBXL_NICTYPE_VIF
+#define NICTYPE_IOEMU		LIBXL_NIC_TYPE_IOEMU
+#define NICTYPE_VIF		LIBXL_NIC_TYPE_VIF
 
 #define POWER_BUTTON		LIBXL_BUTTON_POWER
 #define SLEEP_BUTTON		LIBXL_BUTTON_SLEEP
 
+#define LIBXL_ACTION_DESTROY		LIBXL_ACTION_ON_SHUTDOWN_DESTROY
+#define LIBXL_ACTION_RESTART		LIBXL_ACTION_ON_SHUTDOWN_RESTART
+#define LIBXL_ACTION_RESTART_RENAME	LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME
+#define LIBXL_ACTION_PRESERVE		LIBXL_ACTION_ON_SHUTDOWN_PRESERVE
+#define LIBXL_ACTION_COREDUMP_DESTROY	LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY
+#define LIBXL_ACTION_COREDUMP_RESTART	LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART
+
+#define LIBXL_EVENT_DOMAIN_DEATH	LIBXL_EVENT_TYPE_DOMAIN_DEATH
+#define LIBXL_EVENT_DISK_EJECT		LIBXL_EVENT_TYPE_DISK_EJECT
+
+
 #endif
 
 #endif /* LIBXL_COMPAT_H */
tools/libxl/libxl_create.c +2 -2
diff -r f4bbcbd0417f -r 6a72a608fe9e tools/libxl/libxl_create.c
@@ -138,7 +138,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;
@@ -515,7 +515,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 f4bbcbd0417f -r 6a72a608fe9e tools/libxl/libxl_dm.c
@@ -130,7 +130,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]);
@@ -272,7 +272,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]);
@@ -581,7 +581,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;
         console[i].domid = domid;
         /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging
          * STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file
@@ -838,7 +838,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 f4bbcbd0417f -r 6a72a608fe9e 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 f4bbcbd0417f -r 6a72a608fe9e tools/python/xen/lowlevel/xl/xl.c
@@ -772,11 +772,11 @@ PyMODINIT_FUNC initxl(void)
     _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);
+    _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);
#6 lore raw

PATCH 1/1 libxl: add an Enumeration type to the IDL, use it for all enums

In reply to Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1301571244 -3600
# Node ID acb800c269780d7c69dc2a1fd6571c92d4269707
# Parent 6a72a608fe9e8d3639038697fcea0197c59156fe
libxl: add an Enumeration type to the IDL, use it for all enums

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 6a72a608fe9e -r acb800c26978 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 {\n"
+
+        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/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 6a72a608fe9e -r acb800c26978 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 6a72a608fe9e -r acb800c26978 tools/libxl/xl_cmdimpl.c
@@ -450,6 +450,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 6a72a608fe9e -r acb800c26978 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, QEMU_MACHINE_TYPE_FV);
-    _INT_CONST_LIBXL(m, QEMU_MACHINE_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);
 }
#7 lore raw

Re: [PATCH 4 of 4] libxl: add an Enumeration type to the IDL, use it for all enums

I forgot to qrefresh a last minute change (autogen the typedef enum FOO { } FOO syntax) into this version please use the following instead.

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1301571721 -3600
# Node ID a3b5c15e1f8b4abca3db2457cafe719fa26348b8
# Parent 6a72a608fe9e8d3639038697fcea0197c59156fe
libxl: add an Enumeration type to the IDL, use it for all enums

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 6a72a608fe9e -r a3b5c15e1f8b 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/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 6a72a608fe9e -r a3b5c15e1f8b 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 6a72a608fe9e -r a3b5c15e1f8b tools/libxl/xl_cmdimpl.c
@@ -450,6 +450,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 6a72a608fe9e -r a3b5c15e1f8b 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, QEMU_MACHINE_TYPE_FV);
-    _INT_CONST_LIBXL(m, QEMU_MACHINE_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);
 }
#8 lore raw

Re: [PATCH 4 of 4] libxl: add an Enumeration type to the IDL, use it for all enums

Ian Campbell writes ("[Xen-devel] Re: [PATCH 4 of 4] libxl: add an Enumeration type to the IDL, use it for all enums"):

Quoted 2 lines

I forgot to qrefresh a last minute change (autogen the typedef enum FOO { } FOO syntax) into this version please use the following instead.

I think this probably needs to be refreshed too. Can you repost the series ? It might be easier if you posted your current patch queue in a single series.

Thanks,
Ian.