aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl.c
Commit message (Collapse)AuthorAgeFilesLines
* libxl: don't write physical-device node for driver domain disksRoger Pau Monne2013-05-081-1/+2
| | | | | | | | | This will be handled by the driver domain itself, since the toolstack does not have access to the physical device because it is in a different domain. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: adjust point of backend name resolutionEric Shelton2013-05-011-4/+7
| | | | | | | | | | | | | | | | | | | | | Resolution of a backend name to a domid needs to happen a little earlier in some cases. For example, if a domU is specified as a backend for a disk and, as previously written, libxl__device_disk_setdefault() calls libxl__resolve_domid() last, then disk->backend_domid still equals LIBXL_TOOLSTACK_DOMID when libxl__device_disk_set_backend() is called. This results in libxl__device_disk_set_backend() making an incorrect attempt to validate the target by calling stat() on a file on dom0, resulting in ERROR_INVAL (see libxl_device.c lines 239-248), which prevents creation of the frontend domain. Likewise, libxl__device_nic_setdefault() previously made use of nic->backend_domid before it was set. Signed-off-by: Eric Shelton <eshelton@pobox.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Reviewed-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
* libxl: fix spelling of "backend-id" for vtpmMarek Marczykowski2013-04-301-1/+1
| | | | | Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: write IO ABI for disk frontendsWei Liu2013-04-261-0/+23
| | | | | | | | | | | | | | | This is a patch to forward-port a Xend behaviour. Xend writes IO ABI used for all frontends. Blkfront before 2.6.26 relies on this behaviour otherwise guest cannot boot when running in 32-on-64 mode. Blkfront after 2.6.26 writes that node itself, in which case it's just an overwrite to an existing node which should be OK. In fact Xend writes the ABI for all frontends including console and vif. But nowadays only old disk frontends rely on that behaviour so that we only write the ABI for disk frontends in libxl, minimizing the impact. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: properly initialize device structuresDaniel De Graaf2013-04-171-3/+5
| | | | | | | | | This avoids returning unallocated memory in the libxl_device_vtpm structure in libxl_device_vtpm_list, and uses libxl_device_nic_init instead of memset when initializing libxl_device_nics. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: postpone backend name resolutionDaniel De Graaf2013-04-171-7/+25
| | | | | | | | | | | | | | | | | | | | 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/+20
| | | | | | | | | | 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: Fix 'free_memory' to include outstanding_claims value.Konrad Rzeszutek Wilk2013-04-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Updating to make it clear that free_memory reported by 'xl info' is influenced by the outstanding claim value. That is the free memory that will be available to the host once all outstanding claims have been completed. This modifies the behavior that the patch titled "xl: 'xl info' print outstanding claims if enabled (claim_mode=1 in xl.conf)" had - which reported the outstanding claims and nothing else. The free_pages as reported by the hypervisor is the currently available count of pages on the heap. The outstanding pages is the total amount of pages reserved for guests (so not taken from the heap yet). As guests are being populated the memory from the heap shrinks and the outstanding count of pages decreases. The total memory used for guests increases. As the available count of pages on the heap and outstanding claims are intertwined, report the amount of free memory available to be a combination of that. That is free heap memory minus the outstanding pages. We also make some odd choices in reporting. By default we will only display 'outstanding_claims' if the claim_mode is enabled in the global configuration file. However, if there are outstanding claims, we will ignore the claim_mode and report these values. Suggested-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
* xl: 'xl claims' print outstanding per domain claimsKonrad Rzeszutek Wilk2013-04-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to "xl: 'xl info' print outstanding claims if enabled (claim_mode=1 in xl.conf)" which exposes the global claim value. This patch provides the value of the currently outstanding pages claimed for each domains. This is per domain value which is added to the global claim value which influences the hypervisors' MM system. When a claim call is done, a reservation for a specific amount of pages is set (and this patch lists said number) 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 printed irregardless of global "claim_mode" option in xl.conf(5). That is b/c the user might have enabled, launched a guest, and then disabled the option - and we should still report the correct outstanding claim value. The 'man xl' shows the details of this argument. The output is close to what 'xl list' looks like: Name ID Mem VCPUs State Time(s) Claimed Domain-0 0 2047 4 r----- 19.7 0 OL5 2 2048 1 --p--- 0.0 847 OL6 3 1024 4 r----- 5.9 0 Windows_XP 4 2047 1 --p--- 0.0 1989 [In which it can be seen that the OL5 guest still has 847MB of claimed memory (out of the total 2048MB where 1191MB has been allocated to the guest).] Please note that the 'Mem' column has the cumulative value of outstanding claims and the total amount of memory that has been allocated to the guest. [v1: claims, not claim-list] [v2: Add outstanding and current memkb in the output list] [v3: Clairy docs and relax some checks] [v4: Removed comments about guest config memory being the same as 'Mem'] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
* xl: export 'outstanding_pages' value from xcinfoKonrad Rzeszutek Wilk2013-04-161-0/+1
| | | | | | | | | | | | | | | | | | This patch provides the value of the currently outstanding pages claimed for a specific domain. This is a value that influences the global outstanding claims value (See patch: "xl: 'xl info' print outstanding claims if enabled") returned via xc_domain_get_outstanding_pages hypercall. This domain value decrements as the memory is populated for the guest and eventually reaches zero. With this patch it is possible to utilize this field. Acked-by: Ian Campbell <ian.campbell@citrix.com> [v2: s/unclaimed/outstanding/ per Tim's suggestion] [v3: Don't use SXP printout file per Ian's suggestion] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: 'xl info' print outstanding claims if enabled (claim_mode=1 in xl.conf)Konrad Rzeszutek Wilk2013-04-161-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/libxl: add gatewaydev/netdev to vif specificationRoger Pau Monne2013-03-151-1/+5
| | | | | | | | | | | | | | | | | | This option is used by the vif-route hotplug script. A new more descriptive name is used, "gatewaydev", but "netdev" is also supported as a deprecated backwards compatible option. This option was supported in the past, according to http://wiki.xen.org/wiki/Vif-route, so we should also support it in libxl. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Tested-by: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de> Cc: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de> Cc: Ian Campbell <ian.campbell@citrix.com> Cc: George Dunlap <george.dunlap@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: move libxl_device_action to idlRoger Pau Monne2013-03-131-9/+9
| | | | | | | | Move to idl for ease of expansion and auto-generated functions. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: don't launch more than one tapdisk process for each diskRoger Pau Monne2013-03-131-7/+10
| | | | | | | | | | | When adding a disk don't launch multiple tapdisk instances for the same disk, if transaction fails in device_disk_add reuse the same tapdisk for further tries instead of creating a new instance each time a transaction fails. Reported-by: Darren Shepherd <darren.s.shepherd@gmail.com> Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Tested-by: Darren Shepherd <darren.s.shepherd@gmail.com>
* libxl: Set vfb and vkb devid if not done so by the callerJim Fehlig2013-01-111-20/+39
| | | | | | | | | | | Other devices set a sensible devid if the caller has not done so. Do the same for vfb and vkb. While at it, factor out the common code used to determine a sensible devid, so it can be used by other libxl__device_*_add functions. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Make an internal function explicitly check existence of expected pathsGeorge Dunlap2012-12-061-20/+47
| | | | | | | | | | | | | | | | | | | | | | | libxl__device_disk_from_xs_be() was failing without error for some missing xenstore nodes in a backend, while assuming (without checking) that other nodes were valid, causing a crash when another internal error wrote these nodes in the wrong place. Make this function consistent by: * Checking the existence of all nodes before using * Choosing a default only when the node is not written in device_disk_add() * Failing with log msg if any node written by device_disk_add() is not present * Returning an error on failure * Disposing of the structure before returning using libxl_device_disk_displose() Also make the callers of the function pay attention to the error and behave appropriately. In the case of libxl__append_disk_list_of_type(), this means only incrementing *ndisks as the disk structures are successfully initialized. 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: Fix bug in libxl_cdrom_insert, make more robust against bad xenstore dataGeorge Dunlap2012-11-271-1/+16
| | | | | | | | | | | | | | | | | libxl_cdrom_insert was failing to initialize the backend type, resulting in the wrong default backend. The result was not only that the CD was not inserted properly, but also that some improper xenstore entries were created, causing further block commands to fail. This patch fixes the bug by setting the disk backend type based on the type of the existing device. It also makes the system more robust by checking to see that it has got a valid path before proceeding to write a partial xenstore entry. 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: fix a variable underflow in libxl_wait_for_free_memoryRonny Hegewald2012-11-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | When xl is called to create a domU and there is not enough memory available, then the autoballooning is called to extract memory from dom0. During the ballooning a loop in libxl_wait_for_free_memory() waits unless enough memory is available to create the domU. But because of a variable-underflow the loop can finish too soon and xl finally aborts with the message: xc: error: panic: xc_dom_boot.c:161: xc_dom_boot_mem_init: can't allocate low memory for domain: Out of memory libxl: error: libxl_dom.c:430:libxl__build_pv: xc_dom_boot_mem_init failed: Device or resource busy libxl: error: libxl_create.c:901:domcreate_rebuild_done: cannot (re-)build domain: -3 The variable-underflow happens when freemem_slack is larger then info.free_pages*4, because the solution of this operation is converted implicit to a unsigned int to match the type of memory_kb. Add a extra check for this condition to solve the problem. Signed-off-by: Ronny Hegewald <Ronny.Hegewald@online.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* xl: Suppress spurious warning message for cpupool-listGeorge Dunlap2012-11-231-1/+2
| | | | | | | | | | | | | | | | libxl_cpupool_list() enumerates the cpupools by "probing": calling cpupool_info, starting at 0 and stopping when it gets an error. However, cpupool_info will print an error when the call to xc_cpupool_getinfo() fails, resulting in every xl command that uses libxl_list_cpupool (such as cpupool-list) printing that error message spuriously. Since at the moment the times we want to print the message correspond with the use of the existing "exact" parameter, use it to decide whether to print the message or not. 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: fix vfb related assertion problem when starting pv-domURonny Hegewald2012-11-131-0/+2
| | | | | | | | | | | | | | | | | | | When a config-file for a pv-domU has a vfb section with a vnc=0 option then a "xl create" for that domU crashes with the message xl: libxl.c:252: libxl_defbool_val: Assertion `!libxl_defbool_is_default(db)' failed. and the domU hangs early in the start. This patch fixes the cause of the assertion and let the domU start normally. This problem exists since xen 4.2. Signed-off-by: Ronny Hegewald <Ronny.Hegewald@online.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: add vtpm supportMatthew Fioravante2012-11-131-0/+247
| | | | | | | | | | | | 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: propagate user supplied values into event for_user field.Ian Campbell2012-10-181-4/+5
| | | | | | | | | | This was ommited in the majority of cases. Add as a parameter to libxl__event_new and the NEW_EVENT wrapper to help prevent it being forgotten in the future. 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: Fix cd-insert with qemu-xen.Anthony PERARD2012-10-091-6/+6
| | | | | | | | | | If qemu-xen is used as a device model, the command to insert, change or eject a cdrom will go through QMP. XenStore is still updated even if QEMU will not read from it. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Allow migration with qemu-xen.Anthony PERARD2012-10-081-17/+0
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Have flexarray using the GCAnthony PERARD2012-10-051-80/+19
| | | | | | | | | | | This patch makes the flexarray function libxl__gc aware. It also updates every function that use a flexarray to pass the gc and removes every memory allocation check and free. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Enable -Wshadow.Ian Campbell2012-09-171-18/+19
| | | | | | | | | | | | | | | | | | | | | | It was convenient to invent $(CFLAGS_LIBXL) to do this. Various renamings to avoid shadowing standard functions: - index(3) - listen(2) - link(2) - abort(3) - abs(3) Reduced the scope of some variables to avoid conflicts. Change to libxc is due to the nested hypercall buf macros in set_xen_guest_handle (used in libxl) using the same local private vars. Build tested only. 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: fix usage of backend parameter and run_hotplug_scriptsRoger Pau Monne2012-09-141-0/+14
| | | | | | | | | | | vif interfaces allows the user to specify the domain that should run the backend (also known as driver domain) using the 'backend' parameter. This is not compatible with run_hotplug_scripts=1, since libxl can only run the hotplug scripts from the Domain 0. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: handle errors from xc_sharing_* info functionsIan Campbell2012-09-141-2/+19
| | | | | | | | | | | | | | | | On a 32 bit hypervisor xl info currently reports: sharing_freed_memory : 72057594037927935 sharing_used_memory : 72057594037927935 Eat the ENOSYS and turn it into 0. Log and propagate other errors. I don't have a 32 bit system handy, so tested on x86_64 with a libxc hacked to return -ENOSYS and -EINVAL. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: make domain resume API asynchronousIan Campbell2012-08-231-14/+16
| | | | | | | | | | | | | | | | | | 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: write physical-device node if user did not supply a block scriptIan Campbell2012-08-071-10/+20
| | | | | | | | | | | | | | | | | | | | | | This reverts one of the intentional changes from 25733:353bc0801b11. That change exposed an issue with the xl migration protocol, which although safe triggers the hotplug scripts device sharing logic. For 4.2 we disable this logic by writing the physical-device xenstore node ourselves if a user did not supply a script. If the user did supply a script then we continue to rely on it to write the physical-device node (not least because the script may create the device and therefore it is not available before we run the script). This means that to support localhost migration a block hotplug script needs to be robust against adding a device twice and should not deactivate the device until it has been removed twice. This should be revisited for 4.3. 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: support custom block hotplug scriptsIan Campbell2012-08-061-28/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are provided using the "script=" syntax described in docs/misc/xl-disk-configuration.txt. The existing hotplug scripts currently conflate two different concepts, namely that of making a datapath available in the backend domain (logging into iSCSI LUNs and the like) and that of actually connecting that datapath to a Xen backend path (e.g. writing "physical-device" node in xenstore to bring up blkback). For this reason the script support implemented here is only supported in conjunction with backendtype=phy. Eventually we hope to rework the hotplug scripts to separate the to concepts, but that is not 4.2 material. In addition there are some other subtleties: - Previously in the blktap case we would add "script = .../blktap" to the backend flex array, but then jumped to the PHY case which added "script = .../block" too. The block one takes precendence since it comes second. This was, accidentally, correct. The blktap script is for blktap1 devices and not blktap2 devices. libxl completely manages the blktap2 side of things without resorting to hotplug scripts and creates a blkback device directly. Therefore the "block" script is always the correct one to call. Custom script are not supported in this context. - libxl should not write the "physical-device" node. This is the responsibility of the block script. Writing the "physical-device" node in libxl basically completely short-cuts the standard block hotplug script which uses "physical-device" to know if it has run already or not. In the case of more complex scripts libxl cannot know the right value to write here anyway, in particular the device may not exist until after the script is called. This change has the side effect of re-enabling the checks for device sharing aspect of the default block script, which I have tested and which now cause libxl to properly abort now that libxl properly checks for hotplug script errors. There is no sharing check for blktap2 since even if you reuse the same vhd the resulting tap device is different. I would have preferred to simply write the "physical-device" node for the blktap2 case but the hotplug script infrastructure is not currently setup to handle LIBXL__DEVICE_KIND_VBD devices without a hotplug script (backendtype phy and tap both end up as KIND_VBD). Changing this was more surgery than I was happy doing for 4.2 and therefore I have simply hardcoded to the block script for the LIBXL_DISK_BACKEND_TAP case. - libxl__device_disk_set_backend running against a phy device with a script cannot stat the device to check its properties since it may not exist until the script is run. Therefore I have special cased this in disk_try_backend to simply assume that backend == phy is always ok if a script was configured. Similarly the other backend types are always rejected if a script was configured. Note that the reason for implementing the default script behaviour in device_disk_add instead of libxl__device_disk_setdefault is because we need to be able to tell when the script was user-supplied rather than defaulted by libxl in order to correctly implement the above. The setdefault function must be idempotent so we cannot simply update disk->script. I suspect that for 4.3 a script member should be added to libxl__device, this would also help in the case above of handling devices with no script in a consistent manner. This is not 4.2 material. - When the block script falls through and shells out to a block-$type script it used to pass "$node" however the only place this was assigned was in the remove+phy case (in which case it contains the file:// derived /dev/loopN device), and in that case the script exits without falling through to the block-$type case. Since libxl never creates a type other than phy this never happens in practice anyway and we now call the correct block-$type script directly. But fix it up anyway since it is confusing. - The block-nbd and block-enbd scripts which we supply appear to be broken WRT the hotplug calling convention, in that they seem to expect a command line parameter (perhaps the $node described above) rather than reading the appropriate node from xenstore. I rather suspect this was broken by 7774:e2e7f47e6f79 in November 2005. I think it is safe to say no one is using these scripts! I haven't fixed this here. It would be good to track down some working scripts and either incorproate them or defer to them in their existing home (e.g. if they live somewhere useful like the nbd tools package). - Added a few block script related entries to check-xl-disk-parse from http://backdrift.org/xen-block-iscsi-script-with-multipath-support and http://lists.linbit.com/pipermail/drbd-user/2008-September/010221.html / http://www.drbd.org/users-guide-emb/s-xen-configure-domu.html (and snuck in another interesting empty CDROM case) This highlighted two bugs in the libxlu disk parser handling of the deprecated "<script>:" prefix: - It was failing to prefix with "block-" to construct the actual script name - The regex for matching iscsi or drdb or e?nbd was incorrect - Use libxl__abs_path for the nic script too. Just because the existing code nearly tricked me into repeating the mistake I have tested with a custom block script which uses "lvchange -a" to dynamically add remove the referenced device (simulates iSCSI login/logout without requiring me to faff around setting up an iSCSI target). I also tested on a blktap2 system. I haven't directly tested anything more complex like iscsi: or nbd: other than what check-xl-disk-parse exercises. [ Recommit of correct version of 25727:a8d708fcb347, which was mangled during commit. Sorry. -iwj ] 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>
* Backed out changeset a8d708fcb347Ian Jackson2012-08-061-18/+28
| | | | | | | 25727:a8d708fcb347 was mangled during commit. Back it out so that we can commit it properly. Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: support custom block hotplug scriptsIan Campbell2012-08-031-28/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are provided using the "script=" syntax described in docs/misc/xl-disk-configuration.txt. The existing hotplug scripts currently conflate two different concepts, namely that of making a datapath available in the backend domain (logging into iSCSI LUNs and the like) and that of actually connecting that datapath to a Xen backend path (e.g. writing "physical-device" node in xenstore to bring up blkback). For this reason the script support implemented here is only supported in conjunction with backendtype=phy. Eventually we hope to rework the hotplug scripts to separate the to concepts, but that is not 4.2 material. In addition there are some other subtleties: - Previously in the blktap case we would add "script = .../blktap" to the backend flex array, but then jumped to the PHY case which added "script = .../block" too. The block one takes precendence since it comes second. This was, accidentally, correct. The blktap script is for blktap1 devices and not blktap2 devices. libxl completely manages the blktap2 side of things without resorting to hotplug scripts and creates a blkback device directly. Therefore the "block" script is always the correct one to call. Custom script are not supported in this context. - libxl should not write the "physical-device" node. This is the responsibility of the block script. Writing the "physical-device" node in libxl basically completely short-cuts the standard block hotplug script which uses "physical-device" to know if it has run already or not. In the case of more complex scripts libxl cannot know the right value to write here anyway, in particular the device may not exist until after the script is called. This change has the side effect of re-enabling the checks for device sharing aspect of the default block script, which I have tested and which now cause libxl to properly abort now that libxl properly checks for hotplug script errors. There is no sharing check for blktap2 since even if you reuse the same vhd the resulting tap device is different. I would have preferred to simply write the "physical-device" node for the blktap2 case but the hotplug script infrastructure is not currently setup to handle LIBXL__DEVICE_KIND_VBD devices without a hotplug script (backendtype phy and tap both end up as KIND_VBD). Changing this was more surgery than I was happy doing for 4.2 and therefore I have simply hardcoded to the block script for the LIBXL_DISK_BACKEND_TAP case. - libxl__device_disk_set_backend running against a phy device with a script cannot stat the device to check its properties since it may not exist until the script is run. Therefore I have special cased this in disk_try_backend to simply assume that backend == phy is always ok if a script was configured. Similarly the other backend types are always rejected if a script was configured. Note that the reason for implementing the default script behaviour in device_disk_add instead of libxl__device_disk_setdefault is because we need to be able to tell when the script was user-supplied rather than defaulted by libxl in order to correctly implement the above. The setdefault function must be idempotent so we cannot simply update disk->script. I suspect that for 4.3 a script member should be added to libxl__device, this would also help in the case above of handling devices with no script in a consistent manner. This is not 4.2 material. - When the block script falls through and shells out to a block-$type script it used to pass "$node" however the only place this was assigned was in the remove+phy case (in which case it contains the file:// derived /dev/loopN device), and in that case the script exits without falling through to the block-$type case. Since libxl never creates a type other than phy this never happens in practice anyway and we now call the correct block-$type script directly. But fix it up anyway since it is confusing. - The block-nbd and block-enbd scripts which we supply appear to be broken WRT the hotplug calling convention, in that they seem to expect a command line parameter (perhaps the $node described above) rather than reading the appropriate node from xenstore. I rather suspect this was broken by 7774:e2e7f47e6f79 in November 2005. I think it is safe to say no one is using these scripts! I haven't fixed this here. It would be good to track down some working scripts and either incorproate them or defer to them in their existing home (e.g. if they live somewhere useful like the nbd tools package). - Added a few block script related entries to check-xl-disk-parse from http://backdrift.org/xen-block-iscsi-script-with-multipath-support and http://lists.linbit.com/pipermail/drbd-user/2008-September/010221.html / http://www.drbd.org/users-guide-emb/s-xen-configure-domu.html (and snuck in another interesting empty CDROM case) This highlighted two bugs in the libxlu disk parser handling of the deprecated "<script>:" prefix: - It was failing to prefix with "block-" to construct the actual script name - The regex for matching iscsi or drdb or e?nbd was incorrect - Use libxl__abs_path for the nic script too. Just because the existing code nearly tricked me into repeating the mistake I have tested with a custom block script which uses "lvchange -a" to dynamically add remove the referenced device (simulates iSCSI login/logout without requiring me to faff around setting up an iSCSI target). I also tested on a blktap2 system. I haven't directly tested anything more complex like iscsi: or nbd: other than what check-xl-disk-parse exercises. [ reran flex/bison -iwj ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix unitialized variables in libxl__primary_console_findOlaf Hering2012-08-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of LIBXL_DOMAIN_TYPE_INVALID properly: cc1: warnings being treated as errors libxl.c: In function 'libxl_primary_console_exec': libxl.c:1408:14: error: 'domid' may be used uninitialized in this function libxl.c:1409:9: error: 'cons_num' may be used uninitialized in this function libxl.c:1410:24: error: 'type' may be used uninitialized in this function libxl.c: In function 'libxl_primary_console_get_tty': libxl.c:1421:14: error: 'domid' may be used uninitialized in this function libxl.c:1422:9: error: 'cons_num' may be used uninitialized in this function libxl.c:1423:24: error: 'type' may be used uninitialized in this function make[3]: *** [libxl.o] Error 1 Fix this by adding a default case. Signed-off-by: Olaf Hering <olaf@aepfle.de> 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-3/+18
| | | | | | | | | | 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-3/+19
| | | | | | | | | | 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: call hotplug scripts for disk devices from libxlRoger Pau Monne2012-07-261-0/+10
| | | | | | | | | | | | | | | | Since most of the needed work is already done in previous patches, this patch only contains the necessary code to call hotplug scripts for disk devices, that should be called when the device is added or removed from a guest. We will chain the launch of the disk hotplug scripts after the device_backend_callback callback, or directly from libxl__initiate_device_{add,remove} if the device is already in the desired state. 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: set correct nic type depending on the guestRoger Pau Monne2012-07-261-4/+22
| | | | | | | | | | | | Fix the use of nic type, which results in the following for each type of domain: * HVM: let the user choose, if none specified use VIF_IOEMU. * PV: use VIF is none provided, return error if VIF_IOEMU requested. 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-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>