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-changelog

[Xen-changelog] [xen-unstable] Merge

# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1281547607 -3600
# Node ID 8bb9cfaca402d19ba5d990a72fcb34560b2fcb71
# Parent  786b163da49bbf18857b5484cce5e5aed33528b3
# Parent  d3de6f484610f6e9e6f9e613d3e8ea1e9bc63e5e
Merge
---
 config/StdGNU.mk                    |    2 
 config/SunOS.mk                     |    2 
 tools/Rules.mk                      |    8 -
 tools/blktap/drivers/Makefile       |   10 -
 tools/blktap/lib/Makefile           |    6 
 tools/blktap2/Makefile              |    2 
 tools/blktap2/drivers/Makefile      |   12 -
 tools/blktap2/vhd/Makefile          |    4 
 tools/blktap2/vhd/lib/Makefile      |    2 
 tools/console/Makefile              |   13 -
 tools/debugger/xenitp/Makefile      |    4 
 tools/flask/libflask/Makefile       |    2 
 tools/flask/utils/Makefile          |    4 
 tools/fs-back/Makefile              |    4 
 tools/libfsimage/Rules.mk           |    2 
 tools/libfsimage/common/Makefile    |    2 
 tools/libxc/Makefile                |    4 
 tools/libxc/xc_hvm_build.c          |   18 --
 tools/libxen/Makefile               |    2 
 tools/libxen/Makefile.dist          |    4 
 tools/libxl/Makefile                |    6 
 tools/libxl/flexarray.c             |    3 
 tools/libxl/flexarray.h             |   12 -
 tools/libxl/libxl.c                 |  109 +++++++++-----
 tools/libxl/libxl.h                 |    6 
 tools/libxl/libxl_internal.c        |   15 --
 tools/libxl/libxl_internal.h        |  114 ++++++++-------
 tools/libxl/libxl_pci.c             |    2 
 tools/libxl/libxl_utils.c           |   37 +++--
 tools/libxl/xl_cmdimpl.c            |   71 ++++++---
 tools/misc/Makefile                 |    2 
 tools/ocaml/common.make             |    2 
 tools/ocaml/libs/xl/xl_stubs.c      |  264 +++++++++++++++++++++---------------
 tools/python/xen/util/vscsi_util.py |    2 
 tools/security/Makefile             |    2 
 tools/vnet/libxutil/Makefile        |    2 
 tools/xcutils/Makefile              |    2 
 tools/xenbackendd/Makefile          |    4 
 tools/xenmon/Makefile               |    6 
 tools/xenpaging/Makefile            |    7 
 tools/xenpmd/Makefile               |    4 
 tools/xenstat/libxenstat/Makefile   |    6 
 tools/xenstore/Makefile             |    4 
 tools/xentrace/Makefile             |    6 
 44 files changed, 453 insertions(+), 342 deletions(-)

diff -r 786b163da49b -r 8bb9cfaca402 config/StdGNU.mk
--- a/config/StdGNU.mk  Wed Aug 11 17:01:02 2010 +0100
+++ b/config/StdGNU.mk  Wed Aug 11 18:26:47 2010 +0100
@@ -59,7 +59,7 @@ PTHREAD_LIBS = -lpthread
 PTHREAD_LIBS = -lpthread
 UTIL_LIBS = -lutil
 SONAME_LDFLAG = -soname
-SHLIB_CFLAGS = -shared
+SHLIB_LDFLAGS = -shared
 
 ifneq ($(debug),y)
 CFLAGS += -O2 -fomit-frame-pointer
diff -r 786b163da49b -r 8bb9cfaca402 config/SunOS.mk
--- a/config/SunOS.mk   Wed Aug 11 17:01:02 2010 +0100
+++ b/config/SunOS.mk   Wed Aug 11 18:26:47 2010 +0100
@@ -51,7 +51,7 @@ PTHREAD_LIBS = -lpthread
 PTHREAD_LIBS = -lpthread
 UTIL_LIBS =
 SONAME_LDFLAG = -h
-SHLIB_CFLAGS = -R $(SunOS_LIBDIR) -shared
+SHLIB_LDFLAGS = -R $(SunOS_LIBDIR) -shared
 
 ifneq ($(debug),y)
 CFLAGS += -O2 -fno-omit-frame-pointer
diff -r 786b163da49b -r 8bb9cfaca402 tools/Rules.mk
--- a/tools/Rules.mk    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/Rules.mk    Wed Aug 11 18:26:47 2010 +0100
@@ -18,16 +18,16 @@ CFLAGS_include = -I$(XEN_INCLUDE)
 CFLAGS_include = -I$(XEN_INCLUDE)
 
 CFLAGS_libxenctrl = -I$(XEN_LIBXC) $(CFLAGS_include)
-LDFLAGS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl
+LDLIBS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl
 
 CFLAGS_libxenguest = -I$(XEN_LIBXC) $(CFLAGS_include)
-LDFLAGS_libxenguest = -L$(XEN_LIBXC) -lxenguest
+LDLIBS_libxenguest = -L$(XEN_LIBXC) -lxenguest
 
 CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include)
-LDFLAGS_libxenstore = -L$(XEN_XENSTORE) -lxenstore
+LDLIBS_libxenstore = -L$(XEN_XENSTORE) -lxenstore
 
 CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include 
$(CFLAGS_include)
-LDFLAGS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl
+LDLIBS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl
 
 X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR)
 
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile     Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap/drivers/Makefile     Wed Aug 11 18:26:47 2010 +0100
@@ -29,8 +29,8 @@ MEMSHRLIBS += $(MEMSHR_DIR)/libmemshr.a
 MEMSHRLIBS += $(MEMSHR_DIR)/libmemshr.a
 endif
 
-LDFLAGS_blktapctrl := $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore) 
$(MEMSHRLIBS) -L../lib -lblktap -lrt -lm -lpthread
-LDFLAGS_img := $(LIBAIO_DIR)/libaio.a $(CRYPT_LIB) -lpthread -lz
+LDLIBS_blktapctrl := $(MEMSHRLIBS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) 
-L../lib -lblktap -lrt -lm -lpthread
+LDLIBS_img := $(LIBAIO_DIR)/libaio.a $(CRYPT_LIB) -lpthread -lz
 
 BLK-OBJS-y  := block-aio.o
 BLK-OBJS-y  += block-sync.o
@@ -48,16 +48,16 @@ all: $(IBIN) qcow-util
 all: $(IBIN) qcow-util
 
 blktapctrl: $(BLKTAB-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDFLAGS_blktapctrl)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS_blktapctrl)
 
 tapdisk: tapdisk.o $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDFLAGS_img)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS_img)
 
 .PHONY: qcow-util
 qcow-util: img2qcow qcow2raw qcow-create
 
 img2qcow qcow2raw qcow-create: %: %.o $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $* $^ $(LDFLAGS) $(LDFLAGS_img)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $* $^ $(LDLIBS_img)
 
 install: all
        $(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(VHD_UTIL) $(DESTDIR)$(SBINDIR)
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap/lib/Makefile
--- a/tools/blktap/lib/Makefile Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap/lib/Makefile Wed Aug 11 18:26:47 2010 +0100
@@ -8,7 +8,7 @@ CFLAGS   += -I.
 CFLAGS   += -I.
 CFLAGS   += $(CFLAGS_libxenctrl)
 CFLAGS   += $(CFLAGS_libxenstore)
-LDFLAGS  += $(LDFLAGS_libxenstore)
+LDLIBS   += $(LDLIBS_libxenstore)
 
 SRCS     :=
 SRCS     += xenbus.c blkif.c xs_api.c
@@ -46,8 +46,8 @@ clean:
        rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen TAGS
 
 libblktap.so.$(MAJOR).$(MINOR): $(OBJS_PIC) 
-       $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_CFLAGS) \
-             $(LDFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) 
$(SHLIB_LDFLAGS) \
+             -o $@ $^ $(LDLIBS)
        ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR)
        ln -sf libblktap.so.$(MAJOR) libblktap.so
 
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap2/Makefile
--- a/tools/blktap2/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap2/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -2,7 +2,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
-LDFLAGS += $(LDFLAGS_libxenctrl)
+LDLIBS += $(LDLIBS_libxenctrl)
 
 SUBDIRS-y :=
 SUBDIRS-y += include
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap2/drivers/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -25,7 +25,7 @@ endif
 
 LIBS      += -lrt -lz
 
-LDFLAGS_img := $(LDFLAGS_libxenctrl) $(CRYPT_LIB) -lpthread -lz -lm
+LBLIBS_img := $(LDLIBS_libxenctrl) $(CRYPT_LIB) -lpthread -lz -lm
 
 LIBS += -L$(LIBVHDDIR) -lvhd
 
@@ -93,16 +93,16 @@ all: $(IBIN) lock-util qcow-util
 
 
 tapdisk2: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk2.c
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LDFLAGS_img)
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
 
 tapdisk-client: tapdisk-client.o
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LDFLAGS_img)
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LBLIBS_img)
 
 tapdisk-stream tapdisk-diff: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LDFLAGS_img)
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
 
 td-util: td.o tapdisk-utils.o tapdisk-log.o $(PORTABLE-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LDFLAGS_img)
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LBLIBS_img)
 
 lock-util: lock.c
        $(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LDFLAGS) $(LIBS)
@@ -111,7 +111,7 @@ qcow-util: img2qcow qcow2raw qcow-create
 qcow-util: img2qcow qcow2raw qcow-create
 
 img2qcow qcow2raw qcow-create: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LDFLAGS_img)
+       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(MEMSHRLIBS) 
$(LBLIBS_img)
 
 install: all
        $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap2/vhd/Makefile
--- a/tools/blktap2/vhd/Makefile        Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap2/vhd/Makefile        Wed Aug 11 18:26:47 2010 +0100
@@ -38,10 +38,10 @@ LIBS_DEPENDS          := lib/libvhd.so lib/vhd.
 $(LIBS_DEPENDS):subdirs-all
 
 vhd-util: vhd-util.o $(LIBS_DEPENDS)
-       $(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o vhd-util vhd-util.o $(LIBS)
 
 vhd-update: vhd-update.o $(LIBS_DEPENDS)
-       $(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o vhd-update vhd-update.o $(LIBS)
 
 install: all
        $(MAKE) subdirs-install
diff -r 786b163da49b -r 8bb9cfaca402 tools/blktap2/vhd/lib/Makefile
--- a/tools/blktap2/vhd/lib/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/blktap2/vhd/lib/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -55,7 +55,7 @@ build: $(LIBVHD-BUILD)
 build: $(LIBVHD-BUILD)
 
 libvhd.a: $(LIB-OBJS)
-       $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_CFLAGS) \
+       $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_LDFLAGS) \
                $(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) 
$^
        ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) 
libvhd.so.$(LIBVHD-MAJOR)
        ln -sf libvhd.so.$(LIBVHD-MAJOR) libvhd.so
diff -r 786b163da49b -r 8bb9cfaca402 tools/console/Makefile
--- a/tools/console/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/console/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -6,8 +6,11 @@ CFLAGS  += -Werror
 
 CFLAGS  += $(CFLAGS_libxenctrl)
 CFLAGS  += $(CFLAGS_libxenstore)
-LDFLAGS += $(LDFLAGS_libxenctrl)
-LDFLAGS += $(LDFLAGS_libxenstore)
+LDLIBS += $(LDLIBS_libxenctrl)
+LDLIBS += $(LDLIBS_libxenstore)
+LDLIBS += $(UTIL_LIBS)
+LDLIBS += $(SOCKET_LIBS)
+LDLIBS += -lrt
 
 BIN      = xenconsoled xenconsole
 
@@ -20,12 +23,10 @@ clean:
        $(RM) client/*.o daemon/*.o
 
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) \
-              $(UTIL_LIBS) $(SOCKET_LIBS) -lrt
+       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
 
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
-       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) \
-             $(UTIL_LIBS) $(SOCKET_LIBS)
+       $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
 
 .PHONY: install
 install: $(BIN)
diff -r 786b163da49b -r 8bb9cfaca402 tools/debugger/xenitp/Makefile
--- a/tools/debugger/xenitp/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/debugger/xenitp/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -46,8 +46,8 @@ clean:
        $(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN)
 
 %: %.c $(HDRS) Makefile
-       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_libxenctrl)
+       $(CC) $(CFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
 
 XENITP_OBJS=xenitp.o ia64-dis.o ia64-opc.o cpu-ia64-opc.o
 xenitp: $(XENITP_OBJS)
-       $(CC) $(CFLAGS) -o $@ $(XENITP_OBJS) $(LDFLAGS_libxenctrl)
+       $(CC) $(CFLAGS) -o $@ $(XENITP_OBJS) $(LDLIBS_libxenctrl)
diff -r 786b163da49b -r 8bb9cfaca402 tools/flask/libflask/Makefile
--- a/tools/flask/libflask/Makefile     Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/flask/libflask/Makefile     Wed Aug 11 18:26:47 2010 +0100
@@ -59,6 +59,6 @@ libflask.so.$(MAJOR): libflask.so.$(MAJO
        ln -sf $< $@
 
 libflask.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libflask.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libflask.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 -include $(DEPS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/flask/utils/Makefile
--- a/tools/flask/utils/Makefile        Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/flask/utils/Makefile        Wed Aug 11 18:26:47 2010 +0100
@@ -14,7 +14,7 @@ BASECFLAGS+= -I.
 BASECFLAGS+= -I.
 
 CFLAGS  += $(BASECFLAGS)
-LDFLAGS += $(PROFILE) -L$(XEN_LIBXC) -L$(LIBFLASK_ROOT)
+LDLIBS += $(PROFILE) -L$(XEN_LIBXC) -L$(LIBFLASK_ROOT)
 TESTDIR  = testsuite/tmp
 TESTFLAGS= -DTESTING
 TESTENV  = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
@@ -27,7 +27,7 @@ all: $(CLIENTS)
 all: $(CLIENTS)
 
 $(CLIENTS): flask-%: %.o
-       $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lflask 
$(LDFLAGS_libxenctrl) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lflask 
$(LDLIBS_libxenctrl) -o $@
 
 .PHONY: clean
 clean: 
diff -r 786b163da49b -r 8bb9cfaca402 tools/fs-back/Makefile
--- a/tools/fs-back/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/fs-back/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -14,8 +14,8 @@ CFLAGS   += -D_GNU_SOURCE
 CFLAGS   += -D_GNU_SOURCE
 
 LIBS      := -L. -L.. -L../lib
-LIBS      += $(LDFLAGS_libxenctrl)
-LIBS      += $(LDFLAGS_libxenstore)
+LIBS      += $(LDLIBS_libxenctrl)
+LIBS      += $(LDLIBS_libxenstore)
 LIBS      += -lrt -lpthread
 
 OBJS     := fs-xenbus.o fs-ops.o
diff -r 786b163da49b -r 8bb9cfaca402 tools/libfsimage/Rules.mk
--- a/tools/libfsimage/Rules.mk Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libfsimage/Rules.mk Wed Aug 11 18:26:47 2010 +0100
@@ -24,7 +24,7 @@ fs-install: fs-all
        $(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)
 
 $(FSLIB): $(PIC_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(SHLIB_CFLAGS) -o $@ $^ -lfsimage 
$(FS_LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lfsimage 
$(FS_LIBDEPS)
 
 clean distclean:
        rm -f $(PIC_OBJS) $(FSLIB) $(DEPS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/libfsimage/common/Makefile
--- a/tools/libfsimage/common/Makefile  Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libfsimage/common/Makefile  Wed Aug 11 18:26:47 2010 +0100
@@ -37,7 +37,7 @@ libfsimage.so.$(MAJOR): libfsimage.so.$(
        ln -sf $< $@
 
 libfsimage.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libfsimage.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ -lpthread
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libfsimage.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ -lpthread
 
 -include $(DEPS)
 
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxc/Makefile
--- a/tools/libxc/Makefile      Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxc/Makefile      Wed Aug 11 18:26:47 2010 +0100
@@ -145,7 +145,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(
        ln -sf $< $@
 
 libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenctrl.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ $(PTHREAD_LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(PTHREAD_LIBS)
 
 # libxenguest
 
@@ -181,7 +181,7 @@ xc_dom_bzimageloader.opic: CFLAGS += $(c
 
 libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(call zlib-options,l)
 libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenguest.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $(GUEST_PIC_OBJS) 
$(COMPRESSION_LIBS) -lz -lxenctrl $(PTHREAD_LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) 
$(COMPRESSION_LIBS) -lz -lxenctrl $(PTHREAD_LIBS)
 
 -include $(DEPS)
 
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxc/xc_hvm_build.c        Wed Aug 11 18:26:47 2010 +0100
@@ -123,7 +123,6 @@ static int setup_guest(xc_interface *xch
     xen_pfn_t *page_array = NULL;
     unsigned long i, nr_pages = (unsigned long)memsize << (20 - PAGE_SHIFT);
     unsigned long target_pages = (unsigned long)target << (20 - PAGE_SHIFT);
-    unsigned long pod_pages = 0;
     unsigned long entry_eip, cur_pages;
     void *hvm_info_page;
     uint32_t *ident_pt;
@@ -238,11 +237,6 @@ static int setup_guest(xc_interface *xch
             {
                 stat_1gb_pages += done;
                 done <<= SUPERPAGE_1GB_SHIFT;
-                if ( pod_mode && target_pages > cur_pages )
-                {
-                    int d = target_pages - cur_pages;
-                    pod_pages += ( done < d ) ? done : d;
-                }
                 cur_pages += done;
                 count -= done;
             }
@@ -285,11 +279,6 @@ static int setup_guest(xc_interface *xch
                 {
                     stat_2mb_pages += done;
                     done <<= SUPERPAGE_2MB_SHIFT;
-                    if ( pod_mode && target_pages > cur_pages )
-                    {
-                        int d = target_pages - cur_pages;
-                        pod_pages += ( done < d ) ? done : d;
-                    }
                     cur_pages += done;
                     count -= done;
                 }
@@ -303,15 +292,16 @@ static int setup_guest(xc_interface *xch
                 xch, dom, count, 0, 0, &page_array[cur_pages]);
             cur_pages += count;
             stat_normal_pages += count;
-            if ( pod_mode )
-                pod_pages -= count;
         }
     }
 
+    /* Subtract 0x20 from target_pages for the VGA "hole".  Xen will
+     * adjust the PoD cache size so that domain tot_pages will be
+     * target_pages - 0x20 after this call. */
     if ( pod_mode )
         rc = xc_domain_memory_set_pod_target(xch,
                                              dom,
-                                             pod_pages,
+                                             target_pages - 0x20,
                                              NULL, NULL, NULL);
 
     if ( rc != 0 )
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxen/Makefile
--- a/tools/libxen/Makefile     Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxen/Makefile     Wed Aug 11 18:26:47 2010 +0100
@@ -44,7 +44,7 @@ libxenapi.so.$(MAJOR): libxenapi.so.$(MA
        ln -sf $< $@
 
 libxenapi.so.$(MAJOR).$(MINOR): $(LIBXENAPI_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenapi.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenapi.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxenapi.a: $(LIBXENAPI_OBJS)
        $(AR) rcs libxenapi.a $^
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxen/Makefile.dist
--- a/tools/libxen/Makefile.dist        Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxen/Makefile.dist        Wed Aug 11 18:26:47 2010 +0100
@@ -30,7 +30,7 @@ LDFLAGS = $(shell xml2-config --libs) \
 # -h for Solaris
 SONAME_LDFLAG ?= -soname
 # -R /usr/sfw/$(LIBDIR) -shared for Solaris
-SHLIB_CFLAGS ?= -shared
+SHLIB_LDFLAGS ?= -shared
 
 # ginstall for Solaris
 INSTALL      = install
@@ -54,7 +54,7 @@ libxenapi.so.$(MAJOR): libxenapi.so.$(MA
        ln -sf $< $@
 
 libxenapi.so.$(MAJOR).$(MINOR): $(LIBXENAPI_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenapi.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenapi.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxenapi.a: $(LIBXENAPI_OBJS)
        $(AR) rcs libxenapi.a $^
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/Makefile      Wed Aug 11 18:26:47 2010 +0100
@@ -15,7 +15,7 @@ CFLAGS += -I. -fPIC
 CFLAGS += -I. -fPIC
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) 
$(CFLAGS_libblktapctl)
 
-LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) 
$(LDFLAGS_libblktapctl) $(UTIL_LIBS)
+LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) 
$(LDLIBS_libblktapctl) $(UTIL_LIBS)
 
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o
 LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o 
libxl_xshelp.o libxl_device.o libxl_internal.o xenguest.o libxl_utils.o 
$(LIBXL_OBJS-y)
@@ -59,7 +59,7 @@ libxenlight.so.$(MAJOR): libxenlight.so.
        ln -sf $< $@
 
 libxenlight.so.$(MAJOR).$(MINOR): $(LIBXL_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenlight.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxenlight.a: $(LIBXL_OBJS)
        $(AR) rcs libxenlight.a $^
@@ -71,7 +71,7 @@ libxlutil.so.$(XLUMAJOR): libxlutil.so.$
        ln -sf $< $@
 
 libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxlutil.a: $(LIBXLU_OBJS)
        $(AR) rcs libxlutil.a $^
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/flexarray.c
--- a/tools/libxl/flexarray.c   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/flexarray.c   Wed Aug 11 18:26:47 2010 +0100
@@ -13,8 +13,7 @@
  * GNU Lesser General Public License for more details.
  */
 
-#include <stdlib.h>
-#include "flexarray.h"
+#include "libxl_internal.h"
 
 flexarray_t *flexarray_make(int size, int autogrow)
 {
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/flexarray.h
--- a/tools/libxl/flexarray.h   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/flexarray.h   Wed Aug 11 18:26:47 2010 +0100
@@ -22,12 +22,12 @@ typedef struct flexarray {
     void **data; /* array of pointer */
 } flexarray_t;
 
-flexarray_t *flexarray_make(int size, int autogrow);
-void flexarray_free(flexarray_t *array);
-int flexarray_grow(flexarray_t *array, int extents);
-int flexarray_set(flexarray_t *array, unsigned int index, void *ptr);
-int flexarray_get(flexarray_t *array, int index, void **ptr);
+_hidden flexarray_t *flexarray_make(int size, int autogrow);
+_hidden void flexarray_free(flexarray_t *array);
+_hidden int flexarray_grow(flexarray_t *array, int extents);
+_hidden int flexarray_set(flexarray_t *array, unsigned int index, void *ptr);
+_hidden int flexarray_get(flexarray_t *array, int index, void **ptr);
 
-void **flexarray_contents(flexarray_t *array);
+_hidden void **flexarray_contents(flexarray_t *array);
 
 #endif
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Aug 11 18:26:47 2010 +0100
@@ -70,11 +70,13 @@ int libxl_ctx_init(libxl_ctx *ctx, int v
     return 0;
 }
 
+static void do_free_version_info(libxl_version_info *info);
 int libxl_ctx_free(libxl_ctx *ctx)
 {
     libxl_free_all(ctx);
     free(ctx->alloc_ptrs);
     xc_interface_close(ctx->xch);
+    do_free_version_info(&ctx->version_info);
     if (ctx->xsh) xs_daemon_close(ctx->xsh); 
     return 0;
 }
@@ -1377,7 +1379,7 @@ static int libxl_create_stubdom(libxl_ct
 
     memset(&c_info, 0x00, sizeof(libxl_domain_create_info));
     c_info.hvm = 0;
-    c_info.name = libxl_sprintf(ctx, "%s-dm", libxl_domid_to_name(ctx, 
info->domid));
+    c_info.name = libxl_sprintf(ctx, "%s-dm", _libxl_domid_to_name(ctx, 
info->domid));
     for (i = 0; i < 16; i++)
         c_info.uuid[i] = info->uuid[i];
 
@@ -1885,10 +1887,21 @@ int libxl_device_nic_del(libxl_ctx *ctx,
     return libxl_device_del(ctx, &device, wait);
 }
 
+void libxl_free_nics_list(libxl_nicinfo *nics, unsigned int nb)
+{
+    unsigned int i;
+    for(i = 0; i < nb; i++) {
+        free(nics[i].backend);
+        free(nics[i].frontend);
+        free(nics[i].script);
+    }
+    free(nics);
+}
+
 libxl_nicinfo *libxl_list_nics(libxl_ctx *ctx, uint32_t domid, unsigned int 
*nb)
 {
     char *dompath, *nic_path_fe;
-    char **l;
+    char **l, **list;
     char *val, *tok;
     unsigned int nb_nics, i;
     libxl_nicinfo *res, *nics;
@@ -1897,22 +1910,21 @@ libxl_nicinfo *libxl_list_nics(libxl_ctx
     if (!dompath) {
         return NULL;
     }
-    l = libxl_xs_directory(ctx, XBT_NULL,
+    list = l = libxl_xs_directory(ctx, XBT_NULL,
                            libxl_sprintf(ctx, "%s/device/vif", dompath), 
&nb_nics);
     if (!l) {
         return NULL;
     }
-    res = libxl_calloc(ctx, nb_nics, sizeof (libxl_device_nic));
+    nics = res = calloc(nb_nics, sizeof (libxl_device_nic));
     if (!res) {
         libxl_free(ctx, l);
         return NULL;
     }
-    nics = res;
     for (*nb = nb_nics; nb_nics > 0; --nb_nics, ++l, ++nics) {
         nic_path_fe = libxl_sprintf(ctx, "%s/device/vif/%s", dompath, *l);
 
-        nics->backend = libxl_xs_read(ctx, XBT_NULL,
-                                      libxl_sprintf(ctx, "%s/backend", 
nic_path_fe));
+        nics->backend = xs_read(ctx->xsh, XBT_NULL,
+                                libxl_sprintf(ctx, "%s/backend", nic_path_fe), 
NULL);
         val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", 
nic_path_fe));
         nics->backend_id = val ? strtoul(val, NULL, 10) : -1;
 
@@ -1930,17 +1942,14 @@ libxl_nicinfo *libxl_list_nics(libxl_ctx
         nics->rref_tx = val ? strtol(val, NULL, 10) : -1;
         val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, 
"%s/rx-ring-ref", nic_path_fe));
         nics->rref_rx = val ? strtol(val, NULL, 10) : -1;
-        nics->frontend = libxl_xs_read(ctx, XBT_NULL,
-                                       libxl_sprintf(ctx, "%s/frontend", 
nics->backend));
+        nics->frontend = xs_read(ctx->xsh, XBT_NULL,
+                                 libxl_sprintf(ctx, "%s/frontend", 
nics->backend), NULL);
         val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, 
"%s/frontend-id", nics->backend));
         nics->frontend_id = val ? strtoul(val, NULL, 10) : -1;
-        nics->script = libxl_xs_read(ctx, XBT_NULL,
-                                     libxl_sprintf(ctx, "%s/script", 
nics->backend));
-
-        libxl_free(ctx, nic_path_fe);
-    }
-
-    libxl_free(ctx, l);
+        nics->script = xs_read(ctx->xsh, XBT_NULL,
+                               libxl_sprintf(ctx, "%s/script", nics->backend), 
NULL);
+    }
+
     return res;
 }
 
@@ -2177,7 +2186,7 @@ retry_transaction:
     flexarray_set(back, boffset++, "state");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", 1));
     flexarray_set(back, boffset++, "domain");
-    flexarray_set(back, boffset++, libxl_domid_to_name(ctx, domid));
+    flexarray_set(back, boffset++, _libxl_domid_to_name(ctx, domid));
     flexarray_set(back, boffset++, "protocol");
     flexarray_set(back, boffset++, LIBXL_XENCONSOLE_PROTOCOL);
 
@@ -2234,7 +2243,7 @@ int libxl_device_vkb_add(libxl_ctx *ctx,
     flexarray_set(back, boffset++, "state");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", 1));
     flexarray_set(back, boffset++, "domain");
-    flexarray_set(back, boffset++, libxl_domid_to_name(ctx, domid));
+    flexarray_set(back, boffset++, _libxl_domid_to_name(ctx, domid));
 
     flexarray_set(front, foffset++, "backend-id");
     flexarray_set(front, foffset++, libxl_sprintf(ctx, "%d", 
vkb->backend_domid));
@@ -2411,7 +2420,7 @@ static int libxl_build_xenpv_qemu_args(l
         uint32_t guest_domid;
         if (libxl_is_stubdom(ctx, vfb->domid, &guest_domid)) {
             char *filename;
-            char *name = libxl_sprintf(ctx, "qemu-dm-%s", 
libxl_domid_to_name(ctx, guest_domid));
+            char *name = libxl_sprintf(ctx, "qemu-dm-%s", 
_libxl_domid_to_name(ctx, guest_domid));
             libxl_create_logfile(ctx, name, &filename);
             info->serial = libxl_sprintf(ctx, "file:%s", filename);
             free(filename);
@@ -2429,7 +2438,7 @@ static int libxl_build_xenpv_qemu_args(l
         info->extra[j] = NULL;
     }
     info->domid = vfb->domid;
-    info->dom_name = libxl_domid_to_name(ctx, vfb->domid);
+    info->dom_name = _libxl_domid_to_name(ctx, vfb->domid);
     info->device_model = libxl_abs_path(ctx, "qemu-dm", libxl_libexec_path());
     info->type = XENPV;
     return 0;
@@ -2475,7 +2484,7 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
     flexarray_set(back, boffset++, "state");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", 1));
     flexarray_set(back, boffset++, "domain");
-    flexarray_set(back, boffset++, libxl_domid_to_name(ctx, domid));
+    flexarray_set(back, boffset++, _libxl_domid_to_name(ctx, domid));
     flexarray_set(back, boffset++, "vnc");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", vfb->vnc));
     flexarray_set(back, boffset++, "vnclisten");
@@ -2648,6 +2657,18 @@ int libxl_get_physinfo(libxl_ctx *ctx, l
     return 0;
 }
 
+static void do_free_version_info(libxl_version_info *info)
+{
+    free(info->xen_version_extra);
+    free(info->compiler);
+    free(info->compile_by);
+    free(info->compile_domain);
+    free(info->compile_date);
+    free(info->capabilities);
+    free(info->changeset);
+    free(info->commandline);
+}
+
 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
 {
     union {
@@ -2667,20 +2688,21 @@ const libxl_version_info* libxl_get_vers
     xen_version = xc_version(ctx->xch, XENVER_version, NULL);
     info->xen_version_major = xen_version >> 16;
     info->xen_version_minor = xen_version & 0xFF;
+
     xc_version(ctx->xch, XENVER_extraversion, &u.xen_extra);
-    info->xen_version_extra = libxl_strdup(ctx, u.xen_extra);
+    info->xen_version_extra = strdup(u.xen_extra);
 
     xc_version(ctx->xch, XENVER_compile_info, &u.xen_cc);
-    info->compiler = libxl_strdup(ctx, u.xen_cc.compiler);
-    info->compile_by = libxl_strdup(ctx, u.xen_cc.compile_by);
-    info->compile_domain = libxl_strdup(ctx, u.xen_cc.compile_domain);
-    info->compile_date = libxl_strdup(ctx, u.xen_cc.compile_date);
+    info->compiler = strdup(u.xen_cc.compiler);
+    info->compile_by = strdup(u.xen_cc.compile_by);
+    info->compile_domain = strdup(u.xen_cc.compile_domain);
+    info->compile_date = strdup(u.xen_cc.compile_date);
 
     xc_version(ctx->xch, XENVER_capabilities, &u.xen_caps);
-    info->capabilities = libxl_strdup(ctx, u.xen_caps);
+    info->capabilities = strdup(u.xen_caps);
 
     xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset);
-    info->changeset = libxl_strdup(ctx, u.xen_chgset);
+    info->changeset = strdup(u.xen_chgset);
 
     xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms);
     info->virt_start = u.p_parms.virt_start;
@@ -2688,18 +2710,20 @@ const libxl_version_info* libxl_get_vers
     info->pagesize = xc_version(ctx->xch, XENVER_pagesize, NULL);
 
     xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline);
-    info->commandline = libxl_strdup(ctx, u.xen_commandline);
+    info->commandline = strdup(u.xen_commandline);
 
     return info;
 }
 
 libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
-                                       int *nb_vcpu, int *cpusize)
+                                       int *nb_vcpu, int *nrcpus)
 {
     libxl_vcpuinfo *ptr, *ret;
     xc_domaininfo_t domaininfo;
     xc_vcpuinfo_t vcpuinfo;
     xc_physinfo_t physinfo = { 0 };
+    uint64_t *cpumaps;
+    unsigned num_cpuwords;
 
     if (xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo) != 1) {
         XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting infolist");
@@ -2709,15 +2733,16 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
         XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting physinfo");
         return NULL;
     }
-    *cpusize = physinfo.max_cpu_id + 1;
-    ptr = libxl_calloc(ctx, domaininfo.max_vcpu_id + 1, sizeof 
(libxl_vcpuinfo));
+    *nrcpus = physinfo.max_cpu_id + 1;
+    ret = ptr = calloc(domaininfo.max_vcpu_id + 1, sizeof (libxl_vcpuinfo));
     if (!ptr) {
         return NULL;
     }
 
-    ret = ptr;
+    num_cpuwords = ((physinfo.max_cpu_id + 64) / 64);
+    cpumaps = calloc(num_cpuwords * sizeof(*cpumaps), domaininfo.max_vcpu_id + 
1);
     for (*nb_vcpu = 0; *nb_vcpu <= domaininfo.max_vcpu_id; ++*nb_vcpu, ++ptr) {
-        ptr->cpumap = libxl_calloc(ctx, (*cpusize + 63) / 64, sizeof 
(uint64_t));
+        ptr->cpumap = cpumaps + (num_cpuwords * *nb_vcpu);
         if (!ptr->cpumap) {
             return NULL;
         }
@@ -2725,7 +2750,8 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
             XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu info");
             return NULL;
         }
-        if (xc_vcpu_getaffinity(ctx->xch, domid, *nb_vcpu, ptr->cpumap, 
*cpusize) == -1) {
+        if (xc_vcpu_getaffinity(ctx->xch, domid, *nb_vcpu,
+            ptr->cpumap, ((*nrcpus) + 7) / 8) == -1) {
             XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu affinity");
             return NULL;
         }
@@ -2739,10 +2765,17 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
     return ret;
 }
 
+void libxl_free_vcpu_list(libxl_vcpuinfo *vcpu)
+{
+    if ( vcpu )
+        free(vcpu[0].cpumap);
+    free(vcpu);
+}
+
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
-                           uint64_t *cpumap, int cpusize)
-{
-    if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, cpusize)) {
+                           uint64_t *cpumap, int nrcpus)
+{
+    if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, (nrcpus + 7) / 
8)) {
         XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting vcpu affinity");
         return ERROR_FAIL;
     }
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl.h       Wed Aug 11 18:26:47 2010 +0100
@@ -511,6 +511,7 @@ int libxl_device_nic_add(libxl_ctx *ctx,
 int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic 
*nic);
 int libxl_device_nic_del(libxl_ctx *ctx, libxl_device_nic *nic, int wait);
 libxl_nicinfo *libxl_list_nics(libxl_ctx *ctx, uint32_t domid, unsigned int 
*nb);
+void libxl_free_nics_list(libxl_nicinfo *nics, unsigned int nb);
 
 int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid, 
libxl_device_console *console);
 
@@ -596,9 +597,10 @@ typedef struct {
 
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
 libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
-                                       int *nb_vcpu, int *cpusize);
+                                       int *nb_vcpu, int *nrcpus);
+void libxl_free_vcpu_list(libxl_vcpuinfo *vcpu);
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
-                           uint64_t *cpumap, int cpusize);
+                           uint64_t *cpumap, int nrcpus);
 int libxl_set_vcpucount(libxl_ctx *ctx, uint32_t domid, uint32_t count);
 
 int libxl_get_sched_id(libxl_ctx *ctx);
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c      Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl_internal.c      Wed Aug 11 18:26:47 2010 +0100
@@ -59,26 +59,26 @@ int libxl_ptr_add(libxl_ctx *ctx, void *
     return 0;
 }
 
-int libxl_free(libxl_ctx *ctx, void *ptr)
+void libxl_free(libxl_ctx *ctx, void *ptr)
 {
     int i;
 
     if (!ptr)
-        return 0;
+        return;
 
     /* remove the pointer from the tracked ptrs */
     for (i = 0; i < ctx->alloc_maxsize; i++) {
         if (ctx->alloc_ptrs[i] == ptr) {
             ctx->alloc_ptrs[i] = NULL;
             free(ptr);
-            return 0;
+            return;
         }
     }
     /* haven't find the pointer, really bad */
-    return -1;
-}
-
-int libxl_free_all(libxl_ctx *ctx)
+    abort();
+}
+
+void libxl_free_all(libxl_ctx *ctx)
 {
     void *ptr;
     int i;
@@ -88,7 +88,6 @@ int libxl_free_all(libxl_ctx *ctx)
         ctx->alloc_ptrs[i] = NULL;
         free(ptr);
     }
-    return 0;
 }
 
 void *libxl_zalloc(libxl_ctx *ctx, int bytes)
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Wed Aug 11 18:26:47 2010 +0100
@@ -25,6 +25,14 @@
 #include <xenctrl.h>
 #include "xentoollog.h"
 
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define _hidden __attribute__((visibility("hidden")))
+#define _protected __attribute__((visibility("protected")))
+#else
+#define _hidden
+#define _protected
+#endif
+
 #include "flexarray.h"
 #include "libxl_utils.h"
 
@@ -51,13 +59,13 @@
   /* all of these macros preserve errno (saving and restoring) */
 
 /* logging */
-void xl_logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+_hidden void xl_logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
              const char *file /* may be 0 */, int line /* ignored if !file */,
              const char *func /* may be 0 */,
              char *fmt, va_list al)
      __attribute__((format(printf,7,0)));
 
-void xl_log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+_hidden void xl_log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
             const char *file /* may be 0 */, int line /* ignored if !file */,
             const char *func /* may be 0 */,
             char *fmt, ...)
@@ -104,74 +112,74 @@ typedef struct {
                 (u)[0], (u)[1], (u)[2], (u)[3], (u)[4], (u)[5], (u)[6], 
(u)[7], \
                 (u)[8], (u)[9], (u)[10], (u)[11], (u)[12], (u)[13], (u)[14], 
(u)[15])
 
-int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char 
*kvs[]);
+_hidden int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, 
char *kvs[]);
 
 /* memory allocation tracking/helpers */
