aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl.h
Commit message (Collapse)AuthorAgeFilesLines
* libxl,xl: add max_event_channels option to xl configuration fileDavid Vrabel2013-10-141-0/+5
| | | | | | | | | | | | | | | | | | | Add the 'max_event_channels' option to the xl configuration file to limit the number of event channels that domain may use. Plumb this option through to libxl via a new libxl_build_info field and call xc_domain_set_max_evtchn() in the post build stage of domain creation. A new LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS #define indicates that this new field is available. The default value of 1023 limits the domain to using the minimum amount of global mapping pages and at most 5 xenheap pages. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
* tools/migrate: Fix regression when migrating from older version of XenAndrew Cooper2013-10-101-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | Commit 00a4b65f8534c9e6521eab2e6ce796ae36037774 Sep 7 2010 "libxc: provide notification of final checkpoint to restore end" broke migration from any version of Xen using tools from prior to that commit Older tools have no idea about an XC_SAVE_ID_LAST_CHECKPOINT, causing newer tools xc_domain_restore() to start reading the qemu save record, as ctx->last_checkpoint is 0. The failure looks like: xc: error: Max batch size exceeded (1970103633). Giving up. where 1970103633 = 0x756d6551 = *(uint32_t*)"Qemu" With this fix in place, the behaviour for normal migrations is reverted to how it was before the regression; the migration is considered non-checkpointed right from the start. A XC_SAVE_ID_LAST_CHECKPOINT chunk seen in the migration stream is a nop. For checkpointed migrations the behaviour is unchanged. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <Ian.Campbell@citrix.com> CC: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> (Remus bits)
* libxl: Spice vdagent support for upstream qemuFabio Fantoni2013-09-131-0/+11
| | | | | | | | | | | | | | | | | | Usage: - spicevdagent=1|0 (default=0) Enables spice vdagent. The Spice vdagent is an optional component for enhancing user experience and performing guest-oriented management tasks. Its features includes: client mouse mode (no need to grab mouse by client, no mouse lag), automatic adjustment of screen resolution, copy and paste (text and image) between client and domU. It also requires vdagent service installed on domU o.s. to work. - spice_clipboard_sharing=1|0 (default=0) Enables Spice clipboard sharing (copy/paste). It requires spicevdagent enabled. Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* Add vendor_device parameter for HVM guestsPaul Durrant2013-08-051-0/+8
| | | | | | | | | | | | The parameter determines which, if any, xen-pvdevice is specified on the QEMU command line. The default value is 'none' which means no argument will be passed. A value of 'xenserver' specifies a xen-pvdevice with device-id 0xc000 (the initial value in the xenserver namespace - see docs/misc/pci-device-reservations.txt). Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- s/BUILD_INFO/BUILDINFO for consistency in LIBXL_HAVE define ]
* libxl: add LIBXL_HAVE_<foo> for outstanding_pages and outstanding_memkbDario Faggioli2013-06-121-0/+18
| | | | | | | | | | | | Commits d0782481 ("xl: export 'outstanding_pages' value from xcinfo") and bec8f17e ("xen: Remove the XENMEM_get_oustanding_pages and provide the data via xc_phys_info") added these two fields in libxl_physinfo and in libxl_dominfo, respectively, but did not include the needed LIBXL_HAVE_<foo> runes. Adding them. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
* hypervisor/xen/tools: Remove the XENMEM_get_oustanding_pages and provide the ↵Konrad Rzeszutek Wilk2013-05-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | data via xc_phys_info During the review of the patches it was noticed that there exists a race wherein the 'free_memory' value consists of information from two hypercalls. That is the XEN_SYSCTL_physinfo and XENMEM_get_outstanding_pages. The free memory the host has available for guest is the difference between the 'free_pages' (from XEN_SYSCTL_physinfo) and 'outstanding_pages'. As they are two hypercalls many things can happen in between the execution of them. This patch resolves this by eliminating the XENMEM_get_outstanding_pages hypercall and providing the free_pages and outstanding_pages information via the xc_phys_info structure. It also removes the XSM hooks and adds locking as needed. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Tim Deegan <tim@xen.org> Acked-by: Keir Fraser <keir.xen@gmail.com>
* libxl: unconst the event argument to the event_occurs hook.Ian Campbell2013-05-011-2/+12
| | | | | | | | | | | | | | | The event is supposed to become owned, and therefore freed, by the application and the const prevents this. Unfortunately there is no way to remove the const without breaking existing callers. The best we can do is use the LIBXL_API_VERSION provisions to remove the const for callers who wish only to support the 4.3 API and newer. Callers who wish to support 4.2 will need to live with casting away the const. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: postpone backend name resolutionDaniel De Graaf2013-04-171-0/+12
| | | | | | | | | | | | | | | | | | | | This adds a backend_domname field in libxl devices that contain a backend_domid field, allowing either a domid or a domain name to be specified in the configuration structures. The domain name is resolved into a domain ID in the _setdefault function when adding the device. This change allows the backend of the block devices to be specified (which previously required passing the libxl_ctx down into the block device parser), and will simplify specification of backend domains in other users of libxl. The check on run_hotplug_scripts in parse_config_data is removed because it is a duplicate of the one in libxl__device_nic_setdefault, and is removed here because it no longer has the resolved domain ID to check. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- reran flex ]
* libxl: allow for explicitly specifying node-affinityDario Faggioli2013-04-171-0/+11
| | | | | | | | | | By introducing a nodemap in libxl_domain_build_info and providing the get/set methods to deal with it. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* xl: 'xl info' print outstanding claims if enabled (claim_mode=1 in xl.conf)Konrad Rzeszutek Wilk2013-04-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides the value of the currently outstanding pages claimed for all domains. This is a total global value that influences the hypervisors' MM system. When a claim call is done, a reservation for a specific amount of pages is set and also a global value is incremented. This global value is then reduced as the domain's memory is populated and eventually reaches zero. The toolstack (libxc) also sets the domain's claim to zero when the population of memory has completed as an extra step. Any call to destroy the domain will also set the domain's claim to zero. If the reservation cannot be meet the guest creation fails immediately instead of taking seconds or minutes (depending on the size of the guest) while the toolstack populates memory. See patch: "xl: Implement XENMEM_claim_pages support via 'claim_mode' global config" for details on how it is implemented. The value fluctuates quite often so the value is stale once it is provided to the user-space. However it is useful for diagnostic purposes. It is only printed when the global "claim_mode" option in xl.conf(5) is set to enabled (1). The 'man xl' shows the details of this item. [v1: s/unclaimed/outstanding/] [v2: Made libxl_get_claiminfo return just MemKB suggested by Ian Campbell] [v3: Made libxl_get_claininfo return MemMB to conform to the other values printed] [v4: Improvements suggested by Ian Jackson, also added docs to xl.pod.1] [v5: Clarify how claims are cancelled, split >72 characters - Ian Jackson] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: Implement XENMEM_claim_pages support via 'claim_mode' global configKonrad Rzeszutek Wilk2013-04-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The XENMEM_claim_pages hypercall operates per domain and it should be used system wide. As such this patch introduces a global configuration option 'claim_mode' that by default is disabled. If this option is enabled then when a guest is created there will be an guarantee that there is memory available for the guest. This is an particularly acute problem on hosts with memory over-provisioned guests that use tmem and have self-balloon enabled (which is the default option for them). The self-balloon mechanism can deflate/inflate the balloon quickly and the amount of free memory (which 'xl info' can show) is stale the moment it is printed. When claim is enabled a reservation for the amount of memory ('memory' in guest config) is set, which is then reduced as the domain's memory is populated and eventually reaches zero. If the reservation cannot be meet the guest creation fails immediately instead of taking seconds/minutes (depending on the size of the guest) while the guest is populated. Note that to enable tmem type guests, one needs to provide 'tmem' on the Xen hypervisor argument and as well on the Linux kernel command line. There are two boolean options: (0) No claim is made. Memory population during guest creation will be attempted as normal and may fail due to memory exhaustion. (1) Normal memory and freeable pool of ephemeral pages (tmem) is used when calculating whether there is enough memory free to launch a guest. This guarantees immediate feedback whether the guest can be launched due to memory exhaustion (which can take a long time to find out if launching massively huge guests) and in parallel. [v1: Removed own claim_mode type, using just bool, improved docs, all per Ian's suggestion] [v2: Updated the comments] [v3: Rebase on top 733b9c524dbc2bec318bfc3588ed1652455d30ec (xl: add vif.default.script)] [v4: Fixed up comments] [v5: s/global_claim_mode/claim_mode/] [v6: Ian Jackson's feedback: use libxl_defbool, better comments, etc] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Allow multiple USB devices on HVM domain creationGeorge Dunlap2013-04-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows an HVM domain to be created with multiple USB devices. Since the previous interface only allowed the passing of a single device, this requires us to add a new element to the hvm struct of libxl_domain_build_info -- usbdevice_list. For API compatibility, the old element, usbdevice, remains. If hvm.usbdevice_list is set, each device listed will cause an extra "-usbdevice [foo]" to be appended to the qemu command line. Callers may set either hvm.usbdevice or hvm.usbdevice_list, but not both; libxl will throw an error if both are set. In order to allow users of libxl to write software compatible with older versions of libxl, also define LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST. If this is defined, callers may use either hvm.usbdevice or hvm.usbdevice_list; otherwise, only hvm.usbdevice will be available. as applied: - Fix whitespace errors -iwj v3: - Duplicate functionality in both "new" and "old", since we're not unifying the two anymore. v2: - Throw an error if both usbdevice and usbdevice_list are set - Update and clarify definition based on feedback - Previous patches means this works for both traditional and upstream Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: HVM firmware passthrough supportRoss Philipson2013-02-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | This patch introduces support for two new parameters in libxl: smbios_firmware=<path_to_smbios_structures_file> acpi_firmware=<path_to_acpi_tables_file> The changes are primarily in the domain building code where the firmware files are read and passed to libxc for loading into the new guest. After the domain building call to libxc, the addresses for the loaded blobs are returned and written to xenstore. LIBXL_HAVE_FIRMWARE_PASSTHROUGH is defined in libxl.h to allow users to determine if the feature is present. This patch also updates the xl.cfg man page with descriptions of the two new parameters for firmware passthrough. Signed-off-by: Ross Philipson <ross.philipson@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: move definition of libxl_domain_config into the IDLIan Campbell2012-12-191-20/+0
| | | | | | 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: add vtpm supportMatthew Fioravante2012-11-131-1/+22
| | | | | | | | | | | | This patch adds vtpm support to libxl. It adds vtpm parsing to config files and 3 new xl commands: vtpm-attach vtpm-detach vtpm-list Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: make devid a type so it is initialized properlyMatthew Fioravante2012-10-051-0/+1
| | | | | | | | | | | | | | | | Previously device ids in libxl were treated as integers meaning they were being initialized to 0, which is a valid device id. This patch makes devid its own type in libxl and initializes it to -1, an invalid value. This fixes a bug where if you try to do a xl DEV-attach multiple time it will continuously try to reattach device 0 instead of generating a new device id. Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> Reviewed-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: make domain resume API asynchronousIan Campbell2012-08-231-1/+3
| | | | | | | | | | | | | | | | | | Although the current implementation has no asynchromous parts I can envisage it needing to do bits of create/destroy like functionality which may need async support in the future. To do this make the meat into an internal libxl__domain_resume function in order to satisfy the no-internal-callers rule for the async function. Since I needed to touch the logging to s/ctx/CTX/ anyway switch to the LOG* helper macros. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-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: add a comment re the memory management API instabilityIan Jackson2012-08-031-0/+12
| | | | | | 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: make libxl_device_pci_{add,remove,destroy} interfaces asynchronousIan Campbell2012-08-031-4/+15
| | | | | | | | | | | | | | This does not make the implementation fully asynchronous but just updates the API to support asynchrony in the future. Currently although these functions do not call hotplug scripts etc and therefore are not "slow" (per the comment about ao machinery in libxl_internal.h) they do interact with the device model and so are not quite "fast" either. We can live with this 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: enforce prohibitions of internal callersIan Jackson2012-08-011-19/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libxl_internal.h says: * Functions using LIBXL__INIT_EGC may *not* generally be called from * within libxl, because libxl__egc_cleanup may call back into the * application. ... and * ... [Functions which take an ao_how] MAY NOT * be called from inside libxl, because they can cause reentrancy * callbacks. However, this was not enforced. Particularly the latter restriction is easy to overlook, especially since during the transition period to the new event system we have bent this rule a couple of times, and the bad pattern simply involves passing 0 or NULL for the ao_how. So use the compiler to enforce this property, as follows: - Mark all functions which take a libxl_asyncop_how, or which use EGC_INIT or LIBXL__INIT_EGC, with a new annotation LIBXL_EXTERNAL_CALLERS_ONLY in the public header. - Change the documentation comment for asynch operations and egcs to say that this should always be done. - Arrange that if libxl.h is included via libxl_internal.h, LIBXL_EXTERNAL_CALLERS_ONLY expands to __attribute__((warning(...))), which generates a message like this: libxl.c:1772: warning: call to 'libxl_device_disk_remove' declared with attribute warning: may not be called from within libxl Otherwise, the annotation expands to nothing, so external callers are unaffected. - Forbid inclusion of both libxl.h and libxl_internal.h unless libxl_internal.h came first, so that the above check doesn't have any loopholes. Files which include libxl_internal.h should not include libxl.h as well. This is enforced explicitly using #error. However, in practice with the current tree it just changes the error message when this mistake is made; otherwise we would carry on to immediately following #define which would cause the compiler to complain that LIBXL_EXTERNAL_CALLERS_ONLY was redefined. Then the developer might be tempted to add a #ifndef which would be wrong - it would leave the affected translation unit unprotected by the new enforcement regime. So let's be explicit. - Fix the one source of files which violate the above principle, the output from the idl compiler, by removing the redundant inclusion of libxl.h from the output. Also introduce a new script "check-libxl-api-rules" which contains some ad-hoc regexps to spot and complain when libxl.h contains functions which mention libxl_asyncop_how but not LIBXL_EXTERNAL_CALLERS_ONLY. This isn't a full C parser but is likely to get the common cases right and err on the side of complaining. While we are here, the invocation of perl for the bsd queue.h seddery to $(PERL). Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: convert libxl_device_vfb_add to an async operationRoger Pau Monne2012-07-261-1/+2
| | | | | | | | | | Split libxl_device_vfb_add into libxl__device_vfb_add (to be used inside already running ao's), and make libxl_device_vfb_add a stub to call libxl__device_vfb_add. 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_vkb_add to an async operationRoger Pau Monne2012-07-261-1/+2
| | | | | | | | | | Split libxl_device_vkb_add into libxl__device_vkb_add (to be used inside already running ao's), and make libxl_device_vkb_add a stub to call libxl__device_vkb_add. 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_nic_add to an async operationRoger Pau Monne2012-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | 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-1/+3
| | | | | | | | | | | | | | | | | | 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: make libxl_cdrom_insert async.Ian Campbell2012-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 vifs to nicsRoger Pau Monne2012-07-261-2/+2
| | | | | | | | | | | | | This change renames functions and struct values that used to contain vifs in their names to nics, that provides a more clear name to define network interfaces without referring to the backend that is behind them. This is not a functional 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: convert libxl_domain_destroy to an async opRoger Pau Monne2012-07-231-1/+2
| | | | | | | | | | | | | | | | | | | | | 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-4/+11
| | | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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/+7
| | | | | | | | | | | | | 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: domain save: API changes for asynchronyIan Jackson2012-06-281-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: document the memory ownership of some functionsDario Faggioli2012-06-281-12/+22
| | | | | | | | | 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: Add API to retrieve domain console ttyBamvor Jian Zhang2012-06-061-0/+12
| | | | | | | | | | | 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: expose a single get/setter for domain scheduler parametersIan Campbell2012-06-011-12/+5
| | | | | | | | | | | | | | | | 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: make it possible to explicitly specify default sched paramsIan Campbell2012-06-011-9/+19
| | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | | | 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: remove lockdir and config dir from the APIIan Campbell2012-05-291-4/+0
| | | | | | | | | | | | 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>
* libxl: make libxl_device_disk_local_attach/detach internal functionsStefano Stabellini2012-05-291-7/+0
| | | | | | | 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_vcpuinfo_list_freeDario Faggioli2012-05-291-0/+1
| | | | | | | And fix a leak due to it being missing. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: do not overwrite user supplied config when running bootloaderIan Campbell2012-05-291-34/+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: Remus - suspend/postflush/commit callbacksShriram Rajagopalan2012-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | * 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-1/+6
| | | | | | | | | | 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: Introduce pci_assignable_add and pci_assignable_removeGeorge Dunlap2012-05-151-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce libxl helper functions to prepare devices to be passed through to guests. This is meant to replace of all the manual sysfs commands which are currently required. pci_assignable_add accepts a BDF for a device and will: * Unbind a device from its current driver, if any * If "rebind" is set, it will store the path of the driver from which we unplugged it in /libxl/pciback/$BDF/driver_path * If create a slot for it in pciback if one doesn't yet exist * Bind the device to pciback At this point it will show up in pci_assignable_list, and is ready to be passed through to a guest. pci_assignable_remove accepts a BDF for a device and will: * Unbind the device from pciback * Remove the slot from pciback * If "rebind" is set, and /libx/pciback/$BDF/driver_path exists, it will attempt to rebind the device to its original driver. Both functions are idempotent: if the desired end state has already been reached, they return SUCCESS. NB that "$BDF" in this case uses '-' instead of ':' and '.', because ':' and '.' are illegal characters in xenstore paths. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Rename pci_list_assignable to pci_assignable_listGeorge Dunlap2012-05-151-1/+1
| | | | | | | | | | | | | ...to prepare for a consistent "pci_assignable_*" naming scheme. Also move the man page entry into the PCI PASS-THROUGH section, rather than the XEN HOST section. No functional changes. 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: convert console callback to libxl_asyncprogress_howIan Jackson2012-05-111-8/+9
| | | | | | | | | | | | | | | | | | | | | | 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: provide progress reporting for long-running operationsIan Jackson2012-05-111-0/+45
| | | | | | | | | | | | | | | | This will be used for reporting, during domain creation, that the console is ready. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v7: * If aop->how.callback, actually add the aop to the for_callback list (!) * Document the threadsafety of aop's, and make appropriate cross-references. * Allocate the actual aop from its thread's egc; do not free it. * Remove pointless code motion of libxl__ao_create. * Minor formatting fixes. Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: ao: convert libxl__spawn_*Ian Jackson2012-05-111-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libxl__spawn_spawn becomes a callback-style asynchronous function. The implementation is now in terms of libxl__ev_* including libxl_ev_child. All the callers need to be updated. This includes the device model spawning functions libxl__create_device_model and libxl__create_stubdom; these are replaced with libxl__spawn_local_dm and libxl__spawn_stubdom. libxl__confirm_device_model_startup is abolished; instead the dm spawner calls back. (The choice of which kind of device model to create is lifted out of what used to be libxl__create_device_model, because that function was indirectly recursive. Recursive callback-style operations are clumsy because they require a pointer indirection for the nested states.) Waiting for proper device model startup it is no longer notionally optional. Previously the code appeared to tolerate this by passing NULL for various libxl__spawner_starting* parameters to device model spawners. However, this was not used anywhere. Conversely, the "for_spawn" parameter to libxl__wait_for_offspring is no longer supported. It remains as an unused formal parameter to avoid updating, in this patch, all the call sites which pass NULL. libxl__wait_for_offspring is in any case itself an obsolete function, so this wrinkle will go away when its callers are updated to use the event system. Consequently libxl__spawn_check is also abolished. The "console ready" callback also remains unchanged in this patch. The API for this needs to be reviewed in the context of the event series and its reentrancy restrictions documented. Thus their callers need to be updated. These are the domain creation functions libxl_domain_create_new and _restore. These functions now take ao_hows, and have a private state structure. However domain creation remains not completely converted to the event mechanism; in particular it runs the outward-facing function libxl_run_bootloader with a NULL ao_how, which is quite wrong. As it happens in the current code this is not a bug because none of the rest of the functionality surrounding the bootloader call will mind if the event loop is reentered in the middle of its execution. The file-scope function libxl__set_fd_flag which was used by the previous spawn arrangements becomes unused and is removed; other places in libxl can use libxl_fd_set_nonblock and libxl_fd_set_cloexec, which of course remain. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v8: * Make midproc_cb callback with correct pid (that of the grandchild, not "middle" which is zero). Reported by Roger Pau Monne. Changes since v7: * Rename libxl__spawn_stubdom to libxl__spawn_stub_dm (and ..._state); rename the state's stubdom_* members to dm_*. * Eliminate the union between the two dm creation states in libxl__domain_create_state. Instead, the domain creation code simply uses libxl__stub_dm_spawn_state.dm directly, if we're taking the local dm path. * Remove a spurious "break". * In domain creation, move the PV non-qemu case into the switch. * Code style fixes. * Constify some convenience aliases. * Improve comments (including typo fixes). Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: add a dummy ao_how to libxl_domain_core_dumpIan Campbell2012-05-111-1/+3
| | | | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | 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>