[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools: Make build again on netbsd



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1257858069 0
# Node ID 50d33023051db488c5c50b317522b09f824ce7ab
# Parent  494ad84ad38c4a67bfc2d7bab3d2c786c24803df
tools: Make build again on netbsd

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 .hgignore                           |    2 
 config/NetBSD.mk                    |    2 
 config/StdGNU.mk                    |    2 
 tools/blktap2/drivers/block-remus.c |   10 +-
 tools/libxl/Makefile                |   14 ++-
 tools/libxl/libxl.c                 |   32 +++++++-
 tools/libxl/libxl.h                 |    5 -
 tools/libxl/libxl_device.c          |    1 
 tools/libxl/libxl_dom.c             |   31 ++++++--
 tools/libxl/libxl_internal.h        |    1 
 tools/libxl/libxl_utils.c           |   37 ++++------
 tools/libxl/libxl_utils.h           |    8 +-
 tools/libxl/osdeps.h                |    2 
 tools/libxl/xen_uuid.h              |  131 ++++++++++++++++++++++++++++++++++++
 tools/libxl/xl.c                    |   14 +--
 15 files changed, 235 insertions(+), 57 deletions(-)

diff -r 494ad84ad38c -r 50d33023051d .hgignore
--- a/.hgignore Mon Nov 09 22:41:23 2009 +0000
+++ b/.hgignore Tue Nov 10 13:01:09 2009 +0000
@@ -179,6 +179,8 @@
 ^tools/libxen/libxenapi-
 ^tools/libxen/test/test_bindings$
 ^tools/libxen/test/test_event_handling$
+^tools/libxl/libconfig.*$
+^tools/libxl/xl$
 ^tools/libaio/src/.*\.ol$
 ^tools/libaio/src/.*\.os$
 ^tools/misc/cpuperf/cpuperf-perfcntr$
diff -r 494ad84ad38c -r 50d33023051d config/NetBSD.mk
--- a/config/NetBSD.mk  Mon Nov 09 22:41:23 2009 +0000
+++ b/config/NetBSD.mk  Tue Nov 10 13:01:09 2009 +0000
@@ -6,3 +6,5 @@ LIBLEAFDIR_x86_64 = lib
 LIBLEAFDIR_x86_64 = lib
 LIBEXEC = $(PREFIX)/libexec
 PRIVATE_BINDIR = $(BINDIR)
+
+WGET = ftp
diff -r 494ad84ad38c -r 50d33023051d config/StdGNU.mk
--- a/config/StdGNU.mk  Mon Nov 09 22:41:23 2009 +0000
+++ b/config/StdGNU.mk  Tue Nov 10 13:01:09 2009 +0000
@@ -15,6 +15,8 @@ MSGMERGE   = msgmerge
 
 # Allow git to be wrappered in the environment
 GIT        ?= git
+
+WGET       ?= wget -c
 
 INSTALL      = install
 INSTALL_DIR  = $(INSTALL) -d -m0755 -p
diff -r 494ad84ad38c -r 50d33023051d tools/blktap2/drivers/block-remus.c
--- a/tools/blktap2/drivers/block-remus.c       Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/blktap2/drivers/block-remus.c       Tue Nov 10 13:01:09 2009 +0000
@@ -754,7 +754,9 @@ static int primary_blocking_connect(stru
        }
 
        do {
-               if ((rc = connect(fd, &state->sa, sizeof(state->sa))) < 0) {
+               if ((rc = connect(fd, (struct sockaddr *)&state->sa,
+                   sizeof(state->sa))) < 0)
+               {
                        if (errno == ECONNREFUSED) {
                                RPRINTF("connection refused -- retrying in 1 
second\n");
                                sleep(1);
@@ -883,7 +885,9 @@ static void remus_retry_connect_event(ev
        struct tdremus_state *s = (struct tdremus_state *)private;
 
        /* do a non-blocking connect */
-       if (connect(s->stream_fd.fd, &s->sa, sizeof(s->sa)) && errno != 
EINPROGRESS) {
+       if (connect(s->stream_fd.fd, (struct sockaddr *)&s->sa, sizeof(s->sa))
+           && errno != EINPROGRESS)
+       {
                if(errno == ECONNREFUSED || errno == ENETUNREACH || errno == 
EAGAIN || errno == ECONNABORTED)
                {
                        /* try again in a second */
@@ -1048,7 +1052,7 @@ static int remus_bind(struct tdremus_sta
        if (setsockopt(s->server_fd.fd, SOL_SOCKET, SO_REUSEADDR, &opt, 
sizeof(opt)) < 0)
                RPRINTF("Error setting REUSEADDR on %d: %d\n", s->server_fd.fd, 
errno);
 
-       if (bind(s->server_fd.fd, &s->sa, sizeof(s->sa)) < 0) {
+       if (bind(s->server_fd.fd, (struct sockaddr *)&s->sa, sizeof(s->sa)) < 
0) {
                RPRINTF("could not bind server socket %d to %s:%d: %d %s\n", 
s->server_fd.fd,
                        inet_ntoa(s->sa.sin_addr), ntohs(s->sa.sin_port), 
errno, strerror(errno));
                if (errno != EADDRINUSE)
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/Makefile
--- a/tools/libxl/Makefile      Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/Makefile      Tue Nov 10 13:01:09 2009 +0000
@@ -12,14 +12,20 @@ CFLAGS += -I. -fPIC
 CFLAGS += -I. -fPIC
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 
-LDFLAGS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) 
-luuid
+
+LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
+
+ifeq ($(CONFIG_Linux),y)
+LIBS += -luuid
+endif
 
 LIBCONFIG_URL ?= http://www.hyperrealm.com/libconfig
 LIBCONFIG_SOURCE = libconfig-1.3.2
 LIBCONFIG_OUTPUT = $(LIBCONFIG_SOURCE)/.libs
-WGET=wget -c
 
-LIBXL_OBJS = flexarray.o libxl.o libxl_dom.o libxl_exec.o libxl_xshelp.o 
libxl_device.o libxl_internal.o xenguest.o osdeps.o libxl_utils.o
+LIBXL_OBJS-y =
+LIBXL_OBJS-$(CONFIG_Linux) += osdeps.o
+LIBXL_OBJS = flexarray.o libxl.o libxl_dom.o libxl_exec.o libxl_xshelp.o 
libxl_device.o libxl_internal.o xenguest.o libxl_utils.o $(LIBXL_OBJS-y)
 
 CLIENTS = xl
 
@@ -51,7 +57,7 @@ xl.o: $(LIBCONFIG_SOURCE)
        $(CC) $(CFLAGS) -I$(LIBCONFIG_SOURCE) -c xl.c
 
 $(CLIENTS): xl.o libxenlight.so $(LIBCONFIG_OUTPUT)/libconfig.so
-       $(CC) $(LDFLAGS) -o $@ $< -L . -lxenlight -L$(LIBCONFIG_OUTPUT) -lconfig
+       $(CC) $(LDFLAGS) -o $@ $< $(LIBS) -L . -lxenlight -L$(LIBCONFIG_OUTPUT) 
-lconfig
 
 .PHONY: install
 install: all
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl.c       Tue Nov 10 13:01:09 2009 +0000
@@ -22,6 +22,7 @@
 #include <fcntl.h>
 #include <sys/select.h>
 #include <signal.h>
+#include <unistd.h> /* for write, unlink and close */
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
@@ -63,7 +64,7 @@ int libxl_domain_make(struct libxl_ctx *
                        uint32_t *domid)
 {
     int flags, ret, i;
-        char *uuid_string;
+    char *uuid_string;
     char *rw_paths[] = { "device" };
     char *ro_paths[] = { "cpu", "memory", "device", "error", "drivers",
                          "control", "attr", "data", "messages" };
@@ -71,8 +72,9 @@ int libxl_domain_make(struct libxl_ctx *
     struct xs_permissions roperm[2];
     struct xs_permissions rwperm[1];
     xs_transaction_t t;
-
-    uuid_string = uuid_to_string(ctx, info->uuid);
+    xen_domain_handle_t handle;
+
+    uuid_string = libxl_uuid_to_string(ctx, info->uuid);
     if (!uuid_string) {
         XL_LOG(ctx, XL_LOG_ERROR, "missing uuid");
         return ERROR_FAIL;
@@ -82,7 +84,25 @@ int libxl_domain_make(struct libxl_ctx *
     flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
     *domid = 0;
 
-    ret = xc_domain_create(ctx->xch, info->ssidref, info->uuid, flags, domid);
+    /* XXX handle has to be initialised here.
+     * info->uuid != xen_domain_handle_t
+     * See: 
+     *      http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
+     *      http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
+     *
+     * A DCE 1.1 compatible source representation of UUIDs.
+     *
+     * struct uuid {
+     *     uint32_t        time_low;
+     *     uint16_t        time_mid;
+     *     uint16_t        time_hi_and_version;
+     *     uint8_t         clock_seq_hi_and_reserved;
+     *     uint8_t         clock_seq_low;
+     *     uint8_t         node[_UUID_NODE_LEN];
+     * };
+     */
+
+    ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid);
     if (ret < 0) {
         XL_LOG(ctx, XL_LOG_ERROR, "domain creation fail: %d", ret);
         return ERROR_FAIL;
@@ -337,7 +357,7 @@ int libxl_domain_destroy(struct libxl_ct
 int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force)
 {
     char *dom_path, vm_path[41];
-    uint8_t *uuid;
+    xen_uuid_t *uuid;
 
     dom_path = libxl_xs_get_dompath(ctx, domid);
     if (!dom_path) {
@@ -366,7 +386,7 @@ int libxl_domain_destroy(struct libxl_ct
         XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_device_model failed for 
%d\n", domid);
     if (!xs_rm(ctx->xsh, XBT_NULL, dom_path))
         XL_LOG(ctx, XL_LOG_ERROR, "xs_rm failed for %s\n", dom_path);
-    snprintf(vm_path, sizeof(vm_path), "/vm/%s", uuid_to_string(ctx, uuid));
+    snprintf(vm_path, sizeof(vm_path), "/vm/%s", libxl_uuid_to_string(ctx, 
uuid));
     if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
         XL_LOG(ctx, XL_LOG_ERROR, "xs_rm failed for %s\n", vm_path);
     return 0;
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl.h       Tue Nov 10 13:01:09 2009 +0000
@@ -20,6 +20,7 @@
 #include <stdarg.h>
 #include <netinet/in.h>
 #include <xenctrl.h>
+#include "xen_uuid.h"
 
 typedef int bool;
 
@@ -27,7 +28,7 @@ typedef void (*libxl_log_callback)(void 
                                    int line, const char *func, char *s);
 
 struct libxl_dominfo {
-    uint8_t uuid[16];
+    xen_uuid_t uuid[16];
     uint32_t domid;
 };
 
@@ -48,7 +49,7 @@ typedef struct {
     bool hap;
     int ssidref;
     char *name;
-    uint8_t *uuid;
+    xen_uuid_t *uuid;
     char **xsdata;
     char **platformdata;
 } libxl_domain_create_info;
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl_device.c        Tue Nov 10 13:01:09 2009 +0000
@@ -17,6 +17,7 @@
 #include <string.h>
 #include "libxl.h"
 #include "libxl_internal.h"
+#include <sys/time.h> /* for struct timeval */
 
 char *string_of_kinds[] = {
     [DEVICE_VIF] = "vif",
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl_dom.c   Tue Nov 10 13:01:09 2009 +0000
@@ -18,6 +18,8 @@
 #include <inttypes.h>
 #include <xenguest.h>
 #include <string.h>
+#include <sys/time.h> /* for struct timeval */
+#include <unistd.h> /* for sleep(2) */
 
 int is_hvm(struct libxl_ctx *ctx, uint32_t domid)
 {
@@ -93,11 +95,13 @@ int build_pv(struct libxl_ctx *ctx, uint
 int build_pv(struct libxl_ctx *ctx, uint32_t domid,
              libxl_domain_build_info *info, libxl_domain_build_state *state)
 {
+#if 0 /* unused variables */
     int mem_target_kib = info->max_memkb;
     char *domid_str = libxl_sprintf(ctx, "%d", domid);
     char *memsize_str = libxl_sprintf(ctx, "%d", mem_target_kib / 1024);
     char *store_port_str = libxl_sprintf(ctx, "%d", state->store_port);
     char *console_port_str = libxl_sprintf(ctx, "%d", state->console_port);
+#endif
     return ERROR_NI;
 }
 
@@ -199,19 +203,20 @@ read_again:
     free(ret_str);
 }
 
-static int core_suspend_callback(void)
-{
+static int core_suspend_callback(void *data)
+{
+    struct suspendinfo *si = data;
     unsigned long s_state = 0;
     int ret;
 
-    if (si.hvm)
-        xc_get_hvm_param(si.xch, si.domid, HVM_PARAM_ACPI_S_STATE, &s_state);
-    if ((s_state == 0) && (si.suspend_eventchn >= 0)) {
-        ret = xc_evtchn_notify(si.xch, si.suspend_eventchn);
+    if (si->hvm)
+        xc_get_hvm_param(si->xch, si->domid, HVM_PARAM_ACPI_S_STATE, &s_state);
+    if ((s_state == 0) && (si->suspend_eventchn >= 0)) {
+        ret = xc_evtchn_notify(si->xch, si->suspend_eventchn);
         if (ret < 0) {
             return 0;
         }
-        ret = xc_await_suspend(si.xch, si.suspend_eventchn);
+        ret = xc_await_suspend(si->xch, si->suspend_eventchn);
         if (ret < 0) {
             return 0;
         }
@@ -221,7 +226,10 @@ static int core_suspend_callback(void)
     return 0;
 }
 
-int core_suspend(struct libxl_ctx *ctx, uint32_t domid, int fd, int hvm, int 
live, int debug)
+static struct save_callbacks callbacks;
+
+int core_suspend(struct libxl_ctx *ctx, uint32_t domid, int fd,
+               int hvm, int live, int debug)
 {
     int flags;
     int port;
@@ -257,8 +265,13 @@ int core_suspend(struct libxl_ctx *ctx, 
         }
     }
 
+    callbacks.suspend = core_suspend_callback;
+    callbacks.postcopy = NULL;
+    callbacks.checkpoint = NULL;
+    callbacks.data = &si;
+
     xc_domain_save(ctx->xch, fd, domid, 0, 0, flags,
-                   core_suspend_callback, hvm,
+                   &callbacks, hvm,
                    core_suspend_switch_qemu_logdirty);
 
     if (si.suspend_eventchn > 0)
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl_internal.h      Tue Nov 10 13:01:09 2009 +0000
@@ -82,7 +82,6 @@ void *libxl_calloc(struct libxl_ctx *ctx
 void *libxl_calloc(struct libxl_ctx *ctx, size_t nmemb, size_t size);
 char *libxl_sprintf(struct libxl_ctx *ctx, const char *fmt, ...) 
PRINTF_ATTRIBUTE(2, 3);
 char *libxl_dirname(struct libxl_ctx *ctx, const char *s);
-char *uuid_to_string(struct libxl_ctx *ctx, uint8_t *uuid);
 
 char **libxl_xs_kvs_of_flexarray(struct libxl_ctx *ctx, flexarray_t *array, 
int length);
 int libxl_xs_writev(struct libxl_ctx *ctx, xs_transaction_t t,
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl_utils.c Tue Nov 10 13:01:09 2009 +0000
@@ -72,7 +72,7 @@ int libxl_name_to_domid(struct libxl_ctx
     return -1;
 }
 
-int libxl_uuid_to_domid(struct libxl_ctx *ctx, uint8_t *uuid, uint32_t *domid)
+int libxl_uuid_to_domid(struct libxl_ctx *ctx, xen_uuid_t *uuid, uint32_t 
*domid)
 {
     int nb_domain, i;
     struct libxl_dominfo *info = libxl_domain_list(ctx, &nb_domain);
@@ -85,7 +85,7 @@ int libxl_uuid_to_domid(struct libxl_ctx
     return -1;
 }
 
-int libxl_domid_to_uuid(struct libxl_ctx *ctx, uint8_t **uuid, uint32_t domid)
+int libxl_domid_to_uuid(struct libxl_ctx *ctx, xen_uuid_t **uuid, uint32_t 
domid)
 {
     int nb_domain, i;
     struct libxl_dominfo *info = libxl_domain_list(ctx, &nb_domain);
@@ -109,49 +109,44 @@ int libxl_is_uuid(char *s)
             if (s[i] != '-')
                 return 0;
         } else {
-            if (!isxdigit(s[i]))
+            if (!isxdigit((uint8_t)s[i]))
                 return 0;
         }
     }
     return 1;
 }
 
-uint8_t *string_to_uuid(struct libxl_ctx *ctx, char *s)
+xen_uuid_t *libxl_string_to_uuid(struct libxl_ctx *ctx, char *s)
 {
-    uint8_t *buf;
+    xen_uuid_t *uuid;
     if (!s || !ctx)
         return NULL;
-
-    buf = libxl_zalloc(ctx, 16);
-    sscanf(s, UUID_FMT, &buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5],
-           &buf[6], &buf[7], &buf[8], &buf[9], &buf[10], &buf[11], &buf[12],
-           &buf[13], &buf[14], &buf[15]);
-    return buf;
+    uuid = libxl_zalloc(ctx, sizeof(*uuid));
+    xen_uuid_from_string(uuid, s);
+    return uuid;
 }
 
-char *uuid_to_string(struct libxl_ctx *ctx, uint8_t *uuid)
+char *libxl_uuid_to_string(struct libxl_ctx *ctx, xen_uuid_t *uuid)
 {
+    char uuid_str[39];
     if (!uuid)
         return NULL;
-    return libxl_sprintf(ctx, UUID_FMT,
-                         uuid[0], uuid[1], uuid[2], uuid[3],
-                         uuid[4], uuid[5], uuid[6], uuid[7],
-                         uuid[8], uuid[9], uuid[10], uuid[11],
-                         uuid[12], uuid[13], uuid[14], uuid[15]);
+    xen_uuid_to_string(uuid, uuid_str, sizeof(uuid_str));
+    return libxl_sprintf(ctx, "%s", uuid_str);
 }
 
 int libxl_param_to_domid(struct libxl_ctx *ctx, char *p, uint32_t *domid)
 {
-    uint8_t *uuid;
+    xen_uuid_t *uuid;
     uint32_t d;
 
     if (libxl_is_uuid(p)) {
-        uuid = string_to_uuid(ctx, p);
+        uuid = libxl_string_to_uuid(ctx, p);
         return libxl_uuid_to_domid(ctx, uuid, domid);
     }
     errno = 0;
-    d = strtol(p, (char **) NULL, 10);
-    if (!errno && d != 0 && d != LONG_MAX && d != LONG_MIN) {
+    d = strtoul(p, (char **) NULL, 10);
+    if (!errno && d != 0 && d != ULONG_MAX && d != LONG_MIN) {
         *domid = d;
         return 0;
     }
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/libxl_utils.h Tue Nov 10 13:01:09 2009 +0000
@@ -23,11 +23,11 @@ unsigned long libxl_get_required_shadow_
 unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, 
unsigned int smp_cpus);
 int libxl_name_to_domid(struct libxl_ctx *ctx, char *name, uint32_t *domid);
 char *libxl_domid_to_name(struct libxl_ctx *ctx, uint32_t domid);
-int libxl_uuid_to_domid(struct libxl_ctx *ctx, uint8_t *uuid, uint32_t *domid);
-int libxl_domid_to_uuid(struct libxl_ctx *ctx, uint8_t **uuid, uint32_t domid);
+int libxl_uuid_to_domid(struct libxl_ctx *ctx, xen_uuid_t *uuid, uint32_t 
*domid);
+int libxl_domid_to_uuid(struct libxl_ctx *ctx, xen_uuid_t **uuid, uint32_t 
domid);
 int libxl_is_uuid(char *s);
-uint8_t *string_to_uuid(struct libxl_ctx *ctx, char *s);
-char *uuid_to_string(struct libxl_ctx *ctx, uint8_t *uuid);
+xen_uuid_t *libxl_string_to_uuid(struct libxl_ctx *ctx, char *s);
+char *libxl_uuid_to_string(struct libxl_ctx *ctx, xen_uuid_t *uuid);
 int libxl_param_to_domid(struct libxl_ctx *ctx, char *p, uint32_t *domid);
 
 #endif
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/osdeps.h
--- a/tools/libxl/osdeps.h      Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/osdeps.h      Tue Nov 10 13:01:09 2009 +0000
@@ -18,7 +18,9 @@
 
 #include <stdarg.h>
 
+#if defined(__linux__)
 int asprintf(char **buffer, char *fmt, ...);
 int vasprintf(char **buffer, const char *fmt, va_list ap);
+#endif
 
 #endif
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/xen_uuid.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/xen_uuid.h    Tue Nov 10 13:01:09 2009 +0000
@@ -0,0 +1,131 @@
+/* Copyright (c) 2008, XenSource Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of XenSource Inc. nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __XEN_UUID_H__
+#define __XEN_UUID_H__
+
+#if defined(__linux__)
+
+#include <uuid/uuid.h>
+
+typedef struct {
+    uuid_t uuid;
+} xen_uuid_t;
+
+static inline int xen_uuid_is_nil(xen_uuid_t *uuid)
+{
+       return uuid_is_null(uuid->uuid);
+}
+
+static inline void xen_uuid_generate(xen_uuid_t *uuid)
+{
+       uuid_generate(uuid->uuid);
+}
+
+static inline void xen_uuid_to_string(xen_uuid_t *uuid, char *out, size_t size)
+{
+       uuid_unparse(uuid->uuid, out);
+}
+
+static inline void xen_uuid_from_string(xen_uuid_t *uuid, const char *in)
+{
+       uuid_parse(in, uuid->uuid);
+}
+
+static inline void xen_uuid_copy(xen_uuid_t *dst, xen_uuid_t *src)
+{
+       uuid_copy(dst->uuid, src->uuid);
+}
+
+static inline void xen_uuid_clear(xen_uuid_t *uuid)
+{
+       uuid_clear(uuid->uuid);
+}
+
+static inline int xen_uuid_compare(xen_uuid_t *uuid1, xen_uuid_t *uuid2)
+{
+       return uuid_compare(uuid1->uuid, uuid2->uuid);
+}
+
+#elif defined(__NetBSD__)
+
+#include <uuid.h>
+#include <string.h>
+#include <stdlib.h>
+
+typedef uuid_t xen_uuid_t;
+
+static inline int xen_uuid_is_nil(xen_uuid_t *uuid)
+{
+       uint32_t status;
+       return uuid_is_nil((uuid_t *)uuid, &status);
+}
+
+static inline void xen_uuid_generate(xen_uuid_t *uuid)
+{
+       uint32_t status;
+       uuid_create((uuid_t *)uuid, &status);
+}
+
+static inline void xen_uuid_to_string(xen_uuid_t *uuid, char *out, size_t size)
+{
+       uint32_t status;
+       char *_out = NULL;
+       uuid_to_string((uuid_t *)uuid, &_out, &status);
+       strlcpy(out, _out, size);
+       free(_out);
+}
+
+static inline void xen_uuid_from_string(xen_uuid_t *uuid, const char *in)
+{
+       uint32_t status;
+       uuid_from_string(in, (uuid_t *)uuid, &status);
+}
+
+static inline void xen_uuid_copy(xen_uuid_t *dst, xen_uuid_t *src)
+{
+       memcpy((uuid_t *)dst, (uuid_t *)src, sizeof(uuid_t));
+}
+
+static inline void xen_uuid_clear(xen_uuid_t *uuid)
+{
+       memset((uuid_t *)uuid, 0, sizeof(uuid_t));
+}
+
+static inline int xen_uuid_compare(xen_uuid_t *uuid1, xen_uuid_t *uuid2)
+{
+       uint32_t status;
+       return uuid_compare((uuid_t *)uuid1, (uuid_t *)uuid2, &status);
+}
+
+#else
+
+#error "Please update xen_uuid.h for your OS"
+
+#endif
+
+#endif /* __XEN_UUID_H__ */
diff -r 494ad84ad38c -r 50d33023051d tools/libxl/xl.c
--- a/tools/libxl/xl.c  Mon Nov 09 22:41:23 2009 +0000
+++ b/tools/libxl/xl.c  Tue Nov 10 13:01:09 2009 +0000
@@ -19,9 +19,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <uuid/uuid.h>
 #include <libconfig.h>
+#include "xen_uuid.h"
 #include <unistd.h>
+#include <sys/time.h> /* for time */
 #include <getopt.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -42,15 +43,14 @@ static void printf_info(libxl_domain_cre
                         libxl_device_model_info *dm_info)
 {
     int i;
+    char uuid_str[18];
     printf("*** domain_create_info ***\n");
     printf("hvm: %d\n", c_info->hvm);
     printf("hap: %d\n", c_info->hap);
     printf("ssidref: %d\n", c_info->ssidref);
     printf("name: %s\n", c_info->name);
-    printf("uuid: " UUID_FMT "\n", c_info->uuid[0], c_info->uuid[1], 
c_info->uuid[2], c_info->uuid[3],
-           c_info->uuid[4], c_info->uuid[5], c_info->uuid[6], c_info->uuid[7],
-           c_info->uuid[8], c_info->uuid[9], c_info->uuid[10], 
c_info->uuid[11],
-           c_info->uuid[12], c_info->uuid[13], c_info->uuid[14], 
c_info->uuid[15]);
+    xen_uuid_to_string(c_info->uuid, uuid_str, sizeof(uuid_str));
+    printf("uuid: %s\n", uuid_str);
     if (c_info->xsdata)
         printf("xsdata: contains data\n");
     else
@@ -289,7 +289,7 @@ static void parse_config_file(const char
                               libxl_device_model_info *dm_info)
 {
     const char *buf;
-    uint8_t uuid[16];
+    xen_uuid_t uuid[16];
     long l;
     struct config_t config;
     struct config_setting_t *vbds, *nics;
@@ -322,7 +322,7 @@ static void parse_config_file(const char
         c_info->name = strdup(buf);
     else
         c_info->name = "test";
-    uuid_generate(uuid);
+    xen_uuid_generate(uuid);
     c_info->uuid = uuid;
 
     init_build_info(b_info, c_info);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.