direct-io.hg

view Makefile @ 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 be8039f8bc14
children dd0989523d17
line source
1 #
2 # Grand Unified Makefile for Xen.
3 #
5 # Export target architecture overrides to Xen and Linux sub-trees.
6 ifneq ($(XEN_TARGET_ARCH),)
7 SUBARCH := $(subst x86_32,i386,$(XEN_TARGET_ARCH))
8 export XEN_TARGET_ARCH SUBARCH XEN_SYSTYPE
9 endif
11 # Default target must appear before any include lines
12 .PHONY: all
13 all: dist
15 export XEN_ROOT=$(CURDIR)
16 include Config.mk
17 include buildconfigs/Rules.mk
19 ifeq ($(XEN_TARGET_X86_PAE),y)
20 export pae=y
21 endif
23 # build and install everything into the standard system directories
24 .PHONY: install
25 install: install-xen install-kernels install-tools install-docs
27 .PHONY: build
28 build: kernels
29 $(MAKE) -C xen build
30 $(MAKE) -C tools build
31 $(MAKE) -C docs build
33 # The test target is for unit tests that can run without an installation. Of
34 # course, many tests require a machine running Xen itself, and these are
35 # handled elsewhere.
36 .PHONY: test
37 test:
38 $(MAKE) -C tools/python test
40 # build and install everything into local dist directory
41 .PHONY: dist
42 dist: DESTDIR=$(DISTDIR)/install
43 dist: dist-xen dist-kernels dist-tools dist-docs
44 $(INSTALL_DIR) $(DISTDIR)/check
45 $(INSTALL_DATA) ./COPYING $(DISTDIR)
46 $(INSTALL_DATA) ./README $(DISTDIR)
47 $(INSTALL_PROG) ./install.sh $(DISTDIR)
48 $(INSTALL_PROG) tools/check/chk tools/check/check_* $(DISTDIR)/check
49 dist-%: DESTDIR=$(DISTDIR)/install
50 dist-%: install-%
51 @: # do nothing
53 # Legacy dist targets
54 .PHONY: xen tools kernels docs
55 xen: dist-xen
56 tools: dist-tools
57 kernels: dist-kernels
58 docs: dist-docs
60 .PHONY: prep-kernels
61 prep-kernels:
62 for i in $(XKERNELS) ; do $(MAKE) $$i-prep || exit 1; done
64 .PHONY: install-xen
65 install-xen:
66 $(MAKE) -C xen install
68 .PHONY: install-tools
69 install-tools:
70 $(MAKE) -C tools install
72 .PHONY: install-kernels
73 install-kernels:
74 for i in $(XKERNELS) ; do $(MAKE) $$i-install || exit 1; done
76 .PHONY: install-docs
77 install-docs:
78 sh ./docs/check_pkgs && $(MAKE) -C docs install || true
80 .PHONY: dev-docs
81 dev-docs:
82 $(MAKE) -C docs dev-docs
84 # Build all the various kernels and modules
85 .PHONY: kbuild
86 kbuild: kernels
88 # Delete the kernel build trees entirely
89 .PHONY: kdelete
90 kdelete:
91 for i in $(XKERNELS) ; do $(MAKE) $$i-delete ; done
93 # Clean the kernel build trees
94 .PHONY: kclean
95 kclean:
96 for i in $(XKERNELS) ; do $(MAKE) $$i-clean ; done
98 # Make patches from kernel sparse trees
99 .PHONY: mkpatches
100 mkpatches:
101 for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-xen.patch; done
103 # build xen, the tools, and a domain 0 plus unprivileged linux-xen images,
104 # and place them in the install directory. 'make install' should then
105 # copy them to the normal system directories
106 .PHONY: world
107 world:
108 $(MAKE) clean
109 $(MAKE) kdelete
110 $(MAKE) dist
112 # clean doesn't do a kclean
113 .PHONY: clean
114 clean::
115 $(MAKE) -C xen clean
116 $(MAKE) -C tools clean
117 $(MAKE) -C docs clean
119 # clean, but blow away kernel build tree plus tarballs
120 .PHONY: distclean
121 distclean:
122 $(MAKE) -C xen distclean
123 $(MAKE) -C tools distclean
124 $(MAKE) -C docs distclean
125 rm -rf dist patches/tmp
126 for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done
127 for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-mrproper ; done
128 rm -rf patches/*/.makedep
130 # Linux name for GNU distclean
131 .PHONY: mrproper
132 mrproper: distclean
134 .PHONY: help
135 help:
136 @echo 'Installation targets:'
137 @echo ' install - build and install everything'
138 @echo ' install-xen - build and install the Xen hypervisor'
139 @echo ' install-tools - build and install the control tools'
140 @echo ' install-kernels - build and install guest kernels'
141 @echo ' install-docs - build and install user documentation'
142 @echo ''
143 @echo 'Building targets:'
144 @echo ' dist - build and install everything into local dist directory'
145 @echo ' world - clean everything, delete guest kernel build'
146 @echo ' trees then make dist'
147 @echo ' xen - build and install Xen hypervisor'
148 @echo ' tools - build and install tools'
149 @echo ' kernels - build and install guest kernels'
150 @echo ' kbuild - synonym for make kernels'
151 @echo ' docs - build and install user documentation'
152 @echo ' dev-docs - build developer-only documentation'
153 @echo ''
154 @echo 'Cleaning targets:'
155 @echo ' clean - clean the Xen, tools and docs (but not guest kernel trees)'
156 @echo ' distclean - clean plus delete kernel build trees and'
157 @echo ' local downloaded files'
158 @echo ' kdelete - delete guest kernel build trees'
159 @echo ' kclean - clean guest kernel build trees'
160 @echo ''
161 @echo 'Miscellaneous targets:'
162 @echo ' prep-kernels - prepares kernel directories, does not build'
163 @echo ' mkpatches - make patches against vanilla kernels from'
164 @echo ' sparse trees'
165 @echo ' uninstall - attempt to remove installed Xen tools'
166 @echo ' (use with extreme care!)'
167 @echo
168 @echo 'Environment:'
169 @echo ' XEN_PYTHON_NATIVE_INSTALL=y'
170 @echo ' - native python install or dist'
171 @echo ' install into prefix/lib/python<VERSION>'
172 @echo ' instead of <PREFIX>/lib/python'
173 @echo ' true if set to non-empty value, false otherwise'
175 # Use this target with extreme care!
176 .PHONY: uninstall
177 uninstall: D=$(DESTDIR)
178 uninstall:
179 [ -d $(D)/etc/xen ] && mv -f $(D)/etc/xen $(D)/etc/xen.old-`date +%s` || true
180 rm -rf $(D)/etc/init.d/xend*
181 rm -rf $(D)/etc/hotplug/xen-backend.agent
182 rm -f $(D)/etc/udev/rules.d/xen-backend.rules
183 rm -f $(D)/etc/udev/xen-backend.rules
184 rm -f $(D)/etc/sysconfig/xendomains
185 rm -rf $(D)/var/run/xen* $(D)/var/lib/xen*
186 rm -rf $(D)/boot/*xen*
187 rm -rf $(D)/lib/modules/*xen*
188 rm -rf $(D)/usr/bin/xen* $(D)/usr/bin/lomount
189 rm -rf $(D)/usr/bin/cpuperf-perfcntr $(D)/usr/bin/cpuperf-xen
190 rm -rf $(D)/usr/bin/xc_shadow
191 rm -rf $(D)/usr/bin/pygrub
192 rm -rf $(D)/usr/bin/setsize $(D)/usr/bin/tbctl
193 rm -rf $(D)/usr/bin/xsls
194 rm -rf $(D)/usr/include/xenctrl.h $(D)/usr/include/xenguest.h
195 rm -rf $(D)/usr/include/xs_lib.h $(D)/usr/include/xs.h
196 rm -rf $(D)/usr/include/xen
197 rm -rf $(D)/usr/$(LIBDIR)/libxenctrl* $(D)/usr/$(LIBDIR)/libxenguest*
198 rm -rf $(D)/usr/$(LIBDIR)/libxenstore*
199 rm -rf $(D)/usr/$(LIBDIR)/python/xen $(D)/usr/$(LIBDIR)/python/grub
200 rm -rf $(D)/usr/$(LIBDIR)/xen/
201 rm -rf $(D)/usr/lib/xen/
202 rm -rf $(D)/usr/local/sbin/setmask $(D)/usr/local/sbin/xen*
203 rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm
204 rm -rf $(D)/usr/share/doc/xen
205 rm -rf $(D)/usr/share/xen
206 rm -rf $(D)/usr/share/man/man1/xen*
207 rm -rf $(D)/usr/share/man/man8/xen*
209 # Legacy targets for compatibility
210 .PHONY: linux26
211 linux26:
212 $(MAKE) 'KERNELS=linux-2.6*' kernels