aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* libxl: fix api check MakefileIan Jackson2012-09-031-3/+5
| | | | | | | | | | | | | | | | | Touch the libxl.api-ok stamp file, and unconditionally put in place the new _libxl.api-for-check. This avoids needlessly rerunning the preprocessor on libxl.h each time we call "make". Ensure that _libxl.api-for-check gets the CFLAGS used for xl, so that if it is asked for in a standalone make run it can find xentoollog.h. Remove *.api-ok on clean. Also fix .gitignore. 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/xl: implement support for guest ioport and irq permissions.Ian Campbell2012-09-033-1/+124
| | | | | | | | | | | | | | | | | | | | This is useful for passing legacy ISA devices (e.g. com ports, parallel ports) to guests. Supported syntax is as described in http://cmrg.fifthhorseman.net/wiki/xen#grantingaccesstoserialhardwaretoadomU I tested this using Xen's 'q' key handler which prints out the I/O port and IRQ ranges allowed for each domain. e.g.: (XEN) Rangesets belonging to domain 31: (XEN) I/O Ports { 2e8-2ef, 2f8-2ff } (XEN) Interrupts { 3, 5-6 } Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Tested-by: Dieter Bloms <dieter@bloms.de> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: fix double free on some config parser errorsIan Jackson2012-08-312-65/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | If libxlu_cfg_y.y encountered a config file error, the code generated by bison would sometimes _both_ run the %destructor _and_ call xlu__cfg_set_store for the same XLU_ConfigSetting* semantic value. The result would be a double free. This appears to be because of the use of a mid-rule action. There is some discussion of the problems with destructors and mid-rule action error handling in "(bison)Mid-Rule Actions". This area is complex and best avoided. So fix the bug by abolishing the use of a mid-rule action, which was in any case not necessary here. Also while we are there rename the nonterminal rule "setting" to "assignment", to avoid confusion with the token type "setting", which had an identically name in a different namespace. This was especially confusing because the nonterminal "setting" did not have "setting" as the type of its semantic value! (In fact the nonterminal, now called "assignment", does not have a value so it does not have a value type.) 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>
* tools: remove --disable-pythontools optionIan Campbell2012-08-313-113/+80
| | | | | | | | | | | This incorrectly removes the $(PYTHON) variable which is used at build time as well as by the tools. Remove and revisit 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>
* xencommons: Attempt to load blktap2 driverIan Campbell2012-08-311-0/+1
| | | | | | | | | | | | | | | | | | | | | Older kernels, such as those found in Debian Squeeze: * Have bugs in handling of AIO into foreign pages * Have blktap modules, which will cause qemu not to use AIO, but which are not loaded on boot. Attempt to load blktap in xencommons, to make sure modern qemu's which use AIO will work properly on those kernels. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Prefer to load blktap2 if it exists. This is the name of the driver in classic-Xen ports, while in mainline kernels the driver is called just blktap. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Jan Beulich <JBeulich@suse.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* tools: remove vestigial default_lib.m4 macros and adjust substitutionsMatt Wilson2012-08-313-46/+0
| | | | | | | | | | | | | | | | | | | LIB_PATH is no longer used, so the AX_DEFAULT_LIB macro is no longer needed. Additionally lower case make variables are now used as autoconf substitutions, which allows for more correct overrides at build time. I've checked the file layout in dist/install from the build made before this change versus after with ./configure values of: 1) ./configure (no flags provided) 2) ./configure --libdir=/usr/lib/x86_64-linux-gnu (Debian style) 3) ./configure --libdir='${exec_prefix}/lib' (late variable expansion) Signed-off-by: Matt Wilson <msw@amazon.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc - reran autogen.sh ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* uninstall: push tools uninstall down into tools/MakefileIan Campbell2012-08-311-0/+32
| | | | | | | | | | Many of the rules here depend on having run configure and the variables which it defines in config/Tools.mk Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Looks-good: Jan Beulich <JBeulich@suse.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* hotplug/NetBSD: check type of file to attach from paramsRoger Pau Monne2012-08-311-1/+10
| | | | | | | | | | | | xend used to set the xenbus backend entry "type" to either "phy" or "file", but now libxl sets it to "phy" for both file and block device. We have to manually check for the type of the "param" field in order to detect if we are trying to attach a file or a block device. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> 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>
* hotplug/NetBSD: write error message to hotplug-errorRoger Pau Monne2012-08-311-1/+2
| | | | | | | | | As recommended by Ian Campbell, write the hotplug error to hotplug-error, just as the Linux hotplug script does. 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>
* hotplug/NetBSD: fix xenstore_write usage in errorRoger Pau Monne2012-08-311-1/+1
| | | | | | | | | | xenstore_write doesn't exist, use xenstore-write instead. The error function is currently broken without this change. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* xenconsoled: clean-up after all dead domainsDavid Vrabel2012-08-311-1/+11
| | | | | | | | | | | | | | | | | | | | | | | xenconsoled expected domains that are being shutdown to end up in the the DYING state and would only clean-up such domains. HVM domains either didn't enter the DYING state or weren't in long enough for xenconsoled to notice. For every shutdown HVM domain, xenconsoled would leak memory, grow its list of domains and (if guest console logging was enabled) leak the log file descriptor. If the file descriptors were leaked and enough HVM domains were shutdown, no more console connections would work as the evtchn device could not be opened. Guests would then block waiting to send console output. Fix this by tagging domains that exist in enum_domains(). Afterwards, all untagged domains are assumed to be dead and are shutdown and cleaned up. Signed-off-by: David Vrabel <david.vrabel@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>
* tools/xl: Fix uninitialized variable error.Andrew Cooper2012-08-281-4/+4
| | | | | | | | | | | | | | | | | | c/s 25779:4ca40e0559c3 introduced a compilation error for any build system using -Werror=uninitialized, such as the default CentOS 5.7 version of gcc. And with good reason, because if the global libxl default_output_format is neither OUTPUT_FORMAT_SXP nor OUTPUT_FORMAT_JSON, the variable hand will be used before being initialised. The attached patch fixes the warning, and futher fixes the logic to work correctly when a new OUTPUT_FORMAT is added to xl. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Rerun bisonIan Jackson2012-08-242-192/+241
| | | | | | | | | | | | | This updates libxlu_cfg_y.[ch] to code generated by bison from Debian squeeze (1:2.4.1.dfsg-3 i386). There should be no functional change since there is no change to the source file, but we will inherit bugfixes and behavioural changes from the new version of bison. So this is more a matter of hope than knowledge. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Rerun flexIan Jackson2012-08-242-56/+40
| | | | | | | | | | This undoes some systematic changes which were made to libxlu_cfg_l.[ch] along with manually-edited files (eg, whitespace changes, emacs local variables) and returns these two files to exactly the output of flex (Debian squeeze 2.5.35-10 i386). Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: provide "make realclean" targetIan Jackson2012-08-241-1/+3
| | | | | | | | This removes all the autogenerated files. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: make "xl list -l" proper JSONIan Campbell2012-08-231-16/+71
| | | | | | | | | | | | | | | Bastian Blank reports that the output of this command is just multiple JSON objects concatenated and is not a single properly formed JSON object. Fix this by wrapping in an array. This turned out to be a bit more intrusive than I was expecting due to the requirement to keep supporting the SXP output mode. Python's json module is happy to parse the result... Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: make domain resume API asynchronousIan Campbell2012-08-235-20/+27
| | | | | | | | | | | | | | | | | | 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>
* hvm: Remove VM genearation ID device and incr_generationid from build_info.Paul Durrant2012-08-225-41/+1
| | | | | | | | | | | | | | | | Microsoft have now published their VM generation ID specification at https://www.microsoft.com/en-us/download/details.aspx?id=30707. It differs from the original specification upon which I based my implementation in several key areas. Particularly, it is no longer an incrementing 64-bit counter and so this patch is to remove the incr_generationid field from the build_info and also disable the ACPI device before 4.2 is released. I will follow up with further patches to implement the VM generation ID to the new specification. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Committed-by: Keir Fraser <keir@xen.org>
* libxc: Support save/restore of up to 4096 VCPUs (increase from 64 VCPUs).Keir Fraser2012-08-223-20/+24
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* flask/policy: add accesses used by newer dom0sDaniel De Graaf2012-08-222-3/+3
| | | | | Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Committed-by: Keir Fraser <keir@xen.org>
* tools/python: Clean python correctlyAndrew Cooper2012-08-173-20/+18
| | | | | | | | | | Cleaning the python directory should completely remove the build/ directory, otherwise subsequent builds may be short-circuited and a stale build installed. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxc/Linux: Add VM_DONTCOPY flag of the VMA of the hypercall bufferWangzhenguo2012-08-172-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids the hypercall buffer becoming CoW on fork. In multi-threads and multi-processes environment, e.g. the process has two threads, thread A may call hypercall, thread B may call fork() to create child process. After forking, all pages of the process including hypercall buffers are cow. It will cause a write protection and return EFAULT error if hypervisor calls copy_to_user in hypercall in thread A context, Fix: 1. Before hypercall: use MADV_DONTFORK of madvise syscall to make the hypercall buffer not to be copied to child process after fork. 2. After hypercall: undo the effect of MADV_DONTFORK for the hypercall buffer by using MADV_DOFORK of madvise syscall. 3. Use mmap/nunmap for memory alloc/free instead of malloc/free to bypass libc. Note: Child processes must not use the opened xc_{interface,evtchn,gnttab,gntshr} handle that inherits from parents. They should reopen the handle if they want to interact with xc. Otherwise, it may cause segment fault to access hypercall buffer caches of the handle. Signed-off-by: Zhenguo Wang <wangzhenguo@huawei.com> Signed-off-by: Xiaowei Yang <xiaowei.yang@huawei.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- s/ptr/p/ to fix build & tweaked the wording of the comments slightly. ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
* xend: Replace the use of XMLPrettyPrint from PyXML with stdlib functionality.M A Young2012-08-171-2/+1
| | | | | | | | | | | | This appears to have been missed by changeset 22235:b8cc53d22545 "Replace pyxml/xmlproc-based XML validator with lxml based one" This was reported by Toshio Ernie Kuratomi at https://bugzilla.redhat.com/show_bug.cgi?id=842843 Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* x86/PoD: prevent guest from being destroyed upon early access to its memoryJan Beulich2012-08-161-14/+21
| | | | | | | | | | | | | | | | | | | | When an external agent (e.g. a monitoring daemon) happens to access the memory of a PoD guest prior to setting the PoD target, that access must fail for there not being any page in the PoD cache, and only the space above the low 2Mb gets scanned for victim pages (while only the low 2Mb got real pages populated so far). To accomodate for this - set the PoD target first - do all physmap population in PoD mode (i.e. not just large [2Mb or 1Gb] pages) - slightly lift the restrictions enforced by p2m_pod_set_mem_target() to accomodate for the changed tools behavior Tested-by: Jürgen Groß <juergen.gross@ts.fujitsu.com> (in a 4.0.x based incarnation) Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
* etherboot: Build fixes for gcc 4.7.Keir Fraser2012-08-154-0/+92
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* libxl: fix build for gcc prior to 4.3Jan Beulich2012-08-131-1/+3
| | | | | | | | | | So far all we (explicitly) require is gcc 3.4 or better, so we shouldn't be unconditionally using features supported only by much newer versions. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: init.d/Linux/xencommons: load all known backend driversOlaf Hering2012-08-131-0/+6
| | | | | | | | | | | Load all known backend drivers fron xenlinux and pvops based dom0 kernels. There is currently no code in xend or libxl to load these drivers on demand. Currently libxl has also no helpful error message if a backend driver is missing. Signed-off-by: Olaf Hering <olaf@aepfle.de> 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-068-361/+424
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge backout of 25727:a8d708fcb347Ian Jackson2012-08-068-377/+328
|\
| * Backed out changeset a8d708fcb347Ian Jackson2012-08-068-377/+328
| | | | | | | | | | | | | | 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: fix cleanup of tap devices in libxl__device_destroyIan Campbell2012-08-034-18/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We pass be_path to tapdisk_destroy but we've already deleted it so it fails to read tapdisk-params. However it appears that we need to destroy the tap device after tearing down xenstore, to avoid the leak reported by Greg Wettstein in <201207312141.q6VLfJje012656@wind.enjellic.com>. So read the tapdisk-params in the cleanup transaction, before the remove, and pass that down to destroy_tapdisk instead. tapdisk-params may of course be NULL if the device isn't a tap device. There is no need to tear down the tap device from libxl__initiate_device_remove since this ultimately calls libxl__device_destroy. Propagate and log errors from libxl__device_destroy_tapdisk. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* | tools/hotplug/Linux/init.d/: load other xen kernel modules on xencommons startFabio Fantoni2012-08-031-0/+3
|/ | | | | Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: support custom block hotplug scriptsIan Campbell2012-08-038-328/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: correct some comments regarding event API and fdsIan Jackson2012-08-031-3/+14
| | | | | | | | | | | | | | | * libxl may indeed register more than one callback for the same fd, with some restrictions. The allowable range of responses to this by the application means that this should pose no problems for users. But the documentation comment should be fixed. * Document the relaxed synchronicity semantics of the fd_modify registration callback. * A couple of comments referred to old names for functions. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: const correctness for libxl__xs_path_cleanupIan Campbell2012-08-033-3/+4
| | | | | | 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 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: idl: always initialise the KeyedEnum keyvar in the member init functionIan Campbell2012-08-032-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we only initialised it if an explicit keyvar_init_val was given but not if the default was implicitly 0. In the generated code this only changes the unused libxl_event_init_type function: void libxl_event_init_type(libxl_event *p, libxl_event_type type) { + assert(!p->type); + p->type = type; switch (p->type) { case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN: break; However I think it is wrong that this function is unused, this and libxl_event_init should be used by libxl__event_new. As it happens both are just memset to zero but for correctness we should use the init functions (in case the IDL changes). In the generator we also need to properly handle init_var == 0 which the current if statements incorrectly treat as False. This doesn't actually have any impact on the generated code. 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: remove an unused numainfo parameterIan Jackson2012-08-031-2/+2
| | | | | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Dario Faggioli <dario.faggioli@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: remus: mark TODOs more clearlyIan Jackson2012-08-031-4/+5
| | | | | | | | | | | | | Change the TODOs in the remus code to "REMUS TODO" which will make them easier to grep for later. AIUI all of these are essential for use of remus in production. Also add a new TODO and a new assert, to check rc on entry to remus_checkpoint_dm_saved. 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: do not blunder on if bootloader fails (again)Ian Jackson2012-08-031-2/+9
| | | | | | | | | | | | | Do not lose the rc value passed to bootloader_callback. Do not lose the rc value from the bl when the local disk detach succeeds. While we're here rationalise the use of bl->rc to make things clearer. Set it to zero at the start and always update it conditionally; copy it into bootloader_callback's argument each time. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: rename aodevs to multidevIan Jackson2012-08-034-77/+77
| | | | | | | | | | | | To be consistent with the new function naming, rename libxl__ao_devices to libxl__multidev and all variables aodevs to multidev. No functional change. 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: abolish useless `start' parameter to libxl__add_*Ian Jackson2012-08-034-13/+10
| | | | | | | | | 0 is always passed for this parameter and the code doesn't, actually, use it, now. 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: fix formatting of DEFINE_DEVICES_ADDIan Jackson2012-08-031-13/+13
| | | | | | | | | | | | These lines were exactly 80 columns wide, which produces hideous wrap damage in an 80 column emacs. Reformat using emacs's C-c \, which puts the \ in column 72 (by default) where possible. Whitespace change only. 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: fix device counting race in libxl__devices_destroyIan Jackson2012-08-034-110/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't have a fixed number of devices in the aodevs array, and instead size it depending on the devices present in xenstore. Somewhat formalise the multiple device addition/removal machinery to make this clearer and easier to do. As a side-effect we fix a few "lost thread of control" bug which would occur if there were no devices of a particular kind. (Various if statements which checked for there being no devices have become redundant, but are retained to avoid making the patch bigger.) Specifically: * Users of libxl__ao_devices are no longer expected to know in advance how many device operations they are going to do. Instead they can initiate them one at a time, between bracketing calls to "begin" and "prepared". * The array of aodevs used for this is dynamically sized; to support this it's an array of pointers rather than of structs. * Users of libxl__ao_devices are presented with a more opaque interface. They are are no longer expected to, themselves, - look into the array of aodevs (this is now private) - know that the individual addition/removal completions are handled by libxl__ao_devices_callback (this callback function is now a private function for the multidev machinery) - ever deal with populating the contents of an aodevs * The doc comments relating to some of the members of libxl__ao_device are clarified. (And the member `aodevs' is moved to put it with the other members with the same status.) * The multidev machinery allocates an aodev to represent the operation of preparing all of the other operations. See the comment in libxl__multidev_begin. A wrinkle is that the functions are called "multidev" but the structs are called "libxl__ao_devices" and "aodevs". I have given these functions this name to distinguish them from "libxl__ao_device" and "aodev" and so forth by more than just the use of the plural "s" suffix. In the next patch we will rename the structs. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: react correctly to bootloader pty master POLLHUPIan Jackson2012-08-033-12/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | Receive POLLHUP on the bootloader master pty is not an error. Hopefully it means that the bootloader has exited and therefore the pty slave side has no process group any more. (At least NetBSD indicates POLLHUP on the master in this case.) So send the bootloader SIGTERM; if it has already exited then this has no effect (except that on some versions of NetBSD it erroneously returns ESRCH and we print a harmless warning) and we will then collect the bootloader's exit status and be satisfied. However, we remember that we have done this so that if we got POLLHUP for some other reason than that the bootloader exited we report something resembling a useful message. In order to implement this we need to provide a way for users of datacopier to handle POLLHUP rather than treating it as fatal. We rename bootloader_abort to bootloader_stop since it now no longer only applies to error situations. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: unify libxl__device_destroy and device_hotplug_doneIan Jackson2012-08-031-23/+13
| | | | | | | | | | | | | | | | | | | | device_hotplug_done contains an open-coded but improved version of libxl__device_destroy. So move the contents of device_hotplug_done into libxl__device_destroy, deleting the old code, and replace it at its old location with a function call. Add the missing call to libxl__xs_transaction_abort (which was present in neither version and technically speaking is always a no-op with this code as it stands at the moment because no-one does "goto out" other than after libxl__xs_transaction_start or _commit). Also fix the error handling: the rc from the destroy should be propagated into the aodev. Reported-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* tools/vtpm: fix tpm_version.h error during parallel buildOlaf Hering2012-08-031-2/+3
| | | | | | | | | | | | | | | | | Generating the tpm_version.h is not make -j safe: In file included from ../tpm/tpm_emulator.h:25:0, from ../tpm/tpm_startup.c:18: ../tpm/tpm_version.h:1:0: error: unterminated #ifndef make[5]: *** [tpm_startup.o] Error 1 This happens because make can not know that 'all-recursive' depends on 'version'. Fix this by calling the individual make targets. Doing it this way avoids adding yet another patch to the downloaded source. 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: only read script once in libxl__hotplug_*Ian Campbell2012-08-031-12/+4
| | | | | | | | | instead of duplicating the error handling etc in get_hotplug_env just pass the script already read by the caller down. 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: prefix *.for-check with _ to mark it as a generated file.Ian Campbell2012-08-031-3/+3
| | | | | | | | Keeps it out of my greps etc. 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>