aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_internal.c
Commit message (Collapse)AuthorAgeFilesLines
* libxl: fix file open failure check in libxl__file_reference_mapMatthew Daley2013-09-251-1/+1
| | | | | | Coverity-ID: 1055567 Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Move gc_is_real to libxl_internal.h.Anthony PERARD2012-10-051-8/+3
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: add option to choose who executes hotplug scriptsRoger Pau Monne2012-07-261-0/+19
| | | | | | | | | | | | | | | | | Add and option to xl.conf file to decide if hotplug scripts are executed from the toolstack (xl) or from udev as it used to be in the past. This option is only introduced in this patch, but it has no effect since the code to call hotplug scripts from libxl is introduced in a latter patch. This choice will be saved in "libxl/disable_udev", as specified in the DISABLE_UDEV_PATH constant. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: libxl__device_model_version_running should return an intIan Campbell2012-07-251-2/+1
| | | | | | | | | | | On error it returns -1 and therefore it needs to return int and not libxl_device_model_enum. Otherwise gcc 4.6.2 complains: libxl.c: In function ‘libxl_domain_suspend’: libxl.c:778:9: error: case value ‘4294967295’ not in enumerated type ‘libxl_device_model_version’ [-Werror=switch] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Do not pass NULL as gc_opt; introduce NOGCIan Jackson2012-06-281-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 25182:6c3345d7e9d9 the practice of passing NULL to gc-using memory allocation functions was introduced. However, the arrangements there were not correct as committed, because the error handling and logging depends on getting a ctx from the gc - so an allocation error would in fact result in libxl dereferencing NULL. Instead, provide a special dummy gc in the ctx, called `nogc_gc'. It is marked out specially by having alloc_maxsize==-1, which is otherwise invalid. Functions which need to actually look into the gc use the new test function gc_is_real (whose purpose is mainly clarity of the code) to check whether the gc is the dummy one, and do nothing if it is. And we provide a helper macro NOGC which uses the in-scope real gc to find the ctx and hence the dummy gc (and which replaces the previous #define NOGC NULL). Change all callers which pass 0 or NULL to an allocation function to use NOGC or &ctx->nogc_gc, as applicable in the context. We add a comment near the definition of LIBXL_INIT_GC pointing out that it isn't any more the only place a libxl__gc struct is initialised, for the benefit of anyone changing the contents of gc's in the future. Also, actually document that libxl__ptr_add is legal with ptr==NULL, and change a couple of calls not to check for NULL argument. Reported-by: Bamvor Jian Zhang <bjzhang@suse.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Bamvor Jian Zhang <bjzhang@suse.com> Acked-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: do not overwrite user supplied config when running bootloaderIan Campbell2012-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when running the bootloader libxl will update b_info->u.pv.kernel, .ramdisk, .cmdline and .bootloader. This can expose internal details, such as temporary paths in /var/run/xen/bootloader.*/ to the user. This is problematic because it means that the user cannot re-use the struct as is. This does not effect xl in Xen 4.2+ since it always reparses the guest config and reinitialises the build info, however it did cause issues with reboot in 4.1 (reported by Dmitry Morozhnikov) and may cause issues for other users of libxl. Instead make the libxl bootloader infrastructure provide output to its caller which is slurped into the internal libxl__domain_build_state datastructure. If no bootloader is configured then the bootloader instead propagates the user supplied b_info config. In order to simplify this push the error handling for the case where there is no bootdisk down into libxl__bootloader_run. In principal there is no reason why it shouldn't be possible to do a pure netboot guest with a suitable bootloader, but I don't fix that here. This change allow us to make the libxl_file_reference an internal API, and eventually we might be able to get rid of it. Also removes the publix libxl_run_bootloader interface, neither xl nor libvirt use it. I am proposing this for 4.2 due to the API change. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> [ ijc -- reduced log message in libxl__build_pv from INFO to DEBUG ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Make libxl__zalloc et al tolerate a NULL gcIan Jackson2012-04-111-1/+4
| | | | | | | | | | Arrange that if we pass NULL as a gc, we simply don't register the pointer. This instantly gives us non-gc'ing but error-checking versions of malloc, realloc, vasprintf, etc. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: Crash (more sensibly) on malloc failureIan Jackson2012-04-111-44/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formally change the libxl memory allocation failure policy to "crash". Previously we had a very uneven approach; much code assumed that libxl__sprintf (for example) would never return NULL, but some code was written more carefully. We think it is unlikely that we will be able to make the library actually robust against allocation failure (since that would be an awful lot of never-tested error paths) and few calling environments will be able to cope anyway. So, instead, adopt the alternative approach: provide allocation functions which never return null, but will crash the whole process instead. Consequently, - New noreturn function libxl__alloc_failed which may be used for printing a vaguely-useful error message, rather than simply dereferencing a null pointer. - libxl__ptr_add now returns void as it crashes on failure. - libxl__zalloc, _calloc, _strdup, _strndup, crash on failure using libxl__alloc_failed. So all the code that uses these can no longer dereference null on malloc failure. While we're at it, make libxl__ptr_add use realloc rather than emulating it with calloc and free, and make it grow the array exponentially rather than linearly. Things left to do: - Remove a lot of now-spurious error handling. - Remove the ERROR_NOMEM error code. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: fix mutex initializationRoger Pau Monne2012-01-271-0/+27
| | | | | | | | | The macro PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not defined on NetBSD, so define mutex attributes manually. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: move a lot more includes into libxl_internal.hIan Jackson2012-01-131-9/+1
| | | | | | | | | | | | | | | | | Move a lot of #include <stdfoo.h> from individual files into libxl_internal.h. This helps avoid portability mistakes where necessary system headers are omitted from individual files, and is also of course a convenience when developing. Also add #include "libxl_osdeps.h" /* must come before any other headers */ to the top of most libxl*.c files, so that anyone who adds any headers before libxl_internal.h will put the in the right place. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: make libxl__free_all idempotentIan Jackson2011-12-121-0/+2
| | | | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: make libxl__[v]log const-correctIan Jackson2011-12-121-2/+2
| | | | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: Rationalise #includesIan Jackson2011-12-121-4/+0
| | | | | | | | | | | | | | | | | | | | libxl_internal.h now #includes libxl.h and various system headers. This 1. makes the order of header inclusion more predictable 2. explicitly allows libxl_internal.h to use objects defined in libxl.h 3. removes the need for individual files to include these headers Also - remove some unnecessary #includes of libxl_utils.h, flexarray.h, etc. in some libxl*.c files, - include libxl_osdeps.h at the top of libxl_internal.h - add missing includes of libxl_osdeps.h to a couple of files - change libxl.h to libxl_internal.h in a couple of files Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl: Apply CLOEXEC to the restore_fd.Anthony Perard2011-12-011-13/+0
| | | | | | | | | | | At restore time, the file descriptor opened on the migration state file is still open in the device model. Let's apply FD_CLOEXEC to it. This patch provides libxl_fd_set_cloexec to users of libxl, instead of keeping this function internal. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: libxl: Introduce dm-version xenstore key.Anthony PERARD2011-11-041-0/+23
| | | | | | | | | | | | The all key is /libxl/$domid/dm-version. The /libxl/$domid dir is created with the domain and should be only accessible by the toolstack domain. The function libxl__xs_libxl_path() give this path. This come with libxl__device_model_version_running() helper function. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: fixup incorrect indentationIan Campbell2011-10-121-0/+8
| | | | | | | | | Several places which were previsously indented using hard tabs are now incorrectly indented. Fix them up. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fixup incorrect indentationIan Campbell2011-10-111-32/+32
| | | | | | | | | Several places which were previsously indented using hard tabs are now incorrectly indented. Fix them up. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: expand hard tab stopsIan Campbell2011-10-111-32/+32
| | | | | | | | | | | | | | | I ran the following and committed the result. ^I is an actual hard tab for i in $(grep -l --exclude=*_[ly].\[ch\] '^I' tools/libxl/*.[ch]) ; do cat $i | expand | sponge $i done There are some actually wrong indentations too, I'll fix those up manually. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix libxl_mac_to_device_nicIan Campbell2011-10-061-0/+12
| | | | | | | | | | | I think I broke this back in 22041:4c9ef5ec9146, using i as both the inner and outer loop iterator. I've added libxl__compare_macs which helps keep things clean. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: add and use parse_mac helper functionIan Campbell2011-10-061-0/+17
| | | | | | | | rather than open coding a bunch it a bunch of times. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Intruduce libxl__strndup.Anthony PERARD2011-09-291-0/+10
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Introduce libxl__realloc.Anthony PERARD2011-09-291-0/+24
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Introduce libxl__fd_set_cloexecAnthony PERARD2011-09-291-0/+13
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: add missing ":" in log messagesIan Jackson2011-05-261-1/+1
| | | | | | | | | libxl__logv would fail to put a ":" between the function name and the rest of the message. Reported-by: Zhou Peng <zhoupeng@nfs.iscas.ac.cn> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: libxl: constify parameter to libxl__abs_pathIan Campbell2011-05-241-2/+2
| | | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Make all hidden/static functions take a gc not a ctxIan Campbell2011-03-151-3/+3
| | | | | | | | | | | | | | | | Also ensure that static and hidden functions use the libxl__ prefix not just libxl_ (in the case of static functions only when they use a libxl prefix to start with). This follows the policy described in libxl.h "libxl memory management". Based on a manual audit of: grep ^static tools/libxl/libxl*.[ch]| grep libxl_ctx grep libxl__ tools/libxl/*.h| grep libxl_ctx Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Clear file object on successful munmap()Signed-off-by: Jim Fehlig2011-02-171-1/+7
| | | | | | | | Clear members of libxl_file_reference when file is successfully unmapped. Signed-off-by: Jim Fehlig <jfehlig@novell.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Use libxl__ namespace for internal typesIan Campbell2010-09-081-10/+10
| | | | | | | | | | | | | | It's not clear that the namespace rules described in libxl.h are intended to apply to internal types but I don't see why not. sed -i -e 's/\<libxl_device\>/libxl__device/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_device_kinds\>/libxl__device_kinds/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_gc\>/libxl__gc/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_gc_owner\>/libxl__gc_owner/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_spawn_starting\>/libxl__spawn_starting/g' tools/libxl/*.[ch] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Ensure all _hidden functions use libxl__ prefix (manual part)Ian Campbell2010-09-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This patch covers the remaining functions identified by: rgrep _hidden tools/libxl/*.h | grep -v libxl__ sed -i -e 's/XL_LOG/LIBXL__LOG/g' tools/libxl/*.[ch] sed -i -e 's/xl_log/libxl__log/g' tools/libxl/*.[ch] sed -i -e 's/\(build_\(pre\|post\|pv\|hvm\)\)/libxl__\1/g' tools/libxl/*.[ch] sed -i -e 's/is_hvm/libxl__domain_is_hvm/g' tools/libxl/*.[ch] sed -i -e 's/get_shutdown_reason/libxl__domain_shutdown_reason/g' tools/libxl/*.[ch] sed -i -e 's/restore_common/libxl__domain_restore_common/g' tools/libxl/*.[ch] sed -i -e 's/core_suspend/libxl__domain_suspend_common/g' tools/libxl/*.[ch] sed -i -e 's/save_device_model/libxl__domain_save_device_model/g' tools/libxl/*.[ch] sed -i -e 's/device_disk_backend_type_of_phystype/libxl__device_disk_backend_type_of_phystype/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_blktap_enabled\>/libxl__blktap_enabled/g' tools/libxl/*.[ch] sed -i -e 's/\<libxl_blktap_devpath\>/libxl__blktap_devpath/g' tools/libxl/*.[ch] Add _hidden to libxl__blktap_enabled and libxl__blktap_devpath Inline dominfo_libxl__domain_shutdown_reason(info) into libxl__domain_shutdown_reason, its only caller. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Ensure all _hidden functions use libxl__ prefix (autogenerated patch)Ian Campbell2010-09-081-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | This patch covers all those which could be trivially converted automatically. sed -n -e 's/_hidden.*[ \*]libxl_\([^_][^()]*\)(.*/\1/pg' tools/libxl/*.h | \ while read i ; do \ sed -i -e "s/libxl_$i/libxl__$i/g" tools/libxl/*.[ch]; \ done sed -n -e 's/_hidden.*_libxl_\([^_][^()]*\)(.*/\1/pg' tools/libxl/*.h | \ while read i ; do \ sed -i -e "s/_libxl_$i/libxl__$i/g" tools/libxl/*.[ch]; \ done Check that diffstat includes libxl but not xl. Fixup tools/libxl/xl_cmdimpl.c which used libxl_device_del instead of libxl_device_disk_del in a printf. (Patch runes re-run by Ian Jackson to refresh against tip libxl.) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: implement destroy for libxl_file_reference builtin typeIan Campbell2010-08-191-0/+51
| | | | | | | | | | | | | As well as freeing data any file mappings need to be torn down so implement an explicit destroy function. Also the map and unmap function are internal to libxl so make that so. [PATCH 09 of 16 of libxl: autogenerate type definitions and destructor functions] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools/libxl: remove libxl_free() since there are no more callersGianni Tedesco2010-08-161-19/+0
| | | | | | | | | | libxl_free() allows allocated memory to be explicitly free'd from a libxl_gc. Every previous use of this function has now been made redundant and therefore has been removed. We can safely kill it and amend the policy accordingly. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: Implement per-API-call garbage-collection lifetimeGianni Tedesco2010-08-121-32/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently scratch variables allocated by libxl have the same lifetime as the context. While this is suitable for one off invocations of xl. It is not so great for a daemon process linking to libxl. In that case there will be prolific leakage of heap memory. My proposed solution involves create a new libxl_gc structure, which contains a pointer to an owning context as well as the garbage collection data. Top-level library functions which expect to do a lot of scratch allocations put gc struct on the stack and initialize it with a macro. Before returning they then call libxl_free_all on this struct. This means that static helper functions called by such functions will usually take a gc instead of a ctx as a first parameter. The patch touches almost every code-path so a close review and testing would be much appreciated. I have tested with valgrind all of the parts I could which looked non-straightforward. Suffice to say that it seems crash-free even if we have exposed a few real memory leaks. These are for cases where we return eg. block list to an xl caller but there is no appropriate block_list_free() function to call. Ian Campbells work in this area should sew up all these loose ends. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* xl: Return void from libxl_free() and libxl_free_all()"Gianni Tedesco (3P)"2010-08-111-6/+5
| | | | | | | | | Also abort() if a pointer passed in to libxl_free() cannot be found in the mini-gc structures. This exposes several real bugs (ie. not just the libxl_free() something that was allocated via malloc variety). Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* libxl: consistently use typedef struct {} libxl_$typeIan Campbell2010-07-281-12/+12
| | | | | | | | typedef struct seems to be the dominant idiom in the mixture currently in use. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: add libxl_strdup convenience functionIan Jackson2010-07-141-1/+11
| | | | | | Use in preference to libxl_sprintf(..., "%s", "...") Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Use the caller's logger (xentoollog)Keir Fraser2010-05-281-27/+19
| | | | | | | | | | We now require callers to provide a xentoollog_logger* for libxl_ctx_init, and use that for all our own logging and also for xc_interface_open. Corresponding change to xl.c. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: make use of libxl path functionsKeir Fraser2010-05-061-0/+8
| | | | | | | Make use of the new libxl_*_path functions to specify the correct absolute path of qemu-dm, hvmloader and ioemu-stubdom.gz. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* libxl: Make logging functions preserve errnoKeir Fraser2010-04-121-1/+4
| | | | | | | | This is needed by the following patches. It makes it much more convenient for libxl functions to return the errno value from the failure, when they fail. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxenlight: remove all cloning logic.Keir Fraser2010-01-081-22/+3
| | | | | | | replace by simpler xl ctx init/free calls. also don't segfault if there's no callback for log. Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
* libxenlight: fix GC when cloning contextsKeir Fraser2009-12-041-0/+22
| | | | | | | | | | Provide a function to clone a context. This is necessary because simply copying the structs will eventually corrup the GC: maxsize is updated in the cloned context but not in the originating, yet they have the same array of referenced pointers alloc_ptrs. Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
* libxenlight: correct broken osdeps.[ch] and make #includes consistentKeir Fraser2009-11-231-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | osdeps.[hc] previously mistakenly declared and defined [v]asprintf. These functions are available in the libc on most platforms. Also, osdeps.h is used by xc.c but xc.c is not part of the library, so osdeps.h is part of the public interface and should have a better name. So now, instead: * osdeps.h is libxl_osdeps.h. * _GNU_SOURCE is #defined in libxl_osdeps.h so that we get the system [v]asprintf (and various other functions) * libxl_osdeps.h is included first in every libxl*.c file (it needs to be before any system headers so that _GNU_SOURCE) takes effect. * osdeps.[hc] only provide their own reimplementation of [v]asprintf if NEED_OWN_ASPRINTF is defined. Currently it is not ever defined but this is provided for any platform which needs it. * While I was editing the #includes in each .c file, I put them all into the same order: "libxl_osdeps.h", then system headers, then local headers. * xs.h is included in libxl.h. This is needed for "bool"; it has to not be typedefed in libxl.h because otherwise we get a duplicate definition when including xs.h. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxenlight: Clean up logging arrangementsKeir Fraser2009-11-231-6/+33
| | | | | | | | | | | | | | | | | | | | * Introduce new variants of the logging functions which include errno values (converted using strerror) in the messages passed to the application's logging callback. * Use the new errno-including logging functions everywhere where appropriate. In general, xc_... functions return errno values or 0; xs_... functions return 0 or -1 (or some such) setting errno. * When libxl_xs_get_dompath fails, do not treat it as an allocation error. It isn't: it usually means xenstored failed. * Remove many spurious \n's from log messages. (The applications log callback is expected to add a \n if it wants to do that, so libxl's logging functions should be passed strings without \n.) Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxenlight: initial libxenlight implementation under tools/libxlKeir Fraser2009-11-091-0/+159
Signed-off-by: Vincent Hanquez <Vincent.Hanquez@eu.citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>