xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 4] tools: shave build yaks (part two)
@ 2011-03-31 10:56 Ian Campbell
  2011-03-31 10:56 ` [PATCH 1 of 4] tools: Remove $(CFLAGS) from links lines Ian Campbell
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ian Campbell @ 2011-03-31 10:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

Version 2, much of the original series has been applied. This is the
remainder.

Clean up a bunch of inconsistency, wierdness, cut-and-paste etc in the
tools/ build system. All in all it's a bit of a grab bag of stuff I
happened to notice as I was trawling 

One specific useful thing which comes out of it is to isolate users of
libxl from needing to know about libxenstore or libxenctrl.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1 of 4] tools: Remove $(CFLAGS) from links lines
  2011-03-31 10:56 [PATCH 0 of 4] tools: shave build yaks (part two) Ian Campbell
@ 2011-03-31 10:56 ` Ian Campbell
  2011-03-31 10:56 ` [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h Ian Campbell
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Ian Campbell @ 2011-03-31 10:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301568175 -3600
# Node ID f5ada9268c1a7b4128f63619d252395f014ef238
# Parent  b56a21124c7f02979cf96b2404c6ecc0bc48e6f7
tools: Remove $(CFLAGS) from links lines.

The relevant variable in these circumstances is called $(LDFLAGS).

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

diff -r b56a21124c7f -r f5ada9268c1a tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap/drivers/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -48,16 +48,16 @@ BLKTAB-OBJS-$(CONFIG_Linux) += blktapctr
 all: $(IBIN) qcow-util
 
 blktapctrl: $(BLKTAB-OBJS-y)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS_blktapctrl)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_blktapctrl)
 
 tapdisk: tapdisk.o $(BLK-OBJS-y)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS_img)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_img)
 
 .PHONY: qcow-util
 qcow-util: img2qcow qcow2raw qcow-create
 
 img2qcow qcow2raw qcow-create: %: %.o $(BLK-OBJS-y)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $* $^ $(LDLIBS_img)
+	$(CC) $(LDFLAGS) -o $* $^ $(LDLIBS_img)
 
 install: all
 	$(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(VHD_UTIL) $(DESTDIR)$(SBINDIR)
diff -r b56a21124c7f -r f5ada9268c1a tools/blktap/lib/Makefile
--- a/tools/blktap/lib/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap/lib/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -42,7 +42,7 @@ clean:
 	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen TAGS
 
 libblktap.so.$(MAJOR).$(MINOR): $(OBJS_PIC) 
-	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_LDFLAGS) \
+	$(CC) $(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 b56a21124c7f -r f5ada9268c1a tools/blktap2/control/Makefile
--- a/tools/blktap2/control/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap2/control/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -52,13 +52,13 @@ build: $(IBIN) $(LIB_STATIC) $(LIB_SHARE
 	ln -sf $< $@
 
 tap-ctl: tap-ctl.o $(LIBNAME).so
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) -o $@ $^
 
 $(LIB_STATIC): $(CTL_OBJS)
 	$(AR) r $@ $^
 
 $(LIB_SHARED): $(CTL_PICS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -fPIC  -Wl,$(SONAME_LDFLAG) -Wl,$(LIBSONAME) $(SHLIB_LDFLAGS) -rdynamic $^ -o $@
+	$(CC) $(LDFLAGS) -fPIC  -Wl,$(SONAME_LDFLAG) -Wl,$(LIBSONAME) $(SHLIB_LDFLAGS) -rdynamic $^ -o $@
 
 install: $(IBIN) $(LIB_STATIC) $(LIB_SHARED)
 	$(INSTALL_DIR) -p $(DESTDIR)$(SBINDIR)
diff -r b56a21124c7f -r f5ada9268c1a tools/blktap2/lvm/Makefile
--- a/tools/blktap2/lvm/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap2/lvm/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -24,7 +24,7 @@ build: $(TEST) $(LVM-OBJS)
 install: all
 
 lvm-util: lvm-util.o
-	$(CC) $(CFLAGS) -DLVM_UTIL $(LDFLAGS) -o lvm-util lvm-util.c
+	$(CC) -DLVM_UTIL $(LDFLAGS) -o lvm-util lvm-util.c
 
 clean:
 	rm -rf *.o *~ $(DEPS) $(IBIN)
diff -r b56a21124c7f -r f5ada9268c1a tools/blktap2/vhd/Makefile
--- a/tools/blktap2/vhd/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap2/vhd/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -31,10 +31,10 @@ LIBS_DEPENDS	  := lib/libvhd.so lib/vhd.
 $(LIBS_DEPENDS):subdirs-all
 
 vhd-util: vhd-util.o $(LIBS_DEPENDS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o vhd-util vhd-util.o $(LIBS)
+	$(CC) $(LDFLAGS) -o vhd-util vhd-util.o $(LIBS)
 
 vhd-update: vhd-update.o $(LIBS_DEPENDS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o vhd-update vhd-update.o $(LIBS)
+	$(CC) $(LDFLAGS) -o vhd-update vhd-update.o $(LIBS)
 
 install: all
 	$(MAKE) subdirs-install
diff -r b56a21124c7f -r f5ada9268c1a tools/blktap2/vhd/lib/Makefile
--- a/tools/blktap2/vhd/lib/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/blktap2/vhd/lib/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -52,7 +52,7 @@ all: build
 build: $(LIBVHD-BUILD)
 
 libvhd.a: $(LIB-OBJS)
-	$(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_LDFLAGS) \
+	$(CC) -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 b56a21124c7f -r f5ada9268c1a tools/console/Makefile
--- a/tools/console/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/console/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -23,10 +23,10 @@ clean:
 	$(RM) client/*.o daemon/*.o
 
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(LDLIBS_xenconsoled)
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_xenconsoled)
 
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
-	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(LDLIBS_xenconsole)
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_xenconsole)
 
 .PHONY: install
 install: $(BIN)
diff -r b56a21124c7f -r f5ada9268c1a tools/debugger/kdd/Makefile
--- a/tools/debugger/kdd/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/debugger/kdd/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -10,7 +10,7 @@ OBJS    := $(CFILES:.c=.o)
 all: kdd
 
 kdd: $(OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 .PHONY: clean
 clean:
diff -r b56a21124c7f -r f5ada9268c1a tools/flask/libflask/Makefile
--- a/tools/flask/libflask/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/flask/libflask/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -53,6 +53,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_LDFLAGS) -o $@ $^ $(LDLIBS_libxenctrl)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libflask.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxenctrl)
 
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/flask/utils/Makefile
--- a/tools/flask/utils/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/flask/utils/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -19,7 +19,7 @@ CLIENTS_OBJS := $(patsubst flask-%,%.o,$
 all: $(CLIENTS)
 
 $(CLIENTS): flask-%: %.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -L$(LIBFLASK_ROOT) -lflask $(LDLIBS_libxenctrl) -o $@
+	$(CC) $(LDFLAGS) $< $(LDLIBS) -L$(LIBFLASK_ROOT) -lflask $(LDLIBS_libxenctrl) -o $@
 
 .PHONY: clean
 clean: 
diff -r b56a21124c7f -r f5ada9268c1a tools/libfsimage/Rules.mk
--- a/tools/libfsimage/Rules.mk	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libfsimage/Rules.mk	Thu Mar 31 11:42:55 2011 +0100
@@ -24,7 +24,7 @@ fs-install: fs-all
 	$(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)
 
 $(FSLIB): $(PIC_OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lfsimage $(FS_LIBDEPS)
+	$(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lfsimage $(FS_LIBDEPS)
 
 clean distclean:
 	rm -f $(PIC_OBJS) $(FSLIB) $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/libfsimage/common/Makefile
--- a/tools/libfsimage/common/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libfsimage/common/Makefile	Thu Mar 31 11:42:55 2011 +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_LDFLAGS) -o $@ $^ -lpthread
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libfsimage.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ -lpthread
 
 -include $(DEPS)
 
diff -r b56a21124c7f -r f5ada9268c1a tools/libxc/Makefile
--- a/tools/libxc/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libxc/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -156,7 +156,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_LDFLAGS) -o $@ $^ $(DLOPEN_LIBS) $(PTHREAD_LIBS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(DLOPEN_LIBS) $(PTHREAD_LIBS)
 
 # libxenguest
 
@@ -192,10 +192,10 @@ 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_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenctrl) $(PTHREAD_LIBS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenctrl) $(PTHREAD_LIBS)
 
 xenctrl_osdep_ENOSYS.so: $(OSDEP_PIC_OBJS) libxenctrl.so
-	$(CC) -g $(CFLAGS) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $(OSDEP_PIC_OBJS) $(LDLIBS_libxenctrl)
+	$(CC) -g $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $(OSDEP_PIC_OBJS) $(LDLIBS_libxenctrl)
 
 -include $(DEPS)
 
diff -r b56a21124c7f -r f5ada9268c1a tools/libxen/Makefile
--- a/tools/libxen/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libxen/Makefile	Thu Mar 31 11:42:55 2011 +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_LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenapi.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxenapi.a: $(LIBXENAPI_OBJS)
 	$(AR) rcs libxenapi.a $^
diff -r b56a21124c7f -r f5ada9268c1a tools/libxen/Makefile.dist
--- a/tools/libxen/Makefile.dist	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libxen/Makefile.dist	Thu Mar 31 11:42:55 2011 +0100
@@ -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_LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenapi.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^
 
 libxenapi.a: $(LIBXENAPI_OBJS)
 	$(AR) rcs libxenapi.a $^
diff -r b56a21124c7f -r f5ada9268c1a tools/libxl/Makefile
--- a/tools/libxl/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/libxl/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -85,7 +85,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_LDFLAGS) -o $@ $^ $(LIBXL_LIBS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXL_LIBS)
 
 libxenlight.a: $(LIBXL_OBJS)
 	$(AR) rcs libxenlight.a $^
@@ -97,7 +97,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_LDFLAGS) -o $@ $^ $(LIBXLU_LIBS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXLU_LIBS)
 
 libxlutil.a: $(LIBXLU_OBJS)
 	$(AR) rcs libxlutil.a $^
diff -r b56a21124c7f -r f5ada9268c1a tools/misc/Makefile
--- a/tools/misc/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/misc/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -58,9 +58,9 @@ clean:
 	$(CC) -c $(CFLAGS) -o $@ $<
 
 xen-hvmctx xen-hvmcrash xenperf xenpm gtracestat xenlockprof xen-hptool xenwatchdogd: %: %.o Makefile
-	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_$*)
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_$*)
 
 gtraceview: %: %.o Makefile
-	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(CURSES_LIBS)
+	$(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS)
 
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/ocaml/Makefile.rules
--- a/tools/ocaml/Makefile.rules	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/ocaml/Makefile.rules	Thu Mar 31 11:42:55 2011 +0100
@@ -84,7 +84,7 @@ endef
 
 define C_PROGRAM_template
  $(1): $(foreach obj,$($(1)_OBJS),$(obj).o)
-	$(call quiet-command, $(CC) $(CFLAGS) -o $$@ $$+,BIN,$$@)
+	$(call quiet-command, $(CC) $(LDFLAGS) -o $$@ $$+,BIN,$$@)
 endef
 
 -include .ocamldep.make
diff -r b56a21124c7f -r f5ada9268c1a tools/tests/mce-test/tools/Makefile
--- a/tools/tests/mce-test/tools/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/tests/mce-test/tools/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -18,8 +18,5 @@ install:
 clean:
 	$(RM) *.o xen-mceinj
 
-%.o: %.c $(HDRS) Makefile
-	$(CC) -c $(CFLAGS) -o $@ $<
-
 xen-mceinj: %: %.o Makefile
-	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
+	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
diff -r b56a21124c7f -r f5ada9268c1a tools/tests/xen-access/Makefile
--- a/tools/tests/xen-access/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/tests/xen-access/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -25,10 +25,7 @@ clean:
 	$(RM) *.o $(TARGETS) *~ $(DEPS)
 	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
 
-%.o: %.c Makefile
-	$(CC) -c $(CFLAGS) -o $@ $<
+xen-access: %: %.o Makefile
+	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl)
 
-xen-access: %: %.o Makefile
-	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl)
-# $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/vtpm_manager/manager/Makefile
--- a/tools/vtpm_manager/manager/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/vtpm_manager/manager/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -29,7 +29,7 @@ mrproper: clean
 	rm -f *~
 
 $(BIN): $(OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+	$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
 
 # libraries
 LIBS += ../tcs/libTCS.a ../util/libTCGUtils.a ../crypto/libtcpaCrypto.a
diff -r b56a21124c7f -r f5ada9268c1a tools/vtpm_manager/migration/Makefile
--- a/tools/vtpm_manager/migration/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/vtpm_manager/migration/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -33,10 +33,10 @@ mrproper: clean
 	rm -f *~
 
 $(BIND): $(OBJSD)
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+	$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
 
 $(BINC): $(OBJSC)
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+	$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
 
 # libraries
 LIBS += ../util/libTCGUtils.a
diff -r b56a21124c7f -r f5ada9268c1a tools/xcutils/Makefile
--- a/tools/xcutils/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xcutils/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -11,15 +11,14 @@
 XEN_ROOT	= $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-
 PROGRAMS = xc_restore xc_save readnotes lsevtchn
 
 CFLAGS += -Werror
 
-CFLAGS_xc_restore := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
-CFLAGS_xc_save    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
-CFLAGS_readnotes  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
-CFLAGS_lsevtchn   := $(CFLAGS_libxenctrl)
+CFLAGS_xc_restore.o := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
+CFLAGS_xc_save.o    := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
+CFLAGS_readnotes.o  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
+CFLAGS_lsevtchn.o   := $(CFLAGS_libxenctrl)
 
 LDLIBS_xc_restore := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
 LDLIBS_xc_save    := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
@@ -32,11 +31,8 @@ all: build
 .PHONY: build
 build: $(PROGRAMS)
 
-%.o: %.c
-	$(CC) $(CFLAGS) $(CFLAGS_$*) -c $^ -o $@
-
 $(PROGRAMS): %: %.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_$*) -o $@
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_$*) -o $@
 
 .PHONY: install
 install: build
diff -r b56a21124c7f -r f5ada9268c1a tools/xenbackendd/Makefile
--- a/tools/xenbackendd/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenbackendd/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -35,7 +35,7 @@ clean:
 	rm -f $(SBIN) $(DEPS)
 
 
-%: %.c Makefile
-	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
+%: %.o Makefile
+	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/xenmon/Makefile
--- a/tools/xenmon/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenmon/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -40,9 +40,10 @@ clean:
 	rm -f $(BIN) $(DEPS)
 
 
-%: %.c Makefile
-	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
-xentrace_%: %.c Makefile
-	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
+%: %.o Makefile
+	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
+
+xentrace_%: %.o Makefile
+	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/xenpaging/Makefile
--- a/tools/xenpaging/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenpaging/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -19,7 +19,7 @@ IBINS    = xenpaging
 all: $(IBINS)
 
 xenpaging: $(OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 install: all
 	$(INSTALL_DIR) $(DESTDIR)/var/lib/xen/xenpaging
diff -r b56a21124c7f -r f5ada9268c1a tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenpmd/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -1,8 +1,9 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS  += -Werror
-CFLAGS  += $(CFLAGS_libxenstore)
+CFLAGS += -Werror
+CFLAGS += $(CFLAGS_libxenstore)
+
 LDLIBS += $(LDLIBS_libxenstore)
 
 BIN      = xenpmd
@@ -19,7 +20,7 @@ install: all
 clean:
 	$(RM) -f $(BIN) $(DEPS)
 
-%: %.c Makefile
-	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
+%: %.o Makefile
+	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r b56a21124c7f -r f5ada9268c1a tools/xenstat/libxenstat/Makefile
--- a/tools/xenstat/libxenstat/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenstat/libxenstat/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -50,18 +50,9 @@ all: $(LIB) $(SHLIB) $(SHLIB_LINKS)
 	$(RANLIB) $@
 
 $(SHLIB): $(OBJECTS-y)
-	$(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_LDFLAGS) -o $@ \
+	$(CC) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_LDFLAGS) -o $@ \
 	    $(OBJECTS-y) $(LDLIBS-y)
 
-src/xenstat.o: src/xenstat.c src/xenstat.h src/xenstat_priv.h
-	$(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<
-
-src/xenstat_linux.o: src/xenstat_linux.c src/xenstat_priv.h
-	$(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<
-
-src/xenstat_solaris.o: src/xenstat_solaris.c src/xenstat_priv.h
-	$(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<
-
 src/libxenstat.so.$(MAJOR): $(SHLIB)
 	$(MAKE_LINK) $(<F) $@
 
diff -r b56a21124c7f -r f5ada9268c1a tools/xenstore/Makefile
--- a/tools/xenstore/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xenstore/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -47,19 +47,19 @@ CFLAGS += -DHAVE_DTRACE=1
 endif
  
 xenstored: $(XENSTORED_OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@
+	$(CC) $(LDFLAGS) $^ $(LDLIBS_libxenctrl) $(SOCKET_LIBS) -o $@
 
 $(CLIENTS): xenstore
 	ln -f xenstore $@
 
 xenstore: xenstore_client.o $(LIBXENSTORE)
-	$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@
+	$(CC) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@
 
 xenstore-control: xenstore_control.o $(LIBXENSTORE)
-	$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@
+	$(CC) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@
 
 xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
+	$(CC) $(LDFLAGS) $^ -o $@
 
 libxenstore.so: libxenstore.so.$(MAJOR)
 	ln -sf $< $@
@@ -69,7 +69,7 @@ libxenstore.so.$(MAJOR): libxenstore.so.
 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_LDFLAGS) -o $@ $^ $(SOCKET_LIBS) -lpthread
+	$(CC) $(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 b56a21124c7f -r f5ada9268c1a tools/xentrace/Makefile
--- a/tools/xentrace/Makefile	Thu Mar 31 11:41:35 2011 +0100
+++ b/tools/xentrace/Makefile	Thu Mar 31 11:42:55 2011 +0100
@@ -1,9 +1,9 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS  += -Werror
+CFLAGS += -Werror
 
-CFLAGS  += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenctrl)
 LDLIBS += $(LDLIBS_libxenctrl)
 
 HDRS     = $(wildcard *.h)
@@ -49,10 +49,10 @@ install: build
 clean:
 	$(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN) $(DEPS)
 
-%: %.c $(HDRS) Makefile
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
-xentrace_%: %.c $(HDRS) Makefile
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+%: %.o $(HDRS) Makefile
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS)
+xentrace_%: %.o $(HDRS) Makefile
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS)
 
 -include $(DEPS)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h
  2011-03-31 10:56 [PATCH 0 of 4] tools: shave build yaks (part two) Ian Campbell
  2011-03-31 10:56 ` [PATCH 1 of 4] tools: Remove $(CFLAGS) from links lines Ian Campbell
@ 2011-03-31 10:56 ` Ian Campbell
  2011-03-31 18:33   ` Ian Jackson
  2011-03-31 10:56 ` [PATCH 3 of 4] tools: remove pattern matched linking rules Ian Campbell
  2011-03-31 10:57 ` [PATCH 4 of 4] tools: remove some .o and binary files on clean Ian Campbell
  3 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2011-03-31 10:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301568853 -3600
# Node ID f968b14db03fcd7c42125b2ef9bc28c424959b2a
# Parent  f5ada9268c1a7b4128f63619d252395f014ef238
libxl: do not expose libxenctrl/libxenstore headers via libxl.h

This completely removes libxenstore from libxl users' view.

xl still needs libxenctrl directly due to the direct use of the
xentoollog functionality but it is not exposed to the indirect linkage
anymore.

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

diff -r f5ada9268c1a -r f968b14db03f tools/Rules.mk
--- a/tools/Rules.mk	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/Rules.mk	Thu Mar 31 11:54:13 2011 +0100
@@ -49,7 +49,7 @@ LDLIBS_libblktapctl =
 SHLIB_libblktapctl  =
 endif
 
-CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude)
+CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
 LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight
 SHLIB_libxenlight  = -Wl,-rpath-link=$(XEN_XENLIGHT)
 
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/Makefile
--- a/tools/libxl/Makefile	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/Makefile	Thu Mar 31 11:54:13 2011 +0100
@@ -13,7 +13,6 @@ XLUMINOR = 0
 
 CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
 CFLAGS += -I. -fPIC
-CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
 ifeq ($(CONFIG_Linux),y)
 LIBUUID_LIBS += -luuid
@@ -38,13 +37,18 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_c
 			libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o
 
+$(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
+
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
 AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
 LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o
+$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 
 CLIENTS = xl
 
 XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 
 .PHONY: all
 all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/libxl.c	Thu Mar 31 11:54:13 2011 +0100
@@ -41,15 +41,22 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg)
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger * lg)
 {
+    libxl_ctx *ctx;
     struct stat stat_buf;
 
     if (version != LIBXL_VERSION)
         return ERROR_VERSION;
+
+    ctx = malloc(sizeof(*ctx));
+    if (!ctx) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n");
+        return ERROR_NOMEM;
+    }
+
     memset(ctx, 0, sizeof(libxl_ctx));
     ctx->lg = lg;
-    memset(&ctx->version_info, 0, sizeof(libxl_version_info));
 
     if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n"
@@ -73,6 +80,8 @@ int libxl_ctx_init(libxl_ctx *ctx, int v
         xc_interface_close(ctx->xch);
         return ERROR_FAIL;
     }
+
+    *pctx = ctx;
     return 0;
 }
 
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/libxl.h	Thu Mar 31 11:54:13 2011 +0100
@@ -124,13 +124,18 @@
 #ifndef LIBXL_H
 #define LIBXL_H
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <errno.h>
 #include <netinet/in.h>
-#include <xenctrl.h>
-#include <xs.h>
 #include <sys/wait.h> /* for pid_t */
 
+#include <xentoollog.h>
+
+#include <xen/sched.h>
+#include <xen/sysctl.h>
+
 #include "libxl_uuid.h"
 
 typedef uint8_t libxl_mac[6];
@@ -216,17 +221,7 @@ void libxl_cpuid_destroy(libxl_cpuid_pol
 
 #include "_libxl_types.h"
 
-typedef struct {
-    xentoollog_logger *lg;
-    xc_interface *xch;
-    struct xs_handle *xsh;
-
-    /* for callers who reap children willy-nilly; caller must only
-     * set this after libxl_init and before any other call - or
-     * may leave them untouched */
-    int (*waitpid_instead)(pid_t pid, int *status, int flags);
-    libxl_version_info version_info;
-} libxl_ctx;
+typedef struct libxl__ctx libxl_ctx;
 
 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
 
@@ -283,7 +278,7 @@ typedef struct {
 } libxl_domain_config;
 
 /* context functions */
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger*);
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger *lg);
 int libxl_ctx_free(libxl_ctx *ctx);
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/libxl_internal.h	Thu Mar 31 11:54:13 2011 +0100
@@ -82,6 +82,17 @@ _hidden void libxl__log(libxl_ctx *ctx, 
 
      /* these functions preserve errno (saving and restoring) */
 
+struct libxl__ctx {
+    xentoollog_logger *lg;
+    xc_interface *xch;
+    struct xs_handle *xsh;
+
+    /* for callers who reap children willy-nilly; caller must only
+     * set this after libxl_init and before any other call - or
+     * may leave them untouched */
+    int (*waitpid_instead)(pid_t pid, int *status, int flags);
+    libxl_version_info version_info;
+};
 
 typedef enum {
     DEVICE_VIF = 1,
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/libxlu_cfg.c
--- a/tools/libxl/libxlu_cfg.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/libxlu_cfg.c	Thu Mar 31 11:54:13 2011 +0100
@@ -1,3 +1,4 @@
+#include <limits.h>
 
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/xl.c
--- a/tools/libxl/xl.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/xl.c	Thu Mar 31 11:54:13 2011 +0100
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <xenctrl.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -111,7 +112,7 @@ int main(int argc, char **argv)
     logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
     if (!logger) exit(1);
 
-    if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
+    if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
         fprintf(stderr, "cannot init xl context\n");
         exit(1);
     }
@@ -123,7 +124,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    ret = libxl_read_file_contents(&ctx, config_file,
+    ret = libxl_read_file_contents(ctx, config_file,
             &config_data, &config_len);
     if (ret)
         fprintf(stderr, "Failed to read config file: %s: %s\n",
@@ -147,7 +148,7 @@ int main(int argc, char **argv)
         ret = 1;
     }
 
-    libxl_ctx_free(&ctx);
+    libxl_ctx_free(ctx);
     xtl_logger_destroy((xentoollog_logger*)logger);
 
     return ret;
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/xl.h
--- a/tools/libxl/xl.h	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/xl.h	Thu Mar 31 11:54:13 2011 +0100
@@ -95,7 +95,7 @@ extern int cmdtable_len;
 /* Look up a command in the table, allowing unambiguous truncation */
 struct cmd_spec *cmdtable_lookup(const char *s);
 
-extern libxl_ctx ctx;
+extern libxl_ctx *ctx;
 extern xentoollog_logger_stdiostream *logger;
 
 /* global options */
diff -r f5ada9268c1a -r f968b14db03f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Mar 31 11:54:13 2011 +0100
@@ -31,9 +31,10 @@
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <sys/utsname.h> /* for utsname in xl info */
-#include <xenctrl.h>
+#include <xentoollog.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <limits.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -62,7 +63,7 @@
 int logfile = 2;
 
 /* every libxl action in xl uses this same libxl context */
-libxl_ctx ctx;
+libxl_ctx *ctx;
 
 /* when we operate on a domain, it is this one: */
 static uint32_t domid;
@@ -150,11 +151,11 @@ static int domain_qualifier_to_domid(con
         *was_name_r = was_name;
 
     if (was_name) {
-        rc = libxl_name_to_domid(&ctx, p, domid_r);
+        rc = libxl_name_to_domid(ctx, p, domid_r);
         if (rc)
             return rc;
     } else {
-        rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
+        rc = libxl_domain_info(ctx, &dominfo, *domid_r);
         /* error only if domain does not exist */
         if (rc == ERROR_INVAL)
             return rc;
@@ -170,7 +171,7 @@ static int cpupool_qualifier_to_cpupooli
 
     was_name = qualifier_to_id(p, poolid_r);
     if (was_name_r) *was_name_r = was_name;
-    return was_name ? libxl_name_to_cpupoolid(&ctx, p, poolid_r) : 0;
+    return was_name ? libxl_name_to_cpupoolid(ctx, p, poolid_r) : 0;
 }
 
 static void find_domain(const char *p)
@@ -182,7 +183,7 @@ static void find_domain(const char *p)
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    common_domname = was_name ? p : libxl_domid_to_name(ctx, domid);
 }
 
 static int acquire_lock(void)
@@ -303,7 +304,7 @@ static void printf_info(int domid,
     /* retrieve the UUID from dominfo, since it is probably generated
      * during parsing and thus does not match the real one
      */
-    if (libxl_domain_info(&ctx, &info, domid) == 0) {
+    if (libxl_domain_info(ctx, &info, domid) == 0) {
         printf("\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(info.uuid));
     } else {
         printf("\t(uuid <unknown>)\n");
@@ -667,7 +668,7 @@ static void parse_config_data(const char
         c_info->poolid = -1;
         cpupool_qualifier_to_cpupoolid(buf, &c_info->poolid, NULL);
     }
-    c_info->poolname = libxl_cpupoolid_to_name(&ctx, c_info->poolid);
+    c_info->poolname = libxl_cpupoolid_to_name(ctx, c_info->poolid);
     if (!c_info->poolname) {
         fprintf(stderr, "Illegal pool specified\n");
         exit(1);
@@ -875,7 +876,7 @@ static void parse_config_data(const char
                     free(nic->ifname);
                     nic->ifname = strdup(p2 + 1);
                 } else if (!strcmp(p, "backend")) {
-                    if(libxl_name_to_domid(&ctx, (p2 + 1), &(nic->backend_domid))) {
+                    if(libxl_name_to_domid(ctx, (p2 + 1), &(nic->backend_domid))) {
                         fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                         nic->backend_domid = 0;
                     }
@@ -1022,7 +1023,7 @@ skip_vfb:
 
             pcidev->msitranslate = pci_msitranslate;
             pcidev->power_mgmt = pci_power_mgmt;
-            if (!libxl_device_pci_parse_bdf(&ctx, pcidev, buf))
+            if (!libxl_device_pci_parse_bdf(ctx, pcidev, buf))
                 d_config->num_pcidevs++;
         }
     }
@@ -1291,23 +1292,23 @@ static int freemem(libxl_domain_build_in
     if (!autoballoon)
         return 0;
 
-    rc = libxl_domain_need_memory(&ctx, b_info, dm_info, &need_memkb);
+    rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb);
     if (rc < 0)
         return rc;
 
     do {
-        rc = libxl_get_free_memory(&ctx, &free_memkb);
+        rc = libxl_get_free_memory(ctx, &free_memkb);
         if (rc < 0)
             return rc;
 
         if (free_memkb >= need_memkb)
             return 0;
 
-        rc = libxl_set_memory_target(&ctx, 0, free_memkb - need_memkb, 1, 0);
+        rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0);
         if (rc < 0)
             return rc;
 
-        rc = libxl_wait_for_free_memory(&ctx, domid, need_memkb, 10);
+        rc = libxl_wait_for_free_memory(ctx, domid, need_memkb, 10);
         if (!rc)
             return 0;
         else if (rc != ERROR_NOMEM)
@@ -1315,7 +1316,7 @@ static int freemem(libxl_domain_build_in
 
         /* the memory target has been reached but the free memory is still
          * not enough: loop over again */
-        rc = libxl_wait_for_memory_target(&ctx, 0, 1);
+        rc = libxl_wait_for_memory_target(ctx, 0, 1);
         if (rc < 0)
             return rc;
 
@@ -1380,7 +1381,7 @@ static int create_domain(struct domain_c
         restore_fd = migrate_fd >= 0 ? migrate_fd :
             open(restore_file, O_RDONLY);
 
-        CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, &hdr,
+        CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, &hdr,
                    sizeof(hdr), restore_file, "header") );
         if (memcmp(hdr.magic, savefileheader_magic, sizeof(hdr.magic))) {
             fprintf(stderr, "File has wrong magic number -"
@@ -1406,7 +1407,7 @@ static int create_domain(struct domain_c
         }
         if (hdr.optional_data_len) {
             optdata_begin = xmalloc(hdr.optional_data_len);
-            CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, optdata_begin,
+            CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, optdata_begin,
                    hdr.optional_data_len, restore_file, "optdata") );
         }
 
@@ -1438,7 +1439,7 @@ static int create_domain(struct domain_c
 
     if (config_file) {
         free(config_data);  config_data = 0;
-        ret = libxl_read_file_contents(&ctx, config_file,
+        ret = libxl_read_file_contents(ctx, config_file,
                                        &config_data, &config_len);
         if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
                            config_file, strerror(errno)); return ERROR_FAIL; }
@@ -1517,17 +1518,17 @@ start:
     }
 
     if ( restore_file ) {
-        ret = libxl_domain_create_restore(&ctx, &d_config,
+        ret = libxl_domain_create_restore(ctx, &d_config,
                                             cb, &child_console_pid,
                                             &domid, restore_fd);
     }else{
-        ret = libxl_domain_create_new(&ctx, &d_config,
+        ret = libxl_domain_create_new(ctx, &d_config,
                                         cb, &child_console_pid, &domid);
     }
     if ( ret )
         goto error_out;
 
-    ret = libxl_userdata_store(&ctx, domid, "xl",
+    ret = libxl_userdata_store(ctx, domid, "xl",
                                     config_data, config_len);
     if (ret) {
         perror("cannot save config file");
@@ -1538,7 +1539,7 @@ start:
     release_lock();
 
     if (!paused)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
     if (!daemonize)
@@ -1549,7 +1550,7 @@ start:
         pid_t child1, got_child;
         int nullfd;
 
-        child1 = libxl_fork(&ctx);
+        child1 = libxl_fork(ctx);
         if (child1) {
             printf("Daemon running with PID %d\n", child1);
 
@@ -1564,7 +1565,7 @@ start:
                 }
             }
             if (status) {
-                libxl_report_child_exitstatus(&ctx, XTL_ERROR,
+                libxl_report_child_exitstatus(ctx, XTL_ERROR,
                            "daemonizing child", child1, status);
                 ret = ERROR_FAIL;
                 goto error_out;
@@ -1573,7 +1574,7 @@ start:
             goto out;
         }
 
-        rc = libxl_ctx_postfork(&ctx);
+        rc = libxl_ctx_postfork(ctx);
         if (rc) {
             LOG("failed to reinitialise context after fork");
             exit(-1);
@@ -1583,7 +1584,7 @@ start:
             LOG("Failed to allocate memory in asprintf");
             exit(1);
         }
-        rc = libxl_create_logfile(&ctx, name, &fullname);
+        rc = libxl_create_logfile(ctx, name, &fullname);
         if (rc) {
             LOG("failed to open logfile %s: %s",fullname,strerror(errno));
             exit(-1);
@@ -1605,9 +1606,9 @@ start:
         d_config.c_info.name, domid, (long)getpid());
     w1 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter) * d_config.num_disks);
     w2 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter));
-    libxl_wait_for_disk_ejects(&ctx, domid, d_config.disks, d_config.num_disks, w1);
-    libxl_wait_for_domain_death(&ctx, domid, w2);
-    libxl_get_wait_fd(&ctx, &fd);
+    libxl_wait_for_disk_ejects(ctx, domid, d_config.disks, d_config.num_disks, w1);
+    libxl_wait_for_domain_death(ctx, domid, w2);
+    libxl_get_wait_fd(ctx, &fd);
     while (1) {
         int ret;
         fd_set rfds;
@@ -1621,10 +1622,10 @@ start:
         ret = select(fd + 1, &rfds, NULL, NULL, NULL);
         if (!ret)
             continue;
-        libxl_get_event(&ctx, &event);
+        libxl_get_event(ctx, &event);
         switch (event.type) {
             case LIBXL_EVENT_DOMAIN_DEATH:
-                ret = libxl_event_get_domain_death_info(&ctx, domid, &event, &info);
+                ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info);
 
                 if (ret < 0) {
                     libxl_free_event(&event);
@@ -1634,9 +1635,9 @@ start:
                 LOG("Domain %d is dead", domid);
 
                 if (ret) {
-                    switch (handle_domain_death(&ctx, domid, &event, &d_config, &info)) {
+                    switch (handle_domain_death(ctx, domid, &event, &d_config, &info)) {
                     case 2:
-                        if (!preserve_domain(&ctx, domid, &event, &d_config, &info)) {
+                        if (!preserve_domain(ctx, domid, &event, &d_config, &info)) {
                             /* If we fail then exit leaving the old domain in place. */
                             ret = -1;
                             goto out;
@@ -1682,8 +1683,8 @@ start:
                 }
                 break;
             case LIBXL_EVENT_DISK_EJECT:
-                if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) {
-                    libxl_cdrom_insert(&ctx, domid, &disk);
+                if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) {
+                    libxl_cdrom_insert(ctx, domid, &disk);
                     libxl_device_disk_destroy(&disk);
                 }
                 break;
@@ -1694,7 +1695,7 @@ start:
 error_out:
     release_lock();
     if (libxl_domid_valid_guest(domid))
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
 out:
     if (logfile != 2)
@@ -1789,7 +1790,7 @@ static int set_memory_max(const char *p,
         exit(3);
     }
 
-    rc = libxl_domain_setmaxmem(&ctx, domid, memorykb);
+    rc = libxl_domain_setmaxmem(ctx, domid, memorykb);
 
     return rc;
 }
@@ -1839,7 +1840,7 @@ static void set_memory_target(const char
         exit(3);
     }
 
-    libxl_set_memory_target(&ctx, domid, memorykb, 0, /* enforce */ 1);
+    libxl_set_memory_target(ctx, domid, memorykb, 0, /* enforce */ 1);
 }
 
 int main_memset(int argc, char **argv)
@@ -1887,7 +1888,7 @@ static void cd_insert(const char *dom, c
     disk.backend_domid = 0;
     disk.domid = domid;
 
-    libxl_cdrom_insert(&ctx, domid, &disk);
+    libxl_cdrom_insert(ctx, domid, &disk);
     free(buf);
 }
 
@@ -1982,9 +1983,9 @@ int main_console(int argc, char **argv)
 
     find_domain(argv[optind]);
     if (!type)
-        libxl_primary_console_exec(&ctx, domid);
+        libxl_primary_console_exec(ctx, domid);
     else
-        libxl_console_exec(&ctx, domid, num, type);
+        libxl_console_exec(ctx, domid, num, type);
     fprintf(stderr, "Unable to attach console\n");
     return 1;
 }
@@ -1992,7 +1993,7 @@ int main_console(int argc, char **argv)
 static int vncviewer(const char *domain_spec, int autopass)
 {
     find_domain(domain_spec);
-    libxl_vncviewer_exec(&ctx, domid, autopass);
+    libxl_vncviewer_exec(ctx, domid, autopass);
     fprintf(stderr, "Unable to execute vncviewer\n");
     return 1;
 }
@@ -2040,7 +2041,7 @@ static void pcilist_assignable(void)
     libxl_device_pci *pcidevs;
     int num, i;
 
-    if ( libxl_device_pci_list_assignable(&ctx, &pcidevs, &num) )
+    if ( libxl_device_pci_list_assignable(ctx, &pcidevs, &num) )
         return;
     for (i = 0; i < num; i++) {
         printf("%04x:%02x:%02x.%01x\n",
@@ -2075,7 +2076,7 @@ static void pcilist(const char *dom)
 
     find_domain(dom);
 
-    if (libxl_device_pci_list_assigned(&ctx, &pcidevs, domid, &num))
+    if (libxl_device_pci_list_assigned(ctx, &pcidevs, domid, &num))
         return;
     printf("Vdev Device\n");
     for (i = 0; i < num; i++) {
@@ -2120,11 +2121,11 @@ static void pcidetach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_remove(&ctx, domid, &pcidev, force);
+    libxl_device_pci_remove(ctx, domid, &pcidev, force);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2165,11 +2166,11 @@ static void pciattach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_add(&ctx, domid, &pcidev);
+    libxl_device_pci_add(ctx, domid, &pcidev);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2206,13 +2207,13 @@ int main_pciattach(int argc, char **argv
 static void pause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_pause(&ctx, domid);
+    libxl_domain_pause(ctx, domid);
 }
 
 static void unpause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_unpause(&ctx, domid);
+    libxl_domain_unpause(ctx, domid);
 }
 
 static void destroy_domain(const char *p)
@@ -2223,7 +2224,7 @@ static void destroy_domain(const char *p
         fprintf(stderr, "Cannot destroy privileged domain 0.\n\n");
         exit(-1);
     }
-    rc = libxl_domain_destroy(&ctx, domid, 0);
+    rc = libxl_domain_destroy(ctx, domid, 0);
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
 }
 
@@ -2232,16 +2233,16 @@ static void shutdown_domain(const char *
     int rc;
 
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 0);
+    rc=libxl_domain_shutdown(ctx, domid, 0);
     if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); }
 
     if (wait) {
         libxl_waiter waiter;
         int fd;
 
-        libxl_wait_for_domain_death(&ctx, domid, &waiter);
-
-        libxl_get_wait_fd(&ctx, &fd);
+        libxl_wait_for_domain_death(ctx, domid, &waiter);
+
+        libxl_get_wait_fd(ctx, &fd);
 
         while (wait) {
             fd_set rfds;
@@ -2254,10 +2255,10 @@ static void shutdown_domain(const char *
             if (!select(fd + 1, &rfds, NULL, NULL, NULL))
                 continue;
 
-            libxl_get_event(&ctx, &event);
+            libxl_get_event(ctx, &event);
 
             if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
-                if (libxl_event_get_domain_death_info(&ctx, domid, &event, &info) < 0)
+                if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0)
                     continue;
 
                 LOG("Domain %d is dead", domid);
@@ -2274,7 +2275,7 @@ static void reboot_domain(const char *p)
 {
     int rc;
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 1);
+    rc=libxl_domain_shutdown(ctx, domid, 1);
     if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2291,7 +2292,7 @@ static void list_domains_details(const l
         /* no detailed info available on dom0 */
         if (info[i].domid == 0)
             continue;
-        rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len);
+        rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len);
         if (rc)
             continue;
         CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid));
@@ -2315,7 +2316,7 @@ static void list_domains(int verbose, co
     for (i = 0; i < nb_domain; i++) {
         char *domname;
         unsigned shutdown_reason;
-        domname = libxl_domid_to_name(&ctx, info[i].domid);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0;
         printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
                 domname,
@@ -2347,7 +2348,7 @@ static void list_vm(void)
     char *domname;
     int nb_vm, i;
 
-    info = libxl_list_vm(&ctx, &nb_vm);
+    info = libxl_list_vm(ctx, &nb_vm);
 
     if (info < 0) {
         fprintf(stderr, "libxl_domain_infolist failed.\n");
@@ -2355,7 +2356,7 @@ static 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);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         printf(LIBXL_UUID_FMT "  %d    %-30s\n", LIBXL_UUID_BYTES(info[i].uuid),
             info[i].domid, domname);
         free(domname);
@@ -2376,11 +2377,11 @@ static void save_domain_core_begin(const
 
     if (override_config_file) {
         void *config_v = 0;
-        rc = libxl_read_file_contents(&ctx, override_config_file,
+        rc = libxl_read_file_contents(ctx, override_config_file,
                                       &config_v, config_len_r);
         *config_data_r = config_v;
     } else {
-        rc = libxl_userdata_retrieve(&ctx, domid, "xl",
+        rc = libxl_userdata_retrieve(ctx, domid, "xl",
                                      config_data_r, config_len_r);
     }
     if (rc) {
@@ -2417,9 +2418,9 @@ static void save_domain_core_writeconfig
 
     /* that's the optional data */
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         &hdr, sizeof(hdr), filename, "header") );
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         optdata_begin, hdr.optional_data_len, filename, "header") );
 
     fprintf(stderr, "Saving to %s new xl format (info"
@@ -2449,13 +2450,13 @@ static int save_domain(const char *p, co
 
     save_domain_core_writeconfig(fd, filename, config_data, config_len);
 
-    CHK_ERRNO(libxl_domain_suspend(&ctx, NULL, domid, fd));
+    CHK_ERRNO(libxl_domain_suspend(ctx, NULL, domid, fd));
     close(fd);
 
     if (checkpoint)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
     else
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
     exit(0);
 }
@@ -2467,7 +2468,7 @@ static int migrate_read_fixedmessage(int
     int rc;
 
     stream = rune ? "migration receiver stream" : "migration stream";
-    rc = libxl_read_exactly(&ctx, fd, buf, msgsz, stream, what);
+    rc = libxl_read_exactly(ctx, fd, buf, msgsz, stream, what);
     if (rc) return ERROR_FAIL;
 
     if (memcmp(buf, msg, msgsz)) {
@@ -2496,7 +2497,7 @@ static void migration_child_report(pid_t
 
         if (child == migration_child) {
             if (status)
-                libxl_report_child_exitstatus(&ctx, XTL_INFO,
+                libxl_report_child_exitstatus(ctx, XTL_INFO,
                                               "migration target process",
                                               migration_child, status);
             break;
@@ -2567,10 +2568,10 @@ static void migrate_domain(const char *d
         exit(1);
     }
 
-    MUST( libxl_pipe(&ctx, sendpipe) );
-    MUST( libxl_pipe(&ctx, recvpipe) );
-
-    child = libxl_fork(&ctx);
+    MUST( libxl_pipe(ctx, sendpipe) );
+    MUST( libxl_pipe(ctx, recvpipe) );
+
+    child = libxl_fork(ctx);
     if (child==-1) exit(1);
 
     if (!child) {
@@ -2608,7 +2609,7 @@ static void migrate_domain(const char *d
 
     memset(&suspinfo, 0, sizeof(suspinfo));
     suspinfo.flags |= XL_SUSPEND_LIVE;
-    rc = libxl_domain_suspend(&ctx, &suspinfo, domid, send_fd);
+    rc = libxl_domain_suspend(ctx, &suspinfo, domid, send_fd);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -2638,7 +2639,7 @@ static void migrate_domain(const char *d
     if (common_domname) {
         if (asprintf(&away_domname, "%s--migratedaway", common_domname) < 0)
             goto failed_resume;
-        rc = libxl_domain_rename(&ctx, domid, common_domname, away_domname);
+        rc = libxl_domain_rename(ctx, domid, common_domname, away_domname);
         if (rc) goto failed_resume;
     }
 
@@ -2649,7 +2650,7 @@ static void migrate_domain(const char *d
 
     fprintf(stderr, "migration sender: Giving target permission to start.\n");
 
-    rc = libxl_write_exactly(&ctx, send_fd,
+    rc = libxl_write_exactly(ctx, send_fd,
                              migrate_permission_to_go,
                              sizeof(migrate_permission_to_go),
                              "migration stream", "GO message");
@@ -2660,7 +2661,7 @@ static void migrate_domain(const char *d
                                    "success/failure report message", rune);
     if (rc) goto failed_badly;
 
-    rc = libxl_read_exactly(&ctx, recv_fd,
+    rc = libxl_read_exactly(ctx, recv_fd,
                             &rc_buf, 1,
                             "migration ack stream", "success/failure status");
     if (rc) goto failed_badly;
@@ -2678,9 +2679,9 @@ static void migrate_domain(const char *d
         fprintf(stderr, "migration sender: Trying to resume at our end.\n");
 
         if (common_domname) {
-            libxl_domain_rename(&ctx, domid, away_domname, common_domname);
+            libxl_domain_rename(ctx, domid, away_domname, common_domname);
         }
-        rc = libxl_domain_resume(&ctx, domid);
+        rc = libxl_domain_resume(ctx, domid);
         if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n");
 
         fprintf(stderr, "Migration failed due to problems at target.\n");
@@ -2688,7 +2689,7 @@ static void migrate_domain(const char *d
     }
 
     fprintf(stderr, "migration sender: Target reports successful startup.\n");
-    libxl_domain_destroy(&ctx, domid, 1); /* bang! */
+    libxl_domain_destroy(ctx, domid, 1); /* bang! */
     fprintf(stderr, "Migration successful.\n");
     exit(0);
 
@@ -2702,7 +2703,7 @@ static void migrate_domain(const char *d
     close(send_fd);
     migration_child_report(child, recv_fd);
     fprintf(stderr, "Migration failed, resuming at sender.\n");
-    libxl_domain_resume(&ctx, domid);
+    libxl_domain_resume(ctx, domid);
     exit(-ERROR_FAIL);
 
  failed_badly:
@@ -2723,7 +2724,7 @@ static void core_dump_domain(const char 
 {
     int rc;
     find_domain(domain_spec);
-    rc=libxl_domain_core_dump(&ctx, domid, filename);
+    rc=libxl_domain_core_dump(ctx, domid, filename);
     if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2739,7 +2740,7 @@ static void migrate_receive(int debug, i
 
     fprintf(stderr, "migration target: Ready to receive domain.\n");
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, 1,
+    CHK_ERRNO( libxl_write_exactly(ctx, 1,
                                    migrate_receiver_banner,
                                    sizeof(migrate_receiver_banner)-1,
                                    "migration ack stream",
@@ -2763,7 +2764,7 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Transfer complete,"
             " requesting permission to start domain.\n");
 
-    rc = libxl_write_exactly(&ctx, 1,
+    rc = libxl_write_exactly(ctx, 1,
                              migrate_receiver_ready,
                              sizeof(migrate_receiver_ready),
                              "migration ack stream", "ready message");
@@ -2777,18 +2778,18 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Got permission, starting domain.\n");
 
     if (migration_domname) {
-        rc = libxl_domain_rename(&ctx, domid, migration_domname, common_domname);
+        rc = libxl_domain_rename(ctx, domid, migration_domname, common_domname);
         if (rc) goto perhaps_destroy_notify_rc;
     }
 
-    rc = libxl_domain_unpause(&ctx, domid);
+    rc = libxl_domain_unpause(ctx, domid);
     if (rc) goto perhaps_destroy_notify_rc;
 
     fprintf(stderr, "migration target: Domain started successsfully.\n");
     rc = 0;
 
  perhaps_destroy_notify_rc:
-    rc2 = libxl_write_exactly(&ctx, 1,
+    rc2 = libxl_write_exactly(ctx, 1,
                               migrate_report, sizeof(migrate_report),
                               "migration ack stream",
                               "success/failure report");
@@ -2796,7 +2797,7 @@ static void migrate_receive(int debug, i
 
     rc_buf = -rc;
     assert(!!rc_buf == !!rc);
-    rc2 = libxl_write_exactly(&ctx, 1, &rc_buf, 1,
+    rc2 = libxl_write_exactly(ctx, 1, &rc_buf, 1,
                               "migration ack stream",
                               "success/failure code");
     if (rc2) exit(-ERROR_BADFAIL);
@@ -2804,7 +2805,7 @@ static void migrate_receive(int debug, i
     if (rc) {
         fprintf(stderr, "migration target: Failure, destroying our copy.\n");
 
-        rc2 = libxl_domain_destroy(&ctx, domid, 1);
+        rc2 = libxl_domain_destroy(ctx, domid, 1);
         if (rc2) {
             fprintf(stderr, "migration target: Failed to destroy our copy"
                     " (code %d).\n", rc2);
@@ -2814,7 +2815,7 @@ static void migrate_receive(int debug, i
         fprintf(stderr, "migration target: Cleanup OK, granting sender"
                 " permission to resume.\n");
 
-        rc2 = libxl_write_exactly(&ctx, 1,
+        rc2 = libxl_write_exactly(ctx, 1,
                                   migrate_permission_to_go,
                                   sizeof(migrate_permission_to_go),
                                   "migration ack stream",
@@ -3194,7 +3195,7 @@ int main_list(int argc, char **argv)
     }
 
     if (optind >= argc) {
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3202,7 +3203,7 @@ int main_list(int argc, char **argv)
         info_free = info;
     } else if (optind == argc-1) {
         find_domain(argv[optind]);
-        rc = libxl_domain_info(&ctx, &info_buf, domid);
+        rc = libxl_domain_info(ctx, &info_buf, domid);
         if (rc == ERROR_INVAL) {
             fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
                 argv[optind]);
@@ -3353,7 +3354,7 @@ static void button_press(const char *p, 
         exit(2);
     }
 
-    libxl_button_press(&ctx, domid, button);
+    libxl_button_press(ctx, domid, button);
 }
 
 int main_button_press(int argc, char **argv)
@@ -3441,7 +3442,7 @@ static void print_vcpuinfo(uint32_t tdom
     char *domname;
 
     /*      NAME  ID  VCPU */
-    domname = libxl_domid_to_name(&ctx, tdomid);
+    domname = libxl_domid_to_name(ctx, tdomid);
     printf("%-32s %5u %5u",
            domname, tdomid, vcpuinfo->vcpuid);
     free(domname);
@@ -3466,7 +3467,7 @@ static void print_domain_vcpuinfo(uint32
     libxl_vcpuinfo *vcpuinfo;
     int i, nb_vcpu, nrcpus;
 
-    vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &nrcpus);
+    vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nrcpus);
 
     if (!vcpuinfo) {
         fprintf(stderr, "libxl_list_vcpu failed.\n");
@@ -3487,7 +3488,7 @@ static void vcpulist(int argc, char **ar
     libxl_physinfo physinfo;
     int i, nb_domain;
 
-    if (libxl_get_physinfo(&ctx, &physinfo) != 0) {
+    if (libxl_get_physinfo(ctx, &physinfo) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         goto vcpulist_out;
     }
@@ -3495,7 +3496,7 @@ static void vcpulist(int argc, char **ar
     printf("%-32s %5s %5s %5s %5s %9s %s\n",
            "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "CPU Affinity");
     if (!argc) {
-        if (!(dominfo = libxl_list_domain(&ctx, &nb_domain))) {
+        if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) {
             fprintf(stderr, "libxl_list_domain failed.\n");
             goto vcpulist_out;
         }
@@ -3558,7 +3559,7 @@ static void vcpupin(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         goto vcpupin_out;
     }
     if (strcmp(cpu, "all")) {
@@ -3589,17 +3590,17 @@ static void vcpupin(const char *d, const
     }
 
     if (vcpuid != -1) {
-        if (libxl_set_vcpuaffinity(&ctx, domid, vcpuid, &cpumap) == -1) {
+        if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, &cpumap) == -1) {
             fprintf(stderr, "Could not set affinity for vcpu `%u'.\n", vcpuid);
         }
     }
     else {
-        if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &i))) {
+        if (!(vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &i))) {
             fprintf(stderr, "libxl_list_vcpu failed.\n");
             goto vcpupin_out1;
         }
         for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
-            if (libxl_set_vcpuaffinity(&ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
+            if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
                 fprintf(stderr, "libxl_set_vcpuaffinity failed on vcpu `%u'.\n", vcpuinfo->vcpuid);
             }
         }
@@ -3648,14 +3649,14 @@ static void vcpuset(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "libxl_cpumap_alloc failed\n");
         return;
     }
     for (i = 0; i < max_vcpus; i++)
         libxl_cpumap_set(&cpumap, i);
 
-    if (libxl_set_vcpuonline(&ctx, domid, &cpumap) < 0)
+    if (libxl_set_vcpuonline(ctx, domid, &cpumap) < 0)
         fprintf(stderr, "libxl_set_vcpuonline failed domid=%d max_vcpus=%d\n", domid, max_vcpus);
 
     libxl_cpumap_destroy(&cpumap);
@@ -3689,12 +3690,12 @@ static void output_xeninfo(void)
     const libxl_version_info *info;
     int sched_id;
 
-    if (!(info = libxl_get_version_info(&ctx))) {
+    if (!(info = libxl_get_version_info(ctx))) {
         fprintf(stderr, "libxl_get_version_info failed.\n");
         return;
     }
 
-    if ((sched_id = libxl_get_sched_id(&ctx)) < 0) {
+    if ((sched_id = libxl_get_sched_id(ctx)) < 0) {
         fprintf(stderr, "get_sched_id sysctl failed.\n");
         return;
     }
@@ -3703,7 +3704,7 @@ static void output_xeninfo(void)
     printf("xen_minor              : %d\n", info->xen_version_minor);
     printf("xen_extra              : %s\n", info->xen_version_extra);
     printf("xen_caps               : %s\n", info->capabilities);
-    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(&ctx, sched_id));
+    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(ctx, sched_id));
     printf("xen_pagesize           : %lu\n", info->pagesize);
     printf("platform_params        : virt_start=0x%lx\n", info->virt_start);
     printf("xen_changeset          : %s\n", info->changeset);
@@ -3737,7 +3738,7 @@ static void output_physinfo(void)
     libxl_cpumap cpumap;
     int n = 0;
 
-    if (libxl_get_physinfo(&ctx, &info) != 0) {
+    if (libxl_get_physinfo(ctx, &info) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         return;
     }
@@ -3756,13 +3757,13 @@ static void output_physinfo(void)
     if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
         printf(" hvm_directio");
     printf("\n");
-    vinfo = libxl_get_version_info(&ctx);
+    vinfo = libxl_get_version_info(ctx);
     if (vinfo) {
         i = (1 << 20) / vinfo->pagesize;
         printf("total_memory           : %"PRIu64"\n", info.total_pages / i);
         printf("free_memory            : %"PRIu64"\n", info.free_pages / i);
     }
-    if (!libxl_get_freecpus(&ctx, &cpumap)) {
+    if (!libxl_get_freecpus(ctx, &cpumap)) {
         libxl_for_each_cpu(i, cpumap)
             if (libxl_cpumap_test(&cpumap, i))
                 n++;
@@ -3778,7 +3779,7 @@ static void output_topologyinfo(void)
     libxl_topologyinfo info;
     int i;
 
-    if (libxl_get_topologyinfo(&ctx, &info)) {
+    if (libxl_get_topologyinfo(ctx, &info)) {
         fprintf(stderr, "libxl_get_topologyinfo failed.\n");
         return;
     }
@@ -3849,7 +3850,7 @@ static int sched_credit_domain_get(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_get(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_get(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_get failed.\n");
     
@@ -3861,7 +3862,7 @@ static int sched_credit_domain_set(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_set(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_set(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_set failed.\n");
 
@@ -3872,7 +3873,7 @@ static void sched_credit_domain_output(
     int domid, libxl_sched_credit *scinfo)
 {
     char *domname;
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d %4d\n",
         domname,
         domid,
@@ -3918,7 +3919,7 @@ int main_sched_credit(int argc, char **a
     }
 
     if (!dom) { /* list all domain's credit scheduler info */
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3978,7 +3979,7 @@ int main_domid(int argc, char **argv)
         return 1;
     }
 
-    if (libxl_name_to_domid(&ctx, domname, &domid)) {
+    if (libxl_name_to_domid(ctx, domname, &domid)) {
         fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname);
         return 1;
     }
@@ -4017,7 +4018,7 @@ int main_domname(int argc, char **argv)
         return 1;
     }
 
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     if (!domname) {
         fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid);
         return 1;
@@ -4056,7 +4057,7 @@ int main_rename(int argc, char **argv)
     find_domain(dom);
     new_name = argv[optind];
 
-    if (libxl_domain_rename(&ctx, domid, common_domname, new_name)) {
+    if (libxl_domain_rename(ctx, domid, common_domname, new_name)) {
         fprintf(stderr, "Can't rename domain '%s'.\n", dom);
         return 1;
     }
@@ -4101,7 +4102,7 @@ int main_trigger(int argc, char **argv)
         }
     }
 
-    libxl_send_trigger(&ctx, domid, trigger_name, vcpuid);
+    libxl_send_trigger(ctx, domid, trigger_name, vcpuid);
 
     return 0;
 }
@@ -4141,7 +4142,7 @@ int main_sysrq(int argc, char **argv)
         return 1;
     }
 
-    libxl_send_sysrq(&ctx, domid, sysrq[0]);
+    libxl_send_sysrq(ctx, domid, sysrq[0]);
 
     return 0;
 }
@@ -4168,7 +4169,7 @@ int main_debug_keys(int argc, char **arg
 
     keys = argv[optind];
 
-    if (libxl_send_debug_keys(&ctx, keys)) {
+    if (libxl_send_debug_keys(ctx, keys)) {
         fprintf(stderr, "cannot send debug keys: %s\n", keys);
         return 1;
     }
@@ -4197,15 +4198,15 @@ int main_dmesg(int argc, char **argv)
         }
     }
 
-    cr = libxl_xen_console_read_start(&ctx, clear);
+    cr = libxl_xen_console_read_start(ctx, clear);
     if (!cr)
         goto finish;
 
-    while ((ret = libxl_xen_console_read_line(&ctx, cr, &line)) > 0)
+    while ((ret = libxl_xen_console_read_line(ctx, cr, &line)) > 0)
         printf("%s", line);
 
 finish:
-    libxl_xen_console_read_finish(&ctx, cr);
+    libxl_xen_console_read_finish(ctx, cr);
     return ret;
 }
 
@@ -4284,7 +4285,7 @@ int main_networkattach(int argc, char **
         } else if (!strncmp("script=", *argv, 6)) {
             nic.script = (*argv) + 6;
         } else if (!strncmp("backend=", *argv, 8)) {
-            if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) {
+            if(libxl_name_to_domid(ctx, ((*argv) + 8), &val)) {
                 fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                 val = 0;
             }
@@ -4301,7 +4302,7 @@ int main_networkattach(int argc, char **
         }
     }
     nic.domid = domid;
-    if (libxl_device_nic_add(&ctx, domid, &nic)) {
+    if (libxl_device_nic_add(ctx, domid, &nic)) {
         fprintf(stderr, "libxl_device_nic_add failed.\n");
         return 1;
     }
@@ -4338,7 +4339,7 @@ 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 (!(nics = libxl_list_nics(ctx, domid, &nb))) {
             continue;
         }
         for (i = 0; i < nb; ++i) {
@@ -4385,17 +4386,17 @@ int main_networkdetach(int argc, char **
     }
 
     if (!strchr(argv[optind+1], ':')) {
-        if (libxl_devid_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_devid_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     } else {
-        if (libxl_mac_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_mac_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     }
-    if (libxl_device_nic_del(&ctx, &nic, 1)) {
+    if (libxl_device_nic_del(ctx, &nic, 1)) {
         fprintf(stderr, "libxl_device_nic_del failed.\n");
         return 1;
     }
@@ -4473,7 +4474,7 @@ int main_blockattach(int argc, char **ar
     disk.domid = fe_domid;
     disk.backend_domid = be_domid;
 
-    if (libxl_device_disk_add(&ctx, fe_domid, &disk)) {
+    if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
         fprintf(stderr, "libxl_device_disk_add failed.\n");
     }
     return 0;
@@ -4508,12 +4509,12 @@ int main_blocklist(int argc, char **argv
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        disks = libxl_device_disk_list(&ctx, domid, &nb);
+        disks = libxl_device_disk_list(ctx, domid, &nb);
         if (!disks) {
             continue;
         }
         for (i=0; i<nb; i++) {
-            if (!libxl_device_disk_getinfo(&ctx, domid, &disks[i], &diskinfo)) {
+            if (!libxl_device_disk_getinfo(ctx, domid, &disks[i], &diskinfo)) {
                 /*      Vdev BE   hdl  st   evch rref BE-path*/
                 printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
                        diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id,
@@ -4551,11 +4552,11 @@ int main_blockdetach(int argc, char **ar
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_disk(&ctx, domid, argv[optind+1], &disk)) {
+    if (libxl_devid_to_device_disk(ctx, domid, argv[optind+1], &disk)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_disk_del(&ctx, &disk, 1)) {
+    if (libxl_device_disk_del(ctx, &disk, 1)) {
         fprintf(stderr, "libxl_device_disk_del failed.\n");
     }
     return 0;
@@ -4652,7 +4653,7 @@ int main_network2attach(int argc, char *
     }
     net2.domid = domid;
     net2.backend_domid = back_domid;
-    if (libxl_device_net2_add(&ctx, domid, &net2)) {
+    if (libxl_device_net2_add(ctx, domid, &net2)) {
         fprintf(stderr, "libxl_device_net2_add failed.\n");
     }
     return 0;
@@ -4687,7 +4688,7 @@ int main_network2list(int argc, char **a
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        if ((net2s = libxl_device_net2_list(&ctx, domid, &nb))) {
+        if ((net2s = libxl_device_net2_list(ctx, domid, &nb))) {
             for (; nb > 0; --nb, ++net2s) {
                 printf("%3d %2d %5d ", net2s->devid, net2s->backend_id, net2s->state);
                 printf("%02x:%02x:%02x:%02x:%02x:%02x ",
@@ -4727,11 +4728,11 @@ int main_network2detach(int argc, char *
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_net2(&ctx, domid, argv[optind+1], &net2)) {
+    if (libxl_devid_to_device_net2(ctx, domid, argv[optind+1], &net2)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_net2_del(&ctx, &net2, 1)) {
+    if (libxl_device_net2_del(ctx, &net2, 1)) {
         fprintf(stderr, "libxl_device_net2_del failed.\n");
         return 1;
     }
@@ -4811,7 +4812,7 @@ static void print_dom0_uptime(int short_
     strtok(buf, " ");
     uptime = strtoul(buf, NULL, 10);
 
-    domname = libxl_domid_to_name(&ctx, 0);
+    domname = libxl_domid_to_name(ctx, 0);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4844,11 +4845,11 @@ static void print_domU_uptime(uint32_t d
     char *now_str = NULL;
     char *domname;
 
-    s_time = libxl_vm_get_start_time(&ctx, domuid);
+    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);
+    domname = libxl_domid_to_name(ctx, domuid);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4883,7 +4884,7 @@ static void print_uptime(int short_mode,
 
     if (nb_doms == 0) {
         print_dom0_uptime(short_mode, now);
-        info = libxl_list_vm(&ctx, &nb_vm);
+        info = libxl_list_vm(ctx, &nb_vm);
         for (i = 0; i < nb_vm; i++)
             print_domU_uptime(info[i].domid, short_mode, now);
     } else {
@@ -4965,7 +4966,7 @@ int main_tmem_list(int argc, char **argv
     else
         find_domain(dom);
 
-    buf = libxl_tmem_list(&ctx, domid, use_long);
+    buf = libxl_tmem_list(ctx, domid, use_long);
     if (buf == NULL)
         return -1;
 
@@ -5006,7 +5007,7 @@ int main_tmem_freeze(int argc, char **ar
     else
         find_domain(dom);
 
-    libxl_tmem_freeze(&ctx, domid);
+    libxl_tmem_freeze(ctx, domid);
     return 0;
 }
 
@@ -5042,7 +5043,7 @@ int main_tmem_destroy(int argc, char **a
     else
         find_domain(dom);
 
-    libxl_tmem_destroy(&ctx, domid);
+    libxl_tmem_destroy(ctx, domid);
     return 0;
 }
 
@@ -5078,7 +5079,7 @@ int main_tmem_thaw(int argc, char **argv
     else
         find_domain(dom);
 
-    libxl_tmem_thaw(&ctx, domid);
+    libxl_tmem_thaw(ctx, domid);
     return 0;
 }
 
@@ -5135,11 +5136,11 @@ int main_tmem_set(int argc, char **argv)
     }
 
     if (opt_w)
-        libxl_tmem_set(&ctx, domid, "weight", weight);
+        libxl_tmem_set(ctx, domid, "weight", weight);
     if (opt_c)
-        libxl_tmem_set(&ctx, domid, "cap", cap);
+        libxl_tmem_set(ctx, domid, "cap", cap);
     if (opt_p)
-        libxl_tmem_set(&ctx, domid, "compress", compress);
+        libxl_tmem_set(ctx, domid, "compress", compress);
 
     return 0;
 }
@@ -5198,7 +5199,7 @@ int main_tmem_shared_auth(int argc, char
         return 1;
     }
 
-    libxl_tmem_shared_auth(&ctx, domid, uuid, auth);
+    libxl_tmem_shared_auth(ctx, domid, uuid, auth);
 
     return 0;
 }
@@ -5219,7 +5220,7 @@ int main_tmem_freeable(int argc, char **
         }
     }
 
-    mb = libxl_tmem_freeable(&ctx);
+    mb = libxl_tmem_freeable(ctx);
     if (mb == -1)
         return -1;
 
@@ -5300,7 +5301,7 @@ int main_cpupoolcreate(int argc, char **
         return -ERROR_FAIL;
     }
 
-    if (libxl_read_file_contents(&ctx, filename, (void **)&config_data, &config_len)) {
+    if (libxl_read_file_contents(ctx, filename, (void **)&config_data, &config_len)) {
         fprintf(stderr, "Failed to read config file: %s: %s\n",
                 filename, strerror(errno));
         return -ERROR_FAIL;
@@ -5338,36 +5339,36 @@ int main_cpupoolcreate(int argc, char **
         name = strdup(buf);
     else
         name = libxl_basename(filename);
-    if (!libxl_name_to_cpupoolid(&ctx, name, &poolid)) {
+    if (!libxl_name_to_cpupoolid(ctx, name, &poolid)) {
         fprintf(stderr, "Pool name \"%s\" already exists\n", name);
         return -ERROR_FAIL;
     }
 
     if (!xlu_cfg_get_string (config, "sched", &buf)) {
-        if ((schedid = libxl_name_to_schedid(&ctx, buf)) < 0) {
+        if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) {
             fprintf(stderr, "Unknown scheduler\n");
             return -ERROR_FAIL;
         }
     } else {
-        if ((schedid = libxl_get_sched_id(&ctx)) < 0) {
+        if ((schedid = libxl_get_sched_id(ctx)) < 0) {
             fprintf(stderr, "get_sched_id sysctl failed.\n");
             return -ERROR_FAIL;
         }
     }
-    sched = libxl_schedid_to_name(&ctx, schedid);
-
-    if (libxl_get_freecpus(&ctx, &freemap)) {
+    sched = libxl_schedid_to_name(ctx, schedid);
+
+    if (libxl_get_freecpus(ctx, &freemap)) {
         fprintf(stderr, "libxl_get_freecpus failed\n");
         return -ERROR_FAIL;
     }
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         return -ERROR_FAIL;
     }
     if (!xlu_cfg_get_list(config, "nodes", &nodes, 0, 0)) {
         n_cpus = 0;
         n_nodes = 0;
-        if (libxl_get_topologyinfo(&ctx, &topology)) {
+        if (libxl_get_topologyinfo(ctx, &topology)) {
             fprintf(stderr, "libxl_get_topologyinfo failed\n");
             return -ERROR_FAIL;
         }
@@ -5427,7 +5428,7 @@ int main_cpupoolcreate(int argc, char **
         return 0;
 
     poolid = 0;
-    if (libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid)) {
+    if (libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid)) {
         fprintf(stderr, "error on creating cpupool\n");
         return -ERROR_FAIL;
     }
@@ -5481,13 +5482,13 @@ int main_cpupoollist(int argc, char **ar
     }
     if (optind < argc) {
         pool = argv[optind];
-        if (libxl_name_to_cpupoolid(&ctx, pool, &poolid)) {
+        if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
             fprintf(stderr, "Pool \'%s\' does not exist\n", pool);
             return -ERROR_FAIL;
         }
     }
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5501,7 +5502,7 @@ int main_cpupoollist(int argc, char **ar
 
     for (p = 0; p < n_pools; p++) {
         if (!ret && (!pool || (poolinfo[p].poolid == poolid))) {
-            name = libxl_cpupoolid_to_name(&ctx, poolinfo[p].poolid);
+            name = libxl_cpupoolid_to_name(ctx, poolinfo[p].poolid);
             if (!name) {
                 fprintf(stderr, "error getting cpupool info\n");
                 ret = -ERROR_NOMEM;
@@ -5517,7 +5518,7 @@ int main_cpupoollist(int argc, char **ar
                     }
                 if (!opt_cpus) {
                     printf("%3d %9s       y       %4d", n,
-                           libxl_schedid_to_name(&ctx, poolinfo[p].sched_id),
+                           libxl_schedid_to_name(ctx, poolinfo[p].sched_id),
                            poolinfo[p].n_dom);
                 }
                 printf("\n");
@@ -5554,12 +5555,12 @@ int main_cpupooldestroy(int argc, char *
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_destroy_cpupool(&ctx, poolid);
+    return -libxl_destroy_cpupool(ctx, poolid);
 }
 
 int main_cpupoolrename(int argc, char **argv)
@@ -5588,14 +5589,14 @@ int main_cpupoolrename(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     new_name = argv[optind];
 
-    if (libxl_cpupool_rename(&ctx, new_name, poolid)) {
+    if (libxl_cpupool_rename(ctx, new_name, poolid)) {
         fprintf(stderr, "Can't rename cpupool '%s'.\n", pool);
         return 1;
     }
@@ -5644,16 +5645,16 @@ int main_cpupoolcpuadd(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuadd(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuadd(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuadd_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuadd_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5707,16 +5708,16 @@ int main_cpupoolcpuremove(int argc, char
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuremove(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuremove_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuremove(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuremove_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuremove_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5763,18 +5764,18 @@ int main_cpupoolmigrate(int argc, char *
     }
 
     if (domain_qualifier_to_domid(dom, &domid, NULL) ||
-        !libxl_domid_to_name(&ctx, domid)) {
+        !libxl_domid_to_name(ctx, domid)) {
         fprintf(stderr, "unknown domain \'%s\'\n", dom);
         return -ERROR_FAIL;
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_cpupool_movedomain(&ctx, poolid, domid);
+    return -libxl_cpupool_movedomain(ctx, poolid, domid);
 }
 
 int main_cpupoolnumasplit(int argc, char **argv)
@@ -5807,7 +5808,7 @@ int main_cpupoolnumasplit(int argc, char
     }
     ret = 0;
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5822,12 +5823,12 @@ int main_cpupoolnumasplit(int argc, char
         return -ERROR_FAIL;
     }
 
-    if (libxl_get_topologyinfo(&ctx, &topology)) {
+    if (libxl_get_topologyinfo(ctx, &topology)) {
         fprintf(stderr, "libxl_get_topologyinfo failed\n");
         return -ERROR_FAIL;
     }
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         libxl_topologyinfo_destroy(&topology);
         return -ERROR_FAIL;
@@ -5837,13 +5838,13 @@ int main_cpupoolnumasplit(int argc, char
        a cpupool without cpus in between */
 
     node = topology.nodemap.array[0];
-    if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) {
+    if (libxl_cpupool_cpuadd_node(ctx, 0, node, &n)) {
         fprintf(stderr, "error on adding cpu to Pool 0\n");
         return -ERROR_FAIL;
     }
 
     snprintf(name, 15, "Pool-node%d", node);
-    ret = -libxl_cpupool_rename(&ctx, name, 0);
+    ret = -libxl_cpupool_rename(ctx, name, 0);
     if (ret) {
         fprintf(stderr, "error on renaming Pool 0\n");
         goto out;
@@ -5857,12 +5858,12 @@ int main_cpupoolnumasplit(int argc, char
             n++;
         }
     }
-    if (libxl_set_vcpuonline(&ctx, 0, &cpumap)) {
+    if (libxl_set_vcpuonline(ctx, 0, &cpumap)) {
         fprintf(stderr, "error on removing vcpus for Domain-0\n");
         goto out;
     }
     for (c = 0; c < 10; c++) {
-        if (libxl_domain_info(&ctx, &info, 0)) {
+        if (libxl_domain_info(ctx, &info, 0)) {
             fprintf(stderr, "error on getting info for Domain-0\n");
             goto out;
         }
@@ -5883,7 +5884,7 @@ int main_cpupoolnumasplit(int argc, char
         }
 
         node = topology.nodemap.array[c];
-        ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n);
+        ret = -libxl_cpupool_cpuremove_node(ctx, 0, node, &n);
         if (ret) {
             fprintf(stderr, "error on removing cpu from Pool 0\n");
             goto out;
@@ -5892,13 +5893,13 @@ int main_cpupoolnumasplit(int argc, char
         snprintf(name, 15, "Pool-node%d", node);
         libxl_uuid_generate(&uuid);
         poolid = 0;
-        ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid);
+        ret = -libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid);
         if (ret) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out;
         }
 
-        ret = -libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n);
+        ret = -libxl_cpupool_cpuadd_node(ctx, poolid, node, &n);
         if (ret) {
             fprintf(stderr, "error on adding cpus to cpupool\n");
             goto out;
diff -r f5ada9268c1a -r f968b14db03f tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c	Thu Mar 31 11:54:13 2011 +0100
@@ -52,21 +52,21 @@ void log_destroy(struct xentoollog_logge
 {
 }
 
-#define INIT_STRUCT() libxl_ctx ctx; struct caml_logger lg; struct caml_gc gc; gc.offset = 0;
+#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); \
+	ret = libxl_ctx_alloc(&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)
+	libxl_ctx_free(ctx)
 
 static char * dup_String_val(caml_gc *gc, value s)
 {
@@ -372,7 +372,7 @@ value stub_xl_disk_add(value info, value
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("disk_add", &lg);
 	FREE_CTX();
@@ -390,7 +390,7 @@ value stub_xl_disk_remove(value info, va
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_del(&ctx, &c_info, 0);
+	ret = libxl_device_disk_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("disk_remove", &lg);
 	FREE_CTX();
@@ -408,7 +408,7 @@ value stub_xl_nic_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("nic_add", &lg);
 	FREE_CTX();
@@ -426,7 +426,7 @@ value stub_xl_nic_remove(value info, val
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_del(&ctx, &c_info, 0);
+	ret = libxl_device_nic_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("nic_remove", &lg);
 	FREE_CTX();
@@ -447,7 +447,7 @@ value stub_xl_console_add(value info, va
 	c_info.build_state = &c_state;
 
 	INIT_CTX();
-	ret = libxl_device_console_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_console_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("console_add", &lg);
 	FREE_CTX();
@@ -465,7 +465,7 @@ value stub_xl_vkb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vkb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vkb_add", &lg);
 	FREE_CTX();
@@ -480,7 +480,7 @@ value stub_xl_vkb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -495,7 +495,7 @@ value stub_xl_vkb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -514,7 +514,7 @@ value stub_xl_vfb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vfb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vfb_add", &lg);
 	FREE_CTX();
@@ -529,7 +529,7 @@ value stub_xl_vfb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -544,7 +544,7 @@ value stub_xl_vfb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -562,7 +562,7 @@ value stub_xl_pci_add(value info, value 
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("pci_add", &lg);
 	FREE_CTX();
@@ -580,7 +580,7 @@ value stub_xl_pci_remove(value info, val
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_remove(&ctx, Int_val(domid), &c_info, 0);
+	ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0);
 	if (ret != 0)
 		failwith_xl("pci_remove", &lg);
 	FREE_CTX();
@@ -595,7 +595,7 @@ value stub_xl_pci_shutdown(value domid)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_pci_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_pci_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("pci_shutdown", &lg);
 	FREE_CTX();
@@ -610,7 +610,7 @@ value stub_xl_button_press(value domid, 
 	INIT_STRUCT();
 	
 	INIT_CTX();
-	ret = libxl_button_press(&ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
+	ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
 	if (ret != 0)
 		failwith_xl("button_press", &lg);
 	FREE_CTX();
@@ -627,7 +627,7 @@ value stub_xl_physinfo(value unit)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_get_physinfo(&ctx, &c_physinfo);
+	ret = libxl_get_physinfo(ctx, &c_physinfo);
 	if (ret != 0)
 		failwith_xl("physinfo", &lg);
 	FREE_CTX();
@@ -645,7 +645,7 @@ value stub_xl_sched_credit_domain_get(va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_get(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_get(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_get", &lg);
 	FREE_CTX();
@@ -664,7 +664,7 @@ value stub_xl_sched_credit_domain_set(va
 	sched_credit_val(&gc, &c_scinfo, scinfo);
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_set(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_set", &lg);
 	FREE_CTX();
@@ -682,7 +682,7 @@ value stub_xl_send_trigger(value domid, 
 	c_trigger = dup_String_val(&gc, trigger);
 
 	INIT_CTX();
-	ret = libxl_send_trigger(&ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
+	ret = libxl_send_trigger(ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
 	if (ret != 0)
 		failwith_xl("send_trigger", &lg);
 	FREE_CTX();
@@ -696,7 +696,7 @@ value stub_xl_send_sysrq(value domid, va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_send_sysrq(&ctx, Int_val(domid), Int_val(sysrq));
+	ret = libxl_send_sysrq(ctx, Int_val(domid), Int_val(sysrq));
 	if (ret != 0)
 		failwith_xl("send_sysrq", &lg);
 	FREE_CTX();
@@ -713,7 +713,7 @@ value stub_xl_send_debug_keys(value keys
 	c_keys = dup_String_val(&gc, keys);
 
 	INIT_CTX();
-	ret = libxl_send_debug_keys(&ctx, c_keys);
+	ret = libxl_send_debug_keys(ctx, c_keys);
 	if (ret != 0)
 		failwith_xl("send_debug_keys", &lg);
 	FREE_CTX();
diff -r f5ada9268c1a -r f968b14db03f tools/python/setup.py
--- a/tools/python/setup.py	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/python/setup.py	Thu Mar 31 11:54:13 2011 +0100
@@ -83,7 +83,7 @@ netlink = Extension("netlink",
 
 xl = Extension("xl",
                extra_compile_args = extra_compile_args,
-               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, PATH_XENSTORE, "xen/lowlevel/xl" ],
+               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, "xen/lowlevel/xl" ],
                library_dirs       = [ PATH_LIBXL ],
                libraries          = [ "xenlight" ],
                depends            = [ PATH_LIBXL + "/libxenlight.so" ],
diff -r f5ada9268c1a -r f968b14db03f tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c	Thu Mar 31 11:42:55 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c	Thu Mar 31 11:54:13 2011 +0100
@@ -370,7 +370,7 @@ PyObject *attrib__struct_in_addr_get(str
 
 typedef struct {
     PyObject_HEAD;
-    libxl_ctx ctx;
+    libxl_ctx *ctx;
     xentoollog_logger_stdiostream *logger;
     xentoollog_level minmsglevel;
 } XlObject;
@@ -381,7 +381,7 @@ static PyObject *pyxl_list_domains(XlObj
     PyObject *list;
     int nr_dom, i;
 
-    info = libxl_list_domain(&self->ctx, &nr_dom);
+    info = libxl_list_domain(self->ctx, &nr_dom);
     if ( NULL == info )
         return PyList_New(0);
 
@@ -416,7 +416,7 @@ static PyObject *pyxl_domid_to_name(XlOb
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    domname = libxl_domid_to_name(&self->ctx, domid);
+    domname = libxl_domid_to_name(self->ctx, domid);
     ret = PyString_FromString(domname);
     free(domname);
 
@@ -428,7 +428,7 @@ static PyObject *pyxl_domain_shutdown(Xl
     int domid, req = 0;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &req) )
         return NULL;
-    if ( libxl_domain_shutdown(&self->ctx, domid, req) ) {
+    if ( libxl_domain_shutdown(self->ctx, domid, req) ) {
         PyErr_SetString(xl_error_obj, "cannot shutdown domain");
         return NULL;
     }
@@ -441,7 +441,7 @@ static PyObject *pyxl_domain_destroy(XlO
     int domid, force = 1;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &force) )
         return NULL;
-    if ( libxl_domain_destroy(&self->ctx, domid, force) ) {
+    if ( libxl_domain_destroy(self->ctx, domid, force) ) {
         PyErr_SetString(xl_error_obj, "cannot destroy domain");
         return NULL;
     }
@@ -454,7 +454,7 @@ static PyObject *pyxl_domain_pause(XlObj
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_pause(&self->ctx, domid) ) {
+    if ( libxl_domain_pause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot pause domain");
         return NULL;
     }
@@ -467,7 +467,7 @@ static PyObject *pyxl_domain_unpause(XlO
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_unpause(&self->ctx, domid) ) {
+    if ( libxl_domain_unpause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot unpause domain");
         return NULL;
     }
@@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlOb
     int domid;
     if ( !PyArg_ParseTuple(args, "is|s", &domid, &new_name, &old_name) )
         return NULL;
-    if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name) ) {
+    if ( libxl_domain_rename(self->ctx, domid, old_name, new_name) ) {
         PyErr_SetString(xl_error_obj, "cannot rename domain");
         return NULL;
     }
@@ -501,7 +501,7 @@ static PyObject *pyxl_pci_add(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_add(&self->ctx, domid, &pci->obj) ) {
+    if ( libxl_device_pci_add(self->ctx, domid, &pci->obj) ) {
         PyErr_SetString(xl_error_obj, "cannot add pci device");
         return NULL;
     }
@@ -522,7 +522,7 @@ static PyObject *pyxl_pci_del(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_remove(&self->ctx, domid, &pci->obj, force) ) {
+    if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj, force) ) {
         PyErr_SetString(xl_error_obj, "cannot remove pci device");
         return NULL;
     }
@@ -544,7 +544,7 @@ static PyObject *pyxl_pci_parse(XlObject
         return NULL;
     }
 
-    if ( libxl_device_pci_parse_bdf(&self->ctx, &pci->obj, str) ) {
+    if ( libxl_device_pci_parse_bdf(self->ctx, &pci->obj, str) ) {
         PyErr_SetString(xl_error_obj, "cannot parse pci device spec (BDF)");
         Py_DECREF(pci);
         return NULL;
@@ -559,7 +559,7 @@ static PyObject *pyxl_pci_list_assignabl
     PyObject *list;
     int nr_dev, i;
 
-    if ( libxl_device_pci_list_assignable(&self->ctx, &dev, &nr_dev) ) {
+    if ( libxl_device_pci_list_assignable(self->ctx, &dev, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -595,7 +595,7 @@ static PyObject *pyxl_pci_list(XlObject 
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    if ( libxl_device_pci_list_assigned(&self->ctx, &dev, domid, &nr_dev) ) {
+    if ( libxl_device_pci_list_assigned(self->ctx, &dev, domid, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -663,7 +663,7 @@ static PyObject *PyXl_new(PyTypeObject *
     if (self == NULL)
         return NULL;
 
-    memset(&self->ctx, 0, sizeof(self->ctx));
+    self->ctx = NULL;
     self->logger = NULL;
     self->minmsglevel = XTL_PROGRESS;
 
@@ -679,7 +679,7 @@ PyXl_init(XlObject *self, PyObject *args
         return -1;
     }
 
-    if ( libxl_ctx_init(&self->ctx, LIBXL_VERSION,
+    if ( libxl_ctx_alloc(&self->ctx, LIBXL_VERSION,
                 (xentoollog_logger*)self->logger) ) {
         PyErr_SetString(xl_error_obj, "cannot init xl context");
         return -1;
@@ -690,7 +690,7 @@ PyXl_init(XlObject *self, PyObject *args
 
 static void PyXl_dealloc(XlObject *self)
 {
-    libxl_ctx_free(&self->ctx);
+    libxl_ctx_free(self->ctx);
     if ( self->logger )
         xtl_logger_destroy((xentoollog_logger*)self->logger);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3 of 4] tools: remove pattern matched linking rules
  2011-03-31 10:56 [PATCH 0 of 4] tools: shave build yaks (part two) Ian Campbell
  2011-03-31 10:56 ` [PATCH 1 of 4] tools: Remove $(CFLAGS) from links lines Ian Campbell
  2011-03-31 10:56 ` [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h Ian Campbell
@ 2011-03-31 10:56 ` Ian Campbell
  2011-03-31 10:57 ` [PATCH 4 of 4] tools: remove some .o and binary files on clean Ian Campbell
  3 siblings, 0 replies; 9+ messages in thread
From: Ian Campbell @ 2011-03-31 10:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301568860 -3600
# Node ID 25e25665f03db5012283e4dc5957d6aa69a30ddf
# Parent  f968b14db03fcd7c42125b2ef9bc28c424959b2a
tools: remove pattern matched linking rules

Most subdirs only build a single tool to start with and those which
build multiple tools often have different linkage requirements.

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

diff -r f968b14db03f -r 25e25665f03d tools/debugger/xenitp/Makefile
--- a/tools/debugger/xenitp/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/debugger/xenitp/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -5,14 +5,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += $(CFLAGS_libxenctrl)
 
-HDRS     = $(wildcard *.h)
-OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
-
-BIN      =
 LIBBIN   = 
-SCRIPTS  =
-MAN1     = $(wildcard *.1)
-MAN8     = $(wildcard *.8)
 
 ifeq ($(XEN_TARGET_ARCH),ia64)
 LIBBIN  += xenitp
@@ -22,32 +15,18 @@ endif
 all: build
 
 .PHONY: build
-build: $(BIN) $(LIBBIN)
+build: $(LIBBIN)
 
 .PHONY: install
 install: build
-	$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
 	[ -z "$(LIBBIN)" ] || $(INSTALL_DIR) $(DESTDIR)$(PRIVATE_BINDIR)
-	$(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
-	$(INSTALL_DIR) $(DESTDIR)$(MAN8DIR)
-	if [ "x$(SCRIPTS)" != "x" ]; then \
-		$(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR); \
-	fi
 	[ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(PRIVATE_BINDIR)
-	if [ "x$(MAN1)" != "x" ]; then \
-		$(INSTALL_DATA) $(MAN1) $(DESTDIR)$(MAN1DIR); \
-	fi
-	if [ "x$(MAN1)" != "x" ]; then \
-		$(INSTALL_DATA) $(MAN8) $(DESTDIR)$(MAN8DIR); \
-	fi
 
 .PHONY: clean
 clean:
-	$(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN)
-
-%: %.c $(HDRS) Makefile
-	$(CC) $(CFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
+	$(RM) *.a *.so *.o *.rpm $(LIBBIN)
 
 XENITP_OBJS=xenitp.o ia64-dis.o ia64-opc.o cpu-ia64-opc.o
+
 xenitp: $(XENITP_OBJS)
 	$(CC) $(CFLAGS) -o $@ $(XENITP_OBJS) $(LDLIBS_libxenctrl)
diff -r f968b14db03f -r 25e25665f03d tools/flask/utils/Makefile
--- a/tools/flask/utils/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/flask/utils/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -18,7 +18,13 @@ CLIENTS_OBJS := $(patsubst flask-%,%.o,$
 .PHONY: all
 all: $(CLIENTS)
 
-$(CLIENTS): flask-%: %.o
+flask-loadpolicy: loadpolicy.o
+	$(CC) $(LDFLAGS) $< $(LDLIBS) -L$(LIBFLASK_ROOT) -lflask $(LDLIBS_libxenctrl) -o $@
+
+flask-setenforce: setenforce.o
+	$(CC) $(LDFLAGS) $< $(LDLIBS) -L$(LIBFLASK_ROOT) -lflask $(LDLIBS_libxenctrl) -o $@
+
+flask-getenforce: getenforce.o
 	$(CC) $(LDFLAGS) $< $(LDLIBS) -L$(LIBFLASK_ROOT) -lflask $(LDLIBS_libxenctrl) -o $@
 
 .PHONY: clean
@@ -41,6 +47,3 @@ install: all
 	$(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(SBINDIR)
 
 -include $(DEPS)
-
-# never delete any intermediate files.
-.SECONDARY:
diff -r f968b14db03f -r 25e25665f03d tools/misc/Makefile
--- a/tools/misc/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/misc/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -13,14 +13,6 @@ TARGETS-$(CONFIG_X86) += xen-detect xen-
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
-LDLIBS_xenperf      := $(LDLIBS_libxenctrl)
-LDLIBS_xenpm        := $(LDLIBS_libxenctrl)
-LDLIBS_xenlockprof  := $(LDLIBS_libxenctrl)
-LDLIBS_xenwatchdogd := $(LDLIBS_libxenctrl)
-LDLIBS_xen-hvmctx   := $(LDLIBS_libxenctrl)
-LDLIBS_xen-hvmcrash := $(LDLIBS_libxenctrl)
-LDLIBS_xen-hptool   := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
-
 SUBDIRS-$(CONFIG_LOMOUNT) += lomount
 SUBDIRS-$(CONFIG_MINITERM) += miniterm
 SUBDIRS := $(SUBDIRS-y)
@@ -54,13 +46,31 @@ clean:
 	$(RM) *.o $(TARGETS) *~ $(DEPS)
 	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
 
-%.o: %.c $(HDRS) Makefile
-	$(CC) -c $(CFLAGS) -o $@ $<
+xen-hvmctx: xen-hvmctx.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
 
-xen-hvmctx xen-hvmcrash xenperf xenpm gtracestat xenlockprof xen-hptool xenwatchdogd: %: %.o Makefile
-	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_$*)
+xen-hvmcrash: xen-hvmcrash.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
 
-gtraceview: %: %.o Makefile
+xenperf: xenperf.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
+
+xenpm: xenpm.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
+
+gtracestat: gtracestat.o
+	$(CC) $(LDFLAGS) -o $@ $<
+
+xenlockprof: xenlockprof.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
+
+xen-hptool: xen-hptool.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
+
+xenwatchdogd: xenwatchdogd.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl)
+
+gtraceview: gtraceview.o
 	$(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS)
 
 -include $(DEPS)
diff -r f968b14db03f -r 25e25665f03d tools/misc/lomount/Makefile
--- a/tools/misc/lomount/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/misc/lomount/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -3,16 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS  += -Werror
 
-HDRS     = $(wildcard *.h)
-OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
-
-BIN      = lomount
-
 .PHONY: all
 all: build
 
 .PHONY: build
-build: $(BIN)
+build: lomount
 
 .PHONY: install
 install install-recurse: build
@@ -22,6 +17,7 @@ install install-recurse: build
 clean:
 	$(RM) *.a *.so *.o *.rpm $(BIN)
 
-%: %.c $(HDRS) Makefile
+lomount: lomount.o
 	$(CC) $(CFLAGS) -o $@ $< 
 
+-include $(DEPS)
\ No newline at end of file
diff -r f968b14db03f -r 25e25665f03d tools/tests/mce-test/tools/Makefile
--- a/tools/tests/mce-test/tools/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/tests/mce-test/tools/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -2,21 +2,20 @@ XEN_ROOT=$(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 CFLAGS += -Werror
-
 CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenguest)
+CFLAGS += $(CFLAGS_libxenstore) 
 CFLAGS += $(CFLAGS_xeninclude) 
 
-HDRS     = $(wildcard *.h)
-
 .PHONY: all
 all: xen-mceinj
 
 install: 
-	cp xen-mceinj /usr/sbin/
+	$(INSTALL_PROG) xen-mceinj $(DESTDIR)$(SBINDIR)
 
 .PHONY: clean
 clean:
 	$(RM) *.o xen-mceinj
 
-xen-mceinj: %: %.o Makefile
+xen-mceinj: xen-mceinj.o Makefile
 	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
diff -r f968b14db03f -r 25e25665f03d tools/tests/xen-access/Makefile
--- a/tools/tests/xen-access/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/tests/xen-access/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -4,28 +4,24 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror
 
 CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenguest)
 CFLAGS += $(CFLAGS_xeninclude)
 
 TARGETS-y := 
 TARGETS-$(CONFIG_X86) += xen-access
 TARGETS := $(TARGETS-y)
 
-SUBDIRS-y :=
-SUBDIRS := $(SUBDIRS-y)
-
 .PHONY: all
 all: build
 
 .PHONY: build
 build: $(TARGETS)
-	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d; done
 
 .PHONY: clean
 clean:
 	$(RM) *.o $(TARGETS) *~ $(DEPS)
-	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
 
-xen-access: %: %.o Makefile
-	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl)
+xen-access: xen-access.o Makefile
+	$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
 
 -include $(DEPS)
diff -r f968b14db03f -r 25e25665f03d tools/xcutils/Makefile
--- a/tools/xcutils/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/xcutils/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -20,19 +20,23 @@ CFLAGS_xc_save.o    := $(CFLAGS_libxenct
 CFLAGS_readnotes.o  := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_lsevtchn.o   := $(CFLAGS_libxenctrl)
 
-LDLIBS_xc_restore := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
-LDLIBS_xc_save    := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
-LDLIBS_readnotes  := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
-LDLIBS_lsevtchn   := $(LDLIBS_libxenctrl)
-
 .PHONY: all
 all: build
 
 .PHONY: build
 build: $(PROGRAMS)
 
-$(PROGRAMS): %: %.o
-	$(CC) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_$*) -o $@
+xc_restore: xc_restore.o
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+
+xc_save: xc_save.o
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
+
+readnotes: readnotes.o
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+
+lsevtchn: lsevtchn.o
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS_libxenctrl)
 
 .PHONY: install
 install: build
diff -r f968b14db03f -r 25e25665f03d tools/xenbackendd/Makefile
--- a/tools/xenbackendd/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/xenbackendd/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -17,13 +17,11 @@ CFLAGS  += $(CFLAGS_libxenstore)
 CPPFLAGS += -DXEN_SCRIPT_DIR="\"$(XEN_SCRIPT_DIR)\""
 LDLIBS  += $(LDLIBS_libxenstore)
 
-SBIN = xenbackendd
-
 .PHONY: all
 all: build
 
 .PHONY: build
-build: $(SBIN)
+build: xenbackendd
 
 .PHONY: install
 install: build
@@ -32,10 +30,9 @@ install: build
 
 .PHONY: clean
 clean:
-	rm -f $(SBIN) $(DEPS)
+	rm -f $(DEPS)
 
-
-%: %.o Makefile
+xenbackendd: xenbackendd.o
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r f968b14db03f -r 25e25665f03d tools/xenmon/Makefile
--- a/tools/xenmon/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/xenmon/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -17,14 +17,13 @@ CFLAGS  += -Werror
 CFLAGS  += $(CFLAGS_libxenctrl)
 LDLIBS  += $(LDLIBS_libxenctrl)
 
-BIN = xentrace_setmask xenbaked
 SCRIPTS = xenmon.py
 
 .PHONY: all
 all: build
 
 .PHONY: build
-build: $(BIN)
+build: xentrace_setmask xenbaked
 
 .PHONY: install
 install: build
@@ -37,13 +36,12 @@ install: build
 
 .PHONY: clean
 clean:
-	rm -f $(BIN) $(DEPS)
+	rm -f  $(DEPS)
 
-
-%: %.o Makefile
+xenbaked: xenbaked.o Makefile
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
-xentrace_%: %.o Makefile
+xentrace_setmask: setmask.o Makefile
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r f968b14db03f -r 25e25665f03d tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/xenpmd/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -6,21 +6,19 @@ CFLAGS += $(CFLAGS_libxenstore)
 
 LDLIBS += $(LDLIBS_libxenstore)
 
-BIN      = xenpmd
-
 .PHONY: all
-all: $(BIN)
+all: xenpmd
 
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
-	$(INSTALL_PROG) $(BIN) $(DESTDIR)$(SBINDIR)
+	$(INSTALL_PROG) xenpmd $(DESTDIR)$(SBINDIR)
 
 .PHONY: clean
 clean:
-	$(RM) -f $(BIN) $(DEPS)
+	$(RM) -f xenpmd $(DEPS)
 
-%: %.o Makefile
+xenpmd: xenpmd.o Makefile
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
 
 -include $(DEPS)
diff -r f968b14db03f -r 25e25665f03d tools/xentrace/Makefile
--- a/tools/xentrace/Makefile	Thu Mar 31 11:54:13 2011 +0100
+++ b/tools/xentrace/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -6,27 +6,12 @@ CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl)
 LDLIBS += $(LDLIBS_libxenctrl)
 
-HDRS     = $(wildcard *.h)
-OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
-
 BIN      = xentrace xentrace_setsize
-LIBBIN   = 
+LIBBIN   = xenctx
 SCRIPTS  = xentrace_format
 MAN1     = $(wildcard *.1)
 MAN8     = $(wildcard *.8)
 
-ifeq ($(XEN_TARGET_ARCH),x86_32)
-LIBBIN  += xenctx
-endif
-
-ifeq ($(XEN_TARGET_ARCH),x86_64)
-LIBBIN  += xenctx
-endif
-
-ifeq ($(XEN_TARGET_ARCH),ia64)
-LIBBIN  += xenctx
-endif
-
 .PHONY: all
 all: build
 
@@ -49,9 +34,13 @@ install: build
 clean:
 	$(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN) $(DEPS)
 
-%: %.o $(HDRS) Makefile
+xentrace: xentrace.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS)
-xentrace_%: %.o $(HDRS) Makefile
+
+xenctx: xenctx.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+xentrace_setsize: setsize.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS)
 
 -include $(DEPS)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4 of 4] tools: remove some .o and binary files on clean
  2011-03-31 10:56 [PATCH 0 of 4] tools: shave build yaks (part two) Ian Campbell
                   ` (2 preceding siblings ...)
  2011-03-31 10:56 ` [PATCH 3 of 4] tools: remove pattern matched linking rules Ian Campbell
@ 2011-03-31 10:57 ` Ian Campbell
  2011-03-31 18:36   ` Ian Jackson
  3 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2011-03-31 10:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301568860 -3600
# Node ID dcc9d9a5fb46bf4f2e08fcda78526b18367f8b8b
# Parent  25e25665f03db5012283e4dc5957d6aa69a30ddf
tools: remove some .o and binary files on clean

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

diff -r 25e25665f03d -r dcc9d9a5fb46 tools/xenmon/Makefile
--- a/tools/xenmon/Makefile	Thu Mar 31 11:54:20 2011 +0100
+++ b/tools/xenmon/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -36,7 +36,9 @@ install: build
 
 .PHONY: clean
 clean:
-	rm -f  $(DEPS)
+	$(RM) -f $(DEPS)
+	$(RM) -f xenbaked xenbaked.o
+	$(RM) -f xentrace_setmake setmask.o
 
 xenbaked: xenbaked.o Makefile
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)
diff -r 25e25665f03d -r dcc9d9a5fb46 tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile	Thu Mar 31 11:54:20 2011 +0100
+++ b/tools/xenpmd/Makefile	Thu Mar 31 11:54:20 2011 +0100
@@ -16,7 +16,7 @@ install: all
 
 .PHONY: clean
 clean:
-	$(RM) -f xenpmd $(DEPS)
+	$(RM) -f xenpmd xenpmd.o $(DEPS)
 
 xenpmd: xenpmd.o Makefile
 	$(CC) $(LDFLAGS) $< -o $@ $(LDLIBS)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h
  2011-03-31 10:56 ` [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h Ian Campbell
@ 2011-03-31 18:33   ` Ian Jackson
  2011-04-01 13:12     ` Ian Campbell
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Jackson @ 2011-03-31 18:33 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h"):
> libxl: do not expose libxenctrl/libxenstore headers via libxl.h

I'm afraid this one doesn't apply any more:

Hunk #1 FAILED at 124.
1 out of 3 hunks FAILED -- saving rejects to file tools/libxl/libxl.h.rej

Ian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4 of 4] tools: remove some .o and binary files on clean
  2011-03-31 10:57 ` [PATCH 4 of 4] tools: remove some .o and binary files on clean Ian Campbell
@ 2011-03-31 18:36   ` Ian Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Jackson @ 2011-03-31 18:36 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel

Ian Campbell writes ("[Xen-devel] [PATCH 4 of 4] tools: remove some .o and binary files on clean"):
> tools: remove some .o and binary files on clean

Tahnks, I've acked and applied 1, 3 and 4.  I see 4 was a repost
of one I was complaining about earlier, and it applied fine after 1.

Ian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h
  2011-03-31 18:33   ` Ian Jackson
@ 2011-04-01 13:12     ` Ian Campbell
  2011-04-01 14:03       ` Ian Campbell
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Campbell @ 2011-04-01 13:12 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel@lists.xensource.com

On Thu, 2011-03-31 at 19:33 +0100, Ian Jackson wrote:
> Ian Campbell writes ("[Xen-devel] [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h"):
> > libxl: do not expose libxenctrl/libxenstore headers via libxl.h
> 
> I'm afraid this one doesn't apply any more:
> 
> Hunk #1 FAILED at 124.
> 1 out of 3 hunks FAILED -- saving rejects to file tools/libxl/libxl.h.rej
> 
> Ian.

It conflicted with "libxl: use system include for libxl_uuid.h".
Refreshed version below.

Since this touches a lot of lines of xl_cmdimpl.c this patch may be
particularly prone to breakage, fortunately of the easy to fix
mechanically kind (add a & to the ctx).

If you want I'm happy to coordinate a suitable window in the flow of
patches with you.

8<-------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301663079 -3600
# Node ID f92a4b0f40dfcc471d1ec58fb35f4a5f2581bea2
# Parent  b65de5ce62025524cbd47be345a445361affb2b1
libxl: do not expose libxenctrl/libxenstore headers via libxl.h

This completely removes libxenstore from libxl users' view.

xl still needs libxenctrl directly due to the direct use of the
xentoollog functionality but it is not exposed to the indirect linkage
anymore.

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

diff -r b65de5ce6202 -r f92a4b0f40df tools/Rules.mk
--- a/tools/Rules.mk	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/Rules.mk	Fri Apr 01 14:04:39 2011 +0100
@@ -49,7 +49,7 @@ LDLIBS_libblktapctl =
 SHLIB_libblktapctl  =
 endif
 
-CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude)
+CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
 LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight
 SHLIB_libxenlight  = -Wl,-rpath-link=$(XEN_XENLIGHT)
 
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/Makefile
--- a/tools/libxl/Makefile	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/Makefile	Fri Apr 01 14:04:39 2011 +0100
@@ -13,7 +13,6 @@ XLUMINOR = 0
 
 CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
 CFLAGS += -I. -fPIC
-CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
 ifeq ($(CONFIG_Linux),y)
 LIBUUID_LIBS += -luuid
@@ -38,13 +37,18 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_c
 			libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o
 
+$(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
+
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
 AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
 LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o
+$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 
 CLIENTS = xl
 
 XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 
 .PHONY: all
 all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl.c	Fri Apr 01 14:04:39 2011 +0100
@@ -41,15 +41,22 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg)
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger * lg)
 {
+    libxl_ctx *ctx;
     struct stat stat_buf;
 
     if (version != LIBXL_VERSION)
         return ERROR_VERSION;
+
+    ctx = malloc(sizeof(*ctx));
+    if (!ctx) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n");
+        return ERROR_NOMEM;
+    }
+
     memset(ctx, 0, sizeof(libxl_ctx));
     ctx->lg = lg;
-    memset(&ctx->version_info, 0, sizeof(libxl_version_info));
 
     if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n"
@@ -73,6 +80,8 @@ int libxl_ctx_init(libxl_ctx *ctx, int v
         xc_interface_close(ctx->xch);
         return ERROR_FAIL;
     }
+
+    *pctx = ctx;
     return 0;
 }
 
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl.h	Fri Apr 01 14:04:39 2011 +0100
@@ -124,13 +124,18 @@
 #ifndef LIBXL_H
 #define LIBXL_H
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <errno.h>
 #include <netinet/in.h>
-#include <xenctrl.h>
-#include <xs.h>
 #include <sys/wait.h> /* for pid_t */
 
+#include <xentoollog.h>
+
+#include <xen/sched.h>
+#include <xen/sysctl.h>
+
 #include <libxl_uuid.h>
 
 typedef uint8_t libxl_mac[6];
@@ -216,17 +221,7 @@ void libxl_cpuid_destroy(libxl_cpuid_pol
 
 #include "_libxl_types.h"
 
-typedef struct {
-    xentoollog_logger *lg;
-    xc_interface *xch;
-    struct xs_handle *xsh;
-
-    /* for callers who reap children willy-nilly; caller must only
-     * set this after libxl_init and before any other call - or
-     * may leave them untouched */
-    int (*waitpid_instead)(pid_t pid, int *status, int flags);
-    libxl_version_info version_info;
-} libxl_ctx;
+typedef struct libxl__ctx libxl_ctx;
 
 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
 
@@ -283,7 +278,7 @@ typedef struct {
 } libxl_domain_config;
 
 /* context functions */
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger*);
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger *lg);
 int libxl_ctx_free(libxl_ctx *ctx);
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl_internal.h	Fri Apr 01 14:04:39 2011 +0100
@@ -82,6 +82,17 @@ _hidden void libxl__log(libxl_ctx *ctx, 
 
      /* these functions preserve errno (saving and restoring) */
 
+struct libxl__ctx {
+    xentoollog_logger *lg;
+    xc_interface *xch;
+    struct xs_handle *xsh;
+
+    /* for callers who reap children willy-nilly; caller must only
+     * set this after libxl_init and before any other call - or
+     * may leave them untouched */
+    int (*waitpid_instead)(pid_t pid, int *status, int flags);
+    libxl_version_info version_info;
+};
 
 typedef enum {
     DEVICE_VIF = 1,
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/libxlu_cfg.c
--- a/tools/libxl/libxlu_cfg.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxlu_cfg.c	Fri Apr 01 14:04:39 2011 +0100
@@ -1,3 +1,4 @@
+#include <limits.h>
 
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/xl.c
--- a/tools/libxl/xl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl.c	Fri Apr 01 14:04:39 2011 +0100
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <xenctrl.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -111,7 +112,7 @@ int main(int argc, char **argv)
     logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
     if (!logger) exit(1);
 
-    if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
+    if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
         fprintf(stderr, "cannot init xl context\n");
         exit(1);
     }
@@ -123,7 +124,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    ret = libxl_read_file_contents(&ctx, config_file,
+    ret = libxl_read_file_contents(ctx, config_file,
             &config_data, &config_len);
     if (ret)
         fprintf(stderr, "Failed to read config file: %s: %s\n",
@@ -147,7 +148,7 @@ int main(int argc, char **argv)
         ret = 1;
     }
 
-    libxl_ctx_free(&ctx);
+    libxl_ctx_free(ctx);
     xtl_logger_destroy((xentoollog_logger*)logger);
 
     return ret;
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/xl.h
--- a/tools/libxl/xl.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl.h	Fri Apr 01 14:04:39 2011 +0100
@@ -95,7 +95,7 @@ extern int cmdtable_len;
 /* Look up a command in the table, allowing unambiguous truncation */
 struct cmd_spec *cmdtable_lookup(const char *s);
 
-extern libxl_ctx ctx;
+extern libxl_ctx *ctx;
 extern xentoollog_logger_stdiostream *logger;
 
 /* global options */
diff -r b65de5ce6202 -r f92a4b0f40df tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Fri Apr 01 14:04:39 2011 +0100
@@ -31,9 +31,10 @@
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <sys/utsname.h> /* for utsname in xl info */
-#include <xenctrl.h>
+#include <xentoollog.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <limits.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -62,7 +63,7 @@
 int logfile = 2;
 
 /* every libxl action in xl uses this same libxl context */
-libxl_ctx ctx;
+libxl_ctx *ctx;
 
 /* when we operate on a domain, it is this one: */
 static uint32_t domid;
@@ -150,11 +151,11 @@ static int domain_qualifier_to_domid(con
         *was_name_r = was_name;
 
     if (was_name) {
-        rc = libxl_name_to_domid(&ctx, p, domid_r);
+        rc = libxl_name_to_domid(ctx, p, domid_r);
         if (rc)
             return rc;
     } else {
-        rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
+        rc = libxl_domain_info(ctx, &dominfo, *domid_r);
         /* error only if domain does not exist */
         if (rc == ERROR_INVAL)
             return rc;
@@ -170,7 +171,7 @@ static int cpupool_qualifier_to_cpupooli
 
     was_name = qualifier_to_id(p, poolid_r);
     if (was_name_r) *was_name_r = was_name;
-    return was_name ? libxl_name_to_cpupoolid(&ctx, p, poolid_r) : 0;
+    return was_name ? libxl_name_to_cpupoolid(ctx, p, poolid_r) : 0;
 }
 
 static void find_domain(const char *p)
@@ -182,7 +183,7 @@ static void find_domain(const char *p)
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    common_domname = was_name ? p : libxl_domid_to_name(ctx, domid);
 }
 
 static int acquire_lock(void)
@@ -303,7 +304,7 @@ static void printf_info(int domid,
     /* retrieve the UUID from dominfo, since it is probably generated
      * during parsing and thus does not match the real one
      */
-    if (libxl_domain_info(&ctx, &info, domid) == 0) {
+    if (libxl_domain_info(ctx, &info, domid) == 0) {
         printf("\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(info.uuid));
     } else {
         printf("\t(uuid <unknown>)\n");
@@ -667,7 +668,7 @@ static void parse_config_data(const char
         c_info->poolid = -1;
         cpupool_qualifier_to_cpupoolid(buf, &c_info->poolid, NULL);
     }
-    c_info->poolname = libxl_cpupoolid_to_name(&ctx, c_info->poolid);
+    c_info->poolname = libxl_cpupoolid_to_name(ctx, c_info->poolid);
     if (!c_info->poolname) {
         fprintf(stderr, "Illegal pool specified\n");
         exit(1);
@@ -875,7 +876,7 @@ static void parse_config_data(const char
                     free(nic->ifname);
                     nic->ifname = strdup(p2 + 1);
                 } else if (!strcmp(p, "backend")) {
-                    if(libxl_name_to_domid(&ctx, (p2 + 1), &(nic->backend_domid))) {
+                    if(libxl_name_to_domid(ctx, (p2 + 1), &(nic->backend_domid))) {
                         fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                         nic->backend_domid = 0;
                     }
@@ -1022,7 +1023,7 @@ skip_vfb:
 
             pcidev->msitranslate = pci_msitranslate;
             pcidev->power_mgmt = pci_power_mgmt;
-            if (!libxl_device_pci_parse_bdf(&ctx, pcidev, buf))
+            if (!libxl_device_pci_parse_bdf(ctx, pcidev, buf))
                 d_config->num_pcidevs++;
         }
     }
@@ -1291,23 +1292,23 @@ static int freemem(libxl_domain_build_in
     if (!autoballoon)
         return 0;
 
-    rc = libxl_domain_need_memory(&ctx, b_info, dm_info, &need_memkb);
+    rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb);
     if (rc < 0)
         return rc;
 
     do {
-        rc = libxl_get_free_memory(&ctx, &free_memkb);
+        rc = libxl_get_free_memory(ctx, &free_memkb);
         if (rc < 0)
             return rc;
 
         if (free_memkb >= need_memkb)
             return 0;
 
-        rc = libxl_set_memory_target(&ctx, 0, free_memkb - need_memkb, 1, 0);
+        rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0);
         if (rc < 0)
             return rc;
 
-        rc = libxl_wait_for_free_memory(&ctx, domid, need_memkb, 10);
+        rc = libxl_wait_for_free_memory(ctx, domid, need_memkb, 10);
         if (!rc)
             return 0;
         else if (rc != ERROR_NOMEM)
@@ -1315,7 +1316,7 @@ static int freemem(libxl_domain_build_in
 
         /* the memory target has been reached but the free memory is still
          * not enough: loop over again */
-        rc = libxl_wait_for_memory_target(&ctx, 0, 1);
+        rc = libxl_wait_for_memory_target(ctx, 0, 1);
         if (rc < 0)
             return rc;
 
@@ -1380,7 +1381,7 @@ static int create_domain(struct domain_c
         restore_fd = migrate_fd >= 0 ? migrate_fd :
             open(restore_file, O_RDONLY);
 
-        CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, &hdr,
+        CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, &hdr,
                    sizeof(hdr), restore_file, "header") );
         if (memcmp(hdr.magic, savefileheader_magic, sizeof(hdr.magic))) {
             fprintf(stderr, "File has wrong magic number -"
@@ -1406,7 +1407,7 @@ static int create_domain(struct domain_c
         }
         if (hdr.optional_data_len) {
             optdata_begin = xmalloc(hdr.optional_data_len);
-            CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, optdata_begin,
+            CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, optdata_begin,
                    hdr.optional_data_len, restore_file, "optdata") );
         }
 
@@ -1438,7 +1439,7 @@ static int create_domain(struct domain_c
 
     if (config_file) {
         free(config_data);  config_data = 0;
-        ret = libxl_read_file_contents(&ctx, config_file,
+        ret = libxl_read_file_contents(ctx, config_file,
                                        &config_data, &config_len);
         if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
                            config_file, strerror(errno)); return ERROR_FAIL; }
@@ -1517,17 +1518,17 @@ start:
     }
 
     if ( restore_file ) {
-        ret = libxl_domain_create_restore(&ctx, &d_config,
+        ret = libxl_domain_create_restore(ctx, &d_config,
                                             cb, &child_console_pid,
                                             &domid, restore_fd);
     }else{
-        ret = libxl_domain_create_new(&ctx, &d_config,
+        ret = libxl_domain_create_new(ctx, &d_config,
                                         cb, &child_console_pid, &domid);
     }
     if ( ret )
         goto error_out;
 
-    ret = libxl_userdata_store(&ctx, domid, "xl",
+    ret = libxl_userdata_store(ctx, domid, "xl",
                                     config_data, config_len);
     if (ret) {
         perror("cannot save config file");
@@ -1538,7 +1539,7 @@ start:
     release_lock();
 
     if (!paused)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
     if (!daemonize)
@@ -1549,7 +1550,7 @@ start:
         pid_t child1, got_child;
         int nullfd;
 
-        child1 = libxl_fork(&ctx);
+        child1 = libxl_fork(ctx);
         if (child1) {
             printf("Daemon running with PID %d\n", child1);
 
@@ -1564,7 +1565,7 @@ start:
                 }
             }
             if (status) {
-                libxl_report_child_exitstatus(&ctx, XTL_ERROR,
+                libxl_report_child_exitstatus(ctx, XTL_ERROR,
                            "daemonizing child", child1, status);
                 ret = ERROR_FAIL;
                 goto error_out;
@@ -1573,7 +1574,7 @@ start:
             goto out;
         }
 
-        rc = libxl_ctx_postfork(&ctx);
+        rc = libxl_ctx_postfork(ctx);
         if (rc) {
             LOG("failed to reinitialise context after fork");
             exit(-1);
@@ -1583,7 +1584,7 @@ start:
             LOG("Failed to allocate memory in asprintf");
             exit(1);
         }
-        rc = libxl_create_logfile(&ctx, name, &fullname);
+        rc = libxl_create_logfile(ctx, name, &fullname);
         if (rc) {
             LOG("failed to open logfile %s: %s",fullname,strerror(errno));
             exit(-1);
@@ -1605,9 +1606,9 @@ start:
         d_config.c_info.name, domid, (long)getpid());
     w1 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter) * d_config.num_disks);
     w2 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter));
-    libxl_wait_for_disk_ejects(&ctx, domid, d_config.disks, d_config.num_disks, w1);
-    libxl_wait_for_domain_death(&ctx, domid, w2);
-    libxl_get_wait_fd(&ctx, &fd);
+    libxl_wait_for_disk_ejects(ctx, domid, d_config.disks, d_config.num_disks, w1);
+    libxl_wait_for_domain_death(ctx, domid, w2);
+    libxl_get_wait_fd(ctx, &fd);
     while (1) {
         int ret;
         fd_set rfds;
@@ -1621,10 +1622,10 @@ start:
         ret = select(fd + 1, &rfds, NULL, NULL, NULL);
         if (!ret)
             continue;
-        libxl_get_event(&ctx, &event);
+        libxl_get_event(ctx, &event);
         switch (event.type) {
             case LIBXL_EVENT_DOMAIN_DEATH:
-                ret = libxl_event_get_domain_death_info(&ctx, domid, &event, &info);
+                ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info);
 
                 if (ret < 0) {
                     libxl_free_event(&event);
@@ -1634,9 +1635,9 @@ start:
                 LOG("Domain %d is dead", domid);
 
                 if (ret) {
-                    switch (handle_domain_death(&ctx, domid, &event, &d_config, &info)) {
+                    switch (handle_domain_death(ctx, domid, &event, &d_config, &info)) {
                     case 2:
-                        if (!preserve_domain(&ctx, domid, &event, &d_config, &info)) {
+                        if (!preserve_domain(ctx, domid, &event, &d_config, &info)) {
                             /* If we fail then exit leaving the old domain in place. */
                             ret = -1;
                             goto out;
@@ -1682,8 +1683,8 @@ start:
                 }
                 break;
             case LIBXL_EVENT_DISK_EJECT:
-                if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) {
-                    libxl_cdrom_insert(&ctx, domid, &disk);
+                if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) {
+                    libxl_cdrom_insert(ctx, domid, &disk);
                     libxl_device_disk_destroy(&disk);
                 }
                 break;
@@ -1694,7 +1695,7 @@ start:
 error_out:
     release_lock();
     if (libxl_domid_valid_guest(domid))
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
 out:
     if (logfile != 2)
@@ -1789,7 +1790,7 @@ static int set_memory_max(const char *p,
         exit(3);
     }
 
-    rc = libxl_domain_setmaxmem(&ctx, domid, memorykb);
+    rc = libxl_domain_setmaxmem(ctx, domid, memorykb);
 
     return rc;
 }
@@ -1839,7 +1840,7 @@ static void set_memory_target(const char
         exit(3);
     }
 
-    libxl_set_memory_target(&ctx, domid, memorykb, 0, /* enforce */ 1);
+    libxl_set_memory_target(ctx, domid, memorykb, 0, /* enforce */ 1);
 }
 
 int main_memset(int argc, char **argv)
@@ -1887,7 +1888,7 @@ static void cd_insert(const char *dom, c
     disk.backend_domid = 0;
     disk.domid = domid;
 
-    libxl_cdrom_insert(&ctx, domid, &disk);
+    libxl_cdrom_insert(ctx, domid, &disk);
     free(buf);
 }
 
@@ -1982,9 +1983,9 @@ int main_console(int argc, char **argv)
 
     find_domain(argv[optind]);
     if (!type)
-        libxl_primary_console_exec(&ctx, domid);
+        libxl_primary_console_exec(ctx, domid);
     else
-        libxl_console_exec(&ctx, domid, num, type);
+        libxl_console_exec(ctx, domid, num, type);
     fprintf(stderr, "Unable to attach console\n");
     return 1;
 }
@@ -1992,7 +1993,7 @@ int main_console(int argc, char **argv)
 static int vncviewer(const char *domain_spec, int autopass)
 {
     find_domain(domain_spec);
-    libxl_vncviewer_exec(&ctx, domid, autopass);
+    libxl_vncviewer_exec(ctx, domid, autopass);
     fprintf(stderr, "Unable to execute vncviewer\n");
     return 1;
 }
@@ -2040,7 +2041,7 @@ static void pcilist_assignable(void)
     libxl_device_pci *pcidevs;
     int num, i;
 
-    if ( libxl_device_pci_list_assignable(&ctx, &pcidevs, &num) )
+    if ( libxl_device_pci_list_assignable(ctx, &pcidevs, &num) )
         return;
     for (i = 0; i < num; i++) {
         printf("%04x:%02x:%02x.%01x\n",
@@ -2075,7 +2076,7 @@ static void pcilist(const char *dom)
 
     find_domain(dom);
 
-    if (libxl_device_pci_list_assigned(&ctx, &pcidevs, domid, &num))
+    if (libxl_device_pci_list_assigned(ctx, &pcidevs, domid, &num))
         return;
     printf("Vdev Device\n");
     for (i = 0; i < num; i++) {
@@ -2120,11 +2121,11 @@ static void pcidetach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_remove(&ctx, domid, &pcidev, force);
+    libxl_device_pci_remove(ctx, domid, &pcidev, force);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2165,11 +2166,11 @@ static void pciattach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_add(&ctx, domid, &pcidev);
+    libxl_device_pci_add(ctx, domid, &pcidev);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2206,13 +2207,13 @@ int main_pciattach(int argc, char **argv
 static void pause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_pause(&ctx, domid);
+    libxl_domain_pause(ctx, domid);
 }
 
 static void unpause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_unpause(&ctx, domid);
+    libxl_domain_unpause(ctx, domid);
 }
 
 static void destroy_domain(const char *p)
@@ -2223,7 +2224,7 @@ static void destroy_domain(const char *p
         fprintf(stderr, "Cannot destroy privileged domain 0.\n\n");
         exit(-1);
     }
-    rc = libxl_domain_destroy(&ctx, domid, 0);
+    rc = libxl_domain_destroy(ctx, domid, 0);
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
 }
 
@@ -2232,16 +2233,16 @@ static void shutdown_domain(const char *
     int rc;
 
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 0);
+    rc=libxl_domain_shutdown(ctx, domid, 0);
     if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); }
 
     if (wait) {
         libxl_waiter waiter;
         int fd;
 
-        libxl_wait_for_domain_death(&ctx, domid, &waiter);
-
-        libxl_get_wait_fd(&ctx, &fd);
+        libxl_wait_for_domain_death(ctx, domid, &waiter);
+
+        libxl_get_wait_fd(ctx, &fd);
 
         while (wait) {
             fd_set rfds;
@@ -2254,10 +2255,10 @@ static void shutdown_domain(const char *
             if (!select(fd + 1, &rfds, NULL, NULL, NULL))
                 continue;
 
-            libxl_get_event(&ctx, &event);
+            libxl_get_event(ctx, &event);
 
             if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
-                if (libxl_event_get_domain_death_info(&ctx, domid, &event, &info) < 0)
+                if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0)
                     continue;
 
                 LOG("Domain %d is dead", domid);
@@ -2274,7 +2275,7 @@ static void reboot_domain(const char *p)
 {
     int rc;
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 1);
+    rc=libxl_domain_shutdown(ctx, domid, 1);
     if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2291,7 +2292,7 @@ static void list_domains_details(const l
         /* no detailed info available on dom0 */
         if (info[i].domid == 0)
             continue;
-        rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len);
+        rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len);
         if (rc)
             continue;
         CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid));
@@ -2315,7 +2316,7 @@ static void list_domains(int verbose, co
     for (i = 0; i < nb_domain; i++) {
         char *domname;
         unsigned shutdown_reason;
-        domname = libxl_domid_to_name(&ctx, info[i].domid);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0;
         printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
                 domname,
@@ -2347,7 +2348,7 @@ static void list_vm(void)
     char *domname;
     int nb_vm, i;
 
-    info = libxl_list_vm(&ctx, &nb_vm);
+    info = libxl_list_vm(ctx, &nb_vm);
 
     if (info < 0) {
         fprintf(stderr, "libxl_domain_infolist failed.\n");
@@ -2355,7 +2356,7 @@ static 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);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         printf(LIBXL_UUID_FMT "  %d    %-30s\n", LIBXL_UUID_BYTES(info[i].uuid),
             info[i].domid, domname);
         free(domname);
@@ -2376,11 +2377,11 @@ static void save_domain_core_begin(const
 
     if (override_config_file) {
         void *config_v = 0;
-        rc = libxl_read_file_contents(&ctx, override_config_file,
+        rc = libxl_read_file_contents(ctx, override_config_file,
                                       &config_v, config_len_r);
         *config_data_r = config_v;
     } else {
-        rc = libxl_userdata_retrieve(&ctx, domid, "xl",
+        rc = libxl_userdata_retrieve(ctx, domid, "xl",
                                      config_data_r, config_len_r);
     }
     if (rc) {
@@ -2417,9 +2418,9 @@ static void save_domain_core_writeconfig
 
     /* that's the optional data */
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         &hdr, sizeof(hdr), filename, "header") );
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         optdata_begin, hdr.optional_data_len, filename, "header") );
 
     fprintf(stderr, "Saving to %s new xl format (info"
@@ -2449,13 +2450,13 @@ static int save_domain(const char *p, co
 
     save_domain_core_writeconfig(fd, filename, config_data, config_len);
 
-    CHK_ERRNO(libxl_domain_suspend(&ctx, NULL, domid, fd));
+    CHK_ERRNO(libxl_domain_suspend(ctx, NULL, domid, fd));
     close(fd);
 
     if (checkpoint)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
     else
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
     exit(0);
 }
@@ -2467,7 +2468,7 @@ static int migrate_read_fixedmessage(int
     int rc;
 
     stream = rune ? "migration receiver stream" : "migration stream";
-    rc = libxl_read_exactly(&ctx, fd, buf, msgsz, stream, what);
+    rc = libxl_read_exactly(ctx, fd, buf, msgsz, stream, what);
     if (rc) return ERROR_FAIL;
 
     if (memcmp(buf, msg, msgsz)) {
@@ -2496,7 +2497,7 @@ static void migration_child_report(pid_t
 
         if (child == migration_child) {
             if (status)
-                libxl_report_child_exitstatus(&ctx, XTL_INFO,
+                libxl_report_child_exitstatus(ctx, XTL_INFO,
                                               "migration target process",
                                               migration_child, status);
             break;
@@ -2567,10 +2568,10 @@ static void migrate_domain(const char *d
         exit(1);
     }
 
-    MUST( libxl_pipe(&ctx, sendpipe) );
-    MUST( libxl_pipe(&ctx, recvpipe) );
-
-    child = libxl_fork(&ctx);
+    MUST( libxl_pipe(ctx, sendpipe) );
+    MUST( libxl_pipe(ctx, recvpipe) );
+
+    child = libxl_fork(ctx);
     if (child==-1) exit(1);
 
     if (!child) {
@@ -2608,7 +2609,7 @@ static void migrate_domain(const char *d
 
     memset(&suspinfo, 0, sizeof(suspinfo));
     suspinfo.flags |= XL_SUSPEND_LIVE;
-    rc = libxl_domain_suspend(&ctx, &suspinfo, domid, send_fd);
+    rc = libxl_domain_suspend(ctx, &suspinfo, domid, send_fd);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -2638,7 +2639,7 @@ static void migrate_domain(const char *d
     if (common_domname) {
         if (asprintf(&away_domname, "%s--migratedaway", common_domname) < 0)
             goto failed_resume;
-        rc = libxl_domain_rename(&ctx, domid, common_domname, away_domname);
+        rc = libxl_domain_rename(ctx, domid, common_domname, away_domname);
         if (rc) goto failed_resume;
     }
 
@@ -2649,7 +2650,7 @@ static void migrate_domain(const char *d
 
     fprintf(stderr, "migration sender: Giving target permission to start.\n");
 
-    rc = libxl_write_exactly(&ctx, send_fd,
+    rc = libxl_write_exactly(ctx, send_fd,
                              migrate_permission_to_go,
                              sizeof(migrate_permission_to_go),
                              "migration stream", "GO message");
@@ -2660,7 +2661,7 @@ static void migrate_domain(const char *d
                                    "success/failure report message", rune);
     if (rc) goto failed_badly;
 
-    rc = libxl_read_exactly(&ctx, recv_fd,
+    rc = libxl_read_exactly(ctx, recv_fd,
                             &rc_buf, 1,
                             "migration ack stream", "success/failure status");
     if (rc) goto failed_badly;
@@ -2678,9 +2679,9 @@ static void migrate_domain(const char *d
         fprintf(stderr, "migration sender: Trying to resume at our end.\n");
 
         if (common_domname) {
-            libxl_domain_rename(&ctx, domid, away_domname, common_domname);
+            libxl_domain_rename(ctx, domid, away_domname, common_domname);
         }
-        rc = libxl_domain_resume(&ctx, domid);
+        rc = libxl_domain_resume(ctx, domid);
         if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n");
 
         fprintf(stderr, "Migration failed due to problems at target.\n");
@@ -2688,7 +2689,7 @@ static void migrate_domain(const char *d
     }
 
     fprintf(stderr, "migration sender: Target reports successful startup.\n");
-    libxl_domain_destroy(&ctx, domid, 1); /* bang! */
+    libxl_domain_destroy(ctx, domid, 1); /* bang! */
     fprintf(stderr, "Migration successful.\n");
     exit(0);
 
@@ -2702,7 +2703,7 @@ static void migrate_domain(const char *d
     close(send_fd);
     migration_child_report(child, recv_fd);
     fprintf(stderr, "Migration failed, resuming at sender.\n");
-    libxl_domain_resume(&ctx, domid);
+    libxl_domain_resume(ctx, domid);
     exit(-ERROR_FAIL);
 
  failed_badly:
@@ -2723,7 +2724,7 @@ static void core_dump_domain(const char 
 {
     int rc;
     find_domain(domain_spec);
-    rc=libxl_domain_core_dump(&ctx, domid, filename);
+    rc=libxl_domain_core_dump(ctx, domid, filename);
     if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2739,7 +2740,7 @@ static void migrate_receive(int debug, i
 
     fprintf(stderr, "migration target: Ready to receive domain.\n");
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, 1,
+    CHK_ERRNO( libxl_write_exactly(ctx, 1,
                                    migrate_receiver_banner,
                                    sizeof(migrate_receiver_banner)-1,
                                    "migration ack stream",
@@ -2763,7 +2764,7 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Transfer complete,"
             " requesting permission to start domain.\n");
 
-    rc = libxl_write_exactly(&ctx, 1,
+    rc = libxl_write_exactly(ctx, 1,
                              migrate_receiver_ready,
                              sizeof(migrate_receiver_ready),
                              "migration ack stream", "ready message");
@@ -2777,18 +2778,18 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Got permission, starting domain.\n");
 
     if (migration_domname) {
-        rc = libxl_domain_rename(&ctx, domid, migration_domname, common_domname);
+        rc = libxl_domain_rename(ctx, domid, migration_domname, common_domname);
         if (rc) goto perhaps_destroy_notify_rc;
     }
 
-    rc = libxl_domain_unpause(&ctx, domid);
+    rc = libxl_domain_unpause(ctx, domid);
     if (rc) goto perhaps_destroy_notify_rc;
 
     fprintf(stderr, "migration target: Domain started successsfully.\n");
     rc = 0;
 
  perhaps_destroy_notify_rc:
-    rc2 = libxl_write_exactly(&ctx, 1,
+    rc2 = libxl_write_exactly(ctx, 1,
                               migrate_report, sizeof(migrate_report),
                               "migration ack stream",
                               "success/failure report");
@@ -2796,7 +2797,7 @@ static void migrate_receive(int debug, i
 
     rc_buf = -rc;
     assert(!!rc_buf == !!rc);
-    rc2 = libxl_write_exactly(&ctx, 1, &rc_buf, 1,
+    rc2 = libxl_write_exactly(ctx, 1, &rc_buf, 1,
                               "migration ack stream",
                               "success/failure code");
     if (rc2) exit(-ERROR_BADFAIL);
@@ -2804,7 +2805,7 @@ static void migrate_receive(int debug, i
     if (rc) {
         fprintf(stderr, "migration target: Failure, destroying our copy.\n");
 
-        rc2 = libxl_domain_destroy(&ctx, domid, 1);
+        rc2 = libxl_domain_destroy(ctx, domid, 1);
         if (rc2) {
             fprintf(stderr, "migration target: Failed to destroy our copy"
                     " (code %d).\n", rc2);
@@ -2814,7 +2815,7 @@ static void migrate_receive(int debug, i
         fprintf(stderr, "migration target: Cleanup OK, granting sender"
                 " permission to resume.\n");
 
-        rc2 = libxl_write_exactly(&ctx, 1,
+        rc2 = libxl_write_exactly(ctx, 1,
                                   migrate_permission_to_go,
                                   sizeof(migrate_permission_to_go),
                                   "migration ack stream",
@@ -3194,7 +3195,7 @@ int main_list(int argc, char **argv)
     }
 
     if (optind >= argc) {
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3202,7 +3203,7 @@ int main_list(int argc, char **argv)
         info_free = info;
     } else if (optind == argc-1) {
         find_domain(argv[optind]);
-        rc = libxl_domain_info(&ctx, &info_buf, domid);
+        rc = libxl_domain_info(ctx, &info_buf, domid);
         if (rc == ERROR_INVAL) {
             fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
                 argv[optind]);
@@ -3353,7 +3354,7 @@ static void button_press(const char *p, 
         exit(2);
     }
 
-    libxl_button_press(&ctx, domid, button);
+    libxl_button_press(ctx, domid, button);
 }
 
 int main_button_press(int argc, char **argv)
@@ -3441,7 +3442,7 @@ static void print_vcpuinfo(uint32_t tdom
     char *domname;
 
     /*      NAME  ID  VCPU */
-    domname = libxl_domid_to_name(&ctx, tdomid);
+    domname = libxl_domid_to_name(ctx, tdomid);
     printf("%-32s %5u %5u",
            domname, tdomid, vcpuinfo->vcpuid);
     free(domname);
@@ -3466,7 +3467,7 @@ static void print_domain_vcpuinfo(uint32
     libxl_vcpuinfo *vcpuinfo;
     int i, nb_vcpu, nrcpus;
 
-    vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &nrcpus);
+    vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nrcpus);
 
     if (!vcpuinfo) {
         fprintf(stderr, "libxl_list_vcpu failed.\n");
@@ -3487,7 +3488,7 @@ static void vcpulist(int argc, char **ar
     libxl_physinfo physinfo;
     int i, nb_domain;
 
-    if (libxl_get_physinfo(&ctx, &physinfo) != 0) {
+    if (libxl_get_physinfo(ctx, &physinfo) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         goto vcpulist_out;
     }
@@ -3495,7 +3496,7 @@ static void vcpulist(int argc, char **ar
     printf("%-32s %5s %5s %5s %5s %9s %s\n",
            "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "CPU Affinity");
     if (!argc) {
-        if (!(dominfo = libxl_list_domain(&ctx, &nb_domain))) {
+        if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) {
             fprintf(stderr, "libxl_list_domain failed.\n");
             goto vcpulist_out;
         }
@@ -3558,7 +3559,7 @@ static void vcpupin(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         goto vcpupin_out;
     }
     if (strcmp(cpu, "all")) {
@@ -3589,17 +3590,17 @@ static void vcpupin(const char *d, const
     }
 
     if (vcpuid != -1) {
-        if (libxl_set_vcpuaffinity(&ctx, domid, vcpuid, &cpumap) == -1) {
+        if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, &cpumap) == -1) {
             fprintf(stderr, "Could not set affinity for vcpu `%u'.\n", vcpuid);
         }
     }
     else {
-        if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &i))) {
+        if (!(vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &i))) {
             fprintf(stderr, "libxl_list_vcpu failed.\n");
             goto vcpupin_out1;
         }
         for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
-            if (libxl_set_vcpuaffinity(&ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
+            if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
                 fprintf(stderr, "libxl_set_vcpuaffinity failed on vcpu `%u'.\n", vcpuinfo->vcpuid);
             }
         }
@@ -3648,14 +3649,14 @@ static void vcpuset(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "libxl_cpumap_alloc failed\n");
         return;
     }
     for (i = 0; i < max_vcpus; i++)
         libxl_cpumap_set(&cpumap, i);
 
-    if (libxl_set_vcpuonline(&ctx, domid, &cpumap) < 0)
+    if (libxl_set_vcpuonline(ctx, domid, &cpumap) < 0)
         fprintf(stderr, "libxl_set_vcpuonline failed domid=%d max_vcpus=%d\n", domid, max_vcpus);
 
     libxl_cpumap_destroy(&cpumap);
@@ -3689,12 +3690,12 @@ static void output_xeninfo(void)
     const libxl_version_info *info;
     int sched_id;
 
-    if (!(info = libxl_get_version_info(&ctx))) {
+    if (!(info = libxl_get_version_info(ctx))) {
         fprintf(stderr, "libxl_get_version_info failed.\n");
         return;
     }
 
-    if ((sched_id = libxl_get_sched_id(&ctx)) < 0) {
+    if ((sched_id = libxl_get_sched_id(ctx)) < 0) {
         fprintf(stderr, "get_sched_id sysctl failed.\n");
         return;
     }
@@ -3703,7 +3704,7 @@ static void output_xeninfo(void)
     printf("xen_minor              : %d\n", info->xen_version_minor);
     printf("xen_extra              : %s\n", info->xen_version_extra);
     printf("xen_caps               : %s\n", info->capabilities);
-    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(&ctx, sched_id));
+    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(ctx, sched_id));
     printf("xen_pagesize           : %lu\n", info->pagesize);
     printf("platform_params        : virt_start=0x%lx\n", info->virt_start);
     printf("xen_changeset          : %s\n", info->changeset);
@@ -3737,7 +3738,7 @@ static void output_physinfo(void)
     libxl_cpumap cpumap;
     int n = 0;
 
-    if (libxl_get_physinfo(&ctx, &info) != 0) {
+    if (libxl_get_physinfo(ctx, &info) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         return;
     }
@@ -3756,13 +3757,13 @@ static void output_physinfo(void)
     if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
         printf(" hvm_directio");
     printf("\n");
-    vinfo = libxl_get_version_info(&ctx);
+    vinfo = libxl_get_version_info(ctx);
     if (vinfo) {
         i = (1 << 20) / vinfo->pagesize;
         printf("total_memory           : %"PRIu64"\n", info.total_pages / i);
         printf("free_memory            : %"PRIu64"\n", info.free_pages / i);
     }
-    if (!libxl_get_freecpus(&ctx, &cpumap)) {
+    if (!libxl_get_freecpus(ctx, &cpumap)) {
         libxl_for_each_cpu(i, cpumap)
             if (libxl_cpumap_test(&cpumap, i))
                 n++;
@@ -3778,7 +3779,7 @@ static void output_topologyinfo(void)
     libxl_topologyinfo info;
     int i;
 
-    if (libxl_get_topologyinfo(&ctx, &info)) {
+    if (libxl_get_topologyinfo(ctx, &info)) {
         fprintf(stderr, "libxl_get_topologyinfo failed.\n");
         return;
     }
@@ -3849,7 +3850,7 @@ static int sched_credit_domain_get(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_get(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_get(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_get failed.\n");
     
@@ -3861,7 +3862,7 @@ static int sched_credit_domain_set(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_set(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_set(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_set failed.\n");
 
@@ -3872,7 +3873,7 @@ static void sched_credit_domain_output(
     int domid, libxl_sched_credit *scinfo)
 {
     char *domname;
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d %4d\n",
         domname,
         domid,
@@ -3918,7 +3919,7 @@ int main_sched_credit(int argc, char **a
     }
 
     if (!dom) { /* list all domain's credit scheduler info */
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3978,7 +3979,7 @@ int main_domid(int argc, char **argv)
         return 1;
     }
 
-    if (libxl_name_to_domid(&ctx, domname, &domid)) {
+    if (libxl_name_to_domid(ctx, domname, &domid)) {
         fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname);
         return 1;
     }
@@ -4017,7 +4018,7 @@ int main_domname(int argc, char **argv)
         return 1;
     }
 
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     if (!domname) {
         fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid);
         return 1;
@@ -4056,7 +4057,7 @@ int main_rename(int argc, char **argv)
     find_domain(dom);
     new_name = argv[optind];
 
-    if (libxl_domain_rename(&ctx, domid, common_domname, new_name)) {
+    if (libxl_domain_rename(ctx, domid, common_domname, new_name)) {
         fprintf(stderr, "Can't rename domain '%s'.\n", dom);
         return 1;
     }
@@ -4101,7 +4102,7 @@ int main_trigger(int argc, char **argv)
         }
     }
 
-    libxl_send_trigger(&ctx, domid, trigger_name, vcpuid);
+    libxl_send_trigger(ctx, domid, trigger_name, vcpuid);
 
     return 0;
 }
@@ -4141,7 +4142,7 @@ int main_sysrq(int argc, char **argv)
         return 1;
     }
 
-    libxl_send_sysrq(&ctx, domid, sysrq[0]);
+    libxl_send_sysrq(ctx, domid, sysrq[0]);
 
     return 0;
 }
@@ -4168,7 +4169,7 @@ int main_debug_keys(int argc, char **arg
 
     keys = argv[optind];
 
-    if (libxl_send_debug_keys(&ctx, keys)) {
+    if (libxl_send_debug_keys(ctx, keys)) {
         fprintf(stderr, "cannot send debug keys: %s\n", keys);
         return 1;
     }
@@ -4197,15 +4198,15 @@ int main_dmesg(int argc, char **argv)
         }
     }
 
-    cr = libxl_xen_console_read_start(&ctx, clear);
+    cr = libxl_xen_console_read_start(ctx, clear);
     if (!cr)
         goto finish;
 
-    while ((ret = libxl_xen_console_read_line(&ctx, cr, &line)) > 0)
+    while ((ret = libxl_xen_console_read_line(ctx, cr, &line)) > 0)
         printf("%s", line);
 
 finish:
-    libxl_xen_console_read_finish(&ctx, cr);
+    libxl_xen_console_read_finish(ctx, cr);
     return ret;
 }
 
@@ -4286,7 +4287,7 @@ int main_networkattach(int argc, char **
             free(nic.script);
             nic.script = strdup((*argv) + 6);
         } else if (!strncmp("backend=", *argv, 8)) {
-            if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) {
+            if(libxl_name_to_domid(ctx, ((*argv) + 8), &val)) {
                 fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                 val = 0;
             }
@@ -4305,7 +4306,7 @@ int main_networkattach(int argc, char **
         }
     }
     nic.domid = domid;
-    if (libxl_device_nic_add(&ctx, domid, &nic)) {
+    if (libxl_device_nic_add(ctx, domid, &nic)) {
         fprintf(stderr, "libxl_device_nic_add failed.\n");
         return 1;
     }
@@ -4342,7 +4343,7 @@ 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 (!(nics = libxl_list_nics(ctx, domid, &nb))) {
             continue;
         }
         for (i = 0; i < nb; ++i) {
@@ -4389,17 +4390,17 @@ int main_networkdetach(int argc, char **
     }
 
     if (!strchr(argv[optind+1], ':')) {
-        if (libxl_devid_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_devid_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     } else {
-        if (libxl_mac_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_mac_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     }
-    if (libxl_device_nic_del(&ctx, &nic, 1)) {
+    if (libxl_device_nic_del(ctx, &nic, 1)) {
         fprintf(stderr, "libxl_device_nic_del failed.\n");
         return 1;
     }
@@ -4477,7 +4478,7 @@ int main_blockattach(int argc, char **ar
     disk.domid = fe_domid;
     disk.backend_domid = be_domid;
 
-    if (libxl_device_disk_add(&ctx, fe_domid, &disk)) {
+    if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
         fprintf(stderr, "libxl_device_disk_add failed.\n");
     }
     return 0;
@@ -4512,12 +4513,12 @@ int main_blocklist(int argc, char **argv
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        disks = libxl_device_disk_list(&ctx, domid, &nb);
+        disks = libxl_device_disk_list(ctx, domid, &nb);
         if (!disks) {
             continue;
         }
         for (i=0; i<nb; i++) {
-            if (!libxl_device_disk_getinfo(&ctx, domid, &disks[i], &diskinfo)) {
+            if (!libxl_device_disk_getinfo(ctx, domid, &disks[i], &diskinfo)) {
                 /*      Vdev BE   hdl  st   evch rref BE-path*/
                 printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
                        diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id,
@@ -4555,11 +4556,11 @@ int main_blockdetach(int argc, char **ar
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_disk(&ctx, domid, argv[optind+1], &disk)) {
+    if (libxl_devid_to_device_disk(ctx, domid, argv[optind+1], &disk)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_disk_del(&ctx, &disk, 1)) {
+    if (libxl_device_disk_del(ctx, &disk, 1)) {
         fprintf(stderr, "libxl_device_disk_del failed.\n");
     }
     return 0;
@@ -4656,7 +4657,7 @@ int main_network2attach(int argc, char *
     }
     net2.domid = domid;
     net2.backend_domid = back_domid;
-    if (libxl_device_net2_add(&ctx, domid, &net2)) {
+    if (libxl_device_net2_add(ctx, domid, &net2)) {
         fprintf(stderr, "libxl_device_net2_add failed.\n");
     }
     return 0;
@@ -4691,7 +4692,7 @@ int main_network2list(int argc, char **a
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        if ((net2s = libxl_device_net2_list(&ctx, domid, &nb))) {
+        if ((net2s = libxl_device_net2_list(ctx, domid, &nb))) {
             for (; nb > 0; --nb, ++net2s) {
                 printf("%3d %2d %5d ", net2s->devid, net2s->backend_id, net2s->state);
                 printf("%02x:%02x:%02x:%02x:%02x:%02x ",
@@ -4731,11 +4732,11 @@ int main_network2detach(int argc, char *
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_net2(&ctx, domid, argv[optind+1], &net2)) {
+    if (libxl_devid_to_device_net2(ctx, domid, argv[optind+1], &net2)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_net2_del(&ctx, &net2, 1)) {
+    if (libxl_device_net2_del(ctx, &net2, 1)) {
         fprintf(stderr, "libxl_device_net2_del failed.\n");
         return 1;
     }
@@ -4815,7 +4816,7 @@ static void print_dom0_uptime(int short_
     strtok(buf, " ");
     uptime = strtoul(buf, NULL, 10);
 
-    domname = libxl_domid_to_name(&ctx, 0);
+    domname = libxl_domid_to_name(ctx, 0);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4848,11 +4849,11 @@ static void print_domU_uptime(uint32_t d
     char *now_str = NULL;
     char *domname;
 
-    s_time = libxl_vm_get_start_time(&ctx, domuid);
+    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);
+    domname = libxl_domid_to_name(ctx, domuid);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4887,7 +4888,7 @@ static void print_uptime(int short_mode,
 
     if (nb_doms == 0) {
         print_dom0_uptime(short_mode, now);
-        info = libxl_list_vm(&ctx, &nb_vm);
+        info = libxl_list_vm(ctx, &nb_vm);
         for (i = 0; i < nb_vm; i++)
             print_domU_uptime(info[i].domid, short_mode, now);
     } else {
@@ -4969,7 +4970,7 @@ int main_tmem_list(int argc, char **argv
     else
         find_domain(dom);
 
-    buf = libxl_tmem_list(&ctx, domid, use_long);
+    buf = libxl_tmem_list(ctx, domid, use_long);
     if (buf == NULL)
         return -1;
 
@@ -5010,7 +5011,7 @@ int main_tmem_freeze(int argc, char **ar
     else
         find_domain(dom);
 
-    libxl_tmem_freeze(&ctx, domid);
+    libxl_tmem_freeze(ctx, domid);
     return 0;
 }
 
@@ -5046,7 +5047,7 @@ int main_tmem_destroy(int argc, char **a
     else
         find_domain(dom);
 
-    libxl_tmem_destroy(&ctx, domid);
+    libxl_tmem_destroy(ctx, domid);
     return 0;
 }
 
@@ -5082,7 +5083,7 @@ int main_tmem_thaw(int argc, char **argv
     else
         find_domain(dom);
 
-    libxl_tmem_thaw(&ctx, domid);
+    libxl_tmem_thaw(ctx, domid);
     return 0;
 }
 
@@ -5139,11 +5140,11 @@ int main_tmem_set(int argc, char **argv)
     }
 
     if (opt_w)
-        libxl_tmem_set(&ctx, domid, "weight", weight);
+        libxl_tmem_set(ctx, domid, "weight", weight);
     if (opt_c)
-        libxl_tmem_set(&ctx, domid, "cap", cap);
+        libxl_tmem_set(ctx, domid, "cap", cap);
     if (opt_p)
-        libxl_tmem_set(&ctx, domid, "compress", compress);
+        libxl_tmem_set(ctx, domid, "compress", compress);
 
     return 0;
 }
@@ -5202,7 +5203,7 @@ int main_tmem_shared_auth(int argc, char
         return 1;
     }
 
-    libxl_tmem_shared_auth(&ctx, domid, uuid, auth);
+    libxl_tmem_shared_auth(ctx, domid, uuid, auth);
 
     return 0;
 }
@@ -5223,7 +5224,7 @@ int main_tmem_freeable(int argc, char **
         }
     }
 
-    mb = libxl_tmem_freeable(&ctx);
+    mb = libxl_tmem_freeable(ctx);
     if (mb == -1)
         return -1;
 
@@ -5304,7 +5305,7 @@ int main_cpupoolcreate(int argc, char **
         return -ERROR_FAIL;
     }
 
-    if (libxl_read_file_contents(&ctx, filename, (void **)&config_data, &config_len)) {
+    if (libxl_read_file_contents(ctx, filename, (void **)&config_data, &config_len)) {
         fprintf(stderr, "Failed to read config file: %s: %s\n",
                 filename, strerror(errno));
         return -ERROR_FAIL;
@@ -5342,36 +5343,36 @@ int main_cpupoolcreate(int argc, char **
         name = strdup(buf);
     else
         name = libxl_basename(filename);
-    if (!libxl_name_to_cpupoolid(&ctx, name, &poolid)) {
+    if (!libxl_name_to_cpupoolid(ctx, name, &poolid)) {
         fprintf(stderr, "Pool name \"%s\" already exists\n", name);
         return -ERROR_FAIL;
     }
 
     if (!xlu_cfg_get_string (config, "sched", &buf)) {
-        if ((schedid = libxl_name_to_schedid(&ctx, buf)) < 0) {
+        if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) {
             fprintf(stderr, "Unknown scheduler\n");
             return -ERROR_FAIL;
         }
     } else {
-        if ((schedid = libxl_get_sched_id(&ctx)) < 0) {
+        if ((schedid = libxl_get_sched_id(ctx)) < 0) {
             fprintf(stderr, "get_sched_id sysctl failed.\n");
             return -ERROR_FAIL;
         }
     }
-    sched = libxl_schedid_to_name(&ctx, schedid);
-
-    if (libxl_get_freecpus(&ctx, &freemap)) {
+    sched = libxl_schedid_to_name(ctx, schedid);
+
+    if (libxl_get_freecpus(ctx, &freemap)) {
         fprintf(stderr, "libxl_get_freecpus failed\n");
         return -ERROR_FAIL;
     }
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         return -ERROR_FAIL;
     }
     if (!xlu_cfg_get_list(config, "nodes", &nodes, 0, 0)) {
         n_cpus = 0;
         n_nodes = 0;
-        if (libxl_get_topologyinfo(&ctx, &topology)) {
+        if (libxl_get_topologyinfo(ctx, &topology)) {
             fprintf(stderr, "libxl_get_topologyinfo failed\n");
             return -ERROR_FAIL;
         }
@@ -5431,7 +5432,7 @@ int main_cpupoolcreate(int argc, char **
         return 0;
 
     poolid = 0;
-    if (libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid)) {
+    if (libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid)) {
         fprintf(stderr, "error on creating cpupool\n");
         return -ERROR_FAIL;
     }
@@ -5485,13 +5486,13 @@ int main_cpupoollist(int argc, char **ar
     }
     if (optind < argc) {
         pool = argv[optind];
-        if (libxl_name_to_cpupoolid(&ctx, pool, &poolid)) {
+        if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
             fprintf(stderr, "Pool \'%s\' does not exist\n", pool);
             return -ERROR_FAIL;
         }
     }
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5505,7 +5506,7 @@ int main_cpupoollist(int argc, char **ar
 
     for (p = 0; p < n_pools; p++) {
         if (!ret && (!pool || (poolinfo[p].poolid == poolid))) {
-            name = libxl_cpupoolid_to_name(&ctx, poolinfo[p].poolid);
+            name = libxl_cpupoolid_to_name(ctx, poolinfo[p].poolid);
             if (!name) {
                 fprintf(stderr, "error getting cpupool info\n");
                 ret = -ERROR_NOMEM;
@@ -5521,7 +5522,7 @@ int main_cpupoollist(int argc, char **ar
                     }
                 if (!opt_cpus) {
                     printf("%3d %9s       y       %4d", n,
-                           libxl_schedid_to_name(&ctx, poolinfo[p].sched_id),
+                           libxl_schedid_to_name(ctx, poolinfo[p].sched_id),
                            poolinfo[p].n_dom);
                 }
                 printf("\n");
@@ -5558,12 +5559,12 @@ int main_cpupooldestroy(int argc, char *
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_destroy_cpupool(&ctx, poolid);
+    return -libxl_destroy_cpupool(ctx, poolid);
 }
 
 int main_cpupoolrename(int argc, char **argv)
@@ -5592,14 +5593,14 @@ int main_cpupoolrename(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     new_name = argv[optind];
 
-    if (libxl_cpupool_rename(&ctx, new_name, poolid)) {
+    if (libxl_cpupool_rename(ctx, new_name, poolid)) {
         fprintf(stderr, "Can't rename cpupool '%s'.\n", pool);
         return 1;
     }
@@ -5648,16 +5649,16 @@ int main_cpupoolcpuadd(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuadd(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuadd(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuadd_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuadd_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5711,16 +5712,16 @@ int main_cpupoolcpuremove(int argc, char
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuremove(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuremove_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuremove(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuremove_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuremove_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5767,18 +5768,18 @@ int main_cpupoolmigrate(int argc, char *
     }
 
     if (domain_qualifier_to_domid(dom, &domid, NULL) ||
-        !libxl_domid_to_name(&ctx, domid)) {
+        !libxl_domid_to_name(ctx, domid)) {
         fprintf(stderr, "unknown domain \'%s\'\n", dom);
         return -ERROR_FAIL;
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_cpupool_movedomain(&ctx, poolid, domid);
+    return -libxl_cpupool_movedomain(ctx, poolid, domid);
 }
 
 int main_cpupoolnumasplit(int argc, char **argv)
@@ -5811,7 +5812,7 @@ int main_cpupoolnumasplit(int argc, char
     }
     ret = 0;
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5826,12 +5827,12 @@ int main_cpupoolnumasplit(int argc, char
         return -ERROR_FAIL;
     }
 
-    if (libxl_get_topologyinfo(&ctx, &topology)) {
+    if (libxl_get_topologyinfo(ctx, &topology)) {
         fprintf(stderr, "libxl_get_topologyinfo failed\n");
         return -ERROR_FAIL;
     }
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         libxl_topologyinfo_destroy(&topology);
         return -ERROR_FAIL;
@@ -5841,13 +5842,13 @@ int main_cpupoolnumasplit(int argc, char
        a cpupool without cpus in between */
 
     node = topology.nodemap.array[0];
-    if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) {
+    if (libxl_cpupool_cpuadd_node(ctx, 0, node, &n)) {
         fprintf(stderr, "error on adding cpu to Pool 0\n");
         return -ERROR_FAIL;
     }
 
     snprintf(name, 15, "Pool-node%d", node);
-    ret = -libxl_cpupool_rename(&ctx, name, 0);
+    ret = -libxl_cpupool_rename(ctx, name, 0);
     if (ret) {
         fprintf(stderr, "error on renaming Pool 0\n");
         goto out;
@@ -5861,12 +5862,12 @@ int main_cpupoolnumasplit(int argc, char
             n++;
         }
     }
-    if (libxl_set_vcpuonline(&ctx, 0, &cpumap)) {
+    if (libxl_set_vcpuonline(ctx, 0, &cpumap)) {
         fprintf(stderr, "error on removing vcpus for Domain-0\n");
         goto out;
     }
     for (c = 0; c < 10; c++) {
-        if (libxl_domain_info(&ctx, &info, 0)) {
+        if (libxl_domain_info(ctx, &info, 0)) {
             fprintf(stderr, "error on getting info for Domain-0\n");
             goto out;
         }
@@ -5887,7 +5888,7 @@ int main_cpupoolnumasplit(int argc, char
         }
 
         node = topology.nodemap.array[c];
-        ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n);
+        ret = -libxl_cpupool_cpuremove_node(ctx, 0, node, &n);
         if (ret) {
             fprintf(stderr, "error on removing cpu from Pool 0\n");
             goto out;
@@ -5896,13 +5897,13 @@ int main_cpupoolnumasplit(int argc, char
         snprintf(name, 15, "Pool-node%d", node);
         libxl_uuid_generate(&uuid);
         poolid = 0;
-        ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid);
+        ret = -libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid);
         if (ret) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out;
         }
 
-        ret = -libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n);
+        ret = -libxl_cpupool_cpuadd_node(ctx, poolid, node, &n);
         if (ret) {
             fprintf(stderr, "error on adding cpus to cpupool\n");
             goto out;
diff -r b65de5ce6202 -r f92a4b0f40df tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c	Fri Apr 01 14:04:39 2011 +0100
@@ -52,21 +52,21 @@ void log_destroy(struct xentoollog_logge
 {
 }
 
-#define INIT_STRUCT() libxl_ctx ctx; struct caml_logger lg; struct caml_gc gc; gc.offset = 0;
+#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); \
+	ret = libxl_ctx_alloc(&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)
+	libxl_ctx_free(ctx)
 
 static char * dup_String_val(caml_gc *gc, value s)
 {
@@ -379,7 +379,7 @@ value stub_xl_disk_add(value info, value
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("disk_add", &lg);
 	FREE_CTX();
@@ -397,7 +397,7 @@ value stub_xl_disk_remove(value info, va
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_del(&ctx, &c_info, 0);
+	ret = libxl_device_disk_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("disk_remove", &lg);
 	FREE_CTX();
@@ -415,7 +415,7 @@ value stub_xl_nic_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("nic_add", &lg);
 	FREE_CTX();
@@ -433,7 +433,7 @@ value stub_xl_nic_remove(value info, val
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_del(&ctx, &c_info, 0);
+	ret = libxl_device_nic_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("nic_remove", &lg);
 	FREE_CTX();
@@ -454,7 +454,7 @@ value stub_xl_console_add(value info, va
 	c_info.build_state = &c_state;
 
 	INIT_CTX();
-	ret = libxl_device_console_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_console_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("console_add", &lg);
 	FREE_CTX();
@@ -472,7 +472,7 @@ value stub_xl_vkb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vkb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vkb_add", &lg);
 	FREE_CTX();
@@ -487,7 +487,7 @@ value stub_xl_vkb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -502,7 +502,7 @@ value stub_xl_vkb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -521,7 +521,7 @@ value stub_xl_vfb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vfb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vfb_add", &lg);
 	FREE_CTX();
@@ -536,7 +536,7 @@ value stub_xl_vfb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -551,7 +551,7 @@ value stub_xl_vfb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -569,7 +569,7 @@ value stub_xl_pci_add(value info, value 
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("pci_add", &lg);
 	FREE_CTX();
@@ -587,7 +587,7 @@ value stub_xl_pci_remove(value info, val
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_remove(&ctx, Int_val(domid), &c_info, 0);
+	ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0);
 	if (ret != 0)
 		failwith_xl("pci_remove", &lg);
 	FREE_CTX();
@@ -602,7 +602,7 @@ value stub_xl_pci_shutdown(value domid)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_pci_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_pci_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("pci_shutdown", &lg);
 	FREE_CTX();
@@ -617,7 +617,7 @@ value stub_xl_button_press(value domid, 
 	INIT_STRUCT();
 	
 	INIT_CTX();
-	ret = libxl_button_press(&ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
+	ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
 	if (ret != 0)
 		failwith_xl("button_press", &lg);
 	FREE_CTX();
@@ -634,7 +634,7 @@ value stub_xl_physinfo(value unit)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_get_physinfo(&ctx, &c_physinfo);
+	ret = libxl_get_physinfo(ctx, &c_physinfo);
 	if (ret != 0)
 		failwith_xl("physinfo", &lg);
 	FREE_CTX();
@@ -670,7 +670,7 @@ value stub_xl_sched_credit_domain_get(va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_get(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_get(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_get", &lg);
 	FREE_CTX();
@@ -689,7 +689,7 @@ value stub_xl_sched_credit_domain_set(va
 	sched_credit_val(&gc, &c_scinfo, scinfo);
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_set(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_set", &lg);
 	FREE_CTX();
@@ -707,7 +707,7 @@ value stub_xl_send_trigger(value domid, 
 	c_trigger = dup_String_val(&gc, trigger);
 
 	INIT_CTX();
-	ret = libxl_send_trigger(&ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
+	ret = libxl_send_trigger(ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
 	if (ret != 0)
 		failwith_xl("send_trigger", &lg);
 	FREE_CTX();
@@ -721,7 +721,7 @@ value stub_xl_send_sysrq(value domid, va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_send_sysrq(&ctx, Int_val(domid), Int_val(sysrq));
+	ret = libxl_send_sysrq(ctx, Int_val(domid), Int_val(sysrq));
 	if (ret != 0)
 		failwith_xl("send_sysrq", &lg);
 	FREE_CTX();
@@ -738,7 +738,7 @@ value stub_xl_send_debug_keys(value keys
 	c_keys = dup_String_val(&gc, keys);
 
 	INIT_CTX();
-	ret = libxl_send_debug_keys(&ctx, c_keys);
+	ret = libxl_send_debug_keys(ctx, c_keys);
 	if (ret != 0)
 		failwith_xl("send_debug_keys", &lg);
 	FREE_CTX();
diff -r b65de5ce6202 -r f92a4b0f40df tools/python/setup.py
--- a/tools/python/setup.py	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/python/setup.py	Fri Apr 01 14:04:39 2011 +0100
@@ -83,7 +83,7 @@ netlink = Extension("netlink",
 
 xl = Extension("xl",
                extra_compile_args = extra_compile_args,
-               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, PATH_XENSTORE, "xen/lowlevel/xl" ],
+               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, "xen/lowlevel/xl" ],
                library_dirs       = [ PATH_LIBXL ],
                libraries          = [ "xenlight" ],
                depends            = [ PATH_LIBXL + "/libxenlight.so" ],
diff -r b65de5ce6202 -r f92a4b0f40df tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c	Fri Apr 01 14:04:39 2011 +0100
@@ -370,7 +370,7 @@ PyObject *attrib__struct_in_addr_get(str
 
 typedef struct {
     PyObject_HEAD;
-    libxl_ctx ctx;
+    libxl_ctx *ctx;
     xentoollog_logger_stdiostream *logger;
     xentoollog_level minmsglevel;
 } XlObject;
@@ -381,7 +381,7 @@ static PyObject *pyxl_list_domains(XlObj
     PyObject *list;
     int nr_dom, i;
 
-    info = libxl_list_domain(&self->ctx, &nr_dom);
+    info = libxl_list_domain(self->ctx, &nr_dom);
     if ( NULL == info )
         return PyList_New(0);
 
@@ -416,7 +416,7 @@ static PyObject *pyxl_domid_to_name(XlOb
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    domname = libxl_domid_to_name(&self->ctx, domid);
+    domname = libxl_domid_to_name(self->ctx, domid);
     ret = PyString_FromString(domname);
     free(domname);
 
@@ -428,7 +428,7 @@ static PyObject *pyxl_domain_shutdown(Xl
     int domid, req = 0;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &req) )
         return NULL;
-    if ( libxl_domain_shutdown(&self->ctx, domid, req) ) {
+    if ( libxl_domain_shutdown(self->ctx, domid, req) ) {
         PyErr_SetString(xl_error_obj, "cannot shutdown domain");
         return NULL;
     }
@@ -441,7 +441,7 @@ static PyObject *pyxl_domain_destroy(XlO
     int domid, force = 1;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &force) )
         return NULL;
-    if ( libxl_domain_destroy(&self->ctx, domid, force) ) {
+    if ( libxl_domain_destroy(self->ctx, domid, force) ) {
         PyErr_SetString(xl_error_obj, "cannot destroy domain");
         return NULL;
     }
@@ -454,7 +454,7 @@ static PyObject *pyxl_domain_pause(XlObj
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_pause(&self->ctx, domid) ) {
+    if ( libxl_domain_pause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot pause domain");
         return NULL;
     }
@@ -467,7 +467,7 @@ static PyObject *pyxl_domain_unpause(XlO
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_unpause(&self->ctx, domid) ) {
+    if ( libxl_domain_unpause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot unpause domain");
         return NULL;
     }
@@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlOb
     int domid;
     if ( !PyArg_ParseTuple(args, "is|s", &domid, &new_name, &old_name) )
         return NULL;
-    if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name) ) {
+    if ( libxl_domain_rename(self->ctx, domid, old_name, new_name) ) {
         PyErr_SetString(xl_error_obj, "cannot rename domain");
         return NULL;
     }
@@ -501,7 +501,7 @@ static PyObject *pyxl_pci_add(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_add(&self->ctx, domid, &pci->obj) ) {
+    if ( libxl_device_pci_add(self->ctx, domid, &pci->obj) ) {
         PyErr_SetString(xl_error_obj, "cannot add pci device");
         return NULL;
     }
@@ -522,7 +522,7 @@ static PyObject *pyxl_pci_del(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_remove(&self->ctx, domid, &pci->obj, force) ) {
+    if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj, force) ) {
         PyErr_SetString(xl_error_obj, "cannot remove pci device");
         return NULL;
     }
@@ -544,7 +544,7 @@ static PyObject *pyxl_pci_parse(XlObject
         return NULL;
     }
 
-    if ( libxl_device_pci_parse_bdf(&self->ctx, &pci->obj, str) ) {
+    if ( libxl_device_pci_parse_bdf(self->ctx, &pci->obj, str) ) {
         PyErr_SetString(xl_error_obj, "cannot parse pci device spec (BDF)");
         Py_DECREF(pci);
         return NULL;
@@ -559,7 +559,7 @@ static PyObject *pyxl_pci_list_assignabl
     PyObject *list;
     int nr_dev, i;
 
-    if ( libxl_device_pci_list_assignable(&self->ctx, &dev, &nr_dev) ) {
+    if ( libxl_device_pci_list_assignable(self->ctx, &dev, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -595,7 +595,7 @@ static PyObject *pyxl_pci_list(XlObject 
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    if ( libxl_device_pci_list_assigned(&self->ctx, &dev, domid, &nr_dev) ) {
+    if ( libxl_device_pci_list_assigned(self->ctx, &dev, domid, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -663,7 +663,7 @@ static PyObject *PyXl_new(PyTypeObject *
     if (self == NULL)
         return NULL;
 
-    memset(&self->ctx, 0, sizeof(self->ctx));
+    self->ctx = NULL;
     self->logger = NULL;
     self->minmsglevel = XTL_PROGRESS;
 
@@ -679,7 +679,7 @@ PyXl_init(XlObject *self, PyObject *args
         return -1;
     }
 
-    if ( libxl_ctx_init(&self->ctx, LIBXL_VERSION,
+    if ( libxl_ctx_alloc(&self->ctx, LIBXL_VERSION,
                 (xentoollog_logger*)self->logger) ) {
         PyErr_SetString(xl_error_obj, "cannot init xl context");
         return -1;
@@ -690,7 +690,7 @@ PyXl_init(XlObject *self, PyObject *args
 
 static void PyXl_dealloc(XlObject *self)
 {
-    libxl_ctx_free(&self->ctx);
+    libxl_ctx_free(self->ctx);
     if ( self->logger )
         xtl_logger_destroy((xentoollog_logger*)self->logger);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h
  2011-04-01 13:12     ` Ian Campbell
@ 2011-04-01 14:03       ` Ian Campbell
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Campbell @ 2011-04-01 14:03 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel@lists.xensource.com

On Fri, 2011-04-01 at 14:12 +0100, Ian Campbell wrote:
> On Thu, 2011-03-31 at 19:33 +0100, Ian Jackson wrote:
> > Ian Campbell writes ("[Xen-devel] [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h"):
> > > libxl: do not expose libxenctrl/libxenstore headers via libxl.h
> >
> > I'm afraid this one doesn't apply any more:
> >
> > Hunk #1 FAILED at 124.
> > 1 out of 3 hunks FAILED -- saving rejects to file tools/libxl/libxl.h.rej
> >
> > Ian.
> 
> It conflicted with "libxl: use system include for libxl_uuid.h".
> Refreshed version below.
> 
> Since this touches a lot of lines of xl_cmdimpl.c this patch may be
> particularly prone to breakage, fortunately of the easy to fix
> mechanically kind (add a & to the ctx).
> 
> If you want I'm happy to coordinate a suitable window in the flow of
> patches with you.

Darn, somehow I missed build testing the tools/ocaml tree. Updated
version below

8<-------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301666596 -3600
# Node ID ab8fc27358d068294e1f07473060c6b276f747c9
# Parent  b65de5ce62025524cbd47be345a445361affb2b1
libxl: do not expose libxenctrl/libxenstore headers via libxl.h

This completely removes libxenstore from libxl users' view.

xl still needs libxenctrl directly due to the direct use of the
xentoollog functionality but it is not exposed to the indirect linkage
anymore.

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

diff -r b65de5ce6202 -r ab8fc27358d0 tools/Rules.mk
--- a/tools/Rules.mk	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/Rules.mk	Fri Apr 01 15:03:16 2011 +0100
@@ -49,7 +49,7 @@ LDLIBS_libblktapctl =
 SHLIB_libblktapctl  =
 endif
 
-CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude)
+CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
 LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight
 SHLIB_libxenlight  = -Wl,-rpath-link=$(XEN_XENLIGHT)
 
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/Makefile
--- a/tools/libxl/Makefile	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/Makefile	Fri Apr 01 15:03:16 2011 +0100
@@ -13,7 +13,6 @@ XLUMINOR = 0
 
 CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
 CFLAGS += -I. -fPIC
-CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
 ifeq ($(CONFIG_Linux),y)
 LIBUUID_LIBS += -luuid
@@ -38,13 +37,18 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_c
 			libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o
 
+$(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
+
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
 AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
 LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o
+$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 
 CLIENTS = xl
 
 XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 
 .PHONY: all
 all: $(CLIENTS) libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl.c	Fri Apr 01 15:03:16 2011 +0100
@@ -41,15 +41,22 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg)
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger * lg)
 {
+    libxl_ctx *ctx;
     struct stat stat_buf;
 
     if (version != LIBXL_VERSION)
         return ERROR_VERSION;
+
+    ctx = malloc(sizeof(*ctx));
+    if (!ctx) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n");
+        return ERROR_NOMEM;
+    }
+
     memset(ctx, 0, sizeof(libxl_ctx));
     ctx->lg = lg;
-    memset(&ctx->version_info, 0, sizeof(libxl_version_info));
 
     if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n"
@@ -73,6 +80,8 @@ int libxl_ctx_init(libxl_ctx *ctx, int v
         xc_interface_close(ctx->xch);
         return ERROR_FAIL;
     }
+
+    *pctx = ctx;
     return 0;
 }
 
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl.h	Fri Apr 01 15:03:16 2011 +0100
@@ -124,13 +124,18 @@
 #ifndef LIBXL_H
 #define LIBXL_H
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <errno.h>
 #include <netinet/in.h>
-#include <xenctrl.h>
-#include <xs.h>
 #include <sys/wait.h> /* for pid_t */
 
+#include <xentoollog.h>
+
+#include <xen/sched.h>
+#include <xen/sysctl.h>
+
 #include <libxl_uuid.h>
 
 typedef uint8_t libxl_mac[6];
@@ -216,17 +221,7 @@ void libxl_cpuid_destroy(libxl_cpuid_pol
 
 #include "_libxl_types.h"
 
-typedef struct {
-    xentoollog_logger *lg;
-    xc_interface *xch;
-    struct xs_handle *xsh;
-
-    /* for callers who reap children willy-nilly; caller must only
-     * set this after libxl_init and before any other call - or
-     * may leave them untouched */
-    int (*waitpid_instead)(pid_t pid, int *status, int flags);
-    libxl_version_info version_info;
-} libxl_ctx;
+typedef struct libxl__ctx libxl_ctx;
 
 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
 
@@ -283,7 +278,7 @@ typedef struct {
 } libxl_domain_config;
 
 /* context functions */
-int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger*);
+int libxl_ctx_alloc(libxl_ctx **pctx, int version, xentoollog_logger *lg);
 int libxl_ctx_free(libxl_ctx *ctx);
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxl_internal.h	Fri Apr 01 15:03:16 2011 +0100
@@ -82,6 +82,17 @@ _hidden void libxl__log(libxl_ctx *ctx, 
 
      /* these functions preserve errno (saving and restoring) */
 
+struct libxl__ctx {
+    xentoollog_logger *lg;
+    xc_interface *xch;
+    struct xs_handle *xsh;
+
+    /* for callers who reap children willy-nilly; caller must only
+     * set this after libxl_init and before any other call - or
+     * may leave them untouched */
+    int (*waitpid_instead)(pid_t pid, int *status, int flags);
+    libxl_version_info version_info;
+};
 
 typedef enum {
     DEVICE_VIF = 1,
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/libxlu_cfg.c
--- a/tools/libxl/libxlu_cfg.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/libxlu_cfg.c	Fri Apr 01 15:03:16 2011 +0100
@@ -1,3 +1,4 @@
+#include <limits.h>
 
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/xl.c
--- a/tools/libxl/xl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl.c	Fri Apr 01 15:03:16 2011 +0100
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <xenctrl.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -111,7 +112,7 @@ int main(int argc, char **argv)
     logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
     if (!logger) exit(1);
 
-    if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
+    if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
         fprintf(stderr, "cannot init xl context\n");
         exit(1);
     }
@@ -123,7 +124,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    ret = libxl_read_file_contents(&ctx, config_file,
+    ret = libxl_read_file_contents(ctx, config_file,
             &config_data, &config_len);
     if (ret)
         fprintf(stderr, "Failed to read config file: %s: %s\n",
@@ -147,7 +148,7 @@ int main(int argc, char **argv)
         ret = 1;
     }
 
-    libxl_ctx_free(&ctx);
+    libxl_ctx_free(ctx);
     xtl_logger_destroy((xentoollog_logger*)logger);
 
     return ret;
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl.h	Fri Apr 01 15:03:16 2011 +0100
@@ -95,7 +95,7 @@ extern int cmdtable_len;
 /* Look up a command in the table, allowing unambiguous truncation */
 struct cmd_spec *cmdtable_lookup(const char *s);
 
-extern libxl_ctx ctx;
+extern libxl_ctx *ctx;
 extern xentoollog_logger_stdiostream *logger;
 
 /* global options */
diff -r b65de5ce6202 -r ab8fc27358d0 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Fri Apr 01 15:03:16 2011 +0100
@@ -31,9 +31,10 @@
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <sys/utsname.h> /* for utsname in xl info */
-#include <xenctrl.h>
+#include <xentoollog.h>
 #include <ctype.h>
 #include <inttypes.h>
+#include <limits.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -62,7 +63,7 @@
 int logfile = 2;
 
 /* every libxl action in xl uses this same libxl context */
-libxl_ctx ctx;
+libxl_ctx *ctx;
 
 /* when we operate on a domain, it is this one: */
 static uint32_t domid;
@@ -150,11 +151,11 @@ static int domain_qualifier_to_domid(con
         *was_name_r = was_name;
 
     if (was_name) {
-        rc = libxl_name_to_domid(&ctx, p, domid_r);
+        rc = libxl_name_to_domid(ctx, p, domid_r);
         if (rc)
             return rc;
     } else {
-        rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
+        rc = libxl_domain_info(ctx, &dominfo, *domid_r);
         /* error only if domain does not exist */
         if (rc == ERROR_INVAL)
             return rc;
@@ -170,7 +171,7 @@ static int cpupool_qualifier_to_cpupooli
 
     was_name = qualifier_to_id(p, poolid_r);
     if (was_name_r) *was_name_r = was_name;
-    return was_name ? libxl_name_to_cpupoolid(&ctx, p, poolid_r) : 0;
+    return was_name ? libxl_name_to_cpupoolid(ctx, p, poolid_r) : 0;
 }
 
 static void find_domain(const char *p)
@@ -182,7 +183,7 @@ static void find_domain(const char *p)
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    common_domname = was_name ? p : libxl_domid_to_name(ctx, domid);
 }
 
 static int acquire_lock(void)
@@ -303,7 +304,7 @@ static void printf_info(int domid,
     /* retrieve the UUID from dominfo, since it is probably generated
      * during parsing and thus does not match the real one
      */
-    if (libxl_domain_info(&ctx, &info, domid) == 0) {
+    if (libxl_domain_info(ctx, &info, domid) == 0) {
         printf("\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(info.uuid));
     } else {
         printf("\t(uuid <unknown>)\n");
@@ -667,7 +668,7 @@ static void parse_config_data(const char
         c_info->poolid = -1;
         cpupool_qualifier_to_cpupoolid(buf, &c_info->poolid, NULL);
     }
-    c_info->poolname = libxl_cpupoolid_to_name(&ctx, c_info->poolid);
+    c_info->poolname = libxl_cpupoolid_to_name(ctx, c_info->poolid);
     if (!c_info->poolname) {
         fprintf(stderr, "Illegal pool specified\n");
         exit(1);
@@ -875,7 +876,7 @@ static void parse_config_data(const char
                     free(nic->ifname);
                     nic->ifname = strdup(p2 + 1);
                 } else if (!strcmp(p, "backend")) {
-                    if(libxl_name_to_domid(&ctx, (p2 + 1), &(nic->backend_domid))) {
+                    if(libxl_name_to_domid(ctx, (p2 + 1), &(nic->backend_domid))) {
                         fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                         nic->backend_domid = 0;
                     }
@@ -1022,7 +1023,7 @@ skip_vfb:
 
             pcidev->msitranslate = pci_msitranslate;
             pcidev->power_mgmt = pci_power_mgmt;
-            if (!libxl_device_pci_parse_bdf(&ctx, pcidev, buf))
+            if (!libxl_device_pci_parse_bdf(ctx, pcidev, buf))
                 d_config->num_pcidevs++;
         }
     }
@@ -1291,23 +1292,23 @@ static int freemem(libxl_domain_build_in
     if (!autoballoon)
         return 0;
 
-    rc = libxl_domain_need_memory(&ctx, b_info, dm_info, &need_memkb);
+    rc = libxl_domain_need_memory(ctx, b_info, dm_info, &need_memkb);
     if (rc < 0)
         return rc;
 
     do {
-        rc = libxl_get_free_memory(&ctx, &free_memkb);
+        rc = libxl_get_free_memory(ctx, &free_memkb);
         if (rc < 0)
             return rc;
 
         if (free_memkb >= need_memkb)
             return 0;
 
-        rc = libxl_set_memory_target(&ctx, 0, free_memkb - need_memkb, 1, 0);
+        rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0);
         if (rc < 0)
             return rc;
 
-        rc = libxl_wait_for_free_memory(&ctx, domid, need_memkb, 10);
+        rc = libxl_wait_for_free_memory(ctx, domid, need_memkb, 10);
         if (!rc)
             return 0;
         else if (rc != ERROR_NOMEM)
@@ -1315,7 +1316,7 @@ static int freemem(libxl_domain_build_in
 
         /* the memory target has been reached but the free memory is still
          * not enough: loop over again */
-        rc = libxl_wait_for_memory_target(&ctx, 0, 1);
+        rc = libxl_wait_for_memory_target(ctx, 0, 1);
         if (rc < 0)
             return rc;
 
@@ -1380,7 +1381,7 @@ static int create_domain(struct domain_c
         restore_fd = migrate_fd >= 0 ? migrate_fd :
             open(restore_file, O_RDONLY);
 
-        CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, &hdr,
+        CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, &hdr,
                    sizeof(hdr), restore_file, "header") );
         if (memcmp(hdr.magic, savefileheader_magic, sizeof(hdr.magic))) {
             fprintf(stderr, "File has wrong magic number -"
@@ -1406,7 +1407,7 @@ static int create_domain(struct domain_c
         }
         if (hdr.optional_data_len) {
             optdata_begin = xmalloc(hdr.optional_data_len);
-            CHK_ERRNO( libxl_read_exactly(&ctx, restore_fd, optdata_begin,
+            CHK_ERRNO( libxl_read_exactly(ctx, restore_fd, optdata_begin,
                    hdr.optional_data_len, restore_file, "optdata") );
         }
 
@@ -1438,7 +1439,7 @@ static int create_domain(struct domain_c
 
     if (config_file) {
         free(config_data);  config_data = 0;
-        ret = libxl_read_file_contents(&ctx, config_file,
+        ret = libxl_read_file_contents(ctx, config_file,
                                        &config_data, &config_len);
         if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
                            config_file, strerror(errno)); return ERROR_FAIL; }
@@ -1517,17 +1518,17 @@ start:
     }
 
     if ( restore_file ) {
-        ret = libxl_domain_create_restore(&ctx, &d_config,
+        ret = libxl_domain_create_restore(ctx, &d_config,
                                             cb, &child_console_pid,
                                             &domid, restore_fd);
     }else{
-        ret = libxl_domain_create_new(&ctx, &d_config,
+        ret = libxl_domain_create_new(ctx, &d_config,
                                         cb, &child_console_pid, &domid);
     }
     if ( ret )
         goto error_out;
 
-    ret = libxl_userdata_store(&ctx, domid, "xl",
+    ret = libxl_userdata_store(ctx, domid, "xl",
                                     config_data, config_len);
     if (ret) {
         perror("cannot save config file");
@@ -1538,7 +1539,7 @@ start:
     release_lock();
 
     if (!paused)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
     if (!daemonize)
@@ -1549,7 +1550,7 @@ start:
         pid_t child1, got_child;
         int nullfd;
 
-        child1 = libxl_fork(&ctx);
+        child1 = libxl_fork(ctx);
         if (child1) {
             printf("Daemon running with PID %d\n", child1);
 
@@ -1564,7 +1565,7 @@ start:
                 }
             }
             if (status) {
-                libxl_report_child_exitstatus(&ctx, XTL_ERROR,
+                libxl_report_child_exitstatus(ctx, XTL_ERROR,
                            "daemonizing child", child1, status);
                 ret = ERROR_FAIL;
                 goto error_out;
@@ -1573,7 +1574,7 @@ start:
             goto out;
         }
 
-        rc = libxl_ctx_postfork(&ctx);
+        rc = libxl_ctx_postfork(ctx);
         if (rc) {
             LOG("failed to reinitialise context after fork");
             exit(-1);
@@ -1583,7 +1584,7 @@ start:
             LOG("Failed to allocate memory in asprintf");
             exit(1);
         }
-        rc = libxl_create_logfile(&ctx, name, &fullname);
+        rc = libxl_create_logfile(ctx, name, &fullname);
         if (rc) {
             LOG("failed to open logfile %s: %s",fullname,strerror(errno));
             exit(-1);
@@ -1605,9 +1606,9 @@ start:
         d_config.c_info.name, domid, (long)getpid());
     w1 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter) * d_config.num_disks);
     w2 = (libxl_waiter*) xmalloc(sizeof(libxl_waiter));
-    libxl_wait_for_disk_ejects(&ctx, domid, d_config.disks, d_config.num_disks, w1);
-    libxl_wait_for_domain_death(&ctx, domid, w2);
-    libxl_get_wait_fd(&ctx, &fd);
+    libxl_wait_for_disk_ejects(ctx, domid, d_config.disks, d_config.num_disks, w1);
+    libxl_wait_for_domain_death(ctx, domid, w2);
+    libxl_get_wait_fd(ctx, &fd);
     while (1) {
         int ret;
         fd_set rfds;
@@ -1621,10 +1622,10 @@ start:
         ret = select(fd + 1, &rfds, NULL, NULL, NULL);
         if (!ret)
             continue;
-        libxl_get_event(&ctx, &event);
+        libxl_get_event(ctx, &event);
         switch (event.type) {
             case LIBXL_EVENT_DOMAIN_DEATH:
-                ret = libxl_event_get_domain_death_info(&ctx, domid, &event, &info);
+                ret = libxl_event_get_domain_death_info(ctx, domid, &event, &info);
 
                 if (ret < 0) {
                     libxl_free_event(&event);
@@ -1634,9 +1635,9 @@ start:
                 LOG("Domain %d is dead", domid);
 
                 if (ret) {
-                    switch (handle_domain_death(&ctx, domid, &event, &d_config, &info)) {
+                    switch (handle_domain_death(ctx, domid, &event, &d_config, &info)) {
                     case 2:
-                        if (!preserve_domain(&ctx, domid, &event, &d_config, &info)) {
+                        if (!preserve_domain(ctx, domid, &event, &d_config, &info)) {
                             /* If we fail then exit leaving the old domain in place. */
                             ret = -1;
                             goto out;
@@ -1682,8 +1683,8 @@ start:
                 }
                 break;
             case LIBXL_EVENT_DISK_EJECT:
-                if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) {
-                    libxl_cdrom_insert(&ctx, domid, &disk);
+                if (libxl_event_get_disk_eject_info(ctx, domid, &event, &disk)) {
+                    libxl_cdrom_insert(ctx, domid, &disk);
                     libxl_device_disk_destroy(&disk);
                 }
                 break;
@@ -1694,7 +1695,7 @@ start:
 error_out:
     release_lock();
     if (libxl_domid_valid_guest(domid))
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
 out:
     if (logfile != 2)
@@ -1789,7 +1790,7 @@ static int set_memory_max(const char *p,
         exit(3);
     }
 
-    rc = libxl_domain_setmaxmem(&ctx, domid, memorykb);
+    rc = libxl_domain_setmaxmem(ctx, domid, memorykb);
 
     return rc;
 }
@@ -1839,7 +1840,7 @@ static void set_memory_target(const char
         exit(3);
     }
 
-    libxl_set_memory_target(&ctx, domid, memorykb, 0, /* enforce */ 1);
+    libxl_set_memory_target(ctx, domid, memorykb, 0, /* enforce */ 1);
 }
 
 int main_memset(int argc, char **argv)
@@ -1887,7 +1888,7 @@ static void cd_insert(const char *dom, c
     disk.backend_domid = 0;
     disk.domid = domid;
 
-    libxl_cdrom_insert(&ctx, domid, &disk);
+    libxl_cdrom_insert(ctx, domid, &disk);
     free(buf);
 }
 
@@ -1982,9 +1983,9 @@ int main_console(int argc, char **argv)
 
     find_domain(argv[optind]);
     if (!type)
-        libxl_primary_console_exec(&ctx, domid);
+        libxl_primary_console_exec(ctx, domid);
     else
-        libxl_console_exec(&ctx, domid, num, type);
+        libxl_console_exec(ctx, domid, num, type);
     fprintf(stderr, "Unable to attach console\n");
     return 1;
 }
@@ -1992,7 +1993,7 @@ int main_console(int argc, char **argv)
 static int vncviewer(const char *domain_spec, int autopass)
 {
     find_domain(domain_spec);
-    libxl_vncviewer_exec(&ctx, domid, autopass);
+    libxl_vncviewer_exec(ctx, domid, autopass);
     fprintf(stderr, "Unable to execute vncviewer\n");
     return 1;
 }
@@ -2040,7 +2041,7 @@ static void pcilist_assignable(void)
     libxl_device_pci *pcidevs;
     int num, i;
 
-    if ( libxl_device_pci_list_assignable(&ctx, &pcidevs, &num) )
+    if ( libxl_device_pci_list_assignable(ctx, &pcidevs, &num) )
         return;
     for (i = 0; i < num; i++) {
         printf("%04x:%02x:%02x.%01x\n",
@@ -2075,7 +2076,7 @@ static void pcilist(const char *dom)
 
     find_domain(dom);
 
-    if (libxl_device_pci_list_assigned(&ctx, &pcidevs, domid, &num))
+    if (libxl_device_pci_list_assigned(ctx, &pcidevs, domid, &num))
         return;
     printf("Vdev Device\n");
     for (i = 0; i < num; i++) {
@@ -2120,11 +2121,11 @@ static void pcidetach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_remove(&ctx, domid, &pcidev, force);
+    libxl_device_pci_remove(ctx, domid, &pcidev, force);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2165,11 +2166,11 @@ static void pciattach(const char *dom, c
     find_domain(dom);
 
     memset(&pcidev, 0x00, sizeof(pcidev));
-    if (libxl_device_pci_parse_bdf(&ctx, &pcidev, bdf)) {
+    if (libxl_device_pci_parse_bdf(ctx, &pcidev, bdf)) {
         fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n", bdf);
         exit(2);
     }
-    libxl_device_pci_add(&ctx, domid, &pcidev);
+    libxl_device_pci_add(ctx, domid, &pcidev);
     libxl_device_pci_destroy(&pcidev);
 }
 
@@ -2206,13 +2207,13 @@ int main_pciattach(int argc, char **argv
 static void pause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_pause(&ctx, domid);
+    libxl_domain_pause(ctx, domid);
 }
 
 static void unpause_domain(const char *p)
 {
     find_domain(p);
-    libxl_domain_unpause(&ctx, domid);
+    libxl_domain_unpause(ctx, domid);
 }
 
 static void destroy_domain(const char *p)
@@ -2223,7 +2224,7 @@ static void destroy_domain(const char *p
         fprintf(stderr, "Cannot destroy privileged domain 0.\n\n");
         exit(-1);
     }
-    rc = libxl_domain_destroy(&ctx, domid, 0);
+    rc = libxl_domain_destroy(ctx, domid, 0);
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
 }
 
@@ -2232,16 +2233,16 @@ static void shutdown_domain(const char *
     int rc;
 
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 0);
+    rc=libxl_domain_shutdown(ctx, domid, 0);
     if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); }
 
     if (wait) {
         libxl_waiter waiter;
         int fd;
 
-        libxl_wait_for_domain_death(&ctx, domid, &waiter);
-
-        libxl_get_wait_fd(&ctx, &fd);
+        libxl_wait_for_domain_death(ctx, domid, &waiter);
+
+        libxl_get_wait_fd(ctx, &fd);
 
         while (wait) {
             fd_set rfds;
@@ -2254,10 +2255,10 @@ static void shutdown_domain(const char *
             if (!select(fd + 1, &rfds, NULL, NULL, NULL))
                 continue;
 
-            libxl_get_event(&ctx, &event);
+            libxl_get_event(ctx, &event);
 
             if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
-                if (libxl_event_get_domain_death_info(&ctx, domid, &event, &info) < 0)
+                if (libxl_event_get_domain_death_info(ctx, domid, &event, &info) < 0)
                     continue;
 
                 LOG("Domain %d is dead", domid);
@@ -2274,7 +2275,7 @@ static void reboot_domain(const char *p)
 {
     int rc;
     find_domain(p);
-    rc=libxl_domain_shutdown(&ctx, domid, 1);
+    rc=libxl_domain_shutdown(ctx, domid, 1);
     if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2291,7 +2292,7 @@ static void list_domains_details(const l
         /* no detailed info available on dom0 */
         if (info[i].domid == 0)
             continue;
-        rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len);
+        rc = libxl_userdata_retrieve(ctx, info[i].domid, "xl", &data, &len);
         if (rc)
             continue;
         CHK_ERRNO(asprintf(&config_file, "<domid %d data>", info[i].domid));
@@ -2315,7 +2316,7 @@ static void list_domains(int verbose, co
     for (i = 0; i < nb_domain; i++) {
         char *domname;
         unsigned shutdown_reason;
-        domname = libxl_domid_to_name(&ctx, info[i].domid);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0;
         printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
                 domname,
@@ -2347,7 +2348,7 @@ static void list_vm(void)
     char *domname;
     int nb_vm, i;
 
-    info = libxl_list_vm(&ctx, &nb_vm);
+    info = libxl_list_vm(ctx, &nb_vm);
 
     if (info < 0) {
         fprintf(stderr, "libxl_domain_infolist failed.\n");
@@ -2355,7 +2356,7 @@ static 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);
+        domname = libxl_domid_to_name(ctx, info[i].domid);
         printf(LIBXL_UUID_FMT "  %d    %-30s\n", LIBXL_UUID_BYTES(info[i].uuid),
             info[i].domid, domname);
         free(domname);
@@ -2376,11 +2377,11 @@ static void save_domain_core_begin(const
 
     if (override_config_file) {
         void *config_v = 0;
-        rc = libxl_read_file_contents(&ctx, override_config_file,
+        rc = libxl_read_file_contents(ctx, override_config_file,
                                       &config_v, config_len_r);
         *config_data_r = config_v;
     } else {
-        rc = libxl_userdata_retrieve(&ctx, domid, "xl",
+        rc = libxl_userdata_retrieve(ctx, domid, "xl",
                                      config_data_r, config_len_r);
     }
     if (rc) {
@@ -2417,9 +2418,9 @@ static void save_domain_core_writeconfig
 
     /* that's the optional data */
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         &hdr, sizeof(hdr), filename, "header") );
-    CHK_ERRNO( libxl_write_exactly(&ctx, fd,
+    CHK_ERRNO( libxl_write_exactly(ctx, fd,
         optdata_begin, hdr.optional_data_len, filename, "header") );
 
     fprintf(stderr, "Saving to %s new xl format (info"
@@ -2449,13 +2450,13 @@ static int save_domain(const char *p, co
 
     save_domain_core_writeconfig(fd, filename, config_data, config_len);
 
-    CHK_ERRNO(libxl_domain_suspend(&ctx, NULL, domid, fd));
+    CHK_ERRNO(libxl_domain_suspend(ctx, NULL, domid, fd));
     close(fd);
 
     if (checkpoint)
-        libxl_domain_unpause(&ctx, domid);
+        libxl_domain_unpause(ctx, domid);
     else
-        libxl_domain_destroy(&ctx, domid, 0);
+        libxl_domain_destroy(ctx, domid, 0);
 
     exit(0);
 }
@@ -2467,7 +2468,7 @@ static int migrate_read_fixedmessage(int
     int rc;
 
     stream = rune ? "migration receiver stream" : "migration stream";
-    rc = libxl_read_exactly(&ctx, fd, buf, msgsz, stream, what);
+    rc = libxl_read_exactly(ctx, fd, buf, msgsz, stream, what);
     if (rc) return ERROR_FAIL;
 
     if (memcmp(buf, msg, msgsz)) {
@@ -2496,7 +2497,7 @@ static void migration_child_report(pid_t
 
         if (child == migration_child) {
             if (status)
-                libxl_report_child_exitstatus(&ctx, XTL_INFO,
+                libxl_report_child_exitstatus(ctx, XTL_INFO,
                                               "migration target process",
                                               migration_child, status);
             break;
@@ -2567,10 +2568,10 @@ static void migrate_domain(const char *d
         exit(1);
     }
 
-    MUST( libxl_pipe(&ctx, sendpipe) );
-    MUST( libxl_pipe(&ctx, recvpipe) );
-
-    child = libxl_fork(&ctx);
+    MUST( libxl_pipe(ctx, sendpipe) );
+    MUST( libxl_pipe(ctx, recvpipe) );
+
+    child = libxl_fork(ctx);
     if (child==-1) exit(1);
 
     if (!child) {
@@ -2608,7 +2609,7 @@ static void migrate_domain(const char *d
 
     memset(&suspinfo, 0, sizeof(suspinfo));
     suspinfo.flags |= XL_SUSPEND_LIVE;
-    rc = libxl_domain_suspend(&ctx, &suspinfo, domid, send_fd);
+    rc = libxl_domain_suspend(ctx, &suspinfo, domid, send_fd);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -2638,7 +2639,7 @@ static void migrate_domain(const char *d
     if (common_domname) {
         if (asprintf(&away_domname, "%s--migratedaway", common_domname) < 0)
             goto failed_resume;
-        rc = libxl_domain_rename(&ctx, domid, common_domname, away_domname);
+        rc = libxl_domain_rename(ctx, domid, common_domname, away_domname);
         if (rc) goto failed_resume;
     }
 
@@ -2649,7 +2650,7 @@ static void migrate_domain(const char *d
 
     fprintf(stderr, "migration sender: Giving target permission to start.\n");
 
-    rc = libxl_write_exactly(&ctx, send_fd,
+    rc = libxl_write_exactly(ctx, send_fd,
                              migrate_permission_to_go,
                              sizeof(migrate_permission_to_go),
                              "migration stream", "GO message");
@@ -2660,7 +2661,7 @@ static void migrate_domain(const char *d
                                    "success/failure report message", rune);
     if (rc) goto failed_badly;
 
-    rc = libxl_read_exactly(&ctx, recv_fd,
+    rc = libxl_read_exactly(ctx, recv_fd,
                             &rc_buf, 1,
                             "migration ack stream", "success/failure status");
     if (rc) goto failed_badly;
@@ -2678,9 +2679,9 @@ static void migrate_domain(const char *d
         fprintf(stderr, "migration sender: Trying to resume at our end.\n");
 
         if (common_domname) {
-            libxl_domain_rename(&ctx, domid, away_domname, common_domname);
+            libxl_domain_rename(ctx, domid, away_domname, common_domname);
         }
-        rc = libxl_domain_resume(&ctx, domid);
+        rc = libxl_domain_resume(ctx, domid);
         if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n");
 
         fprintf(stderr, "Migration failed due to problems at target.\n");
@@ -2688,7 +2689,7 @@ static void migrate_domain(const char *d
     }
 
     fprintf(stderr, "migration sender: Target reports successful startup.\n");
-    libxl_domain_destroy(&ctx, domid, 1); /* bang! */
+    libxl_domain_destroy(ctx, domid, 1); /* bang! */
     fprintf(stderr, "Migration successful.\n");
     exit(0);
 
@@ -2702,7 +2703,7 @@ static void migrate_domain(const char *d
     close(send_fd);
     migration_child_report(child, recv_fd);
     fprintf(stderr, "Migration failed, resuming at sender.\n");
-    libxl_domain_resume(&ctx, domid);
+    libxl_domain_resume(ctx, domid);
     exit(-ERROR_FAIL);
 
  failed_badly:
@@ -2723,7 +2724,7 @@ static void core_dump_domain(const char 
 {
     int rc;
     find_domain(domain_spec);
-    rc=libxl_domain_core_dump(&ctx, domid, filename);
+    rc=libxl_domain_core_dump(ctx, domid, filename);
     if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); }
 }
 
@@ -2739,7 +2740,7 @@ static void migrate_receive(int debug, i
 
     fprintf(stderr, "migration target: Ready to receive domain.\n");
 
-    CHK_ERRNO( libxl_write_exactly(&ctx, 1,
+    CHK_ERRNO( libxl_write_exactly(ctx, 1,
                                    migrate_receiver_banner,
                                    sizeof(migrate_receiver_banner)-1,
                                    "migration ack stream",
@@ -2763,7 +2764,7 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Transfer complete,"
             " requesting permission to start domain.\n");
 
-    rc = libxl_write_exactly(&ctx, 1,
+    rc = libxl_write_exactly(ctx, 1,
                              migrate_receiver_ready,
                              sizeof(migrate_receiver_ready),
                              "migration ack stream", "ready message");
@@ -2777,18 +2778,18 @@ static void migrate_receive(int debug, i
     fprintf(stderr, "migration target: Got permission, starting domain.\n");
 
     if (migration_domname) {
-        rc = libxl_domain_rename(&ctx, domid, migration_domname, common_domname);
+        rc = libxl_domain_rename(ctx, domid, migration_domname, common_domname);
         if (rc) goto perhaps_destroy_notify_rc;
     }
 
-    rc = libxl_domain_unpause(&ctx, domid);
+    rc = libxl_domain_unpause(ctx, domid);
     if (rc) goto perhaps_destroy_notify_rc;
 
     fprintf(stderr, "migration target: Domain started successsfully.\n");
     rc = 0;
 
  perhaps_destroy_notify_rc:
-    rc2 = libxl_write_exactly(&ctx, 1,
+    rc2 = libxl_write_exactly(ctx, 1,
                               migrate_report, sizeof(migrate_report),
                               "migration ack stream",
                               "success/failure report");
@@ -2796,7 +2797,7 @@ static void migrate_receive(int debug, i
 
     rc_buf = -rc;
     assert(!!rc_buf == !!rc);
-    rc2 = libxl_write_exactly(&ctx, 1, &rc_buf, 1,
+    rc2 = libxl_write_exactly(ctx, 1, &rc_buf, 1,
                               "migration ack stream",
                               "success/failure code");
     if (rc2) exit(-ERROR_BADFAIL);
@@ -2804,7 +2805,7 @@ static void migrate_receive(int debug, i
     if (rc) {
         fprintf(stderr, "migration target: Failure, destroying our copy.\n");
 
-        rc2 = libxl_domain_destroy(&ctx, domid, 1);
+        rc2 = libxl_domain_destroy(ctx, domid, 1);
         if (rc2) {
             fprintf(stderr, "migration target: Failed to destroy our copy"
                     " (code %d).\n", rc2);
@@ -2814,7 +2815,7 @@ static void migrate_receive(int debug, i
         fprintf(stderr, "migration target: Cleanup OK, granting sender"
                 " permission to resume.\n");
 
-        rc2 = libxl_write_exactly(&ctx, 1,
+        rc2 = libxl_write_exactly(ctx, 1,
                                   migrate_permission_to_go,
                                   sizeof(migrate_permission_to_go),
                                   "migration ack stream",
@@ -3194,7 +3195,7 @@ int main_list(int argc, char **argv)
     }
 
     if (optind >= argc) {
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3202,7 +3203,7 @@ int main_list(int argc, char **argv)
         info_free = info;
     } else if (optind == argc-1) {
         find_domain(argv[optind]);
-        rc = libxl_domain_info(&ctx, &info_buf, domid);
+        rc = libxl_domain_info(ctx, &info_buf, domid);
         if (rc == ERROR_INVAL) {
             fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
                 argv[optind]);
@@ -3353,7 +3354,7 @@ static void button_press(const char *p, 
         exit(2);
     }
 
-    libxl_button_press(&ctx, domid, button);
+    libxl_button_press(ctx, domid, button);
 }
 
 int main_button_press(int argc, char **argv)
@@ -3441,7 +3442,7 @@ static void print_vcpuinfo(uint32_t tdom
     char *domname;
 
     /*      NAME  ID  VCPU */
-    domname = libxl_domid_to_name(&ctx, tdomid);
+    domname = libxl_domid_to_name(ctx, tdomid);
     printf("%-32s %5u %5u",
            domname, tdomid, vcpuinfo->vcpuid);
     free(domname);
@@ -3466,7 +3467,7 @@ static void print_domain_vcpuinfo(uint32
     libxl_vcpuinfo *vcpuinfo;
     int i, nb_vcpu, nrcpus;
 
-    vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &nrcpus);
+    vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nrcpus);
 
     if (!vcpuinfo) {
         fprintf(stderr, "libxl_list_vcpu failed.\n");
@@ -3487,7 +3488,7 @@ static void vcpulist(int argc, char **ar
     libxl_physinfo physinfo;
     int i, nb_domain;
 
-    if (libxl_get_physinfo(&ctx, &physinfo) != 0) {
+    if (libxl_get_physinfo(ctx, &physinfo) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         goto vcpulist_out;
     }
@@ -3495,7 +3496,7 @@ static void vcpulist(int argc, char **ar
     printf("%-32s %5s %5s %5s %5s %9s %s\n",
            "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "CPU Affinity");
     if (!argc) {
-        if (!(dominfo = libxl_list_domain(&ctx, &nb_domain))) {
+        if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) {
             fprintf(stderr, "libxl_list_domain failed.\n");
             goto vcpulist_out;
         }
@@ -3558,7 +3559,7 @@ static void vcpupin(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         goto vcpupin_out;
     }
     if (strcmp(cpu, "all")) {
@@ -3589,17 +3590,17 @@ static void vcpupin(const char *d, const
     }
 
     if (vcpuid != -1) {
-        if (libxl_set_vcpuaffinity(&ctx, domid, vcpuid, &cpumap) == -1) {
+        if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, &cpumap) == -1) {
             fprintf(stderr, "Could not set affinity for vcpu `%u'.\n", vcpuid);
         }
     }
     else {
-        if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &i))) {
+        if (!(vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &i))) {
             fprintf(stderr, "libxl_list_vcpu failed.\n");
             goto vcpupin_out1;
         }
         for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
-            if (libxl_set_vcpuaffinity(&ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
+            if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo->vcpuid, &cpumap) == -1) {
                 fprintf(stderr, "libxl_set_vcpuaffinity failed on vcpu `%u'.\n", vcpuinfo->vcpuid);
             }
         }
@@ -3648,14 +3649,14 @@ static void vcpuset(const char *d, const
 
     find_domain(d);
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "libxl_cpumap_alloc failed\n");
         return;
     }
     for (i = 0; i < max_vcpus; i++)
         libxl_cpumap_set(&cpumap, i);
 
-    if (libxl_set_vcpuonline(&ctx, domid, &cpumap) < 0)
+    if (libxl_set_vcpuonline(ctx, domid, &cpumap) < 0)
         fprintf(stderr, "libxl_set_vcpuonline failed domid=%d max_vcpus=%d\n", domid, max_vcpus);
 
     libxl_cpumap_destroy(&cpumap);
@@ -3689,12 +3690,12 @@ static void output_xeninfo(void)
     const libxl_version_info *info;
     int sched_id;
 
-    if (!(info = libxl_get_version_info(&ctx))) {
+    if (!(info = libxl_get_version_info(ctx))) {
         fprintf(stderr, "libxl_get_version_info failed.\n");
         return;
     }
 
-    if ((sched_id = libxl_get_sched_id(&ctx)) < 0) {
+    if ((sched_id = libxl_get_sched_id(ctx)) < 0) {
         fprintf(stderr, "get_sched_id sysctl failed.\n");
         return;
     }
@@ -3703,7 +3704,7 @@ static void output_xeninfo(void)
     printf("xen_minor              : %d\n", info->xen_version_minor);
     printf("xen_extra              : %s\n", info->xen_version_extra);
     printf("xen_caps               : %s\n", info->capabilities);
-    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(&ctx, sched_id));
+    printf("xen_scheduler          : %s\n", libxl_schedid_to_name(ctx, sched_id));
     printf("xen_pagesize           : %lu\n", info->pagesize);
     printf("platform_params        : virt_start=0x%lx\n", info->virt_start);
     printf("xen_changeset          : %s\n", info->changeset);
@@ -3737,7 +3738,7 @@ static void output_physinfo(void)
     libxl_cpumap cpumap;
     int n = 0;
 
-    if (libxl_get_physinfo(&ctx, &info) != 0) {
+    if (libxl_get_physinfo(ctx, &info) != 0) {
         fprintf(stderr, "libxl_physinfo failed.\n");
         return;
     }
@@ -3756,13 +3757,13 @@ static void output_physinfo(void)
     if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
         printf(" hvm_directio");
     printf("\n");
-    vinfo = libxl_get_version_info(&ctx);
+    vinfo = libxl_get_version_info(ctx);
     if (vinfo) {
         i = (1 << 20) / vinfo->pagesize;
         printf("total_memory           : %"PRIu64"\n", info.total_pages / i);
         printf("free_memory            : %"PRIu64"\n", info.free_pages / i);
     }
-    if (!libxl_get_freecpus(&ctx, &cpumap)) {
+    if (!libxl_get_freecpus(ctx, &cpumap)) {
         libxl_for_each_cpu(i, cpumap)
             if (libxl_cpumap_test(&cpumap, i))
                 n++;
@@ -3778,7 +3779,7 @@ static void output_topologyinfo(void)
     libxl_topologyinfo info;
     int i;
 
-    if (libxl_get_topologyinfo(&ctx, &info)) {
+    if (libxl_get_topologyinfo(ctx, &info)) {
         fprintf(stderr, "libxl_get_topologyinfo failed.\n");
         return;
     }
@@ -3849,7 +3850,7 @@ static int sched_credit_domain_get(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_get(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_get(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_get failed.\n");
     
@@ -3861,7 +3862,7 @@ static int sched_credit_domain_set(
 {
     int rc;
 
-    rc = libxl_sched_credit_domain_set(&ctx, domid, scinfo);
+    rc = libxl_sched_credit_domain_set(ctx, domid, scinfo);
     if (rc)
         fprintf(stderr, "libxl_sched_credit_domain_set failed.\n");
 
@@ -3872,7 +3873,7 @@ static void sched_credit_domain_output(
     int domid, libxl_sched_credit *scinfo)
 {
     char *domname;
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     printf("%-33s %4d %6d %4d\n",
         domname,
         domid,
@@ -3918,7 +3919,7 @@ int main_sched_credit(int argc, char **a
     }
 
     if (!dom) { /* list all domain's credit scheduler info */
-        info = libxl_list_domain(&ctx, &nb_domain);
+        info = libxl_list_domain(ctx, &nb_domain);
         if (!info) {
             fprintf(stderr, "libxl_domain_infolist failed.\n");
             return 1;
@@ -3978,7 +3979,7 @@ int main_domid(int argc, char **argv)
         return 1;
     }
 
-    if (libxl_name_to_domid(&ctx, domname, &domid)) {
+    if (libxl_name_to_domid(ctx, domname, &domid)) {
         fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname);
         return 1;
     }
@@ -4017,7 +4018,7 @@ int main_domname(int argc, char **argv)
         return 1;
     }
 
-    domname = libxl_domid_to_name(&ctx, domid);
+    domname = libxl_domid_to_name(ctx, domid);
     if (!domname) {
         fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid);
         return 1;
@@ -4056,7 +4057,7 @@ int main_rename(int argc, char **argv)
     find_domain(dom);
     new_name = argv[optind];
 
-    if (libxl_domain_rename(&ctx, domid, common_domname, new_name)) {
+    if (libxl_domain_rename(ctx, domid, common_domname, new_name)) {
         fprintf(stderr, "Can't rename domain '%s'.\n", dom);
         return 1;
     }
@@ -4101,7 +4102,7 @@ int main_trigger(int argc, char **argv)
         }
     }
 
-    libxl_send_trigger(&ctx, domid, trigger_name, vcpuid);
+    libxl_send_trigger(ctx, domid, trigger_name, vcpuid);
 
     return 0;
 }
@@ -4141,7 +4142,7 @@ int main_sysrq(int argc, char **argv)
         return 1;
     }
 
-    libxl_send_sysrq(&ctx, domid, sysrq[0]);
+    libxl_send_sysrq(ctx, domid, sysrq[0]);
 
     return 0;
 }
@@ -4168,7 +4169,7 @@ int main_debug_keys(int argc, char **arg
 
     keys = argv[optind];
 
-    if (libxl_send_debug_keys(&ctx, keys)) {
+    if (libxl_send_debug_keys(ctx, keys)) {
         fprintf(stderr, "cannot send debug keys: %s\n", keys);
         return 1;
     }
@@ -4197,15 +4198,15 @@ int main_dmesg(int argc, char **argv)
         }
     }
 
-    cr = libxl_xen_console_read_start(&ctx, clear);
+    cr = libxl_xen_console_read_start(ctx, clear);
     if (!cr)
         goto finish;
 
-    while ((ret = libxl_xen_console_read_line(&ctx, cr, &line)) > 0)
+    while ((ret = libxl_xen_console_read_line(ctx, cr, &line)) > 0)
         printf("%s", line);
 
 finish:
-    libxl_xen_console_read_finish(&ctx, cr);
+    libxl_xen_console_read_finish(ctx, cr);
     return ret;
 }
 
@@ -4286,7 +4287,7 @@ int main_networkattach(int argc, char **
             free(nic.script);
             nic.script = strdup((*argv) + 6);
         } else if (!strncmp("backend=", *argv, 8)) {
-            if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) {
+            if(libxl_name_to_domid(ctx, ((*argv) + 8), &val)) {
                 fprintf(stderr, "Specified backend domain does not exist, defaulting to Dom0\n");
                 val = 0;
             }
@@ -4305,7 +4306,7 @@ int main_networkattach(int argc, char **
         }
     }
     nic.domid = domid;
-    if (libxl_device_nic_add(&ctx, domid, &nic)) {
+    if (libxl_device_nic_add(ctx, domid, &nic)) {
         fprintf(stderr, "libxl_device_nic_add failed.\n");
         return 1;
     }
@@ -4342,7 +4343,7 @@ 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 (!(nics = libxl_list_nics(ctx, domid, &nb))) {
             continue;
         }
         for (i = 0; i < nb; ++i) {
@@ -4389,17 +4390,17 @@ int main_networkdetach(int argc, char **
     }
 
     if (!strchr(argv[optind+1], ':')) {
-        if (libxl_devid_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_devid_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     } else {
-        if (libxl_mac_to_device_nic(&ctx, domid, argv[optind+1], &nic)) {
+        if (libxl_mac_to_device_nic(ctx, domid, argv[optind+1], &nic)) {
             fprintf(stderr, "Unknown device %s.\n", argv[optind+1]);
             return 1;
         }
     }
-    if (libxl_device_nic_del(&ctx, &nic, 1)) {
+    if (libxl_device_nic_del(ctx, &nic, 1)) {
         fprintf(stderr, "libxl_device_nic_del failed.\n");
         return 1;
     }
@@ -4477,7 +4478,7 @@ int main_blockattach(int argc, char **ar
     disk.domid = fe_domid;
     disk.backend_domid = be_domid;
 
-    if (libxl_device_disk_add(&ctx, fe_domid, &disk)) {
+    if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
         fprintf(stderr, "libxl_device_disk_add failed.\n");
     }
     return 0;
@@ -4512,12 +4513,12 @@ int main_blocklist(int argc, char **argv
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        disks = libxl_device_disk_list(&ctx, domid, &nb);
+        disks = libxl_device_disk_list(ctx, domid, &nb);
         if (!disks) {
             continue;
         }
         for (i=0; i<nb; i++) {
-            if (!libxl_device_disk_getinfo(&ctx, domid, &disks[i], &diskinfo)) {
+            if (!libxl_device_disk_getinfo(ctx, domid, &disks[i], &diskinfo)) {
                 /*      Vdev BE   hdl  st   evch rref BE-path*/
                 printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
                        diskinfo.devid, diskinfo.backend_id, diskinfo.frontend_id,
@@ -4555,11 +4556,11 @@ int main_blockdetach(int argc, char **ar
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_disk(&ctx, domid, argv[optind+1], &disk)) {
+    if (libxl_devid_to_device_disk(ctx, domid, argv[optind+1], &disk)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_disk_del(&ctx, &disk, 1)) {
+    if (libxl_device_disk_del(ctx, &disk, 1)) {
         fprintf(stderr, "libxl_device_disk_del failed.\n");
     }
     return 0;
@@ -4656,7 +4657,7 @@ int main_network2attach(int argc, char *
     }
     net2.domid = domid;
     net2.backend_domid = back_domid;
-    if (libxl_device_net2_add(&ctx, domid, &net2)) {
+    if (libxl_device_net2_add(ctx, domid, &net2)) {
         fprintf(stderr, "libxl_device_net2_add failed.\n");
     }
     return 0;
@@ -4691,7 +4692,7 @@ int main_network2list(int argc, char **a
             fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
             continue;
         }
-        if ((net2s = libxl_device_net2_list(&ctx, domid, &nb))) {
+        if ((net2s = libxl_device_net2_list(ctx, domid, &nb))) {
             for (; nb > 0; --nb, ++net2s) {
                 printf("%3d %2d %5d ", net2s->devid, net2s->backend_id, net2s->state);
                 printf("%02x:%02x:%02x:%02x:%02x:%02x ",
@@ -4731,11 +4732,11 @@ int main_network2detach(int argc, char *
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
         return 1;
     }
-    if (libxl_devid_to_device_net2(&ctx, domid, argv[optind+1], &net2)) {
+    if (libxl_devid_to_device_net2(ctx, domid, argv[optind+1], &net2)) {
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_net2_del(&ctx, &net2, 1)) {
+    if (libxl_device_net2_del(ctx, &net2, 1)) {
         fprintf(stderr, "libxl_device_net2_del failed.\n");
         return 1;
     }
@@ -4815,7 +4816,7 @@ static void print_dom0_uptime(int short_
     strtok(buf, " ");
     uptime = strtoul(buf, NULL, 10);
 
-    domname = libxl_domid_to_name(&ctx, 0);
+    domname = libxl_domid_to_name(ctx, 0);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4848,11 +4849,11 @@ static void print_domU_uptime(uint32_t d
     char *now_str = NULL;
     char *domname;
 
-    s_time = libxl_vm_get_start_time(&ctx, domuid);
+    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);
+    domname = libxl_domid_to_name(ctx, domuid);
     if (short_mode)
     {
         now_str = current_time_to_string(now);
@@ -4887,7 +4888,7 @@ static void print_uptime(int short_mode,
 
     if (nb_doms == 0) {
         print_dom0_uptime(short_mode, now);
-        info = libxl_list_vm(&ctx, &nb_vm);
+        info = libxl_list_vm(ctx, &nb_vm);
         for (i = 0; i < nb_vm; i++)
             print_domU_uptime(info[i].domid, short_mode, now);
     } else {
@@ -4969,7 +4970,7 @@ int main_tmem_list(int argc, char **argv
     else
         find_domain(dom);
 
-    buf = libxl_tmem_list(&ctx, domid, use_long);
+    buf = libxl_tmem_list(ctx, domid, use_long);
     if (buf == NULL)
         return -1;
 
@@ -5010,7 +5011,7 @@ int main_tmem_freeze(int argc, char **ar
     else
         find_domain(dom);
 
-    libxl_tmem_freeze(&ctx, domid);
+    libxl_tmem_freeze(ctx, domid);
     return 0;
 }
 
@@ -5046,7 +5047,7 @@ int main_tmem_destroy(int argc, char **a
     else
         find_domain(dom);
 
-    libxl_tmem_destroy(&ctx, domid);
+    libxl_tmem_destroy(ctx, domid);
     return 0;
 }
 
@@ -5082,7 +5083,7 @@ int main_tmem_thaw(int argc, char **argv
     else
         find_domain(dom);
 
-    libxl_tmem_thaw(&ctx, domid);
+    libxl_tmem_thaw(ctx, domid);
     return 0;
 }
 
@@ -5139,11 +5140,11 @@ int main_tmem_set(int argc, char **argv)
     }
 
     if (opt_w)
-        libxl_tmem_set(&ctx, domid, "weight", weight);
+        libxl_tmem_set(ctx, domid, "weight", weight);
     if (opt_c)
-        libxl_tmem_set(&ctx, domid, "cap", cap);
+        libxl_tmem_set(ctx, domid, "cap", cap);
     if (opt_p)
-        libxl_tmem_set(&ctx, domid, "compress", compress);
+        libxl_tmem_set(ctx, domid, "compress", compress);
 
     return 0;
 }
@@ -5202,7 +5203,7 @@ int main_tmem_shared_auth(int argc, char
         return 1;
     }
 
-    libxl_tmem_shared_auth(&ctx, domid, uuid, auth);
+    libxl_tmem_shared_auth(ctx, domid, uuid, auth);
 
     return 0;
 }
@@ -5223,7 +5224,7 @@ int main_tmem_freeable(int argc, char **
         }
     }
 
-    mb = libxl_tmem_freeable(&ctx);
+    mb = libxl_tmem_freeable(ctx);
     if (mb == -1)
         return -1;
 
@@ -5304,7 +5305,7 @@ int main_cpupoolcreate(int argc, char **
         return -ERROR_FAIL;
     }
 
-    if (libxl_read_file_contents(&ctx, filename, (void **)&config_data, &config_len)) {
+    if (libxl_read_file_contents(ctx, filename, (void **)&config_data, &config_len)) {
         fprintf(stderr, "Failed to read config file: %s: %s\n",
                 filename, strerror(errno));
         return -ERROR_FAIL;
@@ -5342,36 +5343,36 @@ int main_cpupoolcreate(int argc, char **
         name = strdup(buf);
     else
         name = libxl_basename(filename);
-    if (!libxl_name_to_cpupoolid(&ctx, name, &poolid)) {
+    if (!libxl_name_to_cpupoolid(ctx, name, &poolid)) {
         fprintf(stderr, "Pool name \"%s\" already exists\n", name);
         return -ERROR_FAIL;
     }
 
     if (!xlu_cfg_get_string (config, "sched", &buf)) {
-        if ((schedid = libxl_name_to_schedid(&ctx, buf)) < 0) {
+        if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) {
             fprintf(stderr, "Unknown scheduler\n");
             return -ERROR_FAIL;
         }
     } else {
-        if ((schedid = libxl_get_sched_id(&ctx)) < 0) {
+        if ((schedid = libxl_get_sched_id(ctx)) < 0) {
             fprintf(stderr, "get_sched_id sysctl failed.\n");
             return -ERROR_FAIL;
         }
     }
-    sched = libxl_schedid_to_name(&ctx, schedid);
-
-    if (libxl_get_freecpus(&ctx, &freemap)) {
+    sched = libxl_schedid_to_name(ctx, schedid);
+
+    if (libxl_get_freecpus(ctx, &freemap)) {
         fprintf(stderr, "libxl_get_freecpus failed\n");
         return -ERROR_FAIL;
     }
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         return -ERROR_FAIL;
     }
     if (!xlu_cfg_get_list(config, "nodes", &nodes, 0, 0)) {
         n_cpus = 0;
         n_nodes = 0;
-        if (libxl_get_topologyinfo(&ctx, &topology)) {
+        if (libxl_get_topologyinfo(ctx, &topology)) {
             fprintf(stderr, "libxl_get_topologyinfo failed\n");
             return -ERROR_FAIL;
         }
@@ -5431,7 +5432,7 @@ int main_cpupoolcreate(int argc, char **
         return 0;
 
     poolid = 0;
-    if (libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid)) {
+    if (libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid)) {
         fprintf(stderr, "error on creating cpupool\n");
         return -ERROR_FAIL;
     }
@@ -5485,13 +5486,13 @@ int main_cpupoollist(int argc, char **ar
     }
     if (optind < argc) {
         pool = argv[optind];
-        if (libxl_name_to_cpupoolid(&ctx, pool, &poolid)) {
+        if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
             fprintf(stderr, "Pool \'%s\' does not exist\n", pool);
             return -ERROR_FAIL;
         }
     }
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5505,7 +5506,7 @@ int main_cpupoollist(int argc, char **ar
 
     for (p = 0; p < n_pools; p++) {
         if (!ret && (!pool || (poolinfo[p].poolid == poolid))) {
-            name = libxl_cpupoolid_to_name(&ctx, poolinfo[p].poolid);
+            name = libxl_cpupoolid_to_name(ctx, poolinfo[p].poolid);
             if (!name) {
                 fprintf(stderr, "error getting cpupool info\n");
                 ret = -ERROR_NOMEM;
@@ -5521,7 +5522,7 @@ int main_cpupoollist(int argc, char **ar
                     }
                 if (!opt_cpus) {
                     printf("%3d %9s       y       %4d", n,
-                           libxl_schedid_to_name(&ctx, poolinfo[p].sched_id),
+                           libxl_schedid_to_name(ctx, poolinfo[p].sched_id),
                            poolinfo[p].n_dom);
                 }
                 printf("\n");
@@ -5558,12 +5559,12 @@ int main_cpupooldestroy(int argc, char *
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_destroy_cpupool(&ctx, poolid);
+    return -libxl_destroy_cpupool(ctx, poolid);
 }
 
 int main_cpupoolrename(int argc, char **argv)
@@ -5592,14 +5593,14 @@ int main_cpupoolrename(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     new_name = argv[optind];
 
-    if (libxl_cpupool_rename(&ctx, new_name, poolid)) {
+    if (libxl_cpupool_rename(ctx, new_name, poolid)) {
         fprintf(stderr, "Can't rename cpupool '%s'.\n", pool);
         return 1;
     }
@@ -5648,16 +5649,16 @@ int main_cpupoolcpuadd(int argc, char **
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuadd(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuadd(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuadd_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuadd_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5711,16 +5712,16 @@ int main_cpupoolcpuremove(int argc, char
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
     if (cpu >= 0) {
-        return -libxl_cpupool_cpuremove(&ctx, poolid, cpu);
-    }
-
-    if (libxl_cpupool_cpuremove_node(&ctx, poolid, node, &n)) {
+        return -libxl_cpupool_cpuremove(ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuremove_node(ctx, poolid, node, &n)) {
         fprintf(stderr, "libxl_cpupool_cpuremove_node failed\n");
         return -ERROR_FAIL;
     }
@@ -5767,18 +5768,18 @@ int main_cpupoolmigrate(int argc, char *
     }
 
     if (domain_qualifier_to_domid(dom, &domid, NULL) ||
-        !libxl_domid_to_name(&ctx, domid)) {
+        !libxl_domid_to_name(ctx, domid)) {
         fprintf(stderr, "unknown domain \'%s\'\n", dom);
         return -ERROR_FAIL;
     }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
-        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        !libxl_cpupoolid_to_name(ctx, poolid)) {
         fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
         return -ERROR_FAIL;
     }
 
-    return -libxl_cpupool_movedomain(&ctx, poolid, domid);
+    return -libxl_cpupool_movedomain(ctx, poolid, domid);
 }
 
 int main_cpupoolnumasplit(int argc, char **argv)
@@ -5811,7 +5812,7 @@ int main_cpupoolnumasplit(int argc, char
     }
     ret = 0;
 
-    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
     if (!poolinfo) {
         fprintf(stderr, "error getting cpupool info\n");
         return -ERROR_NOMEM;
@@ -5826,12 +5827,12 @@ int main_cpupoolnumasplit(int argc, char
         return -ERROR_FAIL;
     }
 
-    if (libxl_get_topologyinfo(&ctx, &topology)) {
+    if (libxl_get_topologyinfo(ctx, &topology)) {
         fprintf(stderr, "libxl_get_topologyinfo failed\n");
         return -ERROR_FAIL;
     }
 
-    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+    if (libxl_cpumap_alloc(ctx, &cpumap)) {
         fprintf(stderr, "Failed to allocate cpumap\n");
         libxl_topologyinfo_destroy(&topology);
         return -ERROR_FAIL;
@@ -5841,13 +5842,13 @@ int main_cpupoolnumasplit(int argc, char
        a cpupool without cpus in between */
 
     node = topology.nodemap.array[0];
-    if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) {
+    if (libxl_cpupool_cpuadd_node(ctx, 0, node, &n)) {
         fprintf(stderr, "error on adding cpu to Pool 0\n");
         return -ERROR_FAIL;
     }
 
     snprintf(name, 15, "Pool-node%d", node);
-    ret = -libxl_cpupool_rename(&ctx, name, 0);
+    ret = -libxl_cpupool_rename(ctx, name, 0);
     if (ret) {
         fprintf(stderr, "error on renaming Pool 0\n");
         goto out;
@@ -5861,12 +5862,12 @@ int main_cpupoolnumasplit(int argc, char
             n++;
         }
     }
-    if (libxl_set_vcpuonline(&ctx, 0, &cpumap)) {
+    if (libxl_set_vcpuonline(ctx, 0, &cpumap)) {
         fprintf(stderr, "error on removing vcpus for Domain-0\n");
         goto out;
     }
     for (c = 0; c < 10; c++) {
-        if (libxl_domain_info(&ctx, &info, 0)) {
+        if (libxl_domain_info(ctx, &info, 0)) {
             fprintf(stderr, "error on getting info for Domain-0\n");
             goto out;
         }
@@ -5887,7 +5888,7 @@ int main_cpupoolnumasplit(int argc, char
         }
 
         node = topology.nodemap.array[c];
-        ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n);
+        ret = -libxl_cpupool_cpuremove_node(ctx, 0, node, &n);
         if (ret) {
             fprintf(stderr, "error on removing cpu from Pool 0\n");
             goto out;
@@ -5896,13 +5897,13 @@ int main_cpupoolnumasplit(int argc, char
         snprintf(name, 15, "Pool-node%d", node);
         libxl_uuid_generate(&uuid);
         poolid = 0;
-        ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid);
+        ret = -libxl_create_cpupool(ctx, name, schedid, cpumap, &uuid, &poolid);
         if (ret) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out;
         }
 
-        ret = -libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n);
+        ret = -libxl_cpupool_cpuadd_node(ctx, poolid, node, &n);
         if (ret) {
             fprintf(stderr, "error on adding cpus to cpupool\n");
             goto out;
diff -r b65de5ce6202 -r ab8fc27358d0 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c	Fri Apr 01 15:03:16 2011 +0100
@@ -52,21 +52,21 @@ void log_destroy(struct xentoollog_logge
 {
 }
 
-#define INIT_STRUCT() libxl_ctx ctx; struct caml_logger lg; struct caml_gc gc; gc.offset = 0;
+#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); \
+	ret = libxl_ctx_alloc(&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)
+	libxl_ctx_free(ctx)
 
 static char * dup_String_val(caml_gc *gc, value s)
 {
@@ -379,7 +379,7 @@ value stub_xl_disk_add(value info, value
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_disk_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("disk_add", &lg);
 	FREE_CTX();
@@ -397,7 +397,7 @@ value stub_xl_disk_remove(value info, va
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_disk_del(&ctx, &c_info, 0);
+	ret = libxl_device_disk_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("disk_remove", &lg);
 	FREE_CTX();
@@ -415,7 +415,7 @@ value stub_xl_nic_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_nic_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("nic_add", &lg);
 	FREE_CTX();
@@ -433,7 +433,7 @@ value stub_xl_nic_remove(value info, val
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_nic_del(&ctx, &c_info, 0);
+	ret = libxl_device_nic_del(ctx, &c_info, 0);
 	if (ret != 0)
 		failwith_xl("nic_remove", &lg);
 	FREE_CTX();
@@ -454,7 +454,7 @@ value stub_xl_console_add(value info, va
 	c_info.build_state = &c_state;
 
 	INIT_CTX();
-	ret = libxl_device_console_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_console_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("console_add", &lg);
 	FREE_CTX();
@@ -472,7 +472,7 @@ value stub_xl_vkb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vkb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vkb_add", &lg);
 	FREE_CTX();
@@ -487,7 +487,7 @@ value stub_xl_vkb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -502,7 +502,7 @@ value stub_xl_vkb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vkb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vkb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vkb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -521,7 +521,7 @@ value stub_xl_vfb_add(value info, value 
 	c_info.domid = Int_val(domid);
 
 	INIT_CTX();
-	ret = libxl_device_vfb_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("vfb_add", &lg);
 	FREE_CTX();
@@ -536,7 +536,7 @@ value stub_xl_vfb_clean_shutdown(value d
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_clean_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_clean_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_clean_shutdown", &lg);
 	FREE_CTX();
@@ -551,7 +551,7 @@ value stub_xl_vfb_hard_shutdown(value do
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_vfb_hard_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_vfb_hard_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("vfb_hard_shutdown", &lg);
 	FREE_CTX();
@@ -569,7 +569,7 @@ value stub_xl_pci_add(value info, value 
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_add(&ctx, Int_val(domid), &c_info);
+	ret = libxl_device_pci_add(ctx, Int_val(domid), &c_info);
 	if (ret != 0)
 		failwith_xl("pci_add", &lg);
 	FREE_CTX();
@@ -587,7 +587,7 @@ value stub_xl_pci_remove(value info, val
 	device_pci_val(&gc, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_pci_remove(&ctx, Int_val(domid), &c_info, 0);
+	ret = libxl_device_pci_remove(ctx, Int_val(domid), &c_info, 0);
 	if (ret != 0)
 		failwith_xl("pci_remove", &lg);
 	FREE_CTX();
@@ -602,7 +602,7 @@ value stub_xl_pci_shutdown(value domid)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_device_pci_shutdown(&ctx, Int_val(domid));
+	ret = libxl_device_pci_shutdown(ctx, Int_val(domid));
 	if (ret != 0)
 		failwith_xl("pci_shutdown", &lg);
 	FREE_CTX();
@@ -617,7 +617,7 @@ value stub_xl_button_press(value domid, 
 	INIT_STRUCT();
 	
 	INIT_CTX();
-	ret = libxl_button_press(&ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
+	ret = libxl_button_press(ctx, Int_val(domid), Int_val(button) + POWER_BUTTON);
 	if (ret != 0)
 		failwith_xl("button_press", &lg);
 	FREE_CTX();
@@ -634,7 +634,7 @@ value stub_xl_physinfo(value unit)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_get_physinfo(&ctx, &c_physinfo);
+	ret = libxl_get_physinfo(ctx, &c_physinfo);
 	if (ret != 0)
 		failwith_xl("physinfo", &lg);
 	FREE_CTX();
@@ -652,7 +652,7 @@ value stub_xl_topologyinfo(value unit)
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_get_topologyinfo(&ctx, &c_topologyinfo);
+	ret = libxl_get_topologyinfo(ctx, &c_topologyinfo);
 	if (ret != 0)
 		failwith_xl("topologyinfo", &lg);
 	FREE_CTX();
@@ -670,7 +670,7 @@ value stub_xl_sched_credit_domain_get(va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_get(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_get(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_get", &lg);
 	FREE_CTX();
@@ -689,7 +689,7 @@ value stub_xl_sched_credit_domain_set(va
 	sched_credit_val(&gc, &c_scinfo, scinfo);
 
 	INIT_CTX();
-	ret = libxl_sched_credit_domain_set(&ctx, Int_val(domid), &c_scinfo);
+	ret = libxl_sched_credit_domain_set(ctx, Int_val(domid), &c_scinfo);
 	if (ret != 0)
 		failwith_xl("sched_credit_domain_set", &lg);
 	FREE_CTX();
@@ -707,7 +707,7 @@ value stub_xl_send_trigger(value domid, 
 	c_trigger = dup_String_val(&gc, trigger);
 
 	INIT_CTX();
-	ret = libxl_send_trigger(&ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
+	ret = libxl_send_trigger(ctx, Int_val(domid), c_trigger, Int_val(vcpuid));
 	if (ret != 0)
 		failwith_xl("send_trigger", &lg);
 	FREE_CTX();
@@ -721,7 +721,7 @@ value stub_xl_send_sysrq(value domid, va
 	INIT_STRUCT();
 
 	INIT_CTX();
-	ret = libxl_send_sysrq(&ctx, Int_val(domid), Int_val(sysrq));
+	ret = libxl_send_sysrq(ctx, Int_val(domid), Int_val(sysrq));
 	if (ret != 0)
 		failwith_xl("send_sysrq", &lg);
 	FREE_CTX();
@@ -738,7 +738,7 @@ value stub_xl_send_debug_keys(value keys
 	c_keys = dup_String_val(&gc, keys);
 
 	INIT_CTX();
-	ret = libxl_send_debug_keys(&ctx, c_keys);
+	ret = libxl_send_debug_keys(ctx, c_keys);
 	if (ret != 0)
 		failwith_xl("send_debug_keys", &lg);
 	FREE_CTX();
diff -r b65de5ce6202 -r ab8fc27358d0 tools/python/setup.py
--- a/tools/python/setup.py	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/python/setup.py	Fri Apr 01 15:03:16 2011 +0100
@@ -83,7 +83,7 @@ netlink = Extension("netlink",
 
 xl = Extension("xl",
                extra_compile_args = extra_compile_args,
-               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, PATH_XENSTORE, "xen/lowlevel/xl" ],
+               include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, "xen/lowlevel/xl" ],
                library_dirs       = [ PATH_LIBXL ],
                libraries          = [ "xenlight" ],
                depends            = [ PATH_LIBXL + "/libxenlight.so" ],
diff -r b65de5ce6202 -r ab8fc27358d0 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c	Fri Apr 01 13:43:13 2011 +0100
+++ b/tools/python/xen/lowlevel/xl/xl.c	Fri Apr 01 15:03:16 2011 +0100
@@ -370,7 +370,7 @@ PyObject *attrib__struct_in_addr_get(str
 
 typedef struct {
     PyObject_HEAD;
-    libxl_ctx ctx;
+    libxl_ctx *ctx;
     xentoollog_logger_stdiostream *logger;
     xentoollog_level minmsglevel;
 } XlObject;
@@ -381,7 +381,7 @@ static PyObject *pyxl_list_domains(XlObj
     PyObject *list;
     int nr_dom, i;
 
-    info = libxl_list_domain(&self->ctx, &nr_dom);
+    info = libxl_list_domain(self->ctx, &nr_dom);
     if ( NULL == info )
         return PyList_New(0);
 
@@ -416,7 +416,7 @@ static PyObject *pyxl_domid_to_name(XlOb
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    domname = libxl_domid_to_name(&self->ctx, domid);
+    domname = libxl_domid_to_name(self->ctx, domid);
     ret = PyString_FromString(domname);
     free(domname);
 
@@ -428,7 +428,7 @@ static PyObject *pyxl_domain_shutdown(Xl
     int domid, req = 0;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &req) )
         return NULL;
-    if ( libxl_domain_shutdown(&self->ctx, domid, req) ) {
+    if ( libxl_domain_shutdown(self->ctx, domid, req) ) {
         PyErr_SetString(xl_error_obj, "cannot shutdown domain");
         return NULL;
     }
@@ -441,7 +441,7 @@ static PyObject *pyxl_domain_destroy(XlO
     int domid, force = 1;
     if ( !PyArg_ParseTuple(args, "i|i", &domid, &force) )
         return NULL;
-    if ( libxl_domain_destroy(&self->ctx, domid, force) ) {
+    if ( libxl_domain_destroy(self->ctx, domid, force) ) {
         PyErr_SetString(xl_error_obj, "cannot destroy domain");
         return NULL;
     }
@@ -454,7 +454,7 @@ static PyObject *pyxl_domain_pause(XlObj
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_pause(&self->ctx, domid) ) {
+    if ( libxl_domain_pause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot pause domain");
         return NULL;
     }
@@ -467,7 +467,7 @@ static PyObject *pyxl_domain_unpause(XlO
     int domid;
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
-    if ( libxl_domain_unpause(&self->ctx, domid) ) {
+    if ( libxl_domain_unpause(self->ctx, domid) ) {
         PyErr_SetString(xl_error_obj, "cannot unpause domain");
         return NULL;
     }
@@ -481,7 +481,7 @@ static PyObject *pyxl_domain_rename(XlOb
     int domid;
     if ( !PyArg_ParseTuple(args, "is|s", &domid, &new_name, &old_name) )
         return NULL;
-    if ( libxl_domain_rename(&self->ctx, domid, old_name, new_name) ) {
+    if ( libxl_domain_rename(self->ctx, domid, old_name, new_name) ) {
         PyErr_SetString(xl_error_obj, "cannot rename domain");
         return NULL;
     }
@@ -501,7 +501,7 @@ static PyObject *pyxl_pci_add(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_add(&self->ctx, domid, &pci->obj) ) {
+    if ( libxl_device_pci_add(self->ctx, domid, &pci->obj) ) {
         PyErr_SetString(xl_error_obj, "cannot add pci device");
         return NULL;
     }
@@ -522,7 +522,7 @@ static PyObject *pyxl_pci_del(XlObject *
         return NULL;
     }
     pci = (Py_device_pci *)obj;
-    if ( libxl_device_pci_remove(&self->ctx, domid, &pci->obj, force) ) {
+    if ( libxl_device_pci_remove(self->ctx, domid, &pci->obj, force) ) {
         PyErr_SetString(xl_error_obj, "cannot remove pci device");
         return NULL;
     }
@@ -544,7 +544,7 @@ static PyObject *pyxl_pci_parse(XlObject
         return NULL;
     }
 
-    if ( libxl_device_pci_parse_bdf(&self->ctx, &pci->obj, str) ) {
+    if ( libxl_device_pci_parse_bdf(self->ctx, &pci->obj, str) ) {
         PyErr_SetString(xl_error_obj, "cannot parse pci device spec (BDF)");
         Py_DECREF(pci);
         return NULL;
@@ -559,7 +559,7 @@ static PyObject *pyxl_pci_list_assignabl
     PyObject *list;
     int nr_dev, i;
 
-    if ( libxl_device_pci_list_assignable(&self->ctx, &dev, &nr_dev) ) {
+    if ( libxl_device_pci_list_assignable(self->ctx, &dev, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -595,7 +595,7 @@ static PyObject *pyxl_pci_list(XlObject 
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;
 
-    if ( libxl_device_pci_list_assigned(&self->ctx, &dev, domid, &nr_dev) ) {
+    if ( libxl_device_pci_list_assigned(self->ctx, &dev, domid, &nr_dev) ) {
         PyErr_SetString(xl_error_obj, "Cannot list assignable devices");
         return NULL;
     }
@@ -663,7 +663,7 @@ static PyObject *PyXl_new(PyTypeObject *
     if (self == NULL)
         return NULL;
 
-    memset(&self->ctx, 0, sizeof(self->ctx));
+    self->ctx = NULL;
     self->logger = NULL;
     self->minmsglevel = XTL_PROGRESS;
 
@@ -679,7 +679,7 @@ PyXl_init(XlObject *self, PyObject *args
         return -1;
     }
 
-    if ( libxl_ctx_init(&self->ctx, LIBXL_VERSION,
+    if ( libxl_ctx_alloc(&self->ctx, LIBXL_VERSION,
                 (xentoollog_logger*)self->logger) ) {
         PyErr_SetString(xl_error_obj, "cannot init xl context");
         return -1;
@@ -690,7 +690,7 @@ PyXl_init(XlObject *self, PyObject *args
 
 static void PyXl_dealloc(XlObject *self)
 {
-    libxl_ctx_free(&self->ctx);
+    libxl_ctx_free(self->ctx);
     if ( self->logger )
         xtl_logger_destroy((xentoollog_logger*)self->logger);

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-04-01 14:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-31 10:56 [PATCH 0 of 4] tools: shave build yaks (part two) Ian Campbell
2011-03-31 10:56 ` [PATCH 1 of 4] tools: Remove $(CFLAGS) from links lines Ian Campbell
2011-03-31 10:56 ` [PATCH 2 of 4] libxl: do not expose libxenctrl/libxenstore headers via libxl.h Ian Campbell
2011-03-31 18:33   ` Ian Jackson
2011-04-01 13:12     ` Ian Campbell
2011-04-01 14:03       ` Ian Campbell
2011-03-31 10:56 ` [PATCH 3 of 4] tools: remove pattern matched linking rules Ian Campbell
2011-03-31 10:57 ` [PATCH 4 of 4] tools: remove some .o and binary files on clean Ian Campbell
2011-03-31 18:36   ` Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).