Skip to contentSkip to conversation

make tools build again

PATCH New Christoph Egger 1 participant 1 message Nov 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make tools build again

Hi!

Attached patch makes tools build again on NetBSD.

P.S.: @Keir: xen_uuid.h is copied from blktap2. I think, this should be consolidated.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
config/NetBSD.mk +2 -0
diff -r 494ad84ad38c config/NetBSD.mk
@@ -6,3 +6,5 @@ CURSES_LIBS = -lcurses
 LIBLEAFDIR_x86_64 = lib
 LIBEXEC = $(PREFIX)/libexec
 PRIVATE_BINDIR = $(BINDIR)
+
+WGET = ftp
config/StdGNU.mk +3 -0
diff -r 494ad84ad38c config/StdGNU.mk
@@ -16,6 +16,9 @@ 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
tools/blktap2/drivers/block-remus.c +7 -3
diff -r 494ad84ad38c tools/blktap2/drivers/block-remus.c
@@ -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)
tools/libxl/Makefile +10 -4
diff -r 494ad84ad38c 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
tools/libxl/libxl.c +25 -5
diff -r 494ad84ad38c 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 *
                        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;
+    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 *
     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(st
 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;
tools/libxl/libxl.h +3 -2
diff -r 494ad84ad38c 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 
                                    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;
tools/libxl/libxl_device.c +1 -0
diff -r 494ad84ad38c 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",
tools/libxl/libxl_dom.c +21 -8
diff -r 494ad84ad38c 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, 
         }
     }
 
+    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)
tools/libxl/libxl_internal.h +0 -1
diff -r 494ad84ad38c tools/libxl/libxl_internal.h
@@ -82,7 +82,6 @@ void *libxl_zalloc(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,
tools/libxl/libxl_utils.c +7 -7
diff -r 494ad84ad38c tools/libxl/libxl_utils.c
@@ -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,7 +109,7 @@ int libxl_is_uuid(char *s)
             if (s[i] != '-')
                 return 0;
         } else {
-            if (!isxdigit(s[i]))
+            if (!isxdigit((uint8_t)s[i]))
                 return 0;
         }
     }
@@ -129,7 +129,7 @@ uint8_t *string_to_uuid(struct libxl_ctx
     return buf;
 }
 
-char *uuid_to_string(struct libxl_ctx *ctx, uint8_t *uuid)
+char *libxl_uuid_to_string(struct libxl_ctx *ctx, xen_uuid_t *uuid)
 {
     if (!uuid)
         return NULL;
@@ -142,7 +142,7 @@ char *uuid_to_string(struct libxl_ctx *c
 
 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)) {
@@ -150,8 +150,8 @@ int libxl_param_to_domid(struct libxl_ct
         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;
     }
tools/libxl/libxl_utils.h +4 -4
diff -r 494ad84ad38c 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);
+uint8_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
tools/libxl/osdeps.h +2 -0
diff -r 494ad84ad38c 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
tools/libxl/xen_uuid.h new file +131 -0

131 lines not on this page · raw message

tools/libxl/xl.c +7 -7
diff -r 494ad84ad38c 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_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-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel