aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-11-10 13:01:09 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-11-10 13:01:09 +0000
commit66cc31ec352b38777396bd8689139e932c396e94 (patch)
treeb1e327519baef1e1bacb8b8f206b7afe88e68dd5
parent88069bda2eebb07ebac3325279330f7416282993 (diff)
downloadxen-66cc31ec352b38777396bd8689139e932c396e94.tar.gz
xen-66cc31ec352b38777396bd8689139e932c396e94.tar.bz2
xen-66cc31ec352b38777396bd8689139e932c396e94.zip
tools: Make build again on netbsd
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
-rw-r--r--.hgignore2
-rw-r--r--config/NetBSD.mk2
-rw-r--r--config/StdGNU.mk2
-rw-r--r--tools/blktap2/drivers/block-remus.c10
-rw-r--r--tools/libxl/Makefile14
-rw-r--r--tools/libxl/libxl.c30
-rw-r--r--tools/libxl/libxl.h5
-rw-r--r--tools/libxl/libxl_device.c1
-rw-r--r--tools/libxl/libxl_dom.c29
-rw-r--r--tools/libxl/libxl_internal.h1
-rw-r--r--tools/libxl/libxl_utils.c37
-rw-r--r--tools/libxl/libxl_utils.h8
-rw-r--r--tools/libxl/osdeps.h2
-rw-r--r--tools/libxl/xen_uuid.h131
-rw-r--r--tools/libxl/xl.c14
15 files changed, 233 insertions, 55 deletions
diff --git a/.hgignore b/.hgignore
index ae23387049..b4b27ac3b2 100644
--- a/.hgignore
+++ b/.hgignore
@@ -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 --git a/config/NetBSD.mk b/config/NetBSD.mk
index 19bc25d56f..73b61577c6 100644
--- a/config/NetBSD.mk
+++ b/config/NetBSD.mk
@@ -6,3 +6,5 @@ CURSES_LIBS = -lcurses
LIBLEAFDIR_x86_64 = lib
LIBEXEC = $(PREFIX)/libexec
PRIVATE_BINDIR = $(BINDIR)
+
+WGET = ftp
diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index ff94379208..aa6248801e 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -16,6 +16,8 @@ MSGMERGE = msgmerge
# Allow git to be wrappered in the environment
GIT ?= git
+WGET ?= wget -c
+
INSTALL = install
INSTALL_DIR = $(INSTALL) -d -m0755 -p
INSTALL_DATA = $(INSTALL) -m0644 -p
diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c
index b0bce9745a..aae0fb74c1 100644
--- a/tools/blktap2/drivers/block-remus.c
+++ b/tools/blktap2/drivers/block-remus.c
@@ -754,7 +754,9 @@ static int primary_blocking_connect(struct tdremus_state *state)
}
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(event_id_t id, char mode, void *private)
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_state* s)
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 --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 30e236d145..492d6d9151 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -12,14 +12,20 @@ MINOR = 0
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 --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index dac06c9881..e5daad0161 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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 *ctx, libxl_domain_create_info *info,
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 *ctx, libxl_domain_create_info *info,
struct xs_permissions roperm[2];
struct xs_permissions rwperm[1];
xs_transaction_t t;
+ xen_domain_handle_t handle;
- uuid_string = uuid_to_string(ctx, info->uuid);
+ 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 *ctx, libxl_domain_create_info *info,
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 @@ static int libxl_destroy_device_model(struct libxl_ctx *ctx, uint32_t domid)
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_ctx *ctx, uint32_t domid, int force)
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 --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index b314d37655..47b3a0bbba 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -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 *userdata, int loglevel, const char *fil
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 --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index f10ddd1f23..f2b42a64fc 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -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 --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 72eec36861..92e13242f2 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -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 @@ retry_transaction:
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, uint32_t domid, int fd, int hvm, int liv
}
}
+ 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 --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c0b50a537f..0e566eec5e 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -82,7 +82,6 @@ void *libxl_zalloc(struct libxl_ctx *ctx, int bytes);
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 --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index 97f2f3b0e4..c7b34faf46 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -72,7 +72,7 @@ int libxl_name_to_domid(struct libxl_ctx *ctx, char *name, uint32_t *domid)
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 *ctx, uint8_t *uuid, uint32_t *domid)
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 --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index d5cc2c09e9..77787922f7 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -23,11 +23,11 @@
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 --git a/tools/libxl/osdeps.h b/tools/libxl/osdeps.h
index d5bc27d752..5391727fa7 100644
--- a/tools/libxl/osdeps.h
+++ b/tools/libxl/osdeps.h
@@ -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 --git a/tools/libxl/xen_uuid.h b/tools/libxl/xen_uuid.h
new file mode 100644
index 0000000000..21c41f79bf
--- /dev/null
+++ b/tools/libxl/xen_uuid.h
@@ -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 --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index ada61573ba..dff89ebfc1 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -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_create_info *c_info,
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 *filename,
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 *filename,
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);