direct-io.hg

view Config.mk @ 12765:2dd4569e0640

[LIBXC] Add an error reporting API to the libxc library.

- An 'xc_error' struct is used to pass around error
details. Currently contains two members 'code' an enumeration of
error types, and 'message' a free text description of the specific
problem.

- The xc_get_last_error() method returns a const pointer to the
internal instance of this struct manged by libxc. By returning a
const pointer we can add extra members to the end of the struct at
any time without worrying about ABI of callers. This will let us
provide more fine-grained info if needed in the future.

- The xc_error instance is statically defined inside libxc and marked
__thread. This ensures that errors are recorded per-thread, and
that when dealing with errors we never need to call malloc - all
storage needed is statically allocated.

- The xc_clear_last_error() method resets any currently recorded
error details

- The xc_error_code_to_desc() method converts the integer error code
into a generic user facing messsage. eg "Invalid kernel". Together
with the 'message' field from xc_error, this provides the user
visible feedback. eg "Invalid kernel: Non PAE-kernel on PAE host."

- A callback can be registered with xc_set_error_handler to receive
notification whenever an error is recorded, rather than querying
for error details after the fact with xc_get_last_error

- If built with -DDEBUG set, a default error handler will be
registered which calls fprintf(stderr), thus maintaining current
behaviour of logging errors to stderr during developer builds.

- The python binding for libxc is updated to use xc_get_last_error
to pull out error details whenever appropriate, instead of
returning info based on 'errno'

- The xc_set_error method is private to libxc internals, and is used
for setting error details

- The ERROR and PERROR macros have been updated to call xc_set_error
automatically specifying XC_INTERNAL_ERROR as the error code. This
gives a generic error report for all current failure points

- Some uses of the ERROR macro have been replaced with explicit
calls to xc_set_error to enable finer grained error reporting. In
particular the code dealing with invalid kernel types uses this
to report about PAE/architecture/wordsize mismatches

The patch has been tested by calling xm create against a varietry of
config files defining invalid kernels of various kinds. It has also
been tested with libvirt talking to xend. In both cases the error
messages were propagated all the way back up the stack.

There is only one place where I need to do further work. The suspend
& restore APIs in Xend invoke external helper programs rather than
calling libxc directly. This means that error details are essentially
lost. Since there is already code in XenD which scans STDERR from
these programs I will investigate adapting this to extract actual
error messages from these helpers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author kfraser@localhost.localdomain
date Thu Dec 07 11:36:26 2006 +0000 (2006-12-07)
parents af10df2fed35
children 4a164bf1edfc
line source
1 # -*- mode: Makefile; -*-
3 # A debug build of Xen and tools?
4 debug ?= n
6 XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
7 -e s/ppc/powerpc/ -e s/i86pc/x86_32/)
8 XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH)
9 XEN_TARGET_X86_PAE ?= n
10 XEN_OS ?= $(shell uname -s)
12 CONFIG_$(XEN_OS) := y
14 # Tools to run on system hosting the build
15 HOSTCC = gcc
16 HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
18 DISTDIR ?= $(XEN_ROOT)/dist
19 DESTDIR ?= /
21 include $(XEN_ROOT)/config/$(XEN_OS).mk
22 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
24 ifneq ($(EXTRA_PREFIX),)
25 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
26 EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBDIR)
27 endif
29 # cc-option
30 # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
31 cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
32 /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
34 ifneq ($(debug),y)
35 CFLAGS += -DNDEBUG
36 else
37 CFLAGS += -g
38 endif
40 CFLAGS += -std=gnu99
42 CFLAGS += -Wall -Wstrict-prototypes
44 # -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the
45 # result of any casted expression causes a warning.
46 CFLAGS += -Wno-unused-value
48 HOSTCFLAGS += $(call cc-option,$(HOSTCC),-Wdeclaration-after-statement,)
49 CFLAGS += $(call cc-option,$(CC),-Wdeclaration-after-statement,)
51 LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i))
52 CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
54 # If ACM_SECURITY = y, then the access control module is compiled
55 # into Xen and the policy type can be set by the boot policy file
56 # y - Build the Xen ACM framework
57 # n - Do not build the Xen ACM framework
58 ACM_SECURITY ?= n
60 # If ACM_SECURITY = y and no boot policy file is installed,
61 # then the ACM defaults to the security policy set by
62 # ACM_DEFAULT_SECURITY_POLICY
63 # Supported models are:
64 # ACM_NULL_POLICY
65 # ACM_CHINESE_WALL_POLICY
66 # ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY
67 # ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY
68 ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_POLICY
70 # Optional components
71 XENSTAT_XENTOP ?= y
72 VTPM_TOOLS ?= n
73 LIBXENAPI_BINDINGS ?= n
74 XENFB_TOOLS ?= n
76 -include $(XEN_ROOT)/.config