WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2 of 4] libxl: move all enum values into the libxl na

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 2 of 4] libxl: move all enum values into the libxl namespace
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 31 Mar 2011 12:38:11 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 31 Mar 2011 04:41:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1301571489@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1301571489@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# 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.

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

diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/Makefile
--- a/tools/libxl/Makefile      Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/Makefile      Thu Mar 31 12:32:22 2011 +0100
@@ -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
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/libxl.c       Thu Mar 31 12:32:22 2011 +0100
@@ -694,16 +694,16 @@ 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->domid = domid;
     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,14 +908,14 @@ 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)
         return 0;
 
-    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;
             }
         }
@@ -925,7 +925,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);
@@ -980,7 +980,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
     device.kind = DEVICE_VBD;
 
     switch (disk->backend) {
-        case DISK_BACKEND_PHY: 
+        case LIBXL_DISK_BACKEND_PHY: 
             libxl__device_physdisk_major_minor(disk->pdev_path, &major, 
&minor);
             flexarray_append(back, "physical-device");
             flexarray_append(back, libxl__sprintf(&gc, "%x:%x", major, minor));
@@ -990,8 +990,8 @@ int libxl_device_disk_add(libxl_ctx *ctx
 
             device.backend_kind = DEVICE_VBD;
             break;
-        case DISK_BACKEND_TAP:
-            if (libxl__blktap_enabled(&gc) && disk->format != 
DISK_FORMAT_EMPTY) {
+        case LIBXL_DISK_BACKEND_TAP:
+            if (libxl__blktap_enabled(&gc) && disk->format != 
LIBXL_DISK_FORMAT_EMPTY) {
                 const char *dev = libxl__blktap_devpath(&gc,
                                                disk->pdev_path, disk->format);
                 if (!dev) {
@@ -1012,13 +1012,13 @@ int libxl_device_disk_add(libxl_ctx *ctx
 
                 break;
             }
-        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));
 
             if (libxl__blktap_enabled(&gc) && 
-                 disk->backend != DISK_BACKEND_QDISK)
+                 disk->backend != LIBXL_DISK_BACKEND_QDISK)
                 device.backend_kind = DEVICE_TAP;
             else
                 device.backend_kind = DEVICE_QDISK;
@@ -1085,7 +1085,7 @@ int libxl_device_disk_del(libxl_ctx *ctx
     device.backend_domid    = disk->backend_domid;
     device.backend_devid    = devid;
     device.backend_kind     =
-        (disk->backend == DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
+        (disk->backend == LIBXL_DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
     device.domid            = disk->domid;
     device.devid            = devid;
     device.kind             = DEVICE_VBD;
@@ -1103,8 +1103,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;
@@ -1113,13 +1113,13 @@ 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;
@@ -1131,8 +1131,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 {
@@ -1140,8 +1140,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;
@@ -1150,7 +1150,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);
@@ -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 = NICTYPE_IOEMU;
+    nic_info->nictype = LIBXL_NICTYPE_IOEMU;
     return 0;
 }
 
@@ -1851,7 +1851,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++) {
@@ -2372,10 +2372,10 @@ int libxl_button_press(libxl_ctx *ctx, u
     int rc = -1;
 
     switch (button) {
-    case POWER_BUTTON:
+    case LIBXL_BUTTON_POWER:
         rc = xc_domain_send_trigger(ctx->xch, domid, 
XEN_DOMCTL_SENDTRIGGER_POWER, 0);
         break;
-    case SLEEP_BUTTON:
+    case LIBXL_BUTTON_SLEEP:
         rc = xc_domain_send_trigger(ctx->xch, domid, 
XEN_DOMCTL_SENDTRIGGER_SLEEP, 0);
         break;
     default:
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/libxl.h       Thu Mar 31 12:32:22 2011 +0100
@@ -162,8 +162,8 @@ typedef struct {
 void libxl_cpuarray_destroy(libxl_cpuarray *array);
 
 typedef enum {
-    XENFV = 1,
-    XENPV,
+    LIBXL_QEMU_MACHINE_TYPE_FV = 1,
+    LIBXL_QEMU_MACHINE_TYPE_PV,
 } libxl_qemu_machine_type;
 
 typedef enum {
@@ -177,24 +177,24 @@ typedef enum {
 } libxl_console_consback;
 
 typedef enum {
-    DISK_FORMAT_UNKNOWN = 0,
-    DISK_FORMAT_QCOW,
-    DISK_FORMAT_QCOW2,
-    DISK_FORMAT_VHD,
-    DISK_FORMAT_RAW,
-    DISK_FORMAT_EMPTY,
+    LIBXL_DISK_FORMAT_UNKNOWN = 0,
+    LIBXL_DISK_FORMAT_QCOW,
+    LIBXL_DISK_FORMAT_QCOW2,
+    LIBXL_DISK_FORMAT_VHD,
+    LIBXL_DISK_FORMAT_RAW,
+    LIBXL_DISK_FORMAT_EMPTY,
 } libxl_disk_format;
 
 typedef enum {
-    DISK_BACKEND_UNKNOWN = 0,
-    DISK_BACKEND_PHY,
-    DISK_BACKEND_TAP,
-    DISK_BACKEND_QDISK,
+    LIBXL_DISK_BACKEND_UNKNOWN = 0,
+    LIBXL_DISK_BACKEND_PHY,
+    LIBXL_DISK_BACKEND_TAP,
+    LIBXL_DISK_BACKEND_QDISK,
 } libxl_disk_backend;
 
 typedef enum {
-    NICTYPE_IOEMU = 1,
-    NICTYPE_VIF,
+    LIBXL_NICTYPE_IOEMU = 1,
+    LIBXL_NICTYPE_VIF,
 } libxl_nic_type;
 
 typedef struct {
@@ -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);
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_compat.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_compat.h        Thu Mar 31 12:32:22 2011 +0100
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011      Citrix Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_COMPAT_H
+#define LIBXL_COMPAT_H
+
+/*
+ * This header provides a compatibility shim which allows users of
+ * libxl written against a previous Xen version's libxl some hope of
+ * building against a new release.
+ *
+ * Users can define LIBXL_COMPAT_LEVEL to define the minimum level of
+ * libxl API they would like to be available. e.g. to provide wrappers
+ * for version xx.yy (4.1) the value should be 0xxxyy (0x0401)
+ */
+
+/* Default to including all compatibility code */
+#ifndef LIBXL_COMPAT_LEVEL
+#define LIBXL_COMPAT_LEVEL 0x0000
+#endif
+
+#if LIBXL_COMPAT_LEVEL < 0x0402
+
+#define XENFV LIBXL_QEMU_MACHINE_TYPE_FV
+#define XENPV LIBXL_QEMU_MACHINE_TYPE_PV
+
+#define DISK_FORMAT_UNKNOWN    LIBXL_DISK_FORMAT_UNKNOWN
+#define DISK_FORMAT_QCOW       LIBXL_DISK_FORMAT_QCOW
+#define DISK_FORMAT_QCOW2      LIBXL_DISK_FORMAT_QCOW2
+#define DISK_FORMAT_VHD                LIBXL_DISK_FORMAT_VHD
+#define DISK_FORMAT_RAW                LIBXL_DISK_FORMAT_RAW
+#define DISK_FORMAT_EMPTY      LIBXL_DISK_FORMAT_EMPTY
+
+#define DISK_BACKEND_UNKNOWN   LIBXL_DISK_BACKEND_UNKNOWN
+#define DISK_BACKEND_PHY       LIBXL_DISK_BACKEND_PHY
+#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 POWER_BUTTON           LIBXL_BUTTON_POWER
+#define SLEEP_BUTTON           LIBXL_BUTTON_SLEEP
+
+#endif
+
+#endif /* LIBXL_COMPAT_H */
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/libxl_device.c        Thu Mar 31 12:32:22 2011 +0100
@@ -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;
     }
 }
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Thu Mar 31 12:32:22 2011 +0100
@@ -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;
             }
         }
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/libxl_utils.c Thu Mar 31 12:32:22 2011 +0100
@@ -283,9 +283,9 @@ int libxl_string_to_backend(libxl_ctx *c
     int rc = 0;
 
     if (!strcmp(s, "phy")) {
-        *backend = DISK_BACKEND_PHY;
+        *backend = LIBXL_DISK_BACKEND_PHY;
     } else if (!strcmp(s, "file")) {
-        *backend = DISK_BACKEND_TAP;
+        *backend = LIBXL_DISK_BACKEND_TAP;
     } else if (!strcmp(s, "tap")) {
         p = strchr(s, ':');
         if (!p) {
@@ -294,11 +294,11 @@ int libxl_string_to_backend(libxl_ctx *c
         }
         p++;
         if (!strcmp(p, "vhd")) {
-            *backend = DISK_BACKEND_TAP;
+            *backend = LIBXL_DISK_BACKEND_TAP;
         } else if (!strcmp(p, "qcow")) {
-            *backend = DISK_BACKEND_QDISK;
+            *backend = LIBXL_DISK_BACKEND_QDISK;
         } else if (!strcmp(p, "qcow2")) {
-            *backend = DISK_BACKEND_QDISK;
+            *backend = LIBXL_DISK_BACKEND_QDISK;
         }
     }
 out:
diff -r e307b27c955b -r f4bbcbd0417f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Mar 31 12:32:22 2011 +0100
@@ -480,12 +480,12 @@ static int parse_disk_config(libxl_devic
                 *p = '\0';
                 if ( !strcmp(tok, "phy") ) {
                     state = DSTATE_PHYSPATH;
-                    disk->format = DISK_FORMAT_RAW;
-                    disk->backend = DISK_BACKEND_PHY;
+                    disk->format = LIBXL_DISK_FORMAT_RAW;
+                    disk->backend = LIBXL_DISK_BACKEND_PHY;
                 }else if ( !strcmp(tok, "file") ) {
                     state = DSTATE_PHYSPATH;
-                    disk->format = DISK_FORMAT_RAW;
-                    disk->backend = DISK_BACKEND_TAP;
+                    disk->format = LIBXL_DISK_FORMAT_RAW;
+                    disk->backend = LIBXL_DISK_BACKEND_TAP;
                 }else if ((!strcmp(tok, "tap")) ||
                           (!strcmp(tok, "tap2"))) {
                     state = DSTATE_TAP;
@@ -496,16 +496,16 @@ static int parse_disk_config(libxl_devic
                 tok = p + 1;
             } else if (*p == ',') {
                 state = DSTATE_VIRTPATH;
-                disk->format = DISK_FORMAT_EMPTY;
-                disk->backend = DISK_BACKEND_TAP;
+                disk->format = LIBXL_DISK_FORMAT_EMPTY;
+                disk->backend = LIBXL_DISK_BACKEND_TAP;
                 disk->pdev_path = strdup("");
                 tok = p + 1;
             }
             break;
         case DSTATE_TAP:
             if (*p == ',') {
-                disk->format = DISK_FORMAT_RAW;
-                disk->backend = DISK_BACKEND_TAP;
+                disk->format = LIBXL_DISK_FORMAT_RAW;
+                disk->backend = LIBXL_DISK_BACKEND_TAP;
                 state = DSTATE_PHYSPATH;
             } else if ( *p == ':' ) {
                 *p = '\0';
@@ -514,17 +514,17 @@ static int parse_disk_config(libxl_devic
                     break;
                 }
                 if (!strcmp(tok, "vhd")) {
-                    disk->format = DISK_FORMAT_VHD;
-                    disk->backend = DISK_BACKEND_TAP;
+                    disk->format = LIBXL_DISK_FORMAT_VHD;
+                    disk->backend = LIBXL_DISK_BACKEND_TAP;
                 }else if ( !strcmp(tok, "qcow") ) {
-                    disk->format = DISK_FORMAT_QCOW;
-                    disk->backend = DISK_BACKEND_QDISK;
+                    disk->format = LIBXL_DISK_FORMAT_QCOW;
+                    disk->backend = LIBXL_DISK_BACKEND_QDISK;
                 }else if ( !strcmp(tok, "qcow2") ) {
-                    disk->format = DISK_FORMAT_QCOW2;
-                    disk->backend = DISK_BACKEND_QDISK;
+                    disk->format = LIBXL_DISK_FORMAT_QCOW2;
+                    disk->backend = LIBXL_DISK_BACKEND_QDISK;
                 }else if (!strcmp(tok, "raw")) {
-                    disk->format = DISK_FORMAT_RAW;
-                    disk->backend = DISK_BACKEND_TAP;
+                    disk->format = LIBXL_DISK_FORMAT_RAW;
+                    disk->backend = LIBXL_DISK_BACKEND_TAP;
                 }
                 else {
                     fprintf(stderr, "Unknown tapdisk type: %s\n", tok);
@@ -863,9 +863,9 @@ static void parse_config_data(const char
                     nic->bridge = strdup(p2 + 1);
                 } else if (!strcmp(p, "type")) {
                     if (!strcmp(p2 + 1, "ioemu"))
-                        nic->nictype = NICTYPE_IOEMU;
+                        nic->nictype = LIBXL_NICTYPE_IOEMU;
                     else
-                        nic->nictype = NICTYPE_VIF;
+                        nic->nictype = LIBXL_NICTYPE_VIF;
                 } else if (!strcmp(p, "ip")) {
                     free(nic->ip);
                     nic->ip = strdup(p2 + 1);
@@ -1156,7 +1156,7 @@ skip_vfb:
         }
     }
 
-    dm_info->type = c_info->hvm ? XENFV : XENPV;
+    dm_info->type = c_info->hvm ? LIBXL_QEMU_MACHINE_TYPE_FV : 
LIBXL_QEMU_MACHINE_TYPE_PV;
 
     xlu_cfg_destroy(config);
 }
@@ -3346,9 +3346,9 @@ static void button_press(const char *p, 
     find_domain(p);
 
     if (!strcmp(b, "power")) {
-        button = POWER_BUTTON;
+        button = LIBXL_BUTTON_POWER;
     } else if (!strcmp(b, "sleep")) {
-        button = SLEEP_BUTTON;
+        button = LIBXL_BUTTON_SLEEP;
     } else {
         fprintf(stderr, "%s is an invalid button identifier\n", b);
         exit(2);
@@ -4260,9 +4260,9 @@ int main_networkattach(int argc, char **
     for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) {
         if (!strncmp("type=", *argv, 5)) {
             if (!strncmp("vif", (*argv) + 5, 4)) {
-                nic.nictype = NICTYPE_VIF;
+                nic.nictype = LIBXL_NICTYPE_VIF;
             } else if (!strncmp("ioemu", (*argv) + 5, 5)) {
-                nic.nictype = NICTYPE_IOEMU;
+                nic.nictype = LIBXL_NICTYPE_IOEMU;
             } else {
                 fprintf(stderr, "Invalid parameter `type'.\n");
                 return 1;
@@ -4428,22 +4428,22 @@ int main_blockattach(int argc, char **ar
 
     tok = strtok(argv[optind+1], ":");
     if (!strcmp(tok, "phy")) {
-        disk.backend = DISK_BACKEND_PHY;
+        disk.backend = LIBXL_DISK_BACKEND_PHY;
     } else if (!strcmp(tok, "file")) {
-        disk.backend = DISK_BACKEND_TAP;
+        disk.backend = LIBXL_DISK_BACKEND_TAP;
     } else if (!strcmp(tok, "tap")) {
         tok = strtok(NULL, ":");
         if (!strcmp(tok, "aio")) {
-            disk.backend = DISK_BACKEND_TAP;
+            disk.backend = LIBXL_DISK_BACKEND_TAP;
         } else if (!strcmp(tok, "vhd")) {
-            disk.format = DISK_FORMAT_VHD;
-            disk.backend = DISK_BACKEND_TAP;
+            disk.format = LIBXL_DISK_FORMAT_VHD;
+            disk.backend = LIBXL_DISK_BACKEND_TAP;
         } else if (!strcmp(tok, "qcow")) {
-            disk.format = DISK_FORMAT_QCOW;
-            disk.backend = DISK_BACKEND_QDISK;
+            disk.format = LIBXL_DISK_FORMAT_QCOW;
+            disk.backend = LIBXL_DISK_BACKEND_QDISK;
         } else if (!strcmp(tok, "qcow2")) {
-            disk.format = DISK_FORMAT_QCOW2;
-            disk.backend = DISK_BACKEND_QDISK;
+            disk.format = LIBXL_DISK_FORMAT_QCOW2;
+            disk.backend = LIBXL_DISK_BACKEND_QDISK;
         } else {
             fprintf(stderr, "Error: `%s' is not a valid disk image.\n", tok);
             return 1;
diff -r e307b27c955b -r f4bbcbd0417f tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c    Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c    Thu Mar 31 12:32:22 2011 +0100
@@ -224,7 +224,7 @@ static int device_nic_val(caml_gc *gc, l
        c_val->bridge = dup_String_val(gc, Field(v, 5));
        c_val->ifname = dup_String_val(gc, Field(v, 6));
        c_val->script = dup_String_val(gc, Field(v, 7));
-       c_val->nictype = (Int_val(Field(v, 8))) + NICTYPE_IOEMU;
+       c_val->nictype = (Int_val(Field(v, 8))) + LIBXL_NICTYPE_IOEMU;
 
 out:
        CAMLreturn(ret);
@@ -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();
diff -r e307b27c955b -r f4bbcbd0417f tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Thu Mar 31 12:31:42 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c Thu Mar 31 12:32:22 2011 +0100
@@ -769,8 +769,8 @@ PyMODINIT_FUNC initxl(void)
     _INT_CONST(m, SHUTDOWN_crash);
     _INT_CONST(m, SHUTDOWN_watchdog);
 
-    _INT_CONST(m, XENFV);
-    _INT_CONST(m, XENPV);
+    _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_FV);
+    _INT_CONST_LIBXL(m, QEMU_MACHINE_TYPE_PV);
 
     _INT_CONST_LIBXL(m, CONSTYPE_SERIAL);
     _INT_CONST_LIBXL(m, CONSTYPE_PV);
@@ -778,26 +778,26 @@ PyMODINIT_FUNC initxl(void)
     _INT_CONST_LIBXL(m, CONSBACK_XENCONSOLED);
     _INT_CONST_LIBXL(m, CONSBACK_IOEMU);
 
-    _INT_CONST(m, DISK_FORMAT_UNKNOWN);
-    _INT_CONST(m, DISK_FORMAT_QCOW);
-    _INT_CONST(m, DISK_FORMAT_QCOW2);
-    _INT_CONST(m, DISK_FORMAT_VHD);
-    _INT_CONST(m, DISK_FORMAT_RAW);
-    _INT_CONST(m, DISK_FORMAT_EMPTY);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_UNKNOWN);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_QCOW2);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_VHD);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_RAW);
+    _INT_CONST_LIBXL(m, DISK_FORMAT_EMPTY);
 
-    _INT_CONST(m, DISK_BACKEND_UNKNOWN);
-    _INT_CONST(m, DISK_BACKEND_PHY);
-    _INT_CONST(m, DISK_BACKEND_TAP);
-    _INT_CONST(m, DISK_BACKEND_QDISK);
+    _INT_CONST_LIBXL(m, DISK_BACKEND_UNKNOWN);
+    _INT_CONST_LIBXL(m, DISK_BACKEND_PHY);
+    _INT_CONST_LIBXL(m, DISK_BACKEND_TAP);
+    _INT_CONST_LIBXL(m, DISK_BACKEND_QDISK);
 
-    _INT_CONST(m, NICTYPE_IOEMU);
-    _INT_CONST(m, NICTYPE_VIF);
+    _INT_CONST_LIBXL(m, NICTYPE_IOEMU);
+    _INT_CONST_LIBXL(m, NICTYPE_VIF);
 
     _INT_CONST_LIBXL(m, EVENT_DOMAIN_DEATH);
     _INT_CONST_LIBXL(m, EVENT_DISK_EJECT);
 
-    _INT_CONST(m, POWER_BUTTON);
-    _INT_CONST(m, SLEEP_BUTTON);
+    _INT_CONST_LIBXL(m, BUTTON_POWER);
+    _INT_CONST_LIBXL(m, BUTTON_SLEEP);
     genwrap__init(m);
 }
 

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