-int libxl_ptr_add(libxl_ctx *ctx, void *ptr);
-int libxl_free(libxl_ctx *ctx, void *ptr);
-int libxl_free_all(libxl_ctx *ctx);
-void *libxl_zalloc(libxl_ctx *ctx, int bytes);
-void *libxl_calloc(libxl_ctx *ctx, size_t nmemb, size_t size);
-char *libxl_sprintf(libxl_ctx *ctx, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 
3);
-char *libxl_strdup(libxl_ctx *ctx, const char *c);
-char *libxl_dirname(libxl_ctx *ctx, const char *s);
-
-char **libxl_xs_kvs_of_flexarray(libxl_ctx *ctx, flexarray_t *array, int 
length);
-int libxl_xs_writev(libxl_ctx *ctx, xs_transaction_t t,
+_hidden int libxl_ptr_add(libxl_ctx *ctx, void *ptr);
+_hidden void libxl_free(libxl_ctx *ctx, void *ptr);
+_hidden void libxl_free_all(libxl_ctx *ctx);
+_hidden void *libxl_zalloc(libxl_ctx *ctx, int bytes);
+_hidden void *libxl_calloc(libxl_ctx *ctx, size_t nmemb, size_t size);
+_hidden char *libxl_sprintf(libxl_ctx *ctx, const char *fmt, ...) 
PRINTF_ATTRIBUTE(2, 3);
+_hidden char *libxl_strdup(libxl_ctx *ctx, const char *c);
+_hidden char *libxl_dirname(libxl_ctx *ctx, const char *s);
+
+_hidden char **libxl_xs_kvs_of_flexarray(libxl_ctx *ctx, flexarray_t *array, 
int length);
+_hidden int libxl_xs_writev(libxl_ctx *ctx, xs_transaction_t t,
                     char *dir, char **kvs);
-int libxl_xs_write(libxl_ctx *ctx, xs_transaction_t t,
+_hidden int libxl_xs_write(libxl_ctx *ctx, xs_transaction_t t,
                    char *path, char *fmt, ...) PRINTF_ATTRIBUTE(4, 5);
-char *libxl_xs_get_dompath(libxl_ctx *ctx, uint32_t domid); // logs errs
-char *libxl_xs_read(libxl_ctx *ctx, xs_transaction_t t, char *path);
-char **libxl_xs_directory(libxl_ctx *ctx, xs_transaction_t t, char *path, 
unsigned int *nb);
+_hidden char *libxl_xs_get_dompath(libxl_ctx *ctx, uint32_t domid); // logs 
errs
+_hidden char *libxl_xs_read(libxl_ctx *ctx, xs_transaction_t t, char *path);
+_hidden char **libxl_xs_directory(libxl_ctx *ctx, xs_transaction_t t, char 
*path, unsigned int *nb);
 
 /* from xl_dom */
-int is_hvm(libxl_ctx *ctx, uint32_t domid);
-int get_shutdown_reason(libxl_ctx *ctx, uint32_t domid);
+_hidden int is_hvm(libxl_ctx *ctx, uint32_t domid);
+_hidden int get_shutdown_reason(libxl_ctx *ctx, uint32_t domid);
 #define dominfo_get_shutdown_reason(info) (((info)->flags >> 
XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask)
 
-int build_pre(libxl_ctx *ctx, uint32_t domid,
+_hidden int build_pre(libxl_ctx *ctx, uint32_t domid,
               libxl_domain_build_info *info, libxl_domain_build_state *state);
-int build_post(libxl_ctx *ctx, uint32_t domid,
+_hidden int build_post(libxl_ctx *ctx, uint32_t domid,
                libxl_domain_build_info *info, libxl_domain_build_state *state,
                char **vms_ents, char **local_ents);
 
-int build_pv(libxl_ctx *ctx, uint32_t domid,
+_hidden int build_pv(libxl_ctx *ctx, uint32_t domid,
              libxl_domain_build_info *info, libxl_domain_build_state *state);
-int build_hvm(libxl_ctx *ctx, uint32_t domid,
+_hidden int build_hvm(libxl_ctx *ctx, uint32_t domid,
               libxl_domain_build_info *info, libxl_domain_build_state *state);
 
-int restore_common(libxl_ctx *ctx, uint32_t domid,
+_hidden int restore_common(libxl_ctx *ctx, uint32_t domid,
                    libxl_domain_build_info *info, libxl_domain_build_state 
*state, int fd);
-int core_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int hvm, int live, 
int debug);
-int save_device_model(libxl_ctx *ctx, uint32_t domid, int fd);
-void libxl__userdata_destroyall(libxl_ctx *ctx, uint32_t domid);
+_hidden int core_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int hvm, int 
live, int debug);
+_hidden int save_device_model(libxl_ctx *ctx, uint32_t domid, int fd);
+_hidden void libxl__userdata_destroyall(libxl_ctx *ctx, uint32_t domid);
 
 /* from xl_device */
-char *device_disk_backend_type_of_phystype(libxl_disk_phystype phystype);
-char *device_disk_string_of_phystype(libxl_disk_phystype phystype);
-
-int device_physdisk_major_minor(const char *physpath, int *major, int *minor);
-int device_disk_dev_number(char *virtpath);
-
-int libxl_device_generic_add(libxl_ctx *ctx, libxl_device *device,
+_hidden char *device_disk_backend_type_of_phystype(libxl_disk_phystype 
phystype);
+_hidden char *device_disk_string_of_phystype(libxl_disk_phystype phystype);
+
+_hidden int device_physdisk_major_minor(const char *physpath, int *major, int 
*minor);
+_hidden int device_disk_dev_number(char *virtpath);
+
+_hidden int libxl_device_generic_add(libxl_ctx *ctx, libxl_device *device,
                              char **bents, char **fents);
-int libxl_device_del(libxl_ctx *ctx, libxl_device *dev, int wait);
-int libxl_device_destroy(libxl_ctx *ctx, char *be_path, int force);
-int libxl_devices_destroy(libxl_ctx *ctx, uint32_t domid, int force);
-int libxl_wait_for_device_model(libxl_ctx *ctx,
+_hidden int libxl_device_del(libxl_ctx *ctx, libxl_device *dev, int wait);
+_hidden int libxl_device_destroy(libxl_ctx *ctx, char *be_path, int force);
+_hidden int libxl_devices_destroy(libxl_ctx *ctx, uint32_t domid, int force);
+_hidden int libxl_wait_for_device_model(libxl_ctx *ctx,
                                 uint32_t domid, char *state,
                                 int (*check_callback)(libxl_ctx *ctx,
                                                       uint32_t domid,
                                                       const char *state,
                                                       void *userdata),
                                 void *check_callback_userdata);
-int libxl_wait_for_backend(libxl_ctx *ctx, char *be_path, char *state);
-int libxl_device_pci_reset(libxl_ctx *ctx, unsigned int domain, unsigned int 
bus,
+_hidden int libxl_wait_for_backend(libxl_ctx *ctx, char *be_path, char *state);
+_hidden int libxl_device_pci_reset(libxl_ctx *ctx, unsigned int domain, 
unsigned int bus,
                            unsigned int dev, unsigned int func);
 
 /* from xenguest (helper */
-int hvm_build_set_params(xc_interface *handle, uint32_t domid,
+_hidden int hvm_build_set_params(xc_interface *handle, uint32_t domid,
                          libxl_domain_build_info *info,
                          int store_evtchn, unsigned long *store_mfn,
                          int console_evtchn, unsigned long *console_mfn);
@@ -193,7 +201,7 @@ struct libxl_device_model_starting {
     int domid;
 };
 
-int libxl_spawn_spawn(libxl_ctx *ctx,
+_hidden int libxl_spawn_spawn(libxl_ctx *ctx,
                       libxl_device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(void *for_spawn, pid_t 
innerchild));
@@ -203,11 +211,11 @@ int libxl_spawn_spawn(libxl_ctx *ctx,
    *    0   caller is now the inner child, should probably call libxl_exec
    * Caller, may pass 0 for for_spawn, in which case no need to detach.
    */
-int libxl_spawn_detach(libxl_ctx *ctx,
+_hidden int libxl_spawn_detach(libxl_ctx *ctx,
                        libxl_spawn_starting *for_spawn);
   /* Logs errors.  Idempotent, but only permitted after successful
    * call to libxl_spawn_spawn, and no point calling it again if it fails. */
-int libxl_spawn_check(libxl_ctx *ctx,
+_hidden int libxl_spawn_check(libxl_ctx *ctx,
                       void *for_spawn);
   /* Logs errors but also returns them.
    * for_spawn must actually be a  libxl_spawn_starting*  but
@@ -216,19 +224,19 @@ int libxl_spawn_check(libxl_ctx *ctx,
 
  /* low-level stuff, for synchronous subprocesses etc. */
 
-void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, char 
**args); // logs errors, never returns
-void libxl_log_child_exitstatus(libxl_ctx *ctx,
+_hidden void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, 
char **args); // logs errors, never returns
+_hidden void libxl_log_child_exitstatus(libxl_ctx *ctx,
                                 const char *what, pid_t pid, int status);
 
-char *libxl_abs_path(libxl_ctx *ctx, char *s, const char *path);
+_hidden char *libxl_abs_path(libxl_ctx *ctx, char *s, const char *path);
 
 #define XL_LOG_DEBUG   XTL_DEBUG
 #define XL_LOG_INFO    XTL_INFO
 #define XL_LOG_WARNING XTL_WARN
 #define XL_LOG_ERROR   XTL_ERROR
 
-/* Error handling */
-int libxl_xc_error(int xc_err);
-
-#endif
-
+_hidden char *_libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
+_hidden char *_libxl_poolid_to_name(libxl_ctx *ctx, uint32_t poolid);
+
+#endif
+
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl_pci.c   Wed Aug 11 18:26:47 2010 +0100
@@ -228,7 +228,7 @@ static int libxl_create_pci_backend(libx
     flexarray_set(back, boffset++, "state");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", 1));
     flexarray_set(back, boffset++, "domain");
-    flexarray_set(back, boffset++, libxl_domid_to_name(ctx, domid));
+    flexarray_set(back, boffset++, _libxl_domid_to_name(ctx, domid));
     for (i = 0; i < num; i++) {
         flexarray_set(back, boffset++, libxl_sprintf(ctx, "key-%d", i));
         flexarray_set(back, boffset++, libxl_sprintf(ctx, PCI_BDF, 
pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func));
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/libxl_utils.c Wed Aug 11 18:26:47 2010 +0100
@@ -51,7 +51,14 @@ char *libxl_domid_to_name(libxl_ctx *ctx
 
     snprintf(path, sizeof(path), "/local/domain/%d/name", domid);
     s = xs_read(ctx->xsh, XBT_NULL, path, &len);
-    libxl_ptr_add(ctx, s);
+    return s;
+}
+
+char *_libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid)
+{
+    char *s = libxl_domid_to_name(ctx, domid);
+    if ( s )
+        libxl_ptr_add(ctx, s);
     return s;
 }
 
@@ -68,7 +75,7 @@ int libxl_name_to_domid(libxl_ctx *ctx, 
         return ERROR_NOMEM;
 
     for (i = 0; i < nb_domains; i++) {
-        domname = libxl_domid_to_name(ctx, dominfo[i].domid);
+        domname = _libxl_domid_to_name(ctx, dominfo[i].domid);
         if (!domname)
             continue;
         if (strcmp(domname, name) == 0) {
@@ -91,7 +98,14 @@ char *libxl_poolid_to_name(libxl_ctx *ct
         return "Pool-0";
     snprintf(path, sizeof(path), "/local/pool/%d/name", poolid);
     s = xs_read(ctx->xsh, XBT_NULL, path, &len);
-    libxl_ptr_add(ctx, s);
+    return s;
+}
+
+char *_libxl_poolid_to_name(libxl_ctx *ctx, uint32_t poolid)
+{
+    char *s = libxl_poolid_to_name(ctx, poolid);
+    if ( s )
+        libxl_ptr_add(ctx, s);
     return s;
 }
 
@@ -108,7 +122,7 @@ int libxl_name_to_poolid(libxl_ctx *ctx,
         return ERROR_NOMEM;
 
     for (i = 0; i < nb_pools; i++) {
-        poolname = libxl_poolid_to_name(ctx, poolinfo[i].poolid);
+        poolname = _libxl_poolid_to_name(ctx, poolinfo[i].poolid);
         if (!poolname)
             continue;
         if (strcmp(poolname, name) == 0) {
@@ -368,14 +382,14 @@ int libxl_mac_to_device_nic(libxl_ctx *c
 int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid,
                             const char *mac, libxl_device_nic *nic)
 {
-    libxl_nicinfo *nics;
-    unsigned int nb, i;
+    libxl_nicinfo *nics, *list;
+    unsigned int nb, i, j;
     uint8_t mac_n[6];
     uint8_t *a, *b;
     const char *tok;
     char *endptr;
 
-    nics = libxl_list_nics(ctx, domid, &nb);
+    list = nics = libxl_list_nics(ctx, domid, &nb);
     if (!nics) {
         return ERROR_FAIL;
     }
@@ -387,7 +401,7 @@ int libxl_mac_to_device_nic(libxl_ctx *c
         }
     }
     memset(nic, 0, sizeof (libxl_device_nic));
-    for (; nb; --nb, ++nics) {
+    for (j = 0; j < nb; ++j, ++nics) {
         for (i = 0, a = nics->mac, b = mac_n;
              (b < mac_n + 6) && (*a == *b); ++a, ++b)
             ;
@@ -397,12 +411,12 @@ int libxl_mac_to_device_nic(libxl_ctx *c
             nic->devid = nics->devid;
             memcpy(nic->mac, nics->mac, sizeof (nic->mac));
             nic->script = nics->script;
-            libxl_free(ctx, nics);
+            libxl_free_nics_list(list, nb);
             return 0;
         }
     }
 
-    libxl_free(ctx, nics);
+    libxl_free_nics_list(list, nb);
     return 0;
 }
 
@@ -422,6 +436,9 @@ int libxl_devid_to_device_nic(libxl_ctx 
     nic_path_be = libxl_xs_read(ctx, XBT_NULL,
                                 libxl_sprintf(ctx, "%s/backend", nic_path_fe));
     val = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend-id", 
nic_path_fe));
+    if ( NULL == val ) {
+        return ERROR_FAIL;
+    }
     nic->backend_domid = strtoul(val, NULL, 10);
     nic->devid = strtoul(devid, NULL, 10);
     libxl_free(ctx, val);
diff -r 786b163da49b -r 8bb9cfaca402 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Aug 11 18:26:47 2010 +0100
@@ -2154,8 +2154,10 @@ void list_domains(int verbose, const lib
 
     printf("Name                                        ID   Mem 
VCPUs\tState\tTime(s)\n");
     for (i = 0; i < nb_domain; i++) {
+        char *domname;
+        domname = libxl_domid_to_name(&ctx, info[i].domid);
         printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
-                libxl_domid_to_name(&ctx, info[i].domid),
+                domname,
                 info[i].domid,
                 (unsigned long) (info[i].max_memkb / 1024),
                 info[i].vcpu_online,
@@ -2166,6 +2168,7 @@ void list_domains(int verbose, const lib
                 info[i].shutdown_reason == SHUTDOWN_crash ? 'c' : '-',
                 info[i].dying ? 'd' : '-',
                 ((float)info[i].cpu_time / 1e9));
+        free(domname);
         if (verbose) {
             char *uuid = libxl_uuid2string(&ctx, info[i].uuid);
             printf(" %s", uuid);
@@ -2177,6 +2180,7 @@ void list_vm(void)
 void list_vm(void)
 {
     libxl_vminfo *info;
+    char *domname;
     int nb_vm, i;
 
     info = libxl_list_vm(&ctx, &nb_vm);
@@ -2187,12 +2191,14 @@ void list_vm(void)
     }
     printf("UUID                                  ID    name\n");
     for (i = 0; i < nb_vm; i++) {
+        domname = libxl_domid_to_name(&ctx, info[i].domid);
         printf(UUID_FMT "  %d    %-30s\n",
             info[i].uuid[0], info[i].uuid[1], info[i].uuid[2], info[i].uuid[3],
             info[i].uuid[4], info[i].uuid[5], info[i].uuid[6], info[i].uuid[7],
             info[i].uuid[8], info[i].uuid[9], info[i].uuid[10], 
info[i].uuid[11],
             info[i].uuid[12], info[i].uuid[13], info[i].uuid[14], 
info[i].uuid[15],
-            info[i].domid, libxl_domid_to_name(&ctx, info[i].domid));
+            info[i].domid, domname);
+        free(domname);
     }
     free(info);
 }
@@ -3197,10 +3203,13 @@ static void print_vcpuinfo(uint32_t tdom
     int i, l;
     uint64_t *cpumap;
     uint64_t pcpumap;
+    char *domname;
 
     /*      NAME  ID  VCPU */
+    domname = libxl_domid_to_name(&ctx, tdomid);
     printf("%-32s %5u %5u",
-           libxl_domid_to_name(&ctx, tdomid), tdomid, vcpuinfo->vcpuid);
+           domname, tdomid, vcpuinfo->vcpuid);
+    free(domname);
     if (!vcpuinfo->online) {
         /*      CPU STA */
         printf("%5c %3c%cp ", '-', '-', '-');
@@ -3213,7 +3222,7 @@ static void print_vcpuinfo(uint32_t tdom
     /*      TIM */
     printf("%9.1f  ", ((float)vcpuinfo->vcpu_time / 1e9));
     /* CPU AFFINITY */
-    pcpumap = nr_cpus > 64 ? -1 : ((1 << nr_cpus) - 1);
+    pcpumap = nr_cpus > 64 ? (uint64_t)-1 : ((1ULL << nr_cpus) - 1);
     for (cpumap = vcpuinfo->cpumap; nr_cpus; ++cpumap) {
         if (*cpumap < pcpumap) {
             break;
@@ -3259,9 +3268,9 @@ void vcpulist(int argc, char **argv)
 void vcpulist(int argc, char **argv)
 {
     libxl_dominfo *dominfo;
-    libxl_vcpuinfo *vcpuinfo;
+    libxl_vcpuinfo *vcpuinfo, *list = NULL;
     libxl_physinfo physinfo;
-    int nb_vcpu, nb_domain, cpusize;
+    int nb_vcpu, nb_domain, nrcpus;
 
     if (libxl_get_physinfo(&ctx, &physinfo) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
@@ -3275,26 +3284,29 @@ void vcpulist(int argc, char **argv)
             goto vcpulist_out;
         }
         for (; nb_domain > 0; --nb_domain, ++dominfo) {
-            if (!(vcpuinfo = libxl_list_vcpu(&ctx, dominfo->domid, &nb_vcpu, 
&cpusize))) {
+            if (!(list = vcpuinfo = libxl_list_vcpu(&ctx, dominfo->domid, 
&nb_vcpu,
+                &nrcpus))) {
                 fprintf(stderr, "libxl_list_vcpu failed.\n");
                 goto vcpulist_out;
             }
             for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
                 print_vcpuinfo(dominfo->domid, vcpuinfo, physinfo.nr_cpus);
             }
+            libxl_free_vcpu_list(list);
         }
     } else {
         for (; argc > 0; ++argv, --argc) {
             if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) {
                 fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             }
-            if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, 
&cpusize))) {
+            if (!(list = vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, 
&nrcpus))) {
                 fprintf(stderr, "libxl_list_vcpu failed.\n");
                 goto vcpulist_out;
             }
             for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
                 print_vcpuinfo(domid, vcpuinfo, physinfo.nr_cpus);
             }
+            libxl_free_vcpu_list(list);
         }
     }
   vcpulist_out:
@@ -3607,11 +3619,14 @@ static void sched_credit_domain_output(
 static void sched_credit_domain_output(
     int domid, libxl_sched_credit *scinfo)
 {
+    char *domname;
+    domname = libxl_domid_to_name(&ctx, domid);
     printf("%-33s %4d %6d %4d\n",
-        libxl_domid_to_name(&ctx, domid),
+        domname,
         domid,
         scinfo->weight,
         scinfo->cap);
+    free(domname);
 }
 
 int main_sched_credit(int argc, char **argv)
@@ -3757,6 +3772,7 @@ int main_domname(int argc, char **argv)
     }
 
     printf("%s\n", domname);
+    free(domname);
 
     return 0;
 }
@@ -4044,8 +4060,8 @@ int main_networklist(int argc, char **ar
 int main_networklist(int argc, char **argv)
 {
     int opt;
-    libxl_nicinfo *nics;
-    unsigned int nb;
+    libxl_nicinfo *nics, *list;
+    unsigned int nb, i;
 
     if (argc < 3) {
         help("network-list");
@@ -4070,10 +4086,10 @@ int main_networklist(int argc, char **ar
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        if (!(nics = libxl_list_nics(&ctx, domid, &nb))) {
+        if (!(list = nics = libxl_list_nics(&ctx, domid, &nb))) {
             continue;
         }
-        for (; nb > 0; --nb, ++nics) {
+        for (i = 0; i < nb; ++i, ++nics) {
             /* Idx BE */
             printf("%-3d %-2d ", nics->devid, nics->backend_id);
             /* MAC */
@@ -4085,6 +4101,7 @@ int main_networklist(int argc, char **ar
                    nics->devid, nics->state, nics->evtch,
                    nics->rref_tx, nics->rref_rx, nics->backend);
         }
+        libxl_free_nics_list(list, nb);
     }
     return 0;
 }
@@ -4517,6 +4534,7 @@ static void print_dom0_uptime(int short_
     uint32_t uptime = 0;
     char *uptime_str = NULL;
     char *now_str = NULL;
+    char *domname;
 
     fd = open("/proc/uptime", O_RDONLY);
     if (fd == -1)
@@ -4531,24 +4549,25 @@ static void print_dom0_uptime(int short_
     strtok(buf, " ");
     uptime = strtoul(buf, NULL, 10);
 
+    domname = libxl_domid_to_name(&ctx, 0);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
         uptime_str = uptime_to_string(uptime, 1);
         printf(" %s up %s, %s (%d)\n", now_str, uptime_str,
-               libxl_domid_to_name(&ctx, 0), 0);
+               domname, 0);
     }
     else
     {
+        now_str = NULL;
         uptime_str = uptime_to_string(uptime, 0);
-        printf("%-33s %4d %s\n", libxl_domid_to_name(&ctx, 0),
+        printf("%-33s %4d %s\n", domname,
                0, uptime_str);
     }
 
-    if (now_str)
-        free(now_str);
-    if (uptime_str)
-        free(uptime_str);
+    free(now_str);
+    free(uptime_str);
+    free(domname);
     return;
 err:
     fprintf(stderr, "Can not get Dom0 uptime.\n");
@@ -4561,29 +4580,31 @@ static void print_domU_uptime(uint32_t d
     uint32_t uptime = 0;
     char *uptime_str = NULL;
     char *now_str = NULL;
+    char *domname;
 
     s_time = libxl_vm_get_start_time(&ctx, domuid);
     if (s_time == -1)
         return;
     uptime = now - s_time;
+    domname = libxl_domid_to_name(&ctx, domuid);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
         uptime_str = uptime_to_string(uptime, 1);
         printf(" %s up %s, %s (%d)\n", now_str, uptime_str,
-               libxl_domid_to_name(&ctx, domuid), domuid);
+               domname, domuid);
     }
     else
     {
+        now_str = NULL;
         uptime_str = uptime_to_string(uptime, 0);
-        printf("%-33s %4d %s\n", libxl_domid_to_name(&ctx, domuid),
+        printf("%-33s %4d %s\n", domname,
                domuid, uptime_str);
     }
 
-    if (now_str)
-        free(now_str);
-    if (uptime_str)
-        free(uptime_str);
+    free(domname);
+    free(now_str);
+    free(uptime_str);
     return;
 }
 
diff -r 786b163da49b -r 8bb9cfaca402 tools/misc/Makefile
--- a/tools/misc/Makefile       Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/misc/Makefile       Wed Aug 11 18:26:47 2010 +0100
@@ -52,7 +52,7 @@ clean:
        $(CC) -c $(CFLAGS) -o $@ $<
 
 xen-hvmctx xen-hvmcrash xenperf xenpm gtracestat xenlockprof xen-hptool 
xenwatchdogd: %: %.o Makefile
-       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDFLAGS_libxenctrl) 
$(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
+       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) 
$(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
 
 gtraceview: %: %.o Makefile
        $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(CURSES_LIBS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/ocaml/common.make
--- a/tools/ocaml/common.make   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/ocaml/common.make   Wed Aug 11 18:26:47 2010 +0100
@@ -20,7 +20,7 @@ OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -
 #LDFLAGS = -cclib -L./
 
 DESTDIR ?= /
-VERSION := echo 0.0
+VERSION := 4.1
 
 OCAMLABI = $(shell $(OCAMLC) -version)
 OCAMLLIBDIR = $(shell $(OCAMLC) -where)
diff -r 786b163da49b -r 8bb9cfaca402 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c    Wed Aug 11 18:26:47 2010 +0100
@@ -34,6 +34,11 @@ struct caml_logger {
        char log_buf[2048];
 };
 
+typedef struct caml_gc {
+       int offset;
+       void *ptrs[64];
+} caml_gc;
+
 void log_vmessage(struct xentoollog_logger *logger, xentoollog_level level,
                   int errnoval, const char *context, const char *format, 
va_list al)
 {
@@ -46,17 +51,53 @@ void log_destroy(struct xentoollog_logge
 void log_destroy(struct xentoollog_logger *logger)
 {
 }
+
+#define INIT_STRUCT() libxl_ctx ctx; struct caml_logger lg; struct caml_gc gc; 
gc.offset = 0;
 
 #define INIT_CTX()  \
        lg.logger.vmessage = log_vmessage; \
        lg.logger.destroy = log_destroy; \
        lg.logger.progress = NULL; \
+       caml_enter_blocking_section(); \
        ret = libxl_ctx_init(&ctx, LIBXL_VERSION, (struct xentoollog_logger *) 
&lg); \
        if (ret != 0) \
                failwith_xl("cannot init context", &lg);
 
 #define FREE_CTX()  \
+       gc_free(&gc); \
+       caml_leave_blocking_section(); \
        libxl_ctx_free(&ctx)
+
+static void * gc_calloc(caml_gc *gc, size_t nmemb, size_t size)
+{
+       void *ptr;
+       ptr = calloc(nmemb, size);
+       if (!ptr)
+               caml_raise_out_of_memory();
+       gc->ptrs[gc->offset++] = ptr;
+       return ptr;
+}
+
+static char * dup_String_val(caml_gc *gc, value s)
+{
+       int len;
+       char *c;
+       len = caml_string_length(s);
+       c = calloc(len + 1, sizeof(char));
+       if (!c)
+               caml_raise_out_of_memory();
+       gc->ptrs[gc->offset++] = c;
+       memcpy(c, String_val(s), len);
+       return c;
+}
+
+static void gc_free(caml_gc *gc)
+{
+       int i;
+       for (i = 0; i < gc->offset; i++) {
+               free(gc->ptrs[i]);
+       }
+}
 
 void failwith_xl(char *fname, struct caml_logger *lg)
 {
@@ -65,7 +106,7 @@ void failwith_xl(char *fname, struct cam
        caml_raise_with_string(*caml_named_value("xl.error"), s);
 }
 
-static int string_string_tuple_array_val (char ***c_val, value v)
+static int string_string_tuple_array_val (caml_gc *gc, char ***c_val, value v)
 {
        CAMLparam1(v);
        CAMLlocal1(a);
@@ -74,19 +115,19 @@ static int string_string_tuple_array_val
 
        for (i = 0, a = Field(v, 5); a != Val_emptylist; a = Field(a, 1)) { 
i++; }
 
-       array = calloc((i + 1) * 2, sizeof(char *));
+       array = gc_calloc(gc, (i + 1) * 2, sizeof(char *));
        if (!array)
                return 1;
        for (i = 0, a = Field(v, 5); a != Val_emptylist; a = Field(a, 1), i++) {
                value b = Field(a, 0);
-               array[i * 2] = String_val(Field(b, 0));
-               array[i * 2 + 1] = String_val(Field(b, 1));
+               array[i * 2] = dup_String_val(gc, Field(b, 0));
+               array[i * 2 + 1] = dup_String_val(gc, Field(b, 1));
        }
        *c_val = array;
        CAMLreturn(0);
 }
 
-static int domain_create_info_val (libxl_domain_create_info *c_val, value v)
+static int domain_create_info_val (caml_gc *gc, libxl_domain_create_info 
*c_val, value v)
 {
        CAMLparam1(v);
        CAMLlocal1(a);
@@ -96,20 +137,20 @@ static int domain_create_info_val (libxl
        c_val->hap = Bool_val(Field(v, 1));
        c_val->oos = Bool_val(Field(v, 2));
        c_val->ssidref = Int32_val(Field(v, 3));
-       c_val->name = String_val(Field(v, 4));
+       c_val->name = dup_String_val(gc, Field(v, 4));
        a = Field(v, 5);
        for (i = 0; i < 16; i++)
                c_val->uuid[i] = Int_val(Field(a, i));
-       string_string_tuple_array_val(&(c_val->xsdata), Field(v, 6));
-       string_string_tuple_array_val(&(c_val->platformdata), Field(v, 7));
+       string_string_tuple_array_val(gc, &(c_val->xsdata), Field(v, 6));
+       string_string_tuple_array_val(gc, &(c_val->platformdata), Field(v, 7));
 
        c_val->poolid = Int32_val(Field(v, 8));
-       c_val->poolname = String_val(Field(v, 9));
-
-       CAMLreturn(0);
-}
-
-static int domain_build_info_val (libxl_domain_build_info *c_val, value v)
+       c_val->poolname = dup_String_val(gc, Field(v, 9));
+
+       CAMLreturn(0);
+}
+
+static int domain_build_info_val (caml_gc *gc, libxl_domain_build_info *c_val, 
value v)
 {
        CAMLparam1(v);
        CAMLlocal1(infopriv);
@@ -120,7 +161,7 @@ static int domain_build_info_val (libxl_
        c_val->target_memkb = Int64_val(Field(v, 3));
        c_val->video_memkb = Int64_val(Field(v, 4));
        c_val->shadow_memkb = Int64_val(Field(v, 5));
-       c_val->kernel.path = String_val(Field(v, 6));
+       c_val->kernel.path = dup_String_val(gc, Field(v, 6));
        c_val->hvm = Tag_val(Field(v, 7)) == 0;
        infopriv = Field(Field(v, 7), 0);
        if (c_val->hvm) {
@@ -129,28 +170,28 @@ static int domain_build_info_val (libxl_
                c_val->u.hvm.acpi = Bool_val(Field(infopriv, 2));
                c_val->u.hvm.nx = Bool_val(Field(infopriv, 3));
                c_val->u.hvm.viridian = Bool_val(Field(infopriv, 4));
-               c_val->u.hvm.timeoffset = String_val(Field(infopriv, 5));
+               c_val->u.hvm.timeoffset = dup_String_val(gc, Field(infopriv, 
5));
                c_val->u.hvm.timer_mode = Int_val(Field(infopriv, 6));
                c_val->u.hvm.hpet = Int_val(Field(infopriv, 7));
                c_val->u.hvm.vpt_align = Int_val(Field(infopriv, 8));
        } else {
                c_val->u.pv.slack_memkb = Int64_val(Field(infopriv, 0));
-               c_val->u.pv.cmdline = String_val(Field(infopriv, 1));
-               c_val->u.pv.ramdisk.path = String_val(Field(infopriv, 2));
-               c_val->u.pv.features = String_val(Field(infopriv, 3));
+               c_val->u.pv.cmdline = dup_String_val(gc, Field(infopriv, 1));
+               c_val->u.pv.ramdisk.path = dup_String_val(gc, Field(infopriv, 
2));
+               c_val->u.pv.features = dup_String_val(gc, Field(infopriv, 3));
        }
 
        CAMLreturn(0);
 }
 
-static int device_disk_val(libxl_device_disk *c_val, value v)
+static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
 {
        CAMLparam1(v);
 
        c_val->backend_domid = Int_val(Field(v, 0));
-       c_val->physpath = String_val(Field(v, 1));
+       c_val->physpath = dup_String_val(gc, Field(v, 1));
        c_val->phystype = (Int_val(Field(v, 2))) + PHYSTYPE_QCOW;
-       c_val->virtpath = String_val(Field(v, 3));
+       c_val->virtpath = dup_String_val(gc, Field(v, 3));
        c_val->unpluggable = Bool_val(Field(v, 4));
        c_val->readwrite = Bool_val(Field(v, 5));
        c_val->is_cdrom = Bool_val(Field(v, 6));
@@ -158,7 +199,7 @@ static int device_disk_val(libxl_device_
        CAMLreturn(0);
 }
 
-static int device_nic_val(libxl_device_nic *c_val, value v)
+static int device_nic_val(caml_gc *gc, libxl_device_nic *c_val, value v)
 {
        CAMLparam1(v);
        int i;
@@ -166,7 +207,7 @@ static int device_nic_val(libxl_device_n
        c_val->backend_domid = Int_val(Field(v, 0));
        c_val->devid = Int_val(Field(v, 1));
        c_val->mtu = Int_val(Field(v, 2));
-       c_val->model = String_val(Field(v, 3));
+       c_val->model = dup_String_val(gc, Field(v, 3));
 
        if (Wosize_val(Field(v, 4)) != 6) {
                ret = 1;
@@ -176,16 +217,16 @@ static int device_nic_val(libxl_device_n
                c_val->mac[i] = Int_val(Field(Field(v, 4), i));
 
        /* not handling c_val->ip */
-       c_val->bridge = String_val(Field(v, 5));
-       c_val->ifname = String_val(Field(v, 6));
-       c_val->script = String_val(Field(v, 7));
+       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;
 
 out:
        CAMLreturn(ret);
 }
 
-static int device_console_val(libxl_device_console *c_val, value v)
+static int device_console_val(caml_gc *gc, libxl_device_console *c_val, value 
v)
 {
        CAMLparam1(v);
 
@@ -196,7 +237,7 @@ static int device_console_val(libxl_devi
        CAMLreturn(0);
 }
 
-static int device_vkb_val(libxl_device_vkb *c_val, value v)
+static int device_vkb_val(caml_gc *gc, libxl_device_vkb *c_val, value v)
 {
        CAMLparam1(v);
 
@@ -206,26 +247,26 @@ static int device_vkb_val(libxl_device_v
        CAMLreturn(0);
 }
 
-static int device_vfb_val(libxl_device_vfb *c_val, value v)
+static int device_vfb_val(caml_gc *gc, libxl_device_vfb *c_val, value v)
 {
        CAMLparam1(v);
 
        c_val->backend_domid = Int_val(Field(v, 0));
        c_val->devid = Int_val(Field(v, 1));
        c_val->vnc = Bool_val(Field(v, 2));
-       c_val->vnclisten = String_val(Field(v, 3));
-       c_val->vncpasswd = String_val(Field(v, 4));
+       c_val->vnclisten = dup_String_val(gc, Field(v, 3));
+       c_val->vncpasswd = dup_String_val(gc, Field(v, 4));
        c_val->vncdisplay = Int_val(Field(v, 5));
-       c_val->keymap = String_val(Field(v, 6));
+       c_val->keymap = dup_String_val(gc, Field(v, 6));
        c_val->sdl = Bool_val(Field(v, 7));
        c_val->opengl = Bool_val(Field(v, 8));
-       c_val->display = String_val(Field(v, 9));
-       c_val->xauthority = String_val(Field(v, 10));
-
-       CAMLreturn(0);
-}
-
-static int device_pci_val(libxl_device_pci *c_val, value v)
+       c_val->display = dup_String_val(gc, Field(v, 9));
+       c_val->xauthority = dup_String_val(gc, Field(v, 10));
+
+       CAMLreturn(0);
+}
+
+static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v)
 {
        CAMLparam1(v);
 
@@ -238,7 +279,7 @@ static int device_pci_val(libxl_device_p
        CAMLreturn(0);
 }
 
-static int sched_credit_val(libxl_sched_credit *c_val, value v)
+static int sched_credit_val(caml_gc *gc, libxl_sched_credit *c_val, value v)
 {
        CAMLparam1(v);
        c_val->weight = Int_val(Field(v, 0));
@@ -246,7 +287,7 @@ static int sched_credit_val(libxl_sched_
        CAMLreturn(0);
 }
 
-static int domain_build_state_val(libxl_domain_build_state *c_val, value v)
+static int domain_build_state_val(caml_gc *gc, libxl_domain_build_state 
*c_val, value v)
 {
        CAMLparam1(v);
 
@@ -315,12 +356,12 @@ value stub_xl_domain_make(value info)
 value stub_xl_domain_make(value info)
 {
        CAMLparam1(info);
-       libxl_ctx ctx; struct caml_logger lg;
        uint32_t domid;
        libxl_domain_create_info c_info;
        int ret;
-
-       domain_create_info_val (&c_info, info);
+       INIT_STRUCT();
+
+       domain_create_info_val (&gc, &c_info, info);
 
        INIT_CTX();
 
@@ -330,9 +371,6 @@ value stub_xl_domain_make(value info)
 
        FREE_CTX();
 
-       free(c_info.xsdata);
-       free(c_info.platformdata);
-
        CAMLreturn(Val_int(domid));
 }
 
@@ -340,13 +378,13 @@ value stub_xl_domain_build(value info, v
 {
        CAMLparam2(info, domid);
        CAMLlocal1(result);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_domain_build_info c_info;
        libxl_domain_build_state c_state;
        int ret;
        int c_domid;
-
-       domain_build_info_val (&c_info, info);
+       INIT_STRUCT();
+
+       domain_build_info_val (&gc, &c_info, info);
        c_domid = Int_val(domid);
 
        INIT_CTX();
@@ -365,10 +403,10 @@ value stub_xl_disk_add(value info, value
 {
        CAMLparam2(info, domid);
        libxl_device_disk c_info;
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
-
-       device_disk_val(&c_info, info);
+       int ret;
+       INIT_STRUCT();
+
+       device_disk_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -383,10 +421,10 @@ value stub_xl_disk_remove(value info, va
 {
        CAMLparam2(info, domid);
        libxl_device_disk c_info;
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
-
-       device_disk_val(&c_info, info);
+       int ret;
+       INIT_STRUCT();
+
+       device_disk_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -400,11 +438,11 @@ value stub_xl_nic_add(value info, value 
 value stub_xl_nic_add(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_nic c_info;
        int ret;
-
-       device_nic_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_nic_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -418,11 +456,11 @@ value stub_xl_nic_remove(value info, val
 value stub_xl_nic_remove(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_nic c_info;
        int ret;
-
-       device_nic_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_nic_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -436,13 +474,13 @@ value stub_xl_console_add(value info, va
 value stub_xl_console_add(value info, value state, value domid)
 {
        CAMLparam3(info, state, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_console c_info;
        libxl_domain_build_state c_state;
        int ret;
-
-       device_console_val(&c_info, info);
-       domain_build_state_val(&c_state, state);
+       INIT_STRUCT();
+
+       device_console_val(&gc, &c_info, info);
+       domain_build_state_val(&gc, &c_state, state);
        c_info.domid = Int_val(domid);
        c_info.build_state = &c_state;
 
@@ -457,11 +495,11 @@ value stub_xl_vkb_add(value info, value 
 value stub_xl_vkb_add(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_vkb c_info;
        int ret;
-
-       device_vkb_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_vkb_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -476,8 +514,8 @@ value stub_xl_vkb_clean_shutdown(value d
 value stub_xl_vkb_clean_shutdown(value domid)
 {
        CAMLparam1(domid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_device_vkb_clean_shutdown(&ctx, Int_val(domid));
@@ -491,8 +529,8 @@ value stub_xl_vkb_hard_shutdown(value do
 value stub_xl_vkb_hard_shutdown(value domid)
 {
        CAMLparam1(domid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_device_vkb_hard_shutdown(&ctx, Int_val(domid));
@@ -506,11 +544,11 @@ value stub_xl_vfb_add(value info, value 
 value stub_xl_vfb_add(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_vfb c_info;
        int ret;
-
-       device_vfb_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_vfb_val(&gc, &c_info, info);
        c_info.domid = Int_val(domid);
 
        INIT_CTX();
@@ -525,8 +563,8 @@ value stub_xl_vfb_clean_shutdown(value d
 value stub_xl_vfb_clean_shutdown(value domid)
 {
        CAMLparam1(domid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_device_vfb_clean_shutdown(&ctx, Int_val(domid));
@@ -540,8 +578,8 @@ value stub_xl_vfb_hard_shutdown(value do
 value stub_xl_vfb_hard_shutdown(value domid)
 {
        CAMLparam1(domid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_device_vfb_hard_shutdown(&ctx, Int_val(domid));
@@ -555,11 +593,11 @@ value stub_xl_pci_add(value info, value 
 value stub_xl_pci_add(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_pci c_info;
        int ret;
-
-       device_pci_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_pci_val(&gc, &c_info, info);
 
        INIT_CTX();
        ret = libxl_device_pci_add(&ctx, Int_val(domid), &c_info);
@@ -573,11 +611,11 @@ value stub_xl_pci_remove(value info, val
 value stub_xl_pci_remove(value info, value domid)
 {
        CAMLparam2(info, domid);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_device_pci c_info;
        int ret;
-
-       device_pci_val(&c_info, info);
+       INIT_STRUCT();
+
+       device_pci_val(&gc, &c_info, info);
 
        INIT_CTX();
        ret = libxl_device_pci_remove(&ctx, Int_val(domid), &c_info);
@@ -591,8 +629,8 @@ value stub_xl_pci_shutdown(value domid)
 value stub_xl_pci_shutdown(value domid)
 {
        CAMLparam1(domid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_device_pci_shutdown(&ctx, Int_val(domid));
@@ -606,8 +644,8 @@ value stub_xl_button_press(value domid, 
 value stub_xl_button_press(value domid, value button)
 {
        CAMLparam2(domid, button);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
        
        INIT_CTX();
        ret = libxl_button_press(&ctx, Int_val(domid), Int_val(button) + 
POWER_BUTTON);
@@ -622,9 +660,9 @@ value stub_xl_physinfo(value unit)
 {
        CAMLparam1(unit);
        CAMLlocal1(physinfo);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_physinfo c_physinfo;
        int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_get_physinfo(&ctx, &c_physinfo);
@@ -640,9 +678,9 @@ value stub_xl_sched_credit_domain_get(va
 {
        CAMLparam1(domid);
        CAMLlocal1(scinfo);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_sched_credit c_scinfo;
        int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_sched_credit_domain_get(&ctx, Int_val(domid), &c_scinfo);
@@ -657,11 +695,11 @@ value stub_xl_sched_credit_domain_set(va
 value stub_xl_sched_credit_domain_set(value domid, value scinfo)
 {
        CAMLparam2(domid, scinfo);
-       libxl_ctx ctx; struct caml_logger lg;
        libxl_sched_credit c_scinfo;
        int ret;
-
-       sched_credit_val(&c_scinfo, scinfo);
+       INIT_STRUCT();
+
+       sched_credit_val(&gc, &c_scinfo, scinfo);
 
        INIT_CTX();
        ret = libxl_sched_credit_domain_set(&ctx, Int_val(domid), &c_scinfo);
@@ -675,11 +713,14 @@ value stub_xl_send_trigger(value domid, 
 value stub_xl_send_trigger(value domid, value trigger, value vcpuid)
 {
        CAMLparam3(domid, trigger, vcpuid);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
-
-       INIT_CTX();
-       ret = libxl_send_trigger(&ctx, Int_val(domid), String_val(trigger), 
Int_val(vcpuid));
+       int ret;
+       char *c_trigger;
+       INIT_STRUCT();
+
+       c_trigger = dup_String_val(&gc, trigger);
+
+       INIT_CTX();
+       ret = libxl_send_trigger(&ctx, Int_val(domid), c_trigger, 
Int_val(vcpuid));
        if (ret != 0)
                failwith_xl("send_trigger", &lg);
        FREE_CTX();
@@ -689,8 +730,8 @@ value stub_xl_send_sysrq(value domid, va
 value stub_xl_send_sysrq(value domid, value sysrq)
 {
        CAMLparam2(domid, sysrq);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
+       int ret;
+       INIT_STRUCT();
 
        INIT_CTX();
        ret = libxl_send_sysrq(&ctx, Int_val(domid), Int_val(sysrq));
@@ -703,11 +744,14 @@ value stub_xl_send_debug_keys(value keys
 value stub_xl_send_debug_keys(value keys)
 {
        CAMLparam1(keys);
-       libxl_ctx ctx; struct caml_logger lg;
-       int ret;
-
-       INIT_CTX();
-       ret = libxl_send_debug_keys(&ctx, String_val(keys));
+       int ret;
+       char *c_keys;
+       INIT_STRUCT();
+
+       c_keys = dup_String_val(&gc, keys);
+
+       INIT_CTX();
+       ret = libxl_send_debug_keys(&ctx, c_keys);
        if (ret != 0)
                failwith_xl("send_debug_keys", &lg);
        FREE_CTX();
diff -r 786b163da49b -r 8bb9cfaca402 tools/python/xen/util/vscsi_util.py
--- a/tools/python/xen/util/vscsi_util.py       Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/python/xen/util/vscsi_util.py       Wed Aug 11 18:26:47 2010 +0100
@@ -97,7 +97,7 @@ def _vscsi_get_scsidevices_by_lsscsi(opt
     devices = []
 
     for scsiinfo in os.popen('{ lsscsi -g %s; } 2>/dev/null' % 
option).readlines():
-        s = scsiinfo.split()
+        s = scsiinfo.replace(']', '] ').split()
         hctl = s[0][1:-1]
         try:
             devname = s[-2].split('/dev/')[1]
diff -r 786b163da49b -r 8bb9cfaca402 tools/security/Makefile
--- a/tools/security/Makefile   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/security/Makefile   Wed Aug 11 18:26:47 2010 +0100
@@ -76,7 +76,7 @@ build: $(ACM_INST_TOOLS) $(ACM_NOINST_TO
        chmod 700 $(ACM_SCRIPTS)
 
 xensec_tool: $(OBJS_TOOL)
-       $(CC) -g $(CFLAGS) $(LDFLAGS) -O0 -o $@ $^ $(LDFLAGS_libxenctrl)
+       $(CC) -g $(CFLAGS) $(LDFLAGS) -O0 -o $@ $^ $(LDLIBS_libxenctrl)
 
 xensec_gen: xensec_gen.py
        cp -f $^ $@
diff -r 786b163da49b -r 8bb9cfaca402 tools/vnet/libxutil/Makefile
--- a/tools/vnet/libxutil/Makefile      Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/vnet/libxutil/Makefile      Wed Aug 11 18:26:47 2010 +0100
@@ -52,7 +52,7 @@ libxutil.so.$(MAJOR): libxutil.so.$(MAJO
        ln -sf $^ $@
 
 libxutil.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
-       $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxutil.so.$(MAJOR) 
$(SHLIB_CFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxutil.so.$(MAJOR) 
$(SHLIB_LDFLAGS) -o $@ $^
 
 libxutil.a: $(LIB_OBJS)
        $(AR) rc $@ $^
diff -r 786b163da49b -r 8bb9cfaca402 tools/xcutils/Makefile
--- a/tools/xcutils/Makefile    Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xcutils/Makefile    Wed Aug 11 18:26:47 2010 +0100
@@ -16,7 +16,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_
 
 PROGRAMS = xc_restore xc_save readnotes lsevtchn
 
-LDLIBS   = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
+LDLIBS   = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
 
 .PHONY: all
 all: build
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenbackendd/Makefile
--- a/tools/xenbackendd/Makefile        Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenbackendd/Makefile        Wed Aug 11 18:26:47 2010 +0100
@@ -15,7 +15,7 @@ CFLAGS  += -Werror
 CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenstore)
 CPPFLAGS += -DXEN_SCRIPT_DIR="\"$(XEN_SCRIPT_DIR)\""
-LDFLAGS += $(LDFLAGS_libxenstore)
+LDLIBS  += $(LDLIBS_libxenstore)
 
 SBIN = xenbackendd
 
@@ -36,6 +36,6 @@ clean:
 
 
 %: %.c Makefile
-       $(CC) $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) -o $@
+       $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenmon/Makefile
--- a/tools/xenmon/Makefile     Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenmon/Makefile     Wed Aug 11 18:26:47 2010 +0100
@@ -16,7 +16,7 @@ CFLAGS  += -Werror
 CFLAGS  += -Werror
 CFLAGS  += -I $(XEN_XC)
 CFLAGS  += $(CFLAGS_libxenctrl)
-LDFLAGS += $(LDFLAGS_libxenctrl)
+LDLIBS  += $(LDLIBS_libxenctrl)
 
 BIN = xentrace_setmask xenbaked
 SCRIPTS = xenmon.py
@@ -42,8 +42,8 @@ clean:
 
 
 %: %.c Makefile
-       $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
 xentrace_%: %.c Makefile
-       $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenpaging/Makefile
--- a/tools/xenpaging/Makefile  Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenpaging/Makefile  Wed Aug 11 18:26:47 2010 +0100
@@ -4,7 +4,7 @@ CFLAGS   += -I $(XEN_XC)
 CFLAGS   += -I $(XEN_XC)
 CFLAGS   += -I ./
 CFLAGS   += $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore)
-LDFLAGS  += $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore)
+LDLIBS  += $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore)
 
 POLICY    = default
 
@@ -15,11 +15,8 @@ CFLAGS   += -Wno-unused
 CFLAGS   += -Wno-unused
 CFLAGS   += -g
 
-#CFLAGS   += -Wl,-rpath,..
 CFLAGS   += -Wp,-MD,.$(@F).d
 DEPS     = .*.d
-
-#LDFLAGS  += $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest)
 
 OBJS     = $(SRCS:.c=.o)
 IBINS    = xenpaging
@@ -27,7 +24,7 @@ all: $(IBINS)
 all: $(IBINS)
 
 xenpaging: $(OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 install: all
        $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile     Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenpmd/Makefile     Wed Aug 11 18:26:47 2010 +0100
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenstore)
-LDFLAGS += $(LDFLAGS_libxenstore)
+LDLIBS += $(LDLIBS_libxenstore)
 
 BIN      = xenpmd
 
@@ -20,6 +20,6 @@ clean:
        $(RM) -f $(BIN) $(DEPS)
 
 %: %.c Makefile
-       $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenstat/libxenstat/Makefile
--- a/tools/xenstat/libxenstat/Makefile Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenstat/libxenstat/Makefile Wed Aug 11 18:26:47 2010 +0100
@@ -53,7 +53,7 @@ all: $(LIB)
        $(RANLIB) $@
 
 $(SHLIB): $(OBJECTS-y)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_CFLAGS) -o $@ \
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_LDFLAGS) -o $@ \
            $(OBJECTS-y) $(LDLIBS-y)
 
 src/xenstat.o: src/xenstat.c src/xenstat.h src/xenstat_priv.h
@@ -112,7 +112,7 @@ PYTHON_FLAGS=-I/usr/include/python$(PYTH
        swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $<
 
 $(PYLIB): $(PYSRC)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_CFLAGS) -lxenstat -o 
$@ $<
+       $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_LDFLAGS) -lxenstat 
-o $@ $<
 
 python-bindings: $(PYLIB) $(PYMOD)
 
@@ -134,7 +134,7 @@ PERL_FLAGS=`perl -MConfig -e 'print "$$C
        swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<
 
 $(PERLLIB): $(PERLSRC)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_CFLAGS) -lxenstat -o 
$@ $<
+       $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_LDFLAGS) -lxenstat -o 
$@ $<
 
 .PHONY: perl-bindings
 perl-bindings: $(PERLLIB) $(PERLMOD)
diff -r 786b163da49b -r 8bb9cfaca402 tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xenstore/Makefile   Wed Aug 11 18:26:47 2010 +0100
@@ -47,7 +47,7 @@ endif
 endif
  
 xenstored: $(XENSTORED_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDFLAGS_libxenctrl) $(SOCKET_LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@
 
 $(CLIENTS): xenstore
        ln -f xenstore $@
@@ -69,7 +69,7 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 xs.opic: CFLAGS += -DUSE_PTHREAD
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenstore.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ $(SOCKET_LIBS) -lpthread
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) 
-Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(SOCKET_LIBS) -lpthread
 
 libxenstore.a: xs.o xs_lib.o
        $(AR) rcs $@ $^
diff -r 786b163da49b -r 8bb9cfaca402 tools/xentrace/Makefile
--- a/tools/xentrace/Makefile   Wed Aug 11 17:01:02 2010 +0100
+++ b/tools/xentrace/Makefile   Wed Aug 11 18:26:47 2010 +0100
@@ -4,7 +4,7 @@ CFLAGS  += -Werror
 CFLAGS  += -Werror
 
 CFLAGS  += $(CFLAGS_libxenctrl)
-LDFLAGS += $(LDFLAGS_libxenctrl)
+LDLIBS += $(LDLIBS_libxenctrl)
 
 HDRS     = $(wildcard *.h)
 OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
@@ -50,9 +50,9 @@ clean:
        $(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN) $(DEPS)
 
 %: %.c $(HDRS) Makefile
-       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
 xentrace_%: %.c $(HDRS) Makefile
-       $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
 
 -include $(DEPS)
 

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

<Prev in Thread] Current Thread [Next in Thread>