[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Xen-staging] [xen staging] tools: Refactor "xentoollog" into its own library
On Wed, 2015-12-09 at 12:45 +0000, patchbot@xxxxxxx wrote: > commit c7d3afbb44b47af9103be0b914afd588a84d9e62 > Author:ÂÂÂÂÂIan Campbell <ian.campbell@xxxxxxxxxx> > AuthorDate: Thu Dec 3 11:22:02 2015 +0000 > Commit:ÂÂÂÂÂIan Campbell <ian.campbell@xxxxxxxxxx> > CommitDate: Wed Dec 9 12:37:00 2015 +0000 > > ÂÂÂÂtools: Refactor "xentoollog" into its own library This has broken the libvirt build http://logs.test-lab.xenproject.org/osstest/logs/65648/build-amd64-libvirt/5.ts-libvirt-build.log /usr/bin/ld: ../src/.libs/libvirt_driver_libxl_impl.a(libvirt_driver_libxl_impl_la-libxl_conf.o): undefined reference to symbol 'xtl_logger_destroy@@VERS_1.0' /usr/bin/ld: note: 'xtl_logger_destroy@@VERS_1.0' is defined in DSO /home/osstest/build.65648.build-amd64-libvirt/xendist/usr/local/lib//libxentoollog.so.1 so try adding it to the linker command line /home/osstest/build.65648.build-amd64-libvirt/xendist/usr/local/lib//libxentoollog.so.1: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status I'm sure I had checked libvirt.git for such usage, but it is obviously there and has been since 2013, so clearly I was wrong. I have reverted this commit (see below) while I sort out a libvirt patch. Note that I have wound back MINIOS_UPSTREAM_REVISION andÂQEMU_TRADITIONAL_REVISION here but I have not rewound their respective master branches. In the event we need to push something to one of these before this patch lands again Ian and I have agreed we will do the necessary revert at that point before stacking any new stuff on top. Ian. commit ec0712576198633dd7fbfe25290b030d5a23b252 Author: Ian Campbell <ian.campbell@xxxxxxxxxx> Date:ÂÂÂThu Dec 10 10:21:34 2015 +0000 ÂÂÂÂRevert "tools: Refactor "xentoollog" into its own library"  ÂÂÂÂThis reverts commit c7d3afbb44b47af9103be0b914afd588a84d9e62 which ÂÂÂÂbroke the libvirt build, since libvirt uses xtl_* and hence needs ÂÂÂÂupdating to link against the new library when necessary.  ÂÂÂÂSigned-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff --git a/.gitignore b/.gitignore index a2c85e1..91e1430 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,6 @@ stubdom/gcc-* Âstubdom/include Âstubdom/ioemu Âstubdom/xenstore -stubdom/libxentoollog-* Âstubdom/libxc-* Âstubdom/lwip-* Âstubdom/mini-os-* diff --git a/Config.mk b/Config.mk index 8fc7767..216a642 100644 --- a/Config.mk +++ b/Config.mk @@ -255,9 +255,9 @@ MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git Âendif ÂOVMF_UPSTREAM_REVISION ?= 52a99493cce88a9d4ec8a02d7f1bd1a1001ce60d ÂQEMU_UPSTREAM_REVISION ?= master -MINIOS_UPSTREAM_REVISION ?= d25773c8afa2f4dbbb466116daeb60159ddd22bd -# Thu Dec 3 11:23:25 2015 +0000 -# mini-os: Include libxentoollog with libxc +MINIOS_UPSTREAM_REVISION ?= bccd90071e863ec22216a000f1a07035e2f226ff +# Mon Nov 23 16:34:31 2015 +0000 +# Add a .gitignore  ÂSEABIOS_UPSTREAM_REVISION ?= rel-1.9.0 Â# Tue Nov 17 09:18:44 2015 -0500 @@ -266,9 +266,9 @@ SEABIOS_UPSTREAM_REVISION ?= rel-1.9.0 ÂETHERBOOT_NICS ?= rtl8139 8086100e   -QEMU_TRADITIONAL_REVISION ?= 9fad9ed285835caef64bb8dab352e287ad8538c2 -# Thu Dec 3 11:23:16 2015 +0000 -# qemu-xen-traditional: Use xentoollog as a separate library +QEMU_TRADITIONAL_REVISION ?= 91c15bfaec1764ce2896a393eabee1183afe1130 +# Wed Dec 9 11:47:35 2015 +0000 +# net: pcnet: add check to validate receive data size(CVE-2015-7504)  Â# Specify which qemu-dm to use. This may be `ioemu' to use the old Â# Mercurial in-tree version, or a local directory, or a git URL. diff --git a/stubdom/Makefile b/stubdom/Makefile index 9c923dd..e1359cf 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -313,11 +313,6 @@ mk-headers-$(XEN_TARGET_ARCH): $(IOEMU_LINKFARM_TARGET)  ÂÂln -sf $(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*) include/xen-foreign/ && \  ÂÂ$(MAKE) DESTDIR= -C include/xen-foreign/ && \  ÂÂ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign ) - mkdir -p libs-$(XEN_TARGET_ARCH)/toollog - [ -h libs-$(XEN_TARGET_ARCH)/toollog/Makefile ] || ( cd libs-$(XEN_TARGET_ARCH)/toollog && \ - ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/include/*.h . && \ - ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/*.c . && \ - ÂÂln -sf $(XEN_ROOT)/tools/libs/toollog/Makefile . )  mkdir -p libxc-$(XEN_TARGET_ARCH)  [ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \  ÂÂln -sf $(XEN_ROOT)/tools/libxc/*.h . && \ @@ -341,23 +336,12 @@ $(TARGETS_MINIOS): mini-os-%:  done  Â####### -# libxentoollog -####### - -.PHONY: libxentoollog -libxentoollog: libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a -libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a: $(NEWLIB_STAMPFILE) - $(MAKE) -C $(XEN_ROOT)/tools/include - $(MAKE) DESTDIR= -C $(MINI_OS) links - CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog - -####### Â# libxc Â#######  Â.PHONY: libxc Âlibxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a -libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: libxentoollog cross-zlib +libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: cross-zlib  $(MAKE) -C $(XEN_ROOT)/tools/include  $(MAKE) DESTDIR= -C $(MINI_OS) links  CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH) @@ -531,11 +515,6 @@ clean:  $(MAKE) -C vtpmmgr clean  rm -fr grub-$(XEN_TARGET_ARCH)  rm -f $(STUBDOMPATH) - [ ! -e libs-$(XEN_TARGET_ARCH)/toollog/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog clean - [ ! -e libs-$(XEN_TARGET_ARCH)/evtchn/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/evtchn clean - [ ! -e libs-$(XEN_TARGET_ARCH)/gnttab/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/gnttab clean - [ ! -e libs-$(XEN_TARGET_ARCH)/call/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/call clean - [ ! -e libs-$(XEN_TARGET_ARCH)/foreignmemory/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory clean  [ ! -e libxc-$(XEN_TARGET_ARCH)/Makefile ] || $(MAKE) DESTDIR= -C libxc-$(XEN_TARGET_ARCH) clean  -[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean  -[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean @@ -546,7 +525,6 @@ crossclean: clean  rm -fr $(CROSS_ROOT)  rm -fr newlib-$(XEN_TARGET_ARCH)  rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH) - rm -fr libs-$(XEN_TARGET_ARCH)  rm -fr libxc-$(XEN_TARGET_ARCH) ioemu xenstore  rm -fr gmp-$(XEN_TARGET_ARCH)  rm -fr polarssl-$(XEN_TARGET_ARCH) diff --git a/stubdom/grub/Makefile b/stubdom/grub/Makefile index 26dff45..934cc4c 100644 --- a/stubdom/grub/Makefile +++ b/stubdom/grub/Makefile @@ -5,7 +5,6 @@ vpath %.c ../grub-upstream  ÂBOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o  -DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/toollog/include ÂDEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include -I$(XEN_ROOT)/tools/include -I. ÂDEF_CPPFLAGS += -I../grub-upstream/stage1 ÂDEF_CPPFLAGS += -I../grub-upstream/stage2 diff --git a/tools/Makefile b/tools/Makefile index 9f74ac7..820ca40 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk  ÂSUBDIRS-y := ÂSUBDIRS-y += include -SUBDIRS-y += libs ÂSUBDIRS-y += libxc ÂSUBDIRS-$(FLASK_ENABLE) += flask ÂSUBDIRS-y += xenstore @@ -249,14 +248,12 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find  --includedir=$(LIBEXEC_INC) \  --source-path=$$source \  --extra-cflags="-I$(XEN_ROOT)/tools/include \ - -I$(XEN_ROOT)/tools/libs/toollog/include \  -I$(XEN_ROOT)/tools/libxc/include \  -I$(XEN_ROOT)/tools/xenstore/include \  -I$(XEN_ROOT)/tools/xenstore/compat/include \  $(EXTRA_CFLAGS_QEMU_XEN)" \  --extra-ldflags="-L$(XEN_ROOT)/tools/libxc \  -L$(XEN_ROOT)/tools/xenstore \ - -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \  $(QEMU_UPSTREAM_RPATH)" \  --bindir=$(LIBEXEC_BIN) \  --datadir=$(SHAREDIR)/qemu-xen \ diff --git a/tools/Rules.mk b/tools/Rules.mk index 0652e4b..37b0aaf 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -10,7 +10,6 @@ export _INSTALL := $(INSTALL) ÂINSTALL = $(XEN_ROOT)/tools/cross-install  ÂXEN_INCLUDEÂÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/include -XEN_LIBXENTOOLLOGÂÂ= $(XEN_ROOT)/tools/libs/toollog ÂXEN_LIBXCÂÂÂÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/libxc ÂXEN_XENLIGHTÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/libxl ÂXEN_XENSTOREÂÂÂÂÂÂÂ= $(XEN_ROOT)/tools/xenstore @@ -77,15 +76,10 @@ endif Â# Consumers of libfoo should not directly use $(SHDEPS_libfoo) or Â# $(SHLIB_libfoo)  -CFLAGS_libxentoollog = -I$(XEN_LIBXENTOOLLOG)/include $(CFLAGS_xeninclude) -SHDEPS_libxentoollog = -LDLIBS_libxentoollog = $(XEN_LIBXENTOOLLOG)/libxentoollog$(libextension) -SHLIB_libxentoollogÂÂ= -Wl,-rpath-link=$(XEN_LIBXENTOOLLOG) - -CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_xeninclude) -SHDEPS_libxenctrl = $(SHLIB_libxentoollog) -LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension) -SHLIB_libxenctrlÂÂ= $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC) +CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_xeninclude) +SHDEPS_libxenctrl = +LDLIBS_libxenctrl = $(XEN_LIBXC)/libxenctrl$(libextension) +SHLIB_libxenctrlÂÂ= -Wl,-rpath-link=$(XEN_LIBXC)  ÂCFLAGS_libxenguest = -I$(XEN_LIBXC)/include $(CFLAGS_xeninclude) ÂSHDEPS_libxenguest = diff --git a/tools/libs/Makefile b/tools/libs/Makefile deleted file mode 100644 index 73be500..0000000 --- a/tools/libs/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -XEN_ROOT = $(CURDIR)/../.. -include $(XEN_ROOT)/tools/Rules.mk - -SUBDIRS-y := -SUBDIRS-y += toollog - -all clean install distclean: %: subdirs-% diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile deleted file mode 100644 index bd12403..0000000 --- a/tools/libs/toollog/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -XEN_ROOT = $(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk - -MAJOR = 1 -MINOR = 0 -SHLIB_LDFLAGS += -Wl,--version-script=libxentoollog.map - -CFLAGS += -Werror -Wmissing-prototypes -CFLAGS += -I./include - -SRCS-y += xtl_core.c -SRCS-y += xtl_logger_stdio.c - -LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y)) -PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y)) - -LIB := libxentoollog.a -ifneq ($(nosharedlibs),y) -LIB += libxentoollog.so -endif - -.PHONY: all -all: build - -.PHONY: build -build: - $(MAKE) libs - -.PHONY: libs -libs: $(LIB) - -libxentoollog.a: $(LIB_OBJS) - $(AR) rc $@ $^ - -libxentoollog.so: libxentoollog.so.$(MAJOR) - $(SYMLINK_SHLIB) $< $@ -libxentoollog.so.$(MAJOR): libxentoollog.so.$(MAJOR).$(MINOR) - $(SYMLINK_SHLIB) $< $@ - -libxentoollog.so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxentoollog.map - $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxentoollog.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(APPEND_LDFLAGS) - -.PHONY: install -install: build - $(INSTALL_DIR) $(DESTDIR)$(libdir) - $(INSTALL_DIR) $(DESTDIR)$(includedir) - $(INSTALL_SHLIB) libxentoollog.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir) - $(INSTALL_DATA) libxentoollog.a $(DESTDIR)$(libdir) - $(SYMLINK_SHLIB) libxentoollog.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxentoollog.so.$(MAJOR) - $(SYMLINK_SHLIB) libxentoollog.so.$(MAJOR) $(DESTDIR)$(libdir)/libxentoollog.so - $(INSTALL_DATA) include/xentoollog.h $(DESTDIR)$(includedir) - -.PHONY: TAGS -TAGS: - etags -t *.c *.h - -.PHONY: clean -clean: - rm -rf *.rpm $(LIB) *~ $(DEPS) $(LIB_OBJS) $(PIC_OBJS) diff --git a/tools/libs/toollog/include/xentoollog.h b/tools/libs/toollog/include/xentoollog.h deleted file mode 100644 index 853e9c7..0000000 --- a/tools/libs/toollog/include/xentoollog.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * xentoollog.h - * - * Copyright (c) 2010 Citrix - * Part of a generic logging interface used by various dom0 userland libraries. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef XENTOOLLOG_H -#define XENTOOLLOG_H - -#include <stdio.h> -#include <stdarg.h> - - -/*---------- common declarations and types ----------*/ - -typedef enum xentoollog_level { -ÂÂÂÂXTL_NONE, /* sentinel etc, never used for logging */ -ÂÂÂÂXTL_DEBUG, -ÂÂÂÂXTL_VERBOSE, -ÂÂÂÂXTL_DETAIL, -ÂÂÂÂXTL_PROGRESS, /* also used for "progress" messages */ -ÂÂÂÂXTL_INFO, -ÂÂÂÂXTL_NOTICE, -ÂÂÂÂXTL_WARN, -ÂÂÂÂXTL_ERROR, -ÂÂÂÂXTL_CRITICAL, -ÂÂÂÂXTL_NUM_LEVELS -} xentoollog_level; - -typedef struct xentoollog_logger xentoollog_logger; -struct xentoollog_logger { -ÂÂÂÂvoid (*vmessage)(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xl", may be 0 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* without level, context, \n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) -ÂÂÂÂÂÂÂÂÂ__attribute__((format(printf,5,0))); -ÂÂÂÂvoid (*progress)(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* see above */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what /* no \r,\n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint percent, unsigned long done, unsigned long total) -ÂÂÂÂÂÂÂÂÂ/* null function pointer is ok. -ÂÂÂÂÂÂÂÂÂÂ* will always be called with done==0 for each new -ÂÂÂÂÂÂÂÂÂÂ* context/doing_what */; -ÂÂÂÂvoid (*destroy)(struct xentoollog_logger *logger); -ÂÂÂÂ/* each logger can put its necessary data here */ -}; - - -/*---------- facilities for consuming log messages ----------*/ - -#define XTL_STDIOSTREAM_SHOW_PIDÂÂÂÂÂÂÂÂÂÂÂÂ001u -#define XTL_STDIOSTREAM_SHOW_DATEÂÂÂÂÂÂÂÂÂÂÂ002u -#define XTL_STDIOSTREAM_HIDE_PROGRESSÂÂÂÂÂÂÂ004u -#define XTL_STDIOSTREAM_PROGRESS_USE_CRÂÂÂÂÂ010u /* default is to */ -#define XTL_STDIOSTREAM_PROGRESS_NO_CRÂÂÂÂÂÂ020u /* use \r to ttys */ - -typedef struct xentoollog_logger_stdiostreamÂÂxentoollog_logger_stdiostream; - -xentoollog_logger_stdiostream *xtl_createlogger_stdiostream -ÂÂÂÂÂÂÂÂ(FILE *f, xentoollog_level min_level, unsigned flags); -ÂÂÂÂ/* may return 0 if malloc fails, in which case error was logged */ -ÂÂÂÂ/* destroy on this logger does not close the file */ - -void xtl_stdiostream_set_minlevel(xentoollog_logger_stdiostream*, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level min_level); -void xtl_stdiostream_adjust_flags(xentoollog_logger_stdiostream*, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned set_flags, unsigned clear_flags); -ÂÂ/* if set_flags and clear_flags overlap, set_flags takes precedence */ - -void xtl_logger_destroy(struct xentoollog_logger *logger /* 0 is ok */); - - -/*---------- facilities for generating log messages ----------*/ - -void xtl_logv(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl", may be 0 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list) __attribute__((format(printf,5,0))); - -void xtl_log(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂ...) __attribute__((format(printf,5,6))); - -void xtl_progress(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* see above, may be 0 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total); - - -/*---------- facilities for defining log message consumers ----------*/ - -const char *xtl_level_to_string(xentoollog_level); /* never fails */ - - -#define XTL_NEW_LOGGER(LOGGER,buffer) ({ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂxentoollog_logger_##LOGGER *new_consumer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂ(buffer).vtable.vmessage = LOGGER##_vmessage;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂ(buffer).vtable.progress = LOGGER##_progress;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂ(buffer).vtable.destroyÂÂ= LOGGER##_destroy;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂnew_consumer = malloc(sizeof(*new_consumer));ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂif (!new_consumer) {ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂxtl_log((xentoollog_logger*)&buffer,ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂXTL_CRITICAL, errno, "xtl",ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"failed to allocate memory for new message logger");ÂÂÂÂ\ -ÂÂÂÂ} else {ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂ*new_consumer = buffer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂ}ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -ÂÂÂÂnew_consumer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ -}); - - -#endif /* XENTOOLLOG_H */ diff --git a/tools/libs/toollog/libxentoollog.map b/tools/libs/toollog/libxentoollog.map deleted file mode 100644 index c183cf5..0000000 --- a/tools/libs/toollog/libxentoollog.map +++ /dev/null @@ -1,12 +0,0 @@ -VERS_1.0 { - global: - xtl_createlogger_stdiostream; - xtl_level_to_string; - xtl_log; - xtl_logger_destroy; - xtl_logv; - xtl_progress; - xtl_stdiostream_adjust_flags; - xtl_stdiostream_set_minlevel; - local: *; /* Do not expose anything by default */ -}; diff --git a/tools/libs/toollog/xtl_core.c b/tools/libs/toollog/xtl_core.c deleted file mode 100644 index c4724a0..0000000 --- a/tools/libs/toollog/xtl_core.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * xtl_core.c - * - * core code including functions for generating log messages - * - * Copyright (c) 2010 Citrix - * Part of a generic logging interface used by various dom0 userland libraries. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; If not, see <http://www.gnu.org/licenses/>. - */ - -#include "xentoollog.h" - -#include <assert.h> -#include <errno.h> -#include <limits.h> - -static const char *level_strings[XTL_NUM_LEVELS]= { -ÂÂÂÂ"[BUG:XTL_NONE]", -ÂÂÂÂ"debug", "verbose", "detail",ÂÂ/* normally off by default */ -ÂÂÂÂ"progress", "info", "notice",ÂÂ/* not a problem */ -ÂÂÂÂ"warning", "error", "critical" /* problems and errors */ -}; - -const char *xtl_level_to_string(xentoollog_level level) { -ÂÂÂÂassert(level >= 0 && level < XTL_NUM_LEVELS); -ÂÂÂÂreturn level_strings[level]; -} - -void xtl_logv(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) { -ÂÂÂÂint errno_save = errno; -ÂÂÂÂassert(level > XTL_NONE && level < XTL_NUM_LEVELS); -ÂÂÂÂlogger->vmessage(logger,level,errnoval,context,format,al); -ÂÂÂÂerrno = errno_save; -} - -void xtl_log(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, -ÂÂÂÂÂÂÂÂÂÂÂÂÂ...) { -ÂÂÂÂva_list al; -ÂÂÂÂva_start(al,format); -ÂÂÂÂxtl_logv(logger,level,errnoval,context,format,al); -ÂÂÂÂva_end(al); -} - -void xtl_progress(struct xentoollog_logger *logger, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, const char *doing_what, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total) { -ÂÂÂÂint percent = 0; - -ÂÂÂÂif (!logger->progress) return; - -ÂÂÂÂif ( total ) -ÂÂÂÂÂÂÂÂpercent = (total < LONG_MAX/100) -ÂÂÂÂÂÂÂÂÂÂÂÂ? (done * 100) / total -ÂÂÂÂÂÂÂÂÂÂÂÂ: done / ((total + 99) / 100); - -ÂÂÂÂlogger->progress(logger, context, doing_what, percent, done, total); -} - -void xtl_logger_destroy(struct xentoollog_logger *logger) { -ÂÂÂÂif (!logger) return; -ÂÂÂÂlogger->destroy(logger); -} diff --git a/tools/libs/toollog/xtl_logger_stdio.c b/tools/libs/toollog/xtl_logger_stdio.c deleted file mode 100644 index 0cd9206..0000000 --- a/tools/libs/toollog/xtl_logger_stdio.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * xtl_logger_stdio.c - * - * log message consumer that writes to stdio - * - * Copyright (c) 2010 Citrix - * Part of a generic logging interface used by various dom0 userland libraries. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; If not, see <http://www.gnu.org/licenses/>. - */ - -#include "xentoollog.h" - -#include <time.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#include <stdbool.h> - -struct xentoollog_logger_stdiostream { -ÂÂÂÂxentoollog_logger vtable; -ÂÂÂÂFILE *f; -ÂÂÂÂxentoollog_level min_level; -ÂÂÂÂunsigned flags; -ÂÂÂÂint progress_erase_len, progress_last_percent; -ÂÂÂÂbool progress_use_cr; -}; - -static void progress_erase(xentoollog_logger_stdiostream *lg) { -ÂÂÂÂif (lg->progress_erase_len) -ÂÂÂÂÂÂÂÂfprintf(lg->f, "\r%*s\r", lg->progress_erase_len, ""); -} - -static void stdiostream_vmessage(xentoollog_logger *logger_in, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) { -ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; - -ÂÂÂÂif (level < lg->min_level) -ÂÂÂÂÂÂÂÂreturn; - -ÂÂÂÂprogress_erase(lg); - -ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_SHOW_DATE) { -ÂÂÂÂÂÂÂÂstruct tm lt_buf; -ÂÂÂÂÂÂÂÂtime_t now = time(0); -ÂÂÂÂÂÂÂÂstruct tm *lt= localtime_r(&now, <_buf); -ÂÂÂÂÂÂÂÂif (lt != NULL) -ÂÂÂÂÂÂÂÂÂÂÂÂfprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ", -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlt->tm_year+1900, lt->tm_mon+1, lt->tm_mday, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlt->tm_hour, lt->tm_min, lt->tm_sec, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtzname[!!lt->tm_isdst]); -ÂÂÂÂÂÂÂÂelse -ÂÂÂÂÂÂÂÂÂÂÂÂfprintf(lg->f, "[localtime_r failed: %d] ", errno); -ÂÂÂÂ} -ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_SHOW_PID) -ÂÂÂÂÂÂÂÂfprintf(lg->f, "[%lu] ", (unsigned long)getpid()); - -ÂÂÂÂif (context) -ÂÂÂÂÂÂÂÂfprintf(lg->f, "%s: ", context); - -ÂÂÂÂfprintf(lg->f, "%s: ", xtl_level_to_string(level)); - -ÂÂÂÂvfprintf(lg->f, format, al); - -ÂÂÂÂif (errnoval >= 0) -ÂÂÂÂÂÂÂÂfprintf(lg->f, ": %s", strerror(errnoval)); - -ÂÂÂÂputc('\n', lg->f); -ÂÂÂÂfflush(lg->f); -} - -static void stdiostream_message(struct xentoollog_logger *logger_in, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format, ...) -{ -ÂÂÂÂva_list al; -ÂÂÂÂva_start(al,format); -ÂÂÂÂstdiostream_vmessage(logger_in, level, -1, context, format, al); -ÂÂÂÂva_end(al); -} - -static void stdiostream_progress(struct xentoollog_logger *logger_in, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what, int percent, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total) { -ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; -ÂÂÂÂint newpel, extra_erase; -ÂÂÂÂxentoollog_level this_level; - -ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_HIDE_PROGRESS) -ÂÂÂÂÂÂÂÂreturn; - -ÂÂÂÂif (percent < lg->progress_last_percent) { -ÂÂÂÂÂÂÂÂthis_level = XTL_PROGRESS; -ÂÂÂÂ} else if (percent == lg->progress_last_percent) { -ÂÂÂÂÂÂÂÂreturn; -ÂÂÂÂ} else if (percent < lg->progress_last_percent + 5) { -ÂÂÂÂÂÂÂÂthis_level = XTL_DETAIL; -ÂÂÂÂ} else { -ÂÂÂÂÂÂÂÂthis_level = XTL_PROGRESS; -ÂÂÂÂ} - -ÂÂÂÂif (this_level < lg->min_level) -ÂÂÂÂÂÂÂÂreturn; - -ÂÂÂÂlg->progress_last_percent = percent; - -ÂÂÂÂif (!lg->progress_use_cr) { -ÂÂÂÂÂÂÂÂstdiostream_message(logger_in, this_level, context, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"%s: %lu/%luÂÂ%3d%%", -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdoing_what, done, total, percent); -ÂÂÂÂÂÂÂÂreturn; -ÂÂÂÂ} - -ÂÂÂÂif (lg->progress_erase_len) -ÂÂÂÂÂÂÂÂputc('\r', lg->f); - -ÂÂÂÂnewpel = fprintf(lg->f, "%s%s" "%s: %lu/%luÂÂ%3d%%%s", -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcontext?context:"", context?": ":"", -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdoing_what, done, total, percent, - ÂÂÂÂÂdone == total ? "\n" : ""); - -ÂÂÂÂextra_erase = lg->progress_erase_len - newpel; -ÂÂÂÂif (extra_erase > 0) -ÂÂÂÂÂÂÂÂfprintf(lg->f, "%*s\r", extra_erase, ""); - -ÂÂÂÂlg->progress_erase_len = newpel; -} - -static void stdiostream_destroy(struct xentoollog_logger *logger_in) { -ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; -ÂÂÂÂprogress_erase(lg); -ÂÂÂÂfree(lg); -} - -void xtl_stdiostream_set_minlevel(xentoollog_logger_stdiostream *lg, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level min_level) { -ÂÂÂÂlg->min_level = min_level; -} - -void xtl_stdiostream_adjust_flags(xentoollog_logger_stdiostream *lg, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned set_flags, unsigned clear_flags) { -ÂÂÂÂunsigned new_flags = (lg->flags & ~clear_flags) | set_flags; -ÂÂÂÂif (new_flags & XTL_STDIOSTREAM_HIDE_PROGRESS) -ÂÂÂÂÂÂÂÂprogress_erase(lg); -ÂÂÂÂlg->flags = new_flags; -} - -xentoollog_logger_stdiostream *xtl_createlogger_stdiostream -ÂÂÂÂÂÂÂÂ(FILE *f, xentoollog_level min_level, unsigned flags) { -ÂÂÂÂxentoollog_logger_stdiostream newlogger; - -ÂÂÂÂnewlogger.f = f; -ÂÂÂÂnewlogger.min_level = min_level; -ÂÂÂÂnewlogger.flags = flags; - -ÂÂÂÂswitch (flags & (XTL_STDIOSTREAM_PROGRESS_USE_CR | -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂXTL_STDIOSTREAM_PROGRESS_NO_CR)) { -ÂÂÂÂcase XTL_STDIOSTREAM_PROGRESS_USE_CR: newlogger.progress_use_cr = 1; break; -ÂÂÂÂcase XTL_STDIOSTREAM_PROGRESS_NO_CR:ÂÂnewlogger.progress_use_cr = 0; break; -ÂÂÂÂcase 0: -ÂÂÂÂÂÂÂÂnewlogger.progress_use_cr = isatty(fileno(newlogger.f)) > 0; -ÂÂÂÂÂÂÂÂbreak; -ÂÂÂÂdefault: -ÂÂÂÂÂÂÂÂerrno = EINVAL; -ÂÂÂÂÂÂÂÂreturn 0; -ÂÂÂÂ} - -ÂÂÂÂif (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); - -ÂÂÂÂnewlogger.progress_erase_len = 0; -ÂÂÂÂnewlogger.progress_last_percent = 0; - -ÂÂÂÂreturn XTL_NEW_LOGGER(stdiostream, newlogger); -} diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 940708f..818f2e4 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -39,6 +39,8 @@ CTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_memshr.c ÂCTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_hcall_buf.c ÂCTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_foreign_memory.c ÂCTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_kexec.c +CTRL_SRCS-yÂÂÂÂÂÂÂ+= xtl_core.c +CTRL_SRCS-yÂÂÂÂÂÂÂ+= xtl_logger_stdio.c ÂCTRL_SRCS-yÂÂÂÂÂÂÂ+= xc_resource.c ÂCTRL_SRCS-$(CONFIG_X86) += xc_psr.c ÂCTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c @@ -110,7 +112,6 @@ CFLAGSÂÂÂ+= -I. -I./include $(CFLAGS_xeninclude) ÂCFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE  ÂCFLAGS += $(PTHREAD_CFLAGS) -CFLAGS += $(CFLAGS_libxentoollog)  ÂCTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) ÂCTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y)) @@ -164,7 +165,7 @@ install: build  $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)  $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)  $(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so - $(INSTALL_DATA) include/xenctrl.h include/xenctrlosdep.h $(DESTDIR)$(includedir) + $(INSTALL_DATA) include/xenctrl.h include/xenctrlosdep.h include/xentoollog.h $(DESTDIR)$(includedir)  $(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)  $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)  $(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR) @@ -207,7 +208,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)  $(SYMLINK_SHLIB) $< $@  Âlibxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(DLOPEN_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(DLOPEN_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)  Â# libxenguest  diff --git a/tools/libxc/include/xentoollog.h b/tools/libxc/include/xentoollog.h new file mode 100644 index 0000000..853e9c7 --- /dev/null +++ b/tools/libxc/include/xentoollog.h @@ -0,0 +1,136 @@ +/* + * xentoollog.h + * + * Copyright (c) 2010 Citrix + * Part of a generic logging interface used by various dom0 userland libraries. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef XENTOOLLOG_H +#define XENTOOLLOG_H + +#include <stdio.h> +#include <stdarg.h> + + +/*---------- common declarations and types ----------*/ + +typedef enum xentoollog_level { +ÂÂÂÂXTL_NONE, /* sentinel etc, never used for logging */ +ÂÂÂÂXTL_DEBUG, +ÂÂÂÂXTL_VERBOSE, +ÂÂÂÂXTL_DETAIL, +ÂÂÂÂXTL_PROGRESS, /* also used for "progress" messages */ +ÂÂÂÂXTL_INFO, +ÂÂÂÂXTL_NOTICE, +ÂÂÂÂXTL_WARN, +ÂÂÂÂXTL_ERROR, +ÂÂÂÂXTL_CRITICAL, +ÂÂÂÂXTL_NUM_LEVELS +} xentoollog_level; + +typedef struct xentoollog_logger xentoollog_logger; +struct xentoollog_logger { +ÂÂÂÂvoid (*vmessage)(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xl", may be 0 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* without level, context, \n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) +ÂÂÂÂÂÂÂÂÂ__attribute__((format(printf,5,0))); +ÂÂÂÂvoid (*progress)(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* see above */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what /* no \r,\n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint percent, unsigned long done, unsigned long total) +ÂÂÂÂÂÂÂÂÂ/* null function pointer is ok. +ÂÂÂÂÂÂÂÂÂÂ* will always be called with done==0 for each new +ÂÂÂÂÂÂÂÂÂÂ* context/doing_what */; +ÂÂÂÂvoid (*destroy)(struct xentoollog_logger *logger); +ÂÂÂÂ/* each logger can put its necessary data here */ +}; + + +/*---------- facilities for consuming log messages ----------*/ + +#define XTL_STDIOSTREAM_SHOW_PIDÂÂÂÂÂÂÂÂÂÂÂÂ001u +#define XTL_STDIOSTREAM_SHOW_DATEÂÂÂÂÂÂÂÂÂÂÂ002u +#define XTL_STDIOSTREAM_HIDE_PROGRESSÂÂÂÂÂÂÂ004u +#define XTL_STDIOSTREAM_PROGRESS_USE_CRÂÂÂÂÂ010u /* default is to */ +#define XTL_STDIOSTREAM_PROGRESS_NO_CRÂÂÂÂÂÂ020u /* use \r to ttys */ + +typedef struct xentoollog_logger_stdiostreamÂÂxentoollog_logger_stdiostream; + +xentoollog_logger_stdiostream *xtl_createlogger_stdiostream +ÂÂÂÂÂÂÂÂ(FILE *f, xentoollog_level min_level, unsigned flags); +ÂÂÂÂ/* may return 0 if malloc fails, in which case error was logged */ +ÂÂÂÂ/* destroy on this logger does not close the file */ + +void xtl_stdiostream_set_minlevel(xentoollog_logger_stdiostream*, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level min_level); +void xtl_stdiostream_adjust_flags(xentoollog_logger_stdiostream*, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned set_flags, unsigned clear_flags); +ÂÂ/* if set_flags and clear_flags overlap, set_flags takes precedence */ + +void xtl_logger_destroy(struct xentoollog_logger *logger /* 0 is ok */); + + +/*---------- facilities for generating log messages ----------*/ + +void xtl_logv(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl", may be 0 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list) __attribute__((format(printf,5,0))); + +void xtl_log(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂ...) __attribute__((format(printf,5,6))); + +void xtl_progress(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* see above, may be 0 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total); + + +/*---------- facilities for defining log message consumers ----------*/ + +const char *xtl_level_to_string(xentoollog_level); /* never fails */ + + +#define XTL_NEW_LOGGER(LOGGER,buffer) ({ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂxentoollog_logger_##LOGGER *new_consumer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂ(buffer).vtable.vmessage = LOGGER##_vmessage;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂ(buffer).vtable.progress = LOGGER##_progress;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂ(buffer).vtable.destroyÂÂ= LOGGER##_destroy;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂnew_consumer = malloc(sizeof(*new_consumer));ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂif (!new_consumer) {ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂxtl_log((xentoollog_logger*)&buffer,ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂXTL_CRITICAL, errno, "xtl",ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"failed to allocate memory for new message logger");ÂÂÂÂ\ +ÂÂÂÂ} else {ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂ*new_consumer = buffer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂ}ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +ÂÂÂÂnew_consumer;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ\ +}); + + +#endif /* XENTOOLLOG_H */ diff --git a/tools/libxc/xtl_core.c b/tools/libxc/xtl_core.c new file mode 100644 index 0000000..c4724a0 --- /dev/null +++ b/tools/libxc/xtl_core.c @@ -0,0 +1,83 @@ +/* + * xtl_core.c + * + * core code including functions for generating log messages + * + * Copyright (c) 2010 Citrix + * Part of a generic logging interface used by various dom0 userland libraries. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#include "xentoollog.h" + +#include <assert.h> +#include <errno.h> +#include <limits.h> + +static const char *level_strings[XTL_NUM_LEVELS]= { +ÂÂÂÂ"[BUG:XTL_NONE]", +ÂÂÂÂ"debug", "verbose", "detail",ÂÂ/* normally off by default */ +ÂÂÂÂ"progress", "info", "notice",ÂÂ/* not a problem */ +ÂÂÂÂ"warning", "error", "critical" /* problems and errors */ +}; + +const char *xtl_level_to_string(xentoollog_level level) { +ÂÂÂÂassert(level >= 0 && level < XTL_NUM_LEVELS); +ÂÂÂÂreturn level_strings[level]; +} + +void xtl_logv(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) { +ÂÂÂÂint errno_save = errno; +ÂÂÂÂassert(level > XTL_NONE && level < XTL_NUM_LEVELS); +ÂÂÂÂlogger->vmessage(logger,level,errnoval,context,format,al); +ÂÂÂÂerrno = errno_save; +} + +void xtl_log(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval /* or -1 */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context /* eg "xc", "xenstore", "xl" */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format /* does not contain \n */, +ÂÂÂÂÂÂÂÂÂÂÂÂÂ...) { +ÂÂÂÂva_list al; +ÂÂÂÂva_start(al,format); +ÂÂÂÂxtl_logv(logger,level,errnoval,context,format,al); +ÂÂÂÂva_end(al); +} + +void xtl_progress(struct xentoollog_logger *logger, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, const char *doing_what, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total) { +ÂÂÂÂint percent = 0; + +ÂÂÂÂif (!logger->progress) return; + +ÂÂÂÂif ( total ) +ÂÂÂÂÂÂÂÂpercent = (total < LONG_MAX/100) +ÂÂÂÂÂÂÂÂÂÂÂÂ? (done * 100) / total +ÂÂÂÂÂÂÂÂÂÂÂÂ: done / ((total + 99) / 100); + +ÂÂÂÂlogger->progress(logger, context, doing_what, percent, done, total); +} + +void xtl_logger_destroy(struct xentoollog_logger *logger) { +ÂÂÂÂif (!logger) return; +ÂÂÂÂlogger->destroy(logger); +} diff --git a/tools/libxc/xtl_logger_stdio.c b/tools/libxc/xtl_logger_stdio.c new file mode 100644 index 0000000..0cd9206 --- /dev/null +++ b/tools/libxc/xtl_logger_stdio.c @@ -0,0 +1,192 @@ +/* + * xtl_logger_stdio.c + * + * log message consumer that writes to stdio + * + * Copyright (c) 2010 Citrix + * Part of a generic logging interface used by various dom0 userland libraries. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.ÂÂSee the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#include "xentoollog.h" + +#include <time.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> +#include <errno.h> +#include <stdbool.h> + +struct xentoollog_logger_stdiostream { +ÂÂÂÂxentoollog_logger vtable; +ÂÂÂÂFILE *f; +ÂÂÂÂxentoollog_level min_level; +ÂÂÂÂunsigned flags; +ÂÂÂÂint progress_erase_len, progress_last_percent; +ÂÂÂÂbool progress_use_cr; +}; + +static void progress_erase(xentoollog_logger_stdiostream *lg) { +ÂÂÂÂif (lg->progress_erase_len) +ÂÂÂÂÂÂÂÂfprintf(lg->f, "\r%*s\r", lg->progress_erase_len, ""); +} + +static void stdiostream_vmessage(xentoollog_logger *logger_in, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint errnoval, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂva_list al) { +ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; + +ÂÂÂÂif (level < lg->min_level) +ÂÂÂÂÂÂÂÂreturn; + +ÂÂÂÂprogress_erase(lg); + +ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_SHOW_DATE) { +ÂÂÂÂÂÂÂÂstruct tm lt_buf; +ÂÂÂÂÂÂÂÂtime_t now = time(0); +ÂÂÂÂÂÂÂÂstruct tm *lt= localtime_r(&now, <_buf); +ÂÂÂÂÂÂÂÂif (lt != NULL) +ÂÂÂÂÂÂÂÂÂÂÂÂfprintf(lg->f, "%04d-%02d-%02d %02d:%02d:%02d %s ", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlt->tm_year+1900, lt->tm_mon+1, lt->tm_mday, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlt->tm_hour, lt->tm_min, lt->tm_sec, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtzname[!!lt->tm_isdst]); +ÂÂÂÂÂÂÂÂelse +ÂÂÂÂÂÂÂÂÂÂÂÂfprintf(lg->f, "[localtime_r failed: %d] ", errno); +ÂÂÂÂ} +ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_SHOW_PID) +ÂÂÂÂÂÂÂÂfprintf(lg->f, "[%lu] ", (unsigned long)getpid()); + +ÂÂÂÂif (context) +ÂÂÂÂÂÂÂÂfprintf(lg->f, "%s: ", context); + +ÂÂÂÂfprintf(lg->f, "%s: ", xtl_level_to_string(level)); + +ÂÂÂÂvfprintf(lg->f, format, al); + +ÂÂÂÂif (errnoval >= 0) +ÂÂÂÂÂÂÂÂfprintf(lg->f, ": %s", strerror(errnoval)); + +ÂÂÂÂputc('\n', lg->f); +ÂÂÂÂfflush(lg->f); +} + +static void stdiostream_message(struct xentoollog_logger *logger_in, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level level, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *format, ...) +{ +ÂÂÂÂva_list al; +ÂÂÂÂva_start(al,format); +ÂÂÂÂstdiostream_vmessage(logger_in, level, -1, context, format, al); +ÂÂÂÂva_end(al); +} + +static void stdiostream_progress(struct xentoollog_logger *logger_in, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *context, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst char *doing_what, int percent, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long done, unsigned long total) { +ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; +ÂÂÂÂint newpel, extra_erase; +ÂÂÂÂxentoollog_level this_level; + +ÂÂÂÂif (lg->flags & XTL_STDIOSTREAM_HIDE_PROGRESS) +ÂÂÂÂÂÂÂÂreturn; + +ÂÂÂÂif (percent < lg->progress_last_percent) { +ÂÂÂÂÂÂÂÂthis_level = XTL_PROGRESS; +ÂÂÂÂ} else if (percent == lg->progress_last_percent) { +ÂÂÂÂÂÂÂÂreturn; +ÂÂÂÂ} else if (percent < lg->progress_last_percent + 5) { +ÂÂÂÂÂÂÂÂthis_level = XTL_DETAIL; +ÂÂÂÂ} else { +ÂÂÂÂÂÂÂÂthis_level = XTL_PROGRESS; +ÂÂÂÂ} + +ÂÂÂÂif (this_level < lg->min_level) +ÂÂÂÂÂÂÂÂreturn; + +ÂÂÂÂlg->progress_last_percent = percent; + +ÂÂÂÂif (!lg->progress_use_cr) { +ÂÂÂÂÂÂÂÂstdiostream_message(logger_in, this_level, context, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"%s: %lu/%luÂÂ%3d%%", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdoing_what, done, total, percent); +ÂÂÂÂÂÂÂÂreturn; +ÂÂÂÂ} + +ÂÂÂÂif (lg->progress_erase_len) +ÂÂÂÂÂÂÂÂputc('\r', lg->f); + +ÂÂÂÂnewpel = fprintf(lg->f, "%s%s" "%s: %lu/%luÂÂ%3d%%%s", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcontext?context:"", context?": ":"", +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdoing_what, done, total, percent, + ÂÂÂÂÂdone == total ? "\n" : ""); + +ÂÂÂÂextra_erase = lg->progress_erase_len - newpel; +ÂÂÂÂif (extra_erase > 0) +ÂÂÂÂÂÂÂÂfprintf(lg->f, "%*s\r", extra_erase, ""); + +ÂÂÂÂlg->progress_erase_len = newpel; +} + +static void stdiostream_destroy(struct xentoollog_logger *logger_in) { +ÂÂÂÂxentoollog_logger_stdiostream *lg = (void*)logger_in; +ÂÂÂÂprogress_erase(lg); +ÂÂÂÂfree(lg); +} + +void xtl_stdiostream_set_minlevel(xentoollog_logger_stdiostream *lg, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂxentoollog_level min_level) { +ÂÂÂÂlg->min_level = min_level; +} + +void xtl_stdiostream_adjust_flags(xentoollog_logger_stdiostream *lg, +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned set_flags, unsigned clear_flags) { +ÂÂÂÂunsigned new_flags = (lg->flags & ~clear_flags) | set_flags; +ÂÂÂÂif (new_flags & XTL_STDIOSTREAM_HIDE_PROGRESS) +ÂÂÂÂÂÂÂÂprogress_erase(lg); +ÂÂÂÂlg->flags = new_flags; +} + +xentoollog_logger_stdiostream *xtl_createlogger_stdiostream +ÂÂÂÂÂÂÂÂ(FILE *f, xentoollog_level min_level, unsigned flags) { +ÂÂÂÂxentoollog_logger_stdiostream newlogger; + +ÂÂÂÂnewlogger.f = f; +ÂÂÂÂnewlogger.min_level = min_level; +ÂÂÂÂnewlogger.flags = flags; + +ÂÂÂÂswitch (flags & (XTL_STDIOSTREAM_PROGRESS_USE_CR | +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂXTL_STDIOSTREAM_PROGRESS_NO_CR)) { +ÂÂÂÂcase XTL_STDIOSTREAM_PROGRESS_USE_CR: newlogger.progress_use_cr = 1; break; +ÂÂÂÂcase XTL_STDIOSTREAM_PROGRESS_NO_CR:ÂÂnewlogger.progress_use_cr = 0; break; +ÂÂÂÂcase 0: +ÂÂÂÂÂÂÂÂnewlogger.progress_use_cr = isatty(fileno(newlogger.f)) > 0; +ÂÂÂÂÂÂÂÂbreak; +ÂÂÂÂdefault: +ÂÂÂÂÂÂÂÂerrno = EINVAL; +ÂÂÂÂÂÂÂÂreturn 0; +ÂÂÂÂ} + +ÂÂÂÂif (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); + +ÂÂÂÂnewlogger.progress_erase_len = 0; +ÂÂÂÂnewlogger.progress_last_percent = 0; + +ÂÂÂÂreturn XTL_NEW_LOGGER(stdiostream, newlogger); +} diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 2abae0c..6ff5bee 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -20,12 +20,11 @@ LIBUUID_LIBS += -luuid Âendif  ÂLIBXL_LIBS = -LIBXL_LIBS = $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) +LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) Âifeq ($(CONFIG_REMUS_NETBUF),y) ÂLIBXL_LIBS += $(LIBNL3_LIBS) Âendif  -CFLAGS_LIBXL += $(CFLAGS_libxentoollog) ÂCFLAGS_LIBXL += $(CFLAGS_libxenctrl) ÂCFLAGS_LIBXL += $(CFLAGS_libxenguest) ÂCFLAGS_LIBXL += $(CFLAGS_libxenstore) @@ -150,7 +149,7 @@ CFLAGS_XL += -Wshadow  ÂXL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o xl_sxp.o Â$(XL_OBJS) $(TEST_PROG_OBJS) _libxl.api-for-check: \ -ÂÂÂÂÂÂÂÂÂÂÂÂCFLAGS += $(CFLAGS_libxentoollog) +ÂÂÂÂÂÂÂÂÂÂÂÂCFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h Â$(XL_OBJS): CFLAGS += $(CFLAGS_XL) Â$(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.  @@ -254,19 +253,19 @@ libxlutil.a: $(LIBXLU_OBJS)  $(AR) rcs libxlutil.a $^  Âxl: $(XL_OBJS) libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) -lyajl $(APPEND_LDFLAGS)  Âxen-init-dom0: $(XEN_INIT_DOM0_OBJS) libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)  Âtest_%: test_%.o test_common.o libxlutil.so libxenlight_test.so - $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxenctrl) -lyajl $(APPEND_LDFLAGS)  Âlibxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)  Âtestidl: testidl.o libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)  Â$(PKG_CONFIG): % : %.in Makefile  @sed -e 's/@@version@@/$(MAJOR).$(MINOR)/g' < $< > $@.new diff --git a/tools/ocaml/libs/xentoollog/Makefile b/tools/ocaml/libs/xentoollog/Makefile index 8ae0a78..666eb66 100644 --- a/tools/ocaml/libs/xentoollog/Makefile +++ b/tools/ocaml/libs/xentoollog/Makefile @@ -5,7 +5,7 @@ include $(TOPLEVEL)/common.make Â# allow mixed declarations and code ÂCFLAGS += -Wno-declaration-after-statement  -CFLAGS += $(CFLAGS_libxentoollog) +CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) ÂCFLAGS += $(APPEND_CFLAGS) ÂOCAMLINCLUDE +=  @@ -13,7 +13,7 @@ OBJS = xentoollog ÂINTF = xentoollog.cmi ÂLIBS = xentoollog.cma xentoollog.cmxa  -LIBS_xentoollog = $(LDLIBS_libxentoollog) +LIBS_xentoollog = $(LDLIBS_libxenctrl)  Âxentoollog_OBJS = $(OBJS) Âxentoollog_C_OBJS = xentoollog_stubs @@ -49,7 +49,7 @@ xentoollog.mli: xentoollog.mli.in _xtl_levels.mli.in  Âlibs: $(LIBS)  -_xtl_levels.ml.in _xtl_levels.mli.in _xtl_levels.inc: genlevels.py $(XEN_ROOT)/tools/libs/toollog/include/xentoollog.h +_xtl_levels.ml.in _xtl_levels.mli.in _xtl_levels.inc: genlevels.py $(XEN_ROOT)/tools/libxc/include/xentoollog.h  $(PYTHON) genlevels.py _xtl_levels.mli.in _xtl_levels.ml.in _xtl_levels.inc  Â.PHONY: install diff --git a/tools/ocaml/libs/xentoollog/genlevels.py b/tools/ocaml/libs/xentoollog/genlevels.py index 8c233c5..65d334f 100755 --- a/tools/ocaml/libs/xentoollog/genlevels.py +++ b/tools/ocaml/libs/xentoollog/genlevels.py @@ -3,7 +3,7 @@ Âimport sys  Âdef read_levels(): - f = open('../../../libs/toollog/include/xentoollog.h', 'r') + f = open('../../../libxc/include/xentoollog.h', 'r')   levels = []  record = False diff --git a/tools/python/setup.py b/tools/python/setup.py index 9771cc4..fdba866 100644 --- a/tools/python/setup.py +++ b/tools/python/setup.py @@ -7,17 +7,16 @@ XEN_ROOT = "../.." Âextra_compile_argsÂÂ= [ "-fno-strict-aliasing", "-Werror" ]  ÂPATH_XENÂÂÂÂÂÂ= XEN_ROOT + "/tools/include" -PATH_LIBXENTOOLLOG = XEN_ROOT + "/tools/libs/toollog" ÂPATH_LIBXCÂÂÂÂ= XEN_ROOT + "/tools/libxc" ÂPATH_LIBXLÂÂÂÂ= XEN_ROOT + "/tools/libxl" ÂPATH_XENSTORE = XEN_ROOT + "/tools/xenstore"  Âxc = Extension("xc", ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂextra_compile_args = extra_compile_args, -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinclude_dirsÂÂÂÂÂÂÂ= [ PATH_XEN, PATH_LIBXENTOOLLOG + "/include", PATH_LIBXC + "/include", "xen/lowlevel/xc" ], +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂinclude_dirsÂÂÂÂÂÂÂ= [ PATH_XEN, PATH_LIBXC + "/include", "xen/lowlevel/xc" ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlibrary_dirsÂÂÂÂÂÂÂ= [ PATH_LIBXC ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlibrariesÂÂÂÂÂÂÂÂÂÂ= [ "xenctrl", "xenguest" ], -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdependsÂÂÂÂÂÂÂÂÂÂÂÂ= [ PATH_LIBXC + "/libxenctrl.so", PATH_LIBXC + "/libxenguest.so",ÂÂ"-Wl,-rpath-link="+PATH_LIBXENTOOLLOG ], +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdependsÂÂÂÂÂÂÂÂÂÂÂÂ= [ PATH_LIBXC + "/libxenctrl.so", PATH_LIBXC + "/libxenguest.so" ], ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsourcesÂÂÂÂÂÂÂÂÂÂÂÂ= [ "xen/lowlevel/xc/xc.c" ])  Âxs = Extension("xs", diff --git a/tools/xenpaging/Makefile b/tools/xenpaging/Makefile index e63d894..2407a30 100644 --- a/tools/xenpaging/Makefile +++ b/tools/xenpaging/Makefile @@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk  Â# xenpaging.c and file_ops.c incorrectly use libxc internals ÂCFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(PTHREAD_CFLAGS) -I$(XEN_ROOT)/tools/libxc -LDLIBS += $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS) +LDLIBS += $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS) ÂLDFLAGS += $(PTHREAD_LDFLAGS)  ÂPOLICYÂÂÂÂ= default _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |