aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_bootloader.c
Commit message (Collapse)AuthorAgeFilesLines
* libxl: fix libxl_string_list_length and its only callerMatthew Daley2013-09-251-1/+1
| | | | | | | | | | | | | | | | The wrong amount of indirections were being taken in libxl_string_list_length, and its only caller was miscounting the amount of initial non-list arguments, seemingly since the initial commit (599c784). This has been seen and reported in the wild (##xen): < Trixboxer> Hi, any idea why would I get < Trixboxer> xl: libxl_bootloader.c:42: bootloader_arg: Assertion `bl->nargs < bl->argsspace' failed. < Trixboxer> 4.2.2-23.el6 Coverity-ID: 1054954 Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* fix wrong path while calling pygrub and libxl-save-helperBamvor Jian Zhang2013-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | in current xen x86_64, the default libexec directory is /usr/lib/xen/bin, while the private binder is /usr/lib64/xen/bin. but some commands(pygrub, libxl-save-helper) located in private binder directory is called from libexec directory which lead to the following error: 1, for pygrub bootloader: libxl: debug: libxl_bootloader.c:429:bootloader_disk_attached_cb: /usr/lib/xen/bin/pygrub doesn't exist, falling back to config path 2, for libxl-save-helper: libxl: cannot execute /usr/lib/xen/bin/libxl-save-helper: No such file or directory libxl: error: libxl_utils.c:363:libxl_read_exactly: file/stream truncated reading ipc msg header from domain 3 save/restore helper stdout pipe libxl: error: libxl_exec.c:118:libxl_report_child_exitstatus: domain 3 save/restore helper [10222] exited with error status 255 there are two ways to fix above error. the first one is make such command store in the /usr/lib/xen/bin and /usr/lib64/xen/bin(symbol link to previous), e.g. qemu-dm. The second way is using private binder dir instead of libexec dir. e.g. xenconsole. For these cases, the latter one is suitable. Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: do not blunder on if bootloader fails (again)Ian Jackson2012-08-031-2/+9
| | | | | | | | | | | | | Do not lose the rc value passed to bootloader_callback. Do not lose the rc value from the bl when the local disk detach succeeds. While we're here rationalise the use of bl->rc to make things clearer. Set it to zero at the start and always update it conditionally; copy it into bootloader_callback's argument each time. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: react correctly to bootloader pty master POLLHUPIan Jackson2012-08-031-10/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | Receive POLLHUP on the bootloader master pty is not an error. Hopefully it means that the bootloader has exited and therefore the pty slave side has no process group any more. (At least NetBSD indicates POLLHUP on the master in this case.) So send the bootloader SIGTERM; if it has already exited then this has no effect (except that on some versions of NetBSD it erroneously returns ESRCH and we print a harmless warning) and we will then collect the bootloader's exit status and be satisfied. However, we remember that we have done this so that if we got POLLHUP for some other reason than that the bootloader exited we report something resembling a useful message. In order to implement this we need to provide a way for users of datacopier to handle POLLHUP rather than treating it as fatal. We rename bootloader_abort to bootloader_stop since it now no longer only applies to error situations. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: convert libxl__device_disk_local_attach to an async opRoger Pau Monne2012-07-261-14/+59
| | | | | | | | | | | | | | This will be needed in future patches, when libxl__device_disk_add becomes async also. Create a new status structure that defines the local attach of a disk device and use it in libxl__device_disk_local_attach. This is done in this patch to split the changes introduced when libxl__device_disk_add becomes async. 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>
* xl/libxl: add a blkdev_start parameterStefano Stabellini2012-05-291-1/+2
| | | | | | | | | | | | | | | | Introduce a blkdev_start in xl.conf and a corresponding string in libxl_domain_build_info. Add a blkdev_start parameter to libxl__device_disk_local_attach: it is going to be used in a following patch. blkdev_start specifies the first block device to be used for temporary block device allocations by the toolstack. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: libxl__device_disk_local_attach return a new libxl_device_diskStefano Stabellini2012-05-291-2/+2
| | | | | | | | | | | | | Introduce a new libxl_device_disk* parameter to libxl__device_disk_local_attach, the parameter is allocated by the caller. libxl__device_disk_local_attach is going to fill the new disk with informations about the new locally attached disk. The new libxl_device_disk should be passed to libxl__device_disk_local_detach afterwards. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: make libxl_device_disk_local_attach/detach internal functionsStefano Stabellini2012-05-291-2/+2
| | | | | | | Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: do not overwrite user supplied config when running bootloaderIan Campbell2012-05-291-58/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: pass env vars to libxl__execRoger Pau Monne2012-05-231-2/+2
| | | | | | | | | Add another parameter to libxl__exec call that contains the environment variables to use when performing the execvp call. 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: avoid double free of b_info->u.pv.bootloaderIan Campbell2012-05-181-2/+4
| | | | | | | | | | b_info is a user provided struct and therefore the content must come from malloc and not gc such that libxl_domain_build_info_dispose can free it. This was broken by 25340:373f24c87dee. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Warn that /usr/bin/pygrub is deprecatedGeorge Dunlap2012-05-151-0/+4
| | | | | | Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Look for bootloader in libexec pathGeorge Dunlap2012-05-151-0/+20
| | | | | | | | | If the full path for a bootloader (such as pygrub or xenpvnetboot) is not given, check for it first in the libexec path before falling back to the PATH variable. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: abort bootloader invocation when domain diesIan Jackson2012-05-111-10/+33
| | | | | | | | | | | | | | | | | | | | Cancel the bootloader (specifically, by sending it a signal) if the domain is seen to disappear from xenstore. We use a new utility event source libxl__domaindeathcheck which provides a convenient wrapper for the xenstore watch. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v8: * Fixed the commit message summary line. Changes since v7: * Add a comment explaining why we use a watch on the domain's xenstore path rather than @releaseDomain. * Fix typo in error message. Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: convert console callback to libxl_asyncprogress_howIan Jackson2012-05-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | Remove the old console callback. (Its reentrancy properties were troublesome: in principle, the event loop might be reentered during the callback, and the libxl__domain_create_state swept out from under the feet of the domain creation.) As a side effect of the new code arrangements, the console callback for non-bootloader-using PV guests now occurs near the end of domain creation, in the same place as for HVM guests, rather than near the start. The new arrangements should in principle mean that by the time the console is described as ready by the callback, the xenstore key is indeed ready. So in the future the timeout might be removed from the console client. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: log bootloader outputIan Jackson2012-05-111-0/+24
| | | | | | | | | | | | This involves adding a new log feature to libxl__datacopier, and then using it. If the bootloader exits nonzero we print the log filename in a log message from libxl. 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: ao: Convert libxl_run_bootloaderIan Jackson2012-05-111-340/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert libxl_run_bootloader to an ao_how-taking function. It's implemented in terms of libxl__bootloader_run, which can be used internally. The resulting code is pretty much a rewrite. Significant changes include: - We direct the bootloader's results to a file, not a pipe. This makes it simpler to deal with as we don't have to read it concurrently along with everything else. - We now issue a warning if we find unexpected statements in the bootloader results. - The arrangements for buffering of bootloader input and output are completely changed. Now we have a fixed limit of 64k on output, and 4k on input, and discard the oldest data when this overflows (which it shouldn't). There is no timeout any more. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v6: * Use libxl__ev_child_inuse rather than testing pid directly. * Fix a code style error. * Properly initialise the sub-operations' aos in _init. * Bugfixes. Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* autoconf: New test for openpty et al.Ian Jackson2012-05-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | We may need to #include <libutil.h>, and/or link with -lutil, to use openpty, login_tty, and the like. Provide INCLUDE_LIBUTIL_H (preprocessor constant, not always defined) and PTYFUNCS_LIBS (makefile variable). We link libxl against PTYFUNCS_LIBS (which comes from autoconf) rather than UTIL_LIBS, and #include <libutil.h> where appropriate. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v7: * Actually include the call to AX_CHECK_PTYFUNCS in this patch, not the previous one, and regenerate configure accordingly. Changes since v6: * Put failure macro call in correct place so it might actually happen. * Try both with -lutil and without. * Patch now contains update for config.h.in. Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: make boolean members of libxl_domain_build_info into libxl_defboolIan Campbell2012-03-011-0/+3
| | | | | | | | | This allows them to be set via the _init/_setdefault methods. This just covers the obvious ones. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: provide _init and _setdefault for libxl_domain_build_info.Ian Campbell2012-03-011-0/+3
| | | | | | | Some fields require further scaffolding before they can use the _init/_setdefault scheme and are handled in later patches. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: fix bootloader args settingZhigang Wang2012-02-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | When bootloader_args = ['foo', 'bar'], then info->u.pv.bootloader_args = foo\0 bar\0 \0 Before this patch, 'p++' points to the next character of 'foo\0' and never comes to 'bar\0' (because of the '\0' in 'foo\0'), so the args will be: args[0] = 'oo\0' args[1] = 'o\0' After this patch, 'p++' points to the next string of pv.bootloader_args, so we get the correct args: args[0] = 'foo\0' args[1] = 'bar\0' Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com> 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-6/+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: Use GC_INIT and GC_FREE everywhereIan Jackson2011-12-121-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | Replace libxl__gc gc = LIBXL_INIT_GC(ctx); ... libxl__free_all(&gc); with GC_INIT(ctx); ... GC_FREE; throughout with a couple of perl runes. We must then adjust uses of the resulting gc for pointerness, which is mostly just replacing all occurrences of "&gc" with "gc". Also a couple of unusual uses of LIBXL_INIT_GC needed to be fixed up by hand. Here are those runes: perl -i -pe 's/\Q libxl__gc gc = LIBXL_INIT_GC(ctx);/ GC_INIT(ctx);/' tools/libxl/*.c perl -i -pe 's/\Q libxl__free_all(&gc);/ GC_FREE;/' tools/libxl/*.c 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: make bootloader_args a listIan Campbell2011-11-291-7/+3
| | | | | | | | | | This is much more natural. Continue to support the old syntax in xl but deprecate it. [ Fixed up a long line in xl_cmdimpl.c. -iwj ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: reimplement buffer for bootloading and drop data if buffer is full.Roger Pau Monne2011-11-021-14/+48
| | | | | | | | | | Implement a buffer for the bootloading process that appends data to the end until it's full. Drop the whole buffer if a timeout has occurred and the buffer is full. Prevents the bootloader from getting stuck when using ptys with small buffers. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fixup incorrect indentationIan Campbell2011-10-121-0/+7
| | | | | | | | | 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-5/+5
| | | | | | | | | 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-5/+5
| | | | | | | | | | | | | | | 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: specify HVM vs PV in build_info using libxl_domain_type enumIan Campbell2011-07-181-1/+1
| | | | | | | | | | Also caught one place (in libxl__domain_restore_common) which used info->u.hvm.pae even if !hvm. (fortunately the value was unused in xc_domain_restore). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: don't close file descriptors 4..255 in libxl__execIan Campbell2011-05-241-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It prevents callers from deliberately passing file descriptors to the child, hides any callers who erroneously do so and doesn't deal with all file descriptors in any case. Rather than remove it all together replace it with some debug code which checks for open file handles which do not have either O_CLOEXEC or FD_CLOEXEC set. To enable the debug set _LIBXL_DEBUG_EXEC_FDS=1 to print any open and non-CLOEXEC non-stdio FDs just before libxl__exec actualy calls exec. Set _LIBXL_DEBUG_EXEC_FDS=2 to abort if any of these exist. On the basis of this debugging fix some leaked filehandles: * The read end of the pipe used to wake the parent from the intermediate process during libxl__spawn_spawn was leaked into the intermediate process. * The file descriptor representing the xl lock was not marked O_CLOEXEC (the lock itself is already specified to not be inherited across a fork). * The file descriptors passed to libxl__exec to be dup'd as std{in,out,err} were leaked at their original number. They are harmless (an attacker can just as easily use fd 0..2) but close anyway since it removes a case which a person evaluating open fd's needs to consider. * libxl_run_bootloader was leaking the xenconsole pty master into the bootloader child process. * If the bootloader fails to get as far as opening its end of the FIFO then we can also hang, check that the process has not exited as part of that loop. (we actually block opening the FIFO too so this is only a partial fix for the case where the bootlader has crashed quickly). With these fixes I have tested that device models, bootloaders (pygrub) and vncviewers which are spawned via libxl__exec with no unexpected file descriptors open, at least in my configuration. 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>
* tools: libxl: hide selection of hvmloader by default.Ian Campbell2011-04-191-6/+7
| | | | | | | | | | | | | | | | | | | | | | | This should never have been exposed to users as something they are required to think about, unless they want to. At the libxl API level: * Move libxl_domain_build_info.kernel into the PV side of the tagged union (using this field to specify both PV kernel and hvmloader is confusing) * Add hvmloader (a string) to the HVM side of the tagged union. This defaults to NULL and libxl will DTRT with that default but still allow libxl users to specify something explicit if they want. At the xl level: * WARN if an HVM guest cfg uses the "kernel" config option, and direct users to the "hvmloader_override" option if they really do not want the default hvmloader. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: Make all hidden/static functions take a gc not a ctxIan Campbell2011-03-151-2/+2
| | | | | | | | | | | | | | | | 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>
* Fix copy and paste bug in libxl_run_bootloaderChristoph Egger2010-10-051-1/+1
| | | | | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* libxl: fix compiler warning with fork_exec_bootloaderAndre Przywara2010-09-161-2/+2
| | | | | | | | | | | At least one of my compilers complains about the broken const qualifier in the fork_exec_bootloader() call (despite the cast). Fix this properly by propagating the const attribute down the call stack. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Use libxl__ namespace for internal typesIan Campbell2010-09-081-3/+3
| | | | | | | | | | | | | | 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 (autogenerated patch)Ian Campbell2010-09-081-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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+xend: use correct paths for PV console when running bootloaderIan Campbell2010-09-071-1/+1
| | | | | | | | | Makes "{xl,xm} create -c GUEST" work again with pygrub in interactive mode which was broken by 21994:2e08ec0028e4 Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: do not leak path to dom0 attached disk after running bootloaderIan Campbell2010-08-241-5/+7
| | | | | 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-2/+2
| | | | | | | | | | | | | 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>
* xl: Implement per-API-call garbage-collection lifetimeGianni Tedesco2010-08-121-42/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libxl: Portability fixes for pty handling, in libxl_osdeps.hChristoph Egger2010-07-291-1/+1
| | | | | | | | | | | | | This is the same approach used in tools/console, although we have a separate instance of it as it is difficult to share code between these two places. Also add a missing include of <termios.h>, and fix a literal use of -lutil to refer to UTIL_LIBS. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: consistently use typedef struct {} libxl_$typeIan Campbell2010-07-281-4/+4
| | | | | | | | 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>
* tools/libxl: Revert broken NetBSD portability patchesIan Jackson2010-07-231-8/+1
| | | | | | | | | Revert df9d8319bd37 Fix blktap2 NetBSD build and also revert broken change e76befc7fe2d portability fixes from tools/console 24277e3237ca Fix linking error when creating the xl binary. Now it builds again.
* Attached patch takes over some portability fixes from tools/consoleStefano Stabellini2010-07-201-1/+8
| | | | | | | | | to make libxl build on NetBSD. blktapctl is build on Linux only. This will be another patch to finally unbreak libxl. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* make libxl build since 21811Stefano Stabellini2010-07-191-2/+2
| | | | | | | | | First hunk, I assume is getting the arguments in wrong order on memset. Second hunk is to kill a compiler warning about mis-use of printf-style format strings which kills the build on -Werror. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
* libxl, xl: support running bootloader (e.g. pygrub) in domain 0Ian Jackson2010-07-141-0/+449
Much of the bootloader interaction (including the Solaris and NetBSD portability bits) are translated pretty much directly from the python in tools/python/xen/xend/XendBootloader.py Signed-off-by: Ian Campbell <ian.campbell@citrix.com>