aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/xl.c
Commit message (Collapse)AuthorAgeFilesLines
* libxl: add option to choose who executes hotplug scriptsRoger Pau Monne2012-07-261-0/+4
| | | | | | | | | | | | | | | | | 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>
* xl: Clarify 'xend is running' error messageGeorge Dunlap2012-06-291-3/+3
| | | | | | | | | | * Give reason for check (unpredictable results) * Give a better recommendation (shut down xend) * Make it clear that -f is overriding a safety check. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: remove lockdir and config dir from the APIIan Campbell2012-05-291-17/+9
| | | | | | | | | | | | These are only used by xl. Rename _libxl_paths.h -> _paths.h, these are not actually "libxl" paths but rather are part of the Xen build time configuration. It is fine for xl to also consume them. 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>
* xl/libxl: add a blkdev_start parameterStefano Stabellini2012-05-291-0/+3
| | | | | | | | | | | | | | | | 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>
* xl: track child processes for the benefit of libxlIan Jackson2012-05-291-13/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each time xl forks, it needs to record the pid, so that its exit status can be preserved if it happens that libxl's event loop reaped it. Consequently we also have a new wrapper for waitpid, which in that case returns the previously-reaped status. When we get a console ready callback from libxl, check to see if we have spawned but not reaped a previous console client, and if so reap it now. (This is necessary to prevent improper use of the xlchild struct, but has the happy consequence of checking the exit status of the first console client in the pygrub case.) Refactor the two calls to libxl_ctx_alloc into a new function xl_ctx_alloc which also sets the child reaped handler callback. All of this has the effect of suppressing a message unknown child [nnnn] unexpected exited status zero which would sometimes (depending on a race) appear with `xl create -c' and pygrub. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Reported-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Cc: Roger Pau Monne <roger.pau@citrix.com> [ ijc -- corrected return codes in xl_reaped_callback to match documented convention. ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: prevent xl from doing operations on domains if xend is runningRoger Pau Monne2012-05-141-1/+21
| | | | | | | | | Prevent xl from doing any operation if xend daemon is running. That prevents bugs that happened when xl and xend raced to close a domain. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: child processes cleanupsIan Jackson2012-05-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Abolish libxl_fork. Its only callers were in xl. Its functionality is now moved elsewhere, as follows: * The "logging version of fork", which is what it was billed as, is now xl_fork, which also dies on failure. * Closing the xenstore handle in the child is now done in libxl__ev_child_fork, which is the only remaining place where fork is called in libxl. * We provide a new function libxl__ev_child_xenstore_reopen for in-libxl children to make the ctx useable for xenstore again. * Consequently libxl__spawn_record_pid now no longer needs to mess about with its own xenstore handle. As a bonus it can now just use libxl__xs_write. Also, since we have now converted all the forkers in libxl, we can always honour the fork_replacement childproc hook - so do so. 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: Protect fds with CLOEXEC even with forking threadsIan Jackson2012-04-111-0/+3
| | | | | | | | | | | | | | | | | | | We introduce a new "carefd" concept, which relates to fds that we care about not being inherited by long-lived children. As yet we do not use this anywhere in libxl. Until all locations in libxl which make such fds are converted, libxl__postfork may not work entirely properly. If these locations do not use O_CLOEXEC (or use calls for which there is no O_CLOEXEC) then multithreaded programs may not work properly. This introduces a new API call libxl_postfork_child_noexec which must be called by applications which make long-running non-execing children. Add the appropriate call to xl's postfork function. 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: abolish libxl_ctx_postforkIan Jackson2012-04-111-0/+8
| | | | | | | | | | | | | libxl's task has become too complicated (particularly in the presence of both forking and multithreading) to support reuse of the same libxl_ctx after fork. So abolish libxl_ctx_fork. xl instead simply initialises a new libxl_ctx. 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: do not include xenctrl.hIan Campbell2012-03-271-1/+0
| | | | | | | | Toolstacks which use libxl should not need to use libxc. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: Add defaultbridge config option for xl.confStefan Bader2012-02-131-0/+4
| | | | | | | | | | | | | | Currently guests created with the xl stack will have "xenbr0" written as their default into xenstore. It can be changed in the individual guest config files, but there is no way to have that default globally changed. Add a config option to xl.conf that allows to have a different default bridge name. Signed-off-by: Stefan Bader <stefan.bader@canonical.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: use json output by defaultIan Campbell2012-02-071-0/+10
| | | | | | | | | | | | | | | | | | | | | Move the sxp producing code off into a separate file. It is supported for legacy reasons and needn't be updated other than the improve compatibility with xm. libxl_domain_config is not currently generated by the IDL (adding the necessary support for Array types is on my to do list) so hand code the json generation function for now. Since this rather directly exposes a libxl data structure it's not clear what sort of forward compatibility guarantees we can make. However it seems like it should be as stable as libxl's own API (which we are looking to stabilise) (Gratuitous string.h include needed for memset in libxl_util.h) 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>
* xl: fix a couple of memory leaksIan Jackson2012-01-271-0/+1
| | | | | | | | | | | * dolog leaked the log message (!) * main() leaked the config_data (perhaps a false positive from valgrind, but it's nicer to tidy it up). 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>
* xlu: add "dont_warn" to xlu_cfg_*Ian Campbell2011-11-291-3/+3
| | | | | | | | I want it for get_long but we might as well have it everywhere. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: add a flags argument to libxl_ctx_alloc.Ian Campbell2011-10-181-1/+1
| | | | | | | | | Currently unused but gives us scope for expansion in an ABI compatible manner in the future. 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: 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: clean up trailing whitespaces in code.Wei Liu2011-07-191-1/+1
| | | | | | | | | Commit exactly the results of running find \! -iname '*.txt' -type f -print0 | xargs -0 perl -p -i.bak -E 's/\s+\n/\n/' Signed-off-by: Wei Liu <liuw@liuw.name> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: new global -N option for dry runIan Jackson2011-06-281-4/+13
| | | | | | | | | | This sets a global dryrun_only variable, which individual commands are expected to honour. To avoid accidents, we introduce a new can_dryrun member in the command table, which is initially set to 0 for each command. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: do not expose libxenctrl/libxenstore headers via libxl.hIan Campbell2011-04-061-3/+4
| | | | | | | | | | | | This completely removes libxenstore from libxl users' view. xl still needs libxenctrl directly due to the direct use of the xentoollog functionality but it is not exposed to the indirect linkage anymore. 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/xl: enable support for routed network configurations.Ian Campbell2011-02-181-0/+4
| | | | | | | | | | | | | Add "vifscript" option to xl.conf which configures the default vif script to use (default remains "vif-bridge") Write each VIFs "ip" option to xenstore so the vif-route script can pick it up. Reported-by: W. Michael Petullo <mike@flyn.org>. 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>
* xl: free memory before building a domainStefano Stabellini2010-09-221-0/+12
| | | | | | | | | | | Free the needed amount of memory before proceeding with the domain build. Use a filelock to prevent other xl instances from conflicting during this operation. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: add a global configuration fileStefano Stabellini2010-09-221-0/+46
| | | | | | | | | | Add a global configuration file: /etc/xen/xl.conf; the only option currently parsed is autoballoon that is 1 by default. [fixed up for conflicts with libxl__ naming policy changes -iwj] Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: randomly generate UUIDsGianni Tedesco2010-09-021-2/+0
| | | | | | | | | | | | | This patch converts xl to randomly generate UUID's rather than using a dodgy time-seeded PRNG. I have ignored various suggestions so far on auto-generation of MAC addresses and left it as a topic for a future patch to solve. In other words the behaviour stays the same it's just using a true random source. This patch also implements the "uuid" config file parameter in xl. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Acked-By: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: treat sub-command main function like a regular C main() functionIan Campbell2010-08-241-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | Currently xl passes the entire argc+argv to each subcommand and relies on the preservation of the global optind variable to ensure that the subcommand correctly handles argument parsing (e.g. accounting for "xl [command]" vs "xl -v [command]"). This requirement for individual sub-commands to parse arguments relative to optind is subtle and prone to being forgotten (or simply not expected). Several sub-commands have recently been broken in this way (now fixed). Therefore arrange that the argv+argc passed to the sub-commands looks like you would expect for a regular C main function and includes argv[0] equal to the command name with command specific arguments in argv[1] onwards. Since all sub-commands (currently) correctly obey the optind it is sufficient to reset it to 1 (as described in getopt(3)) in order to not break the sub-commands' own argument parsing. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: disable xc_ptrace on x86 LinuxIan Campbell2010-08-131-1/+1
| | | | | | | | | | | It has been unused since 21732:eb34666befcc. Removing the include of sys/ptrace.h and threaddb.h exposed a few places which were using time(2) or gettimeofday(2) without including time.h or sys/time.h respectively and were relying on an include. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: destroy the logger before exitIan Campbell2010-07-301-0/+1
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: free the libxl context before exitIan Campbell2010-07-301-3/+8
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: tidy up around global '-v' optionKeir Fraser2010-06-181-1/+1
| | | | Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* xl: allow truncation of xl subcommandsKeir Fraser2010-06-181-14/+11
| | | | | | for those of us who are used to typing "xm cr foo" Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* xl: fix 'xl help' commandKeir Fraser2010-06-071-1/+1
| | | | | | | | xl help 'command' should give the help of the 'command', but current it does not, it just gives a full list of xl supported commands. This patch fix it. Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
* xl: Allow control of logging level.Keir Fraser2010-05-281-12/+28
| | | | | | | The -v option, which must come before the xl command, increases the logging level each time it is supplied. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Use the caller's logger (xentoollog)Keir Fraser2010-05-281-15/+3
| | | | | | | | | | 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>
* xl: Move "extern" declarations to xl.hKeir Fraser2010-05-281-3/+0
| | | | | | | Declarations (as opposed to definitions) of external objects should not appear in .c files. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl: Combine headers into one header file.Keir Fraser2010-05-281-2/+1
| | | | | | | This provides a single place to put declarations of external symbols etc. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: Check return codes of write/asprintf/daemon consistently.Keir Fraser2010-05-131-3/+7
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* xl: Use command table to store command name and implementationKeir Fraser2010-05-041-55/+19
| | | | Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
* xl: Move xl command implementation to a seperate fileKeir Fraser2010-05-041-2831/+3
| | | | Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
* xl: Add subcommand "xl sched-credit"Keir Fraser2010-05-041-0/+114
| | | | | Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* xl: Add option '-p' for command 'xl create'Keir Fraser2010-04-261-3/+7
| | | | | | | | Add option '-p' for command 'xl create', and update the help info. * -p Leave the domain paused after it is created. Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
* xl: Fix segment fault of 'xl list'Keir Fraser2010-04-261-1/+1
| | | | | | If libxl_list_domain() returns NULL, segment fault occurs now. Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
* xl: support oos domain parameterKeir Fraser2010-04-231-0/+5
| | | | | Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com> Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
* xl: add "xl info" commandKeir Fraser2010-04-221-0/+114
| | | | | | | | | | The info subcommand was missing from the xl tool. Use the new libxl wrapper functions to create a clone of "xm info". The splitting into several smaller functions is enspired by the implementation in XendNode.py. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
* libxl: <sys/signal.h> -> <signal.h>Keir Fraser2010-04-131-1/+1
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* libxl: build fix for netbsdKeir Fraser2010-04-131-0/+1
| | | | | | <sys/signal.h> is needed to get definition for SIGPIPE and SIG_IGN. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* xl: Migration supportKeir Fraser2010-04-121-68/+558
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement "xl migrate". ssh is used as the transport by default, although this can be overridden by specifying a different sshcommand. This is a very standard approach nowadays and avoids the need for daemons at the target host in the default configuration, while providing flexibility to admins. (In the future it might be nice to support plain unencrypted migration over TCP, which we do not rule out now, although it is not currently implemented.) Properties of the migration protocol: * The domain on the target machine is named "<domname>--incoming" while it is being transferred. * The domain on the source machine is renamed "<domain>--migratedaway" before we give the target permission to rename and unpause. * The locking in libxl_domain_rename ensures that of two simultaneous migration attempts no more than one will succeed. * We go to some considerable effort to avoid leaving the domain in a bad state if something goes wrong with one of the ends or the network, although there is still (inevitably) a possibility of a unresolvable state (in case of very badly timed network failure) which is probably best resolved by destroying the domain at both ends. Incidental changes: create_domain now returns a libxl error code rather than exiting on error. New ERROR_BADFAIL error code for reporting unpleasant failures. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl: Domain creation logging fixesKeir Fraser2010-04-121-5/+45
| | | | | | | | | | | | | | | | | | | | | | * Make create_domain always return to caller * Have create_domain set its log callback sooner * Actually write things to logfile, and some error checking With some combinations of options, create_domain would never return to the caller, since it would have called daemon and will later exit. So we fork an additional time, so that we can call daemon in the child and also return to the caller in the parent. It's a shame that there's no version of daemon(3) that allows us to do this without the extra code and pointless extra fork. daemon(0,0) closes all the fds. So we need to call daemon(0,1) and organise detaching our stdin/out/err ourselves. Doing this makes messages actually appear in the xl logfile in /var/log/xen. Finally, make create_domain call libxl_ctx_set_log sooner. This makes some lost messages appear. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl: New savefile format. Save domain config when saving a domain.Keir Fraser2010-04-121-23/+230
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We introduce a new format for saved domains. The new format, in contrast to the old: * Has a magic number which can distinguish it from other kinds of file * Is extensible * Can contains the domain configuration file On domain creation we remember the actual config file used (using the toolstack data feature of libxl, just introduced), and by default save it to the save file. However, options are provided for the following: * When saving a domain, supplying an alternative config file to store in the savefile. * When restoring a domain, supplying an alternative config file. If a domain is restored with a different config file, it is the responsibility of the xl user to ensure that the two configs are "compatible". Changing the targets of virtual devices is supported; changing other features of the domain is not recommended. Bad changes may lead to undefined behaviour in the domain, and are in practice likely to cause resume failures or crashes. Old format save files generated by old versions of xl are not supported. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl,xl: Fix two minor bugs in domain destructionKeir Fraser2010-04-121-1/+3
| | | | | | | | | | * If /local/domain/<domid>/device does not exist, this is not necessarily an error. It probably means the domain has been partially destroyed already. * Have xl report errors from libxl_domain_destroy. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl: Remove some duplicated boilerplate. (Improves logging slightly.)Keir Fraser2010-04-121-198/+57
| | | | | | | | | | | | | | | | | We remove six lines of boilerplate from the top of each function, and instead have a single struct libxl_ctx which is initialised once at the top of main. Likewise we wrap domain_qualifier_to_domid in a new function find_domain, which does the error handling, and stores the domid and the specified name (if applicable). This reduces the size of xl.c by 7% (!) As a beneficial side effect, the earlier call to libxl_ctx_set_log in main makes some lost messages appear. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* xl, libxl: xl list -v shows the uuid tooKeir Fraser2010-04-121-6/+14
| | | | | | | | | | Break uuid to string conversion (including logging) out into a new function libxl_uuid2string for reuse, and expose it for the convenience of callers. Provide a new -v option to xl list which shows the domain's uuid. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>