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