aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl.c
Commit message (Collapse)AuthorAgeFilesLines
...
* libxl: convert libxl_device_nic_add to an async operationRoger Pau Monne2012-07-261-8/+21
| | | | | | | | | | | | | | | | | | | | This patch converts libxl_device_nic_add to an ao operation that waits for device backend to reach state XenbusStateInitWait and then marks the operation as completed. This is not really useful now, but will be used by latter patches that will launch hotplug scripts after we reached the desired xenbus state. Calls to libxl_device_nic_add have also been moved to occur after the device model has been launched, so when hotplug scripts are called from this functions the interfaces already exists. As usual, libxl_device_nic_add callers have been modified, and the internal function libxl__device_disk_add has been used if the call was inside an already running ao. 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: convert libxl_device_disk_add to an async opRoger Pau Monne2012-07-261-37/+102
| | | | | | | | | | | | | | | | | | This patch converts libxl_device_disk_add to an ao operation that waits for device backend to reach state XenbusStateInitWait and then marks the operation as completed. This is not really useful now, but will be used by later patches that will launch hotplug scripts after we reached the desired xenbus state. As usual, libxl_device_disk_add callers have been modified, and the internal function libxl__device_disk_add has been used if the call was inside an already running ao. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> [ ijc -- drop hunk modifying libxl_cdrom_insert which is not needed after 25670:3666e9712eaf "libxl: make libxl_cdrom_insert async" ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: convert libxl__device_disk_local_attach to an async opRoger Pau Monne2012-07-261-23/+75
| | | | | | | | | | | | | | 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>
* libxl: refactor disk addition to take a helperRoger Pau Monne2012-07-261-123/+147
| | | | | | | | | | | | | Change libxl__device_disk_add to no longer take a xs transaction and instead pass a helper for the local attach case that's used to get the free vdev. This function contains some non-functional changes due to an indentation change. 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: make libxl_cdrom_insert async.Ian Campbell2012-07-261-16/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This functionality is a bit of a mess and several configurations are not properly supported. The protocol for changing is basically to change the params node in the disk xenstore backend. There is no interlock or error reporting in this protocol. Completely removing the device and recreating it is not necessary nor expected. For reference the equivalent xend code is tools/python/xen/xend/server/blkif.py::BlkifController::reconfigureDevice(). Device model stub domains are not supported. There appears to be no way correctly to do a media change on the emulated device while also changing the stub domains PV backend to point to the new backend. Reworking this is a significant task deferred until 4.3. xend (via the equivalent "xm block-configure" functionality) also does not support media change for stub domains (confirmed by code inspection and experiment). Unlike xend this version errors out instead of silently not achieving anything in this case. There is no support for qemu-xen (upstream) media change. I expect this is supported on the qemu side and required QMP plumbing on the libxl side. Again this is deferred until 4.3. On the plus side the current implementation is trivially "asynchronous". Adds a libxl__xs_writev_atonce helper to write a key-value list to xenstore in one go. Tested with Windows 7. 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: rename _IOEMU nic type to VIF_IOEMURoger Pau Monne2012-07-261-3/+3
| | | | | | | | | This change will avoid the confusion caused by the fact that IOEMU means both PV and TAP network interfaces. 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_domain_sched_params_set case for ARINC 653 schedulerAndrew Kane2012-07-251-0/+11
| | | | | | | | | | Implements sched_arinc653_domain_set to match the existing API. Currently, there is no domain-specific configuration when using the ARINC 653 scheduler, so we simply return success. Signed-off-by: Andrew Kane <Andrew.Kane@dornerworks.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: refuse to try and migrate an HVM guest using qemu-xenIan Campbell2012-07-251-0/+17
| | | | | | | | | libxl/qemu-upstream currently do not collude together to enable log-dirty mode and therefore migrations are unsafe. Refuse to even try for now. 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: rename stubdomain when renaming domain.Ian Campbell2012-07-231-0/+19
| | | | | | | | | | | | | | Otherwise after a localhost migrate of an HVM domain with a stubdomain we end up with domains called "FOO" and "FOO--incoming-dm". This because we initially create the domains as "FOO--incoming" and then rename to "FOO" inorder to maintain the uniqueness of domain names on a host. In this state a second attempt to migrate will fail upon attempting to create a new domain named "FOO--incoming-dm" 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: convert libxl_domain_destroy to an async opRoger Pau Monne2012-07-231-8/+168
| | | | | | | | | | | | | | | | | | | | | This change introduces some new structures, and breaks the mutual dependency that libxl_domain_destroy and libxl__destroy_device_model had. This is done by checking if the domid passed to libxl_domain_destroy has a stubdom, and then having the bulk of the destroy machinery in a separate function (libxl__destroy_domid) that doesn't check for stubdom presence, since we check for it in the upper level function. The reason behind this change is the need to use structures for ao operations, and it was impossible to have two different self-referencing structs. All uses of libxl_domain_destroy have been changed, and either replaced by the new libxl_domain_destroy ao function or by the internal libxl__domain_destroy that can be used inside an already running ao. 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: change ao_device_remove to ao_deviceRoger Pau Monne2012-07-231-143/+86
| | | | | | | | | | | | Introduce a new structure to track state of device backends, that will be used in following patches on this series. This structure if used for both device creation and device destruction and removes libxl__ao_device_remove. 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: rename libxl_cpumap to libxl_bitmapDario Faggioli2012-07-061-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | And leave to the caller the burden of knowing and remembering what kind of bitmap each instance of libxl_bitmap is. This is basically just some s/libxl_cpumap/libxl_bitmap/ (and some other related interface name substitution, e.g., libxl_for_each_cpu) in a bunch of files, with no real functional change involved. A specific allocation helper is introduced, besides libxl_bitmap_alloc(). It is called libxl_cpu_bitmap_alloc() and is meant at substituting the old libxl_cpumap_alloc(). It is just something easier to use in cases where one wants to allocate a libxl_bitmap that is going to serve as a cpu map. This is because we want to be able to deal with both cpu and NUMA node maps, but we don't want to duplicate all the various helpers and wrappers. While at it, add the usual initialization function, common to all libxl data structures. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.eu.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl,libxc: introduce libxl_get_numainfo()Dario Faggioli2012-07-061-0/+69
| | | | | | | | | | | | | Make some NUMA node information available to the toolstack. Achieve this by means of xc_numainfo(), which exposes memory size and amount of free memory of each node, as well as the relative distances of each node to all the others. For properly exposing distances we need the IDL to support arrays. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: log on failure in cpupool_info and libxl__domain_cpupoolIan Campbell2012-06-291-1/+12
| | | | | | | | | Also in cpupool_info propagate the failure value from libxl_cpumap_alloc. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: further fixups re LIBXL_DOMAIN_TYPEIan Jackson2012-06-281-5/+23
| | | | | | | | | | | | | | | | | | | * Abolish the macro LIBXL__DOMAIN_IS_TYPE which had incorrect error handling. At every call site, replace it with an open-coded call to libxl_domain_type and check against LIBXL_DOMAIN_TYPE_INVALID. * This involves adding an `out:' to libxl_domain_unpause. * In libxl_domain_destroy and do_pci_add, do not `default: abort();' if the domain type cannot be found. Instead switch on LIBXL_DOMAIN_TYPE_INVALID specifically and do some actual error handling. * In libxl__primary_console_find, remove a spurious default clause from the domain type switch. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Do not pass NULL as gc_opt; introduce NOGCIan Jackson2012-06-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add a gc to libxl_get_cpu_topologyIan Jackson2012-06-281-1/+5
| | | | | | | | | | | | | | | | In the next-but-one patch we are going to change the definition of NOGC to require a local variable libxl__gc *gc. libxl_get_cpu_topology doesn't have one but does use NOGC. Fix this by: - introducing an `out' label - replacing the only call to `return' with a suitable assignment to ret and a `goto out'. - adding uses of GC_INIT and GC_FREE. 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: domain save: API changes for asynchronyIan Jackson2012-06-281-28/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the internal and external APIs for domain save (suspend) to be capable of asynchronous operation. The implementation remains synchronous. The interfaces surrounding device model saving are still synchronous. Public API changes: * libxl_domain_save takes an ao_how. * libxl_domain_remus_start takes an ao_how. If the libxl_domain_remus_info is NULL, we abort rather than returning an error. * The `suspend_callback' function passed to libxl_domain_save is never called by the existing implementation in libxl. Abolish it. * libxl_domain_save takes its flags parameter as an argument. Thus libxl_domain_suspend_info is abolished. * XL_SUSPEND_* flags renamed to LIBXL_SAVE_*. * Callers in xl updated. Internal code restructuring: * libxl__domain_suspend_state member types and names rationalised. * libxl__domain_suspend renamed from libxl__domain_suspend_common. (_common here actually meant "internal function"). * libxl__domain_suspend takes a libxl__domain_suspend_state, which where the parameters to the operation are filled in by the caller. * xc_domain_save is now called via libxl__xc_domain_save which can itself become asynchronous. * Consequently, libxl__domain_suspend is split into two functions at the callback boundary; the second half is libxl__xc_domain_save_done. * libxl__domain_save_device_model is now called by the actual implementation rather than by the public wrapper. It is already in its proper place in the domain save execution sequence. So officially make it part of that execution sequence, renaming it to domain_save_device_model. * Effectively, rewrite the public wrapper functions libxl_domain_suspend and libxl_domain_remus_start. * Remove a needless #include <xenctrl.h> * libxl__domain_suspend aborts on unexpected domain types rather than mysteriously returning EINVAL. * struct save_callbacks moved from the stack to the dss. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: allow to allocate cpumap with specific sizeYang Zhang2012-06-281-4/+4
| | | | | | | | | | | | Currently, libxl_cpumap_alloc()allocate the cpumap with size of number of physical cpus. In some place, we may want to allocate specific size of cpumap. This patch allow to pass a argument to specific the size that you want to allocate. If pass 0, it means the size is equal to number of physical cpus. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: document the memory ownership of some functionsDario Faggioli2012-06-281-11/+12
| | | | | | | | | Specifying they allocate dynamic memory that needs to be explicitly freed. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-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: introduce LIBXL_DOMAIN_TYPE_INVALIDDario Faggioli2012-06-061-3/+6
| | | | | | | | | | | | | | | | | | | | | | | To avoid recent gcc complaining about: libxl.c: In function 'libxl_primary_console_exec': libxl.c:1233:9: error: case value '4294967295' not in enumerated type 'libxl_domain_type' [-Werror=switch] Also: - have all the call sites of libxl__domain_type() return with error in case the function returns LIBXL_DOMAIN_TYPE_INVALID; - adjust all other code segments where -Wswitch makes would claim that LIBXL_DOMAIN_TYPE_INVALID is not handled by adding a "default: abort();" clause. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- use LIBXL_DOMAIN_TYPE_INVALID instead of -1 for libxl_domain_build_info.type's keyvar_init_val. -- what used to be libxl_primary_console_exec is now in libxl__primary_console_find so resolve the rejected hunk accordingly ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Add API to retrieve domain console ttyBamvor Jian Zhang2012-06-061-10/+93
| | | | | | | | | | | This api retrieve domain console from xenstore. With this new api, it is easy to implement "virsh console" command in libvirt libxl driver. Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- use NOGC instead of 0 to allow improvements to this infrastructure in the future ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: convert malloc() to libxl__zalloc(NULL, ...)Dario Faggioli2012-06-061-6/+1
| | | | | | | | | | And ditch the error handling in libxl_get_cpu_topology() Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- define and use NOGC instead of NULL to allow improvements to this infrastructure in the future ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: expose a single get/setter for domain scheduler parametersIan Campbell2012-06-011-51/+77
| | | | | | | | | | | | | | | | This is consistent with having a single struct for all parameters. Effectively renames and exports libxl__sched_set_params as libxl_domain_sched_params_set. libxl_domain_sched_params_get is new. Improve const correctness of the setters while I'm here. Use shorter LOG macros when touching a line anyway. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: move libxl__sched_set_params into libxl.cIan Campbell2012-06-011-0/+27
| | | | | | | | | | All the other sched functions are here and I'm just about to make those static functions as I make libxl__sched_set_params the public function. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: make it possible to explicitly specify default sched paramsIan Campbell2012-06-011-49/+72
| | | | | | | | | | | | | | | | | | | To do so we define a discriminating value which is never a valid real value for each parameter. While there: - removed libxl_sched_*_domain in favour of libxl_domain_sched_params. - use this new functionality for the various xl commands which set sched parameters, which saves an explicit read-modify-write in xl. - removed call of xc_domain_getinfolist from a few functions which weren't actually using the result (looks like a cut and paste error) - fix xl which was setting period for a variety of different config keys. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: add internal function to get a domain's schedulerIan Campbell2012-06-011-23/+48
| | | | | | | | | | | | | | | This takes into account cpupools. Add a helper to get the info for a single cpu pool, refactor libxl_list_cpupool t use this. While there fix the leaks due to not disposing the partial list on realloc failure in that function. Fix the failure of sched_domain_output to free the poolinfo list. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: wait for state "connected" in libxl__device_disk_local_attachStefano Stabellini2012-05-291-4/+18
| | | | | | | | | | | | In order to make sure that the block device is available and ready to be used, wait for state "connected" in the backend before returning. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> [ ijc -- resolved simple conflict in libxl__device_disk_local_detach ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* xl/libxl: implement QDISK libxl_device_disk_local_attachStefano Stabellini2012-05-291-12/+51
| | | | | | | | | | | | | | - Spawn a QEMU instance at boot time to handle disk local attach requests. - Implement libxl__device_disk_local_attach for QDISKs in terms of a regular disk attach with the frontend and backend running in the same domain. 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: introduce libxl__alloc_vdevStefano Stabellini2012-05-291-0/+32
| | | | | | | | | Introduce libxl__alloc_vdev: find a spare virtual block device in the domain passed as argument. 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>
* 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: introduce libxl__device_disk_addStefano Stabellini2012-05-291-3/+11
| | | | | | | | | | Introduce libxl__device_disk_add that takes an additional xs_transaction_t paramter. Implement libxl_device_disk_add using libxl__device_disk_add. 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: export libxl__device_from_diskStefano Stabellini2012-05-291-1/+1
| | | | | | 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: add a transaction parameter to libxl__device_generic_addStefano Stabellini2012-05-291-5/+5
| | | | | | | | | | | | | | | Add a xs_transaction_t parameter to libxl__device_generic_add, if it is XBT_NULL, allocate a proper one. Update all the callers. This patch contains a large number of unchecked xenstore operations, we might want to fix this in the future. 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-3/+13
| | | | | | | | | | | | | 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-8/+3
| | | | | | | 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-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | 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: Remus - suspend/postflush/commit callbacksShriram Rajagopalan2012-05-181-1/+38
| | | | | | | | | | | | | | | | | | | | | * Add libxl callback functions for Remus checkpoint suspend, postflush (aka resume) and checkpoint commit callbacks. * suspend callback is a stub that just bounces off libxl__domain_suspend_common_callback - which suspends the domain and saves the devices model state to a file. * resume callback currently just resumes the domain (and the device model). * commit callback just writes out the saved device model state to the network and sleeps for the checkpoint interval. * Introduce a new public API, libxl_domain_remus_start (currently a stub) that sets up the network and disk buffer and initiates continuous checkpointing. * Future patches will augment these callbacks/functions with more functionalities like issuing network buffer plug/unplug commands, disk checkpoint commands, etc. Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: support suspend_cancel in domain_resumeShriram Rajagopalan2012-05-181-8/+13
| | | | | | | | | | Add an extra parameter to libxl_domain_resume indicating if the caller wishes to use the SUSPEND_CANCEL style resume instead of the normal resume. Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl, xl: fix bootloader immediate console attachIan Jackson2012-05-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Fix bugs related to console handling: * In libxl_primary_console_exec, if libxl__domain_type fails, do not abort, but instead log and return an error. This can occur if the domid is invalid. * In xl's autoconnect_console, rename the ctx formal parameter so that when postfork creates a new ctx and puts it in the global ctx, we don't end up using the old one (via the formal parameter which has shadowed the global). * In xl's autoconnect_console, pass the domid from the event to libxl_primary_console_exec, rather than using the global domid (which has not yet been set, since it is only set at completion of the ao). This causes xl create -c to once more work with pygrub. 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: remove malloc failure handling from NEW_EVENTIan Jackson2012-05-111-2/+0
| | | | | | | | | | Change to use libxl__zalloc, where allocation failure is fatal. Also remove a spurious semicolon from the helper macro. 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: add a dummy ao_how to libxl_domain_core_dumpIan Campbell2012-05-111-4/+14
| | | | | | | | | | | | Although this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an ao_how which it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility. 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: ao: Convert libxl_run_bootloaderIan Jackson2012-05-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* of SIGCHLD. The application can tell us whether it wants to ownIan Jackson2012-05-111-1/+16
| | | | | | | | | | | | | SIGCHLD or not; if it does, it has to tell us about deaths of our children. Currently there are no callers in libxl which use these facilities. All code in libxl which forks needs to be converted and libxl_fork needse to be be abolished. 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/xend: name tap devices vifX.Y-emuIan Campbell2012-04-251-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents the udev scripts from operating on other tap devices (e.g. openvpn etc) Correct the documentation for the "vifname" option which suggested it applied to HVM tap devices only, which is not the case. Reported by Michael Young. Also fix the use of vifname with emulated devices. This is slightly complex. The current hotplug scripts rely on being able to parse the "tapX.Y" (now "vifX.Y-emu") name in order to locate the xenstore backend dir relating to the corresponding vif. This is because we cannot inject our own environment vars into the tap hotplug events. However this means that if the tap is initially named with a user specified name (which will not match the expected scheme) we fail to do anything useful with the device. So now we create the initial tap device with the standard "vifX.Y-emu" name and the hotplug script will handle the rename to the desired name. This is also how PV vif devices work -- they are always created by netback with the name vifX.Y and renamed in the script. Lastly also move libxl__device_* to a better place in the header, otherwise the comment about evgen stuff isn't next to the associated functions (noticed jsut because I was going to add nic_devname near to the setdefault functions) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: use xc_topologyinfo to figure out how many CPUs we actually haveDarrio Faggioli2012-05-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Within libxl_get_cpu_topology(), considering all the CPUs the hypervisor supports to be valid topology entries might lead to misleading and incorrect behaviours, e.g., the output of `xl info -n' below on a 16 cores machine: ... cpu_topology : cpu: core socket node 0: 0 1 0 1: 0 1 0 2: 1 1 0 3: 1 1 0 4: 9 1 0 5: 9 1 0 6: 10 1 0 7: 10 1 0 8: 0 0 1 9: 0 0 1 10: 1 0 1 11: 1 0 1 12: 9 0 1 13: 9 0 1 14: 10 0 1 15: 10 0 1 16: 0 0 0 17: 0 0 0 18: 0 0 0 19: 0 0 0 20: 0 0 0 ... ... 62: 0 0 0 63: 0 0 0 However, xc_topologyinfo() tells us (in max_cpu_index) how many entries arrays it returns corresponds to actually valid CPUs, so let's use that information. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: log failure from libxl__blktap_devpath in libxl_device_disk_addIan Campbell2012-05-081-0/+2
| | | | | | 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>
* libxl: make most libxl_FOO_path() functions internal.Ian Campbell2012-04-121-3/+3
| | | | | | | | | | Only libxl_xen_config_dir_path and libxl_lock_dir_path are used outside the library. Also bindir, sbindir, sharedir and xenpagingdir appeared to be completely unused so nuke them. 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>
* libxl: Remove libxl_tmem_destroy and associated xl commandIan Campbell2012-04-161-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dan Magenheimer explains in <4c2f7fca-dda2-4598-aaab-3a6a3fe532cd@default>: I think the tmem_destroy functionality pre-dates the existence of tmem "freeable" memory* and was a way for a toolset to force the hypervisor to free up the hypervisor memory used by some or all ephemeral tmem pools. Once the tmem allocation/free process was directly linked into alloc_heap_pages() in the hypervisor (see call to tmem_relinquish_pages()), this forcing function was no longer needed. So, bottom line, I *think* it can be ripped out, or at least for now removed from the definition of the stable xl API/UI. The libxl.c routine libxl_tmem_destroy() could also be removed if you like, but I guess I'd prefer to leave the lower level droppings in xc.c and in the hypervisor in case I am misremembering. Accordingly remove this interface from libxl and xl but don't touch libxc or the hypervisor. This is the only libxl_tmem_* function which might potentially have required conversion to be asynchronous and which therefore might have been a potential API stability concern. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>