]> xenbits.xensource.com Git - xen.git/log
xen.git
9 years agoxen: enable XENMEM_memory_map in hvm
Tiejun Chen [Wed, 22 Jul 2015 01:39:58 +0000 (01:39 +0000)]
xen: enable XENMEM_memory_map in hvm

This patch enables XENMEM_memory_map in hvm. So hvmloader can
use it to setup the e820 mappings.

CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
9 years agoxen/passthrough: extend hypercall to support rdm reservation policy
Tiejun Chen [Wed, 22 Jul 2015 01:40:11 +0000 (01:40 +0000)]
xen/passthrough: extend hypercall to support rdm reservation policy

This patch extends the existing hypercall to support rdm reservation policy.
We return error or just throw out a warning message depending on whether
the policy is "strict" or "relaxed" when reserving RDM regions in pfn space.
Note in some special cases, e.g. add a device to hwdomain, and remove a
device from user domain, 'relaxed' is fine enough since this is always safe
to hwdomain.

CC: Tim Deegan <tim@xen.org>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
CC: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
CC: Yang Zhang <yang.z.zhang@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
--
v13a: Fix build on ARM by passing 0 for flags to arm_smmu_assign_dev.

9 years agoxen/vtd: create RMRR mapping
Tiejun Chen [Wed, 22 Jul 2015 01:39:58 +0000 (01:39 +0000)]
xen/vtd: create RMRR mapping

RMRR reserved regions must be setup in the pfn space with an identity
mapping to reported mfn. However existing code has problem to setup
correct mapping when VT-d shares EPT page table, so lead to problem
when assigning devices (e.g GPU) with RMRR reported. So instead, this
patch aims to setup identity mapping in p2m layer, regardless of
whether EPT is shared or not. And we still keep creating VT-d table.

And we also need to introduce a pair of helper to create/clear this
sort of identity mapping as follows:

set_identity_p2m_entry():

If the gfn space is unoccupied, we just set the mapping. If space
is already occupied by desired identity mapping, do nothing.
Otherwise, failure is returned.

clear_identity_p2m_entry():

We just define macro to wrapper guest_physmap_remove_page() with
a returning value as necessary.

CC: Tim Deegan <tim@xen.org>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Yang Zhang <yang.z.zhang@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
9 years agointroduce XENMEM_reserved_device_memory_map
Jan Beulich [Wed, 22 Jul 2015 15:06:01 +0000 (16:06 +0100)]
introduce XENMEM_reserved_device_memory_map

This is a prerequisite for punching holes into HVM and PVH guests' P2M
to allow passing through devices that are associated with (on VT-d)
RMRRs.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v12a: Move interface structure union member to the end, while moving
     the whole public header block into a __XEN__ / __XEN_TOOLS__
     conditional block.
v12: Restore changes as much as possible to my original version, fixing
     a few issues that got introduced after handing it over. Unionize
     new public memop interface structure to allow for non-PCI to be
     supported later on. Check flags to have all currently undefined
     flags clear. Refine adjustments to xen/pci.h.

9 years agox86/MSI: drop bogus NULL check from pci_restore_msi_state()
Jan Beulich [Thu, 23 Jul 2015 12:03:41 +0000 (14:03 +0200)]
x86/MSI: drop bogus NULL check from pci_restore_msi_state()

Commit 372900faf8 ("x86/MSI-X: reduce fiddling with control register
during restore") introduced de-references of pdev before it gets
checked against NULL. Instead of deferring the de-references, drop
the pointless check - both call sites do that check already.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agohvmloader: don't build with __XEN_TOOLS__ defined
Jan Beulich [Thu, 23 Jul 2015 12:03:20 +0000 (14:03 +0200)]
hvmloader: don't build with __XEN_TOOLS__ defined

This being an in-guest component, it shouldn't get to see (and even
less so use) tools-only public interfaces.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/PCI: intercept all PV Dom0 MMCFG writes
Jan Beulich [Thu, 23 Jul 2015 08:17:08 +0000 (10:17 +0200)]
x86/PCI: intercept all PV Dom0 MMCFG writes

... to hook up pci_conf_write_intercept() even for Dom0 not using
method 1 accesses for the base part of PCI device config space.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/MSI: properly track guest masking requests
Jan Beulich [Thu, 23 Jul 2015 08:16:27 +0000 (10:16 +0200)]
x86/MSI: properly track guest masking requests

... by monitoring writes to the mask register.

This allows reverting the main effect of the XSA-129 patches in qemu.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/MSI-X: reduce fiddling with control register during restore
Jan Beulich [Thu, 23 Jul 2015 08:16:03 +0000 (10:16 +0200)]
x86/MSI-X: reduce fiddling with control register during restore

Rather than disabling and enabling MSI-X once per vector, do it just
once per device.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/MSI-X: access MSI-X table only after having enabled MSI-X
Jan Beulich [Thu, 23 Jul 2015 08:15:39 +0000 (10:15 +0200)]
x86/MSI-X: access MSI-X table only after having enabled MSI-X

As done in Linux by f598282f51 ("PCI: Fix the NIU MSI-X problem in a
better way") and its broken predecessor, make sure we don't access the
MSI-X table without having enabled MSI-X first, using the mask-all flag
instead to prevent interrupts from occurring.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/MSI-X: be more careful during teardown
Jan Beulich [Thu, 23 Jul 2015 08:14:59 +0000 (10:14 +0200)]
x86/MSI-X: be more careful during teardown

When a device gets detached from a guest, pciback will clear its
command register, thus disabling both memory and I/O decoding. The
disabled memory decoding, however, has an effect on the MSI-X table
accesses the hypervisor does: These won't have the intended effect
anymore. Even worse, for PCIe devices (but not SR-IOV virtual
functions) such accesses may (will?) be treated as Unsupported
Requests, causing respective errors to be surfaced, potentially in the
form of NMIs that may be fatal to the hypervisor or Dom0 is different
ways. Hence rather than carrying out these accesses, we should avoid
them where we can, and use alternative (e.g. PCI config space based)
mechanisms to achieve at least the same effect.

At this time it continues to be unclear whether this is fixing an
actual bug or is rather just working around bogus (but apparently
common) system behavior.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/MSI-X: track host and guest mask-all requests separately
Jan Beulich [Thu, 23 Jul 2015 08:14:13 +0000 (10:14 +0200)]
x86/MSI-X: track host and guest mask-all requests separately

Host uses of the bits will be added subsequently, and must not be
overridden by guests (including Dom0, namely when acting on behalf of
a guest).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86/PCI: add config space abstract write intercept logic
Jan Beulich [Thu, 23 Jul 2015 08:13:12 +0000 (10:13 +0200)]
x86/PCI: add config space abstract write intercept logic

This is to be used by MSI code, and later to also be hooked up to
MMCFG accesses by Dom0.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMerge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
Ian Campbell [Wed, 22 Jul 2015 14:55:14 +0000 (15:55 +0100)]
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging

9 years agoremove non-POSIX error codes
Roger Pau Monné [Wed, 22 Jul 2015 14:53:22 +0000 (16:53 +0200)]
remove non-POSIX error codes

Xen was using some non-POSIX error codes that are removed in this patch. For
future reference, the list of POSIX error codes has been obtained from:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html

The error codes already present and defined as optional (XSR), have been
left in place.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoreplace non-POSIX error codes
Roger Pau Monné [Wed, 22 Jul 2015 14:47:09 +0000 (16:47 +0200)]
replace non-POSIX error codes

Some DOMCTLs returned non-POSIX error codes, replace them with POSIX
compilant values instead. EBADRQC and EBADSLT are replaced by EDOM, while
EUSERS is replaced with EOVERFLOW.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Replace two EDOM uses.

Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agox86/libxl: replace non-POSIX error codes used by PSR code
Roger Pau Monné [Wed, 22 Jul 2015 14:45:35 +0000 (16:45 +0200)]
x86/libxl: replace non-POSIX error codes used by PSR code

PSR was using EBADSLT and EUSERS which are not POSIX error codes, replace
them with ENOTSOCK and EOVERFLOW respectively.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: fix vcpus to vnode assignement in config file
Dario Faggioli [Tue, 21 Jul 2015 17:31:57 +0000 (19:31 +0200)]
xl: fix vcpus to vnode assignement in config file

In fact, right now, the following (legitimate)
configuration:

 vcpus       = '4'
 vnuma = [ [ "pnode=0","size=512","vcpus=0,1","vdistances=10,20"  ],
           [ "pnode=1","size=512","vcpus=2,3","vdistances=20,10"  ] ]

Produces the following error:

 # xl create /etc/xen/test.cfg
 Parsing config from /etc/xen/test.cfg
 xl: maxvcpus < vcpu

That is because, we only process the first element of the
"vcpus=" list (of each vnode specification). Therefore,
in the above case, we only see 2 vcpus, out of 4, being
assigned to the vnodes, and hence the error.

What we need is either a multidimentional array, or a
bitmap, to temporary store the vcpus of a vnode, while
parsing the vnuma config entry. Let's use the latter,
which happens to also make it easier to copy the outcome
of the parsing to its final destination in b_info, if
everything goes ok.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agox86/psr: remove invalid cpu_to_socket call
Chao Peng [Wed, 22 Jul 2015 12:15:37 +0000 (14:15 +0200)]
x86/psr: remove invalid cpu_to_socket call

cpu_to_socket() can't give correct socket value in CPU_PREPARE notifier
as at that time phys_proc_id has not yet been initialized (the value is
its default 0 in this case) which is incorrect for sockets other than
socket 0.

cos_to_cbm now is pre-allocated in CPU_PREPARE notifier and then consumed
in CPU_STARTING notifier.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
9 years agolibxl: fix build with glibc < 2.9
Jan Beulich [Wed, 22 Jul 2015 12:15:12 +0000 (14:15 +0200)]
libxl: fix build with glibc < 2.9

htobe*() and be*toh() don't exist there. While replacing the 32-bit
ones with hton() and ntoh() would be possible, there wouldn't be an
obvious replacement for the 64-bit ones. Hence just take what current
glibc (2.21) has (assuming __bswap_*() exists, which it does back to
at least 2.4 according to my checking).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agoxl: Command line: Support -h everywhere
Ian Jackson [Fri, 17 Jul 2015 17:00:49 +0000 (18:00 +0100)]
xl: Command line: Support -h everywhere

xl subcommands ought all to take -h.  def_getopt and hence
SWITCH_FOREACH_OPT already handles 'h' by calling helpstr.  None of
the call sites see the 'h'.

In this patch:

 * Change SWITCH_FOREACH_OPT to always add a "h" to the short opts
   string, using string concatenation.

 * Remove the now-redundant h's from some existing option strings.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Command line: Remove maximum argument limit for network-attach
Ian Jackson [Fri, 17 Jul 2015 17:00:48 +0000 (18:00 +0100)]
xl: Command line: Remove maximum argument limit for network-attach

This limit of 11 has been in this function since it was written, but
serves no purpose.  The extra arguments are fed one by one to
parse_nic_config, and it is possible to have as many as you like.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Command line: Adjust "Fix segfaults from `xl psr-cat-cbm-set`..."
Ian Jackson [Fri, 17 Jul 2015 17:00:47 +0000 (18:00 +0100)]
xl: Command line: Adjust "Fix segfaults from `xl psr-cat-cbm-set`..."

This adjust commit a49077e5 "Fix segfaults from `xl psr-cat-cbm-set`
command line handling":

 * Do not use the constant `required_argument' here (we simply use 1
   everywhere else).

 * Fix the minimum required arguments argument to SWITCH_FOREACH_OPT.

Leave the separate check on optind, because it checks for too many as
well as too few arguments.

(There are many things in xl which fail to check for too many
arguments.  I do not intend to drain that swamp now: I started but
decided a complete overhaul of most of xl's command line argument
processing would be best.)

This is just a code cleanup with no ultimate functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agotools: libxl: Refix "Initialise the fd of the unused half of a datacopier"
Ian Campbell [Tue, 21 Jul 2015 15:00:19 +0000 (16:00 +0100)]
tools: libxl: Refix "Initialise the fd of the unused half of a datacopier"

Applying the series out of order led to d72befc35f31 "tools/libxl:
Identify copywhat in stream v2 datacopiers" unintentionally reverting
part of 21d9b079e538 "tools/libxl: Initialise the fd of the unused
half of a datacopier".

Put this back.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agotools/libxl: Identify copywhat in stream v2 datacopiers
Andrew Cooper [Fri, 17 Jul 2015 16:51:17 +0000 (17:51 +0100)]
tools/libxl: Identify copywhat in stream v2 datacopiers

This is an aid to debugging

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxl: Log the subject fd in datacopier messages
Andrew Cooper [Fri, 17 Jul 2015 16:51:16 +0000 (17:51 +0100)]
tools/libxl: Log the subject fd in datacopier messages

This is a substantial aid to debugging

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxc: Identify the path of the kernel image which cannot be found
Andrew Cooper [Fri, 17 Jul 2015 16:51:15 +0000 (17:51 +0100)]
tools/libxc: Identify the path of the kernel image which cannot be found

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: call libxl_cpupoolinfo_{init, dispose} in numa_place_domain
Wei Liu [Fri, 17 Jul 2015 17:01:08 +0000 (18:01 +0100)]
libxl: call libxl_cpupoolinfo_{init, dispose} in numa_place_domain

Call libxl_cpupoolinfo_init at the beginning.  Change two returns to
goto out so that libxl_cpupoolinfo_dispose is called in failure path.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
9 years agolibxl: make libxl__strdup and libxl__strndup handle NULL
Wei Liu [Fri, 17 Jul 2015 17:01:06 +0000 (18:01 +0100)]
libxl: make libxl__strdup and libxl__strndup handle NULL

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
9 years agoxen: arm: Avoid reading beyond the last module
Chris (Christopher) Brand [Fri, 17 Jul 2015 20:48:08 +0000 (20:48 +0000)]
xen: arm: Avoid reading beyond the last module

nr_mods is set in add_boot_module() to the number of module
array elements used. This function also ensures that nr_mods
never exceeds MAX_MODULES (the size of the array). When looping
through the array, the correct maximum index is "nr_mods-1",
not "nr_mods". If the array is full, using the latter will in
fact access beyond the end of the array.
This was done correctly in boot_module_find_by_kind() and
consider_modules() but incorrectly in discard_initial_modules()
and next_module().

Signed-off-by: Chris Brand <chris.brand@broadcom.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agohotplug/FreeBSD: fix xendriverdomain rc.d script
Roger Pau Monne [Mon, 20 Jul 2015 14:55:02 +0000 (16:55 +0200)]
hotplug/FreeBSD: fix xendriverdomain rc.d script

hotplugpath.sh by default is located in /usr/local/etc/xen/scripts on
FreeBSD. Instead of hardcoding it's location use the XEN_SCRIPT_DIR variable
like it's used on the xencommons rc.d script.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agolibxl: include sys/endian.h for FreeBSD
Roger Pau Monne [Mon, 20 Jul 2015 14:55:00 +0000 (16:55 +0200)]
libxl: include sys/endian.h for FreeBSD

be64toh and friends are declared in sys/endian.h on FreeBSD, so include it
as part of libxl_osdeps.h.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxen: arm: gic-v3: avoid \n in the middle of log messages
Ian Campbell [Fri, 17 Jul 2015 13:21:45 +0000 (14:21 +0100)]
xen: arm: gic-v3: avoid \n in the middle of log messages

These result in log messages such as:

(XEN) d0v0: vGICD: RAZ on reserved register offset 0x00000c
(XEN) d0v0: vGICR: write r2 offset 0x000180
(XEN)  not found<G><3>traps.c:2417:d0v0 HSR=0x93820046 pc=0xffffffc000322bfc gva=0xffffff8000090180 gpa=0x0000008d110180

Fix this by rewording without a \n in the middle. Also add one at the end.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
9 years agotools/libxl: Update libxl_domain_unpause() to support qemu-xen
Yang Hongyang [Mon, 13 Jul 2015 08:45:45 +0000 (16:45 +0800)]
tools/libxl: Update libxl_domain_unpause() to support qemu-xen

Currently, libxl_domain_unpause() only supports
qemu-xen-traditional. Update it to support qemu-xen.
We use libxl__domain_resume_device_model to unpause guest dm.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxl: check QEMU state before resume dm
Yang Hongyang [Mon, 13 Jul 2015 08:43:30 +0000 (16:43 +0800)]
tools/libxl: check QEMU state before resume dm

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl/remus: introduce libxl__remus_teardown
Yang Hongyang [Fri, 10 Jul 2015 07:11:38 +0000 (15:11 +0800)]
libxl/remus: introduce libxl__remus_teardown

introduce libxl__remus_teardown to teardown Remus devices.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
9 years agolibxl/remus: introduce libxl__remus_setup
Yang Hongyang [Fri, 10 Jul 2015 06:57:52 +0000 (14:57 +0800)]
libxl/remus: introduce libxl__remus_setup

Refactoring Remus setup by introducing libxl__remus_setup API.
All Remus setup work are done in this function.

There is a subtle behavioural change here, which is that if anything
which is now done in _setup fails then the result is a call to
dss->callback( ..,..,ERROR_FAIL) rather than _start returning
AO_CREATE_FAIL(ERROR_FAIL). But this is correct and intended.

Also remove the libxl__ prefix for static functions.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agotools/libxl: rename remus checkpoint callbacks
Yang Hongyang [Fri, 10 Jul 2015 06:12:10 +0000 (14:12 +0800)]
tools/libxl: rename remus checkpoint callbacks

There are 2 remus checkpoint callbacks(save/restore), currently, they
both called libxl__remus_domain_checkpoint_callback in different
files, so it is ok. But in the following patch, we will move all of the
remus callback code into a separate file, the name should be different.
So rename them to:
  libxl__remus_domain_{save/restore}_checkpoint_callback

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
9 years agotools/libxl: move domain resume code into libxl_dom_suspend.c
Yang Hongyang [Fri, 10 Jul 2015 04:11:54 +0000 (12:11 +0800)]
tools/libxl: move domain resume code into libxl_dom_suspend.c

move domain resume code into libxl_dom_suspend.c.
pure code move.

libxl__domain_resume_device_model() will be used later by COLO,
so we are not making this func static.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
9 years agotools/libxl: move domain suspend code into libxl_dom_suspend.c
Yang Hongyang [Mon, 13 Jul 2015 02:24:30 +0000 (10:24 +0800)]
tools/libxl: move domain suspend code into libxl_dom_suspend.c

Move domain suspend code into a separate file libxl_dom_suspend.c.
Add an API libxl__domain_suspend() which wraps the static
function domain_suspend_callback_common() for internal use.
Export the existing API libxl__domain_suspend_callback() used by
libxc to suspend the guest during migration.

Note that the newly added file libxl_dom_suspend.c is used for
suspend/resume code.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
9 years agotools/libxl: rename libxl__domain_suspend to libxl__domain_save
Yang Hongyang [Wed, 3 Jun 2015 02:57:28 +0000 (10:57 +0800)]
tools/libxl: rename libxl__domain_suspend to libxl__domain_save

The suspend/save terminology used by libxc is more consistent.
"suspend" refers to quiescing the VM, so pausing qemu, making a
remote_shutdown(SHUTDOWN_suspend) hypercall etc.
"save" refers to the actions involved in actually shuffling the
state of the VM, so xc_domain_save() etc.

libxl currently uses "suspend" to encapsulate both. The patch
Rename libxl__domain_suspend() to libxl__domain_save() since it
actually refers to shuffling the state of the VM.

This results in some strangeness in that some functions called *save*
are now passed a struct called *suspend*, this is temporary and is all
fixed up later by the refactoring of the suspend_state.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Some comments, commit messages:
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
9 years agotools/libxl: Initialise the fd of the unused half of a datacopier
Andrew Cooper [Fri, 17 Jul 2015 16:59:09 +0000 (17:59 +0100)]
tools/libxl: Initialise the fd of the unused half of a datacopier

This bug causes a spurious failure if stdin happens to be an
appropriately readable/writeable pipe which receives a POLLHUP

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agotools/hotplug: Add an initscript to start "xl devd" in a driver domain
Ian Campbell [Thu, 16 Jul 2015 16:58:27 +0000 (17:58 +0100)]
tools/hotplug: Add an initscript to start "xl devd" in a driver domain

The removal of the udev rules highlighted that although it has been
replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon
was started/stopped, but not in an actual driver domain environment
since I don't have one conveniently available. I also checked that
running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools/xl: Fix segfaults from `xl psr-cat-cbm-set` command line handling
Andrew Cooper [Thu, 16 Jul 2015 19:32:45 +0000 (20:32 +0100)]
tools/xl: Fix segfaults from `xl psr-cat-cbm-set` command line handling

The socket option takes a mandatory argument.  Mark it as such, so
optarg isn't NULL when passed to trim(), which unconditionally
dereference it.

Range check optind against argc before blindly assuming that
argv[optind] and argv[optind+1] exist.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
9 years agotools/xl: Fix trim() following c/s e316316 "xl: Rewrite trim()"
Andrew Cooper [Thu, 16 Jul 2015 19:18:31 +0000 (20:18 +0100)]
tools/xl: Fix trim() following c/s e316316 "xl: Rewrite trim()"

c/s e316316 "xl: Rewrite trim()" uses the wrong indirection of
'output', causing memory corruption for all callers.

Introduce a new local variable, making the code more obviously
correct.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
9 years agoxl: Rewrite trim()
Ian Jackson [Mon, 15 Jun 2015 14:51:23 +0000 (15:51 +0100)]
xl: Rewrite trim()

This function would produce a NULL output pointer if the input was an
empty string, leading to a crash.

I don't think this is likely to be a security problem, as the two call
sites involve configuration options which callers are unlikely to
expose to other-than-fully-trusted input.

Also, the function would needlessly copy the input string (which I
care about not for performance reasons but because it makes the memory
handling more confusing), and would mishandle strings which contained
only predicate-true characters.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Use xasprintf for cpupoolnumsplit names
Ian Jackson [Mon, 15 Jun 2015 14:39:41 +0000 (15:39 +0100)]
xl: Use xasprintf for cpupoolnumsplit names

Otherwise we have to do complicated reasoning about the length that %d
might produce.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Provide and use xvasprintf and xasprintf internally
Ian Jackson [Mon, 15 Jun 2015 14:35:32 +0000 (15:35 +0100)]
xl: Provide and use xvasprintf and xasprintf internally

Replace all calls to [v]asprintf with this new function.  This removes
a fair amount of bespoke error handling.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Provide and use ARRAY_EXTEND_INIT_NODEVID for disks, pcidevs and dtdevs
Ian Jackson [Mon, 15 Jun 2015 15:10:54 +0000 (16:10 +0100)]
xl: Provide and use ARRAY_EXTEND_INIT_NODEVID for disks, pcidevs and dtdevs

This replaces 3 sets of open-coded reallocs etc.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Use ARRAY_EXTEND_INIT for vtpms and nics
Ian Jackson [Mon, 15 Jun 2015 14:16:48 +0000 (15:16 +0100)]
xl: Use ARRAY_EXTEND_INIT for vtpms and nics

This removes two open-coded reallocs.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxl: Do not ignore unparseable PCI BDFs
Ian Jackson [Mon, 15 Jun 2015 15:18:38 +0000 (16:18 +0100)]
xl: Do not ignore unparseable PCI BDFs

If xlu_pci_parse_bdf fails, abandon the domain creation, rather than
blundering on.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
v2: Print the offending supposed-BDF too.

9 years agotools: libxl: check errors from libxl_create_logfile for stubdom log
Ian Campbell [Wed, 15 Jul 2015 12:14:41 +0000 (13:14 +0100)]
tools: libxl: check errors from libxl_create_logfile for stubdom log

Spotted by Coverity after the recent similar fix to
libxl__create_qemu_logfile.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agoxen: arm: bootfdt: Avoid reading off the front of *_cells array
Ian Campbell [Thu, 16 Jul 2015 08:50:07 +0000 (09:50 +0100)]
xen: arm: bootfdt: Avoid reading off the front of *_cells array

In device_tree_for_each_node the call to the callback was using
{address,size}_cells[depth - 1], which at depth 0 could read off the
front of the array.

We already handled this correctly in the rest of the loop so fixup
this instance as well.

Reported-by: Chris (Christopher) Brand <chris.brand@broadcom.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Chris (Christopher) Brand <chris.brand@broadcom.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
9 years agoxen/arm: gicv3: Update comment for ICC_CTLR_EL1
Julien Grall [Wed, 15 Jul 2015 19:47:41 +0000 (20:47 +0100)]
xen/arm: gicv3: Update comment for ICC_CTLR_EL1

Xen is using EOImode 1 which means that EOI drops the priority and DIR
deactivates the interrupt.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agolibxl: set stub domain size based on VRAM size
Eric Shelton [Sat, 11 Jul 2015 21:30:42 +0000 (17:30 -0400)]
libxl: set stub domain size based on VRAM size

Allocate additional memory to the stub domain for qemu-traditional if
more than 4 MB is assigned to the video adapter to avoid out of memory
condition for QEMU.

For LIBXL_VGA_INTERFACE_TYPE_STD + CIRRUS video_memkb is always at
least 4MB. However if LIBXL_VGA_INTERFACE_TYPE_STD is selected the
video_memkb defaults to 0, resulting in a stubdom which is 4MB smaller
than before. It seems unlikely that VGA disable would require more
memory then the other options, so this should be ok.

Signed-off-by: Eric Shelton <eshelton@pobox.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- added second paragraph of commit message ]

9 years agolibxl: events: Do not abort remus with ERROR_TIMEOUT
Ian Jackson [Wed, 15 Jul 2015 13:35:56 +0000 (14:35 +0100)]
libxl: events: Do not abort remus with ERROR_TIMEOUT

When the timeout set for prompting the next remus iteration fires, we
should not treat the ERROR_TIMEDOUT as an error.

Bug in 31c836f4 "libxl: events: Permit timeouts to signal ao abort".

Reported-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Yang Hongyang <yanghy@cn.fujitsu.com>
9 years agodmar: fix double free in error paths following c/s a8bc99b
Andrew Cooper [Thu, 16 Jul 2015 13:23:37 +0000 (15:23 +0200)]
dmar: fix double free in error paths following c/s a8bc99b

Several error paths would end up freeing scope->devices twice.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
9 years agox86/hvm: unconditionally buffer writes to VRAM
Paul Durrant [Thu, 16 Jul 2015 09:50:41 +0000 (11:50 +0200)]
x86/hvm: unconditionally buffer writes to VRAM

When c/s 3bbaaec09 "unify stdvga mmio intercept with standard mmio
intercept" was added, a small semantic change was made. Prior to
this patch the hypervisor unconditionally sent all guest writes
to the VGA aperture as buffered ioreqs, whereas after the patch it
only does this when the VGA model is in 'stdvga' mode (sequencer
register #7 == 0).

When installing Windows 7 (64-bit) using the default QEMU VGA model
(== cirrus), Windows leaves 'stdvga' mode early in boot and hence
all further writes to the VGA aperture are done using synchronous
ioreqs which slows down boot by several orders of magnitude (thanks
to the elaborate splash screen that Windows presents). This can be
viewed as a regression and so this patch re-instates previous
buffering behaviour.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
9 years agodmar: device scope mem leak fix
Elena Ufimtseva [Thu, 16 Jul 2015 09:50:07 +0000 (11:50 +0200)]
dmar: device scope mem leak fix

Release memory allocated for scope.devices dmar units on various
failure paths and when disabling dmar. Set device count after
sucessfull memory allocation, not before, in device scope parsing function.

Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Yang Zhang <yang.z.zhang@intel.com>
9 years agosysctl: adjust XEN_SYSCTL_numainfo behavior
Jan Beulich [Wed, 15 Jul 2015 16:05:02 +0000 (18:05 +0200)]
sysctl: adjust XEN_SYSCTL_numainfo behavior

... to match XEN_SYSCTL_cputopoinfo, allowing the caller to get what it
needs (if e.g. it's after the data for just one specific node) with
just one hypercall, without caring about the total number of nodes in
the system.

Suggested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agosysctl: adjust XEN_SYSCTL_cputopoinfo behavior
Jan Beulich [Wed, 15 Jul 2015 16:04:00 +0000 (18:04 +0200)]
sysctl: adjust XEN_SYSCTL_cputopoinfo behavior

The new function's implementation, unlike the original one of
XEN_SYSCTL_topologyinfo, didn't allow the caller to get what it needs
(if e.g. it's after the data for just one specific CPU) with just one
hypercall, without caring about the total number of CPUs in the system.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agolibxl: event tests: Fix `=' vs `==' in fdderegrace
Ian Jackson [Wed, 15 Jul 2015 14:38:27 +0000 (15:38 +0100)]
libxl: event tests: Fix `=' vs `==' in fdderegrace

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agomake rangeset_report_ranges() report all ranges
Jan Beulich [Wed, 15 Jul 2015 14:11:42 +0000 (16:11 +0200)]
make rangeset_report_ranges() report all ranges

find_range() returns NULL when s is below the lowest range, so we have
to use first_range() here (which is as good performance wise), or else
no range gets reported at all in that case.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agovm_event: deny register writes if refused by vm_event reply
Razvan Cojocaru [Wed, 15 Jul 2015 14:10:02 +0000 (16:10 +0200)]
vm_event: deny register writes if refused by  vm_event reply

Deny register writes if a vm_client subscribed to mov_to_msr or
control register write events forbids them. Currently supported for
MSR, CR0, CR3 and CR4 events.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tlengyel@novetta.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agovm_event: support for guest-requested events
Razvan Cojocaru [Wed, 15 Jul 2015 14:08:59 +0000 (16:08 +0200)]
vm_event: support for guest-requested events

Added support for a new class of vm_events: VM_EVENT_REASON_REQUEST,
sent via HVMOP_request_vm_event. The guest can request that a
generic vm_event (containing only the vm_event-filled guest registers
as information) be sent to userspace by setting up the correct
registers and doing a VMCALL. For example, for a 32-bit guest, this
means: EAX = 34 (hvmop), EBX = 24 (HVMOP_guest_request_vm_event),
ECX = 0 (NULL required for the hypercall parameter, reserved).

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Tamas K Lengyel <tlengyel@novetta.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agomem_access: support for memory-content hiding
Razvan Cojocaru [Wed, 15 Jul 2015 14:08:03 +0000 (16:08 +0200)]
mem_access: support for memory-content hiding

This patch adds support for memory-content hiding, by modifying the
value returned by emulated instructions that read certain memory
addresses that contain sensitive data. The patch only applies to
cases where VM_FLAG_ACCESS_EMULATE has been set to a vm_event
response.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Tamas K Lengyel <tlengyel@novetta.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools: libxc: Add nomigrate stubs for xc_domain_(save|restore)2.
Ian Campbell [Wed, 15 Jul 2015 11:43:00 +0000 (12:43 +0100)]
tools: libxc: Add nomigrate stubs for xc_domain_(save|restore)2.

Fixes the build on ARM after the switch to migration v2 in
210b4817529d "tools/libxc+libxl+xl: Save v2 streams" and
3a9ace0147d4 "tools/libxc+libxl+xl: Restore v2 streams".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agotools/python: Correct the install path of the python scripts
Andrew Cooper [Wed, 15 Jul 2015 11:09:40 +0000 (12:09 +0100)]
tools/python: Correct the install path of the python scripts

c/s 74a7c7a was actually written long before c/s 2c96ecb "Use
configure --libexecdir=BASEDIR to set LIBEXEC", and I didn't notice
during development because of the method I was using to run a legacy
and migration v2 libxl toolstack side-by-side.

The result is that the conversion script gets installed in the root of
the output tree, rather than in the location libxl is expecting to
find it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
9 years agolibxl: event tests: test_timedereg: Fix rc handling
Ian Jackson [Thu, 9 Jul 2015 17:16:25 +0000 (18:16 +0100)]
libxl: event tests: test_timedereg: Fix rc handling

In 31c836f4 "libxl: events: Permit timeouts to signal ao abort",
timeout callbacks take an extra rc argument.

In that patch the wrong assertion is made about the rc in
test_timedereg's `occurs' callback.  Fix this to make the test pass
again.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: event tests: Introduce `fdderegrace' test
Ian Jackson [Thu, 9 Jul 2015 16:24:25 +0000 (17:24 +0100)]
libxl: event tests: Introduce `fdderegrace' test

This exercises the potential race between fd deregistration and
poll().  (Because we have control of the individual steps, we can do
the whole test in a single thread and ensure that the pessimal order
is always reached.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: event tests: Provide miniature poll machinery
Ian Jackson [Thu, 9 Jul 2015 16:21:23 +0000 (17:21 +0100)]
libxl: event tests: Provide miniature poll machinery

This allows a test case to have a poll-based event loop with exact
control of the sequence of operations.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: event tests: Provide libxl_test_fdevent
Ian Jackson [Thu, 9 Jul 2015 16:19:09 +0000 (17:19 +0100)]
libxl: event tests: Provide libxl_test_fdevent

We are going to use this shortly.  But, it is nicely self-contained.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: event tests: Contemplate separate tests
Ian Jackson [Thu, 9 Jul 2015 17:25:25 +0000 (18:25 +0100)]
libxl: event tests: Contemplate separate tests

Split LIBXL_TESTS into two variables, each of which gets all of
LIBXL_TESTS, so that we can have tests which do use generic test
helper inside functions, rather than test-specific ones.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: event tests: Improve Makefile doc comment
Ian Jackson [Thu, 9 Jul 2015 17:24:59 +0000 (18:24 +0100)]
libxl: event tests: Improve Makefile doc comment

Including the explanation of how to run these tests.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
9 years agolibxl: poll: Avoid fd deregistration race POLLNVAL crash
Ian Jackson [Thu, 9 Jul 2015 16:28:48 +0000 (17:28 +0100)]
libxl: poll: Avoid fd deregistration race POLLNVAL crash

It can happen that an fd is deregistered, and closed, and then a new
fd opened, and reregistered, all while another thread is in poll().

If this happens poll might report POLLNVAL, but the event loop would
think that the fd was supposed to have been valid, and then fail an
assertion:
  libxl_event.c:1183: afterpoll_check_fd: Assertion `poller->fds_changed || !(fds[slot].revents & 0x020)' failed.

We can't simply ignore POLLNVAL because if we have bugs which cause
messed-up fds, it is a serious problem which we really need to detect.

Instead, add extra tracking to spot when this possibility arises, and
abort on POLLNVAL if we are sure that it is unexpected.

Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: poll: Use poller_get and poller_put for poller_app
Ian Jackson [Thu, 9 Jul 2015 16:05:07 +0000 (17:05 +0100)]
libxl: poll: Use poller_get and poller_put for poller_app

This makes the code more regular.  We are going to want to do some
more work in poller_get and poller_put, which work also wants to be
done for poller_app.

Two very minor functional changes:

 * We call malloc an extra time since poller_app is now a pointer

 * ERROR_FAIL on poller_get failing for poller_app is generated in
   libxl_ctx_init rather than passed through by libxl_poller_init
   from libxl__pipe_nonblock.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: poll: Make libxl__poller_get have only one success return path
Ian Jackson [Thu, 9 Jul 2015 15:52:02 +0000 (16:52 +0100)]
libxl: poll: Make libxl__poller_get have only one success return path

In preparation for doing some more work on successful exit.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
9 years agotools/libxl: Drop all knowledge of toolstack callbacks
Andrew Cooper [Sun, 14 Jun 2015 21:11:57 +0000 (22:11 +0100)]
tools/libxl: Drop all knowledge of toolstack callbacks

Libxl has now been fully adjusted not to need them.

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxc: Drop all XG_LIBXL_HVM_COMPAT code from libxc
Andrew Cooper [Sun, 14 Jun 2015 19:14:01 +0000 (20:14 +0100)]
tools/libxc: Drop all XG_LIBXL_HVM_COMPAT code from libxc

Libxl has now been fully adjusted not to need it.

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxl: Handle checkpoint records in a libxl migration v2 stream
Andrew Cooper [Sun, 14 Jun 2015 21:04:04 +0000 (22:04 +0100)]
tools/libxl: Handle checkpoint records in a libxl migration v2 stream

This is the final bit of untangling for Remus.

When libxc issues a checkpoint callback, start reading and buffering
all libxl records from the stream.  Once a CHECKPOINT_END record is
encountered, start processing all records.

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v4: Adjustments in line with review for earlier patches in the series
v3: Simplify, use named constants for API

9 years agotools/libx{c,l}: Introduce restore_callbacks.checkpoint()
Andrew Cooper [Sun, 14 Jun 2015 19:49:19 +0000 (20:49 +0100)]
tools/libx{c,l}: Introduce restore_callbacks.checkpoint()

And call it when a checkpoint record is found in the libxc stream.

Some parts of this patch have been based on patches from the COLO
series.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v3: Named constants for the API
v2: Borrow sufficient fragments from several COLO patches to get
    BROKEN_CHANNEL and checkpoint failover to function.

9 years agotools/libxl: Write checkpoint records into the stream
Andrew Cooper [Sun, 14 Jun 2015 20:29:15 +0000 (21:29 +0100)]
tools/libxl: Write checkpoint records into the stream

when signalled to do so by libxl__remus_domain_checkpoint_callback()

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v4: Adjustments in line with review for earlier patches in the series
v3: Corrections to comments

This patch has changed substantially in v2 as a result of changes earlier in
the series.  No behavioural difference from v1.

9 years agodocs/libxl: Introduce CHECKPOINT_END to support migration v2 remus streams
Andrew Cooper [Sun, 14 Jun 2015 20:31:56 +0000 (21:31 +0100)]
docs/libxl: Introduce CHECKPOINT_END to support migration v2 remus streams

In a remus scenario, libxc will write a CHECKPOINT record, then hand
ownership of the fd to libxl.  Libxl then writes any records required
and finishes with a CHECKPOINT_END record, then hands ownership of the
fd back to libxc.

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agotools/libxc+libxl+xl: Save v2 streams
Andrew Cooper [Sun, 14 Jun 2015 15:36:11 +0000 (16:36 +0100)]
tools/libxc+libxl+xl: Save v2 streams

This is a complicated set of changes which must be done together for
bisectability.

 * libxl-save-helper is updated to unconditionally use libxc migration v2.
 * libxl compatibility workarounds in libxc are disabled for save operations.
 * libxl__stream_write_start() is logically spliced into the event location
   where libxl__xc_domain_save() used to reside.
 * Ownership of the helper state moves into stream_write_state.
 * xl is updated to indicate that the stream is now v2

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
v4:
 * Don't use _init() needlessly

v3: Many small changes, follwing similar review to the restore side

9 years agotools/libxl: Infrastructure for writing a v2 stream
Ross Lagerwall [Sun, 14 Jun 2015 14:59:28 +0000 (15:59 +0100)]
tools/libxl: Infrastructure for writing a v2 stream

This contains the event machinery and state machines to write
non-checkpointed migration v2 stream (with the exception of the
xc_domain_save() handling which is spliced later in a bisectable way).

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v4: Don't make _init() mandatory, use FILLZERO(), adjust stream_success()
v3: Similar changes to the read side, following the read side review.

9 years agotools/libxc+libxl+xl: Restore v2 streams
Andrew Cooper [Fri, 12 Jun 2015 16:21:41 +0000 (17:21 +0100)]
tools/libxc+libxl+xl: Restore v2 streams

This is a complicated set of changes which must be done together for
bisectability.

 * libxl-save-helper is updated to unconditionally use libxc migration
   v2.
 * libxl compatibility workarounds in libxc are disabled for restore
   operations.
 * libxl__stream_read_start() is logically spliced into the event
   location where libxl__xc_domain_restore() used to reside.
 * Ownership of the save_helper_state moves to stream_read_state.

The parameters 'hvm', 'pae', and 'superpages' were previously
superfluous, and are completely unused in migration
v2. callbacks->toolstack_restore is handled via a migration v2 record
now, rather than via a callback from libxc.

NB: this change breaks Remus.  Further untangling needs to happen
before Remus will function.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
v4:
 * Don't use _init() needlessly
v3:
 * Simplify from v2.
 * Alter the ownership of save_helper_state

v2:
 * Drop "legacy_width" from the IDL
 * Gain a LIBXL_HAVE_ to signify support of migration v2 streams

9 years agotools/libxl: Convert a legacy stream if needed
Andrew Cooper [Sat, 13 Jun 2015 13:34:42 +0000 (14:34 +0100)]
tools/libxl: Convert a legacy stream if needed

For backwards compatibility, a legacy stream needs converting before
it can be read by the v2 stream logic.

This causes the v2 stream logic to need to juggle two parallel tasks.
check_all_finished() is introduced for the purpose of joining the
tasks in both success and error cases.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v4: Alter logic layout in check_all_finished()
v3: Simplified greatly from v2.  No practical change.

9 years agotools/libxl: Infrastructure to convert a legacy stream
Andrew Cooper [Mon, 8 Sep 2014 14:24:59 +0000 (15:24 +0100)]
tools/libxl: Infrastructure to convert a legacy stream

Provide a thin wrapper around exec()ing the python conversion utility,
and a stub implementation for cases where conversion is not wanted
(i.e. not x86).

One complication is that the caller of this interface needs to assume
ownership of the output fd, to prevent it being closed while still in
use in a datacopier.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v4: Formatting tweaks, description of the width field.
v3: Trimmed down massively from v2, provide libxl_no_convert_callout.c

9 years agotools/libxl: Infrastructure for reading a libxl migration v2 stream
Ross Lagerwall [Fri, 12 Jun 2015 17:19:00 +0000 (18:19 +0100)]
tools/libxl: Infrastructure for reading a libxl migration v2 stream

This contains the event machinery and state machines to read an act on
a non-checkpointed migration v2 stream (with the exception of the
xc_domain_restore() handling which is spliced later in a bisectable
way).

It also contains some boilerplate to help support checkpointed
streams, which shall be introduced in a later patch.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v4:
 * Don't make _init() mandatory
 * Don't unilaterally clobber rc from datacopier callback
 * Comment adjustments
 * More assertions

v3: More descriptions of the internal state, shuffle function order, add
    an _init() call, condense error handling

9 years agotools/libxl: Migration v2 stream format
Ross Lagerwall [Mon, 1 Sep 2014 15:57:59 +0000 (16:57 +0100)]
tools/libxl: Migration v2 stream format

C structures describing the Libxl migration v2 stream format

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v2: Move into libxl__ namespace

9 years agotools/python: Conversion utility for legacy migration streams
Andrew Cooper [Mon, 18 May 2015 15:20:19 +0000 (16:20 +0100)]
tools/python: Conversion utility for legacy migration streams

This utility will take a legacy stream as in input, and produce a v2
stream as an output.  It is exec()'d by libxl to provide backwards
compatibility.

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agotools/python: Verification utility for v2 stream spec compliance
Andrew Cooper [Mon, 18 May 2015 15:08:17 +0000 (16:08 +0100)]
tools/python: Verification utility for v2 stream spec compliance

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
This is exceedingly useful for development, but not of practical use being
installed into a production dom0.

9 years agotools/python: Other migration infrastructure
Andrew Cooper [Sun, 5 Jul 2015 18:52:21 +0000 (19:52 +0100)]
tools/python: Other migration infrastructure

Contains:
 * Reverse-engineered notes of the legacy format from xg_save_restore.h
 * Python implementation of the legacy format
 * Public HVM Params used in the legacy stream
 * XL header format

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
New in v2 - removes various many magic numbers from subsequent scripts

9 years agotools/python: Libxl migration v2 infrastructure
Andrew Cooper [Mon, 18 May 2015 14:56:10 +0000 (15:56 +0100)]
tools/python: Libxl migration v2 infrastructure

Contains:
 * Python implementation of the libxl migration v2 records
 * Verification code for spec compliance
 * Unit tests

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agotools/python: Libxc migration v2 infrastructure
Andrew Cooper [Mon, 18 May 2015 14:55:57 +0000 (15:55 +0100)]
tools/python: Libxc migration v2 infrastructure

Contains:
 * Python implementation of the libxc migration v2 records
 * Verification code for spec compliance
 * Unit tests

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>
CC: Wei Liu <wei.liu2@citrix.com>
9 years agodocs: Libxl migration v2 stream specification
Andrew Cooper [Fri, 22 Aug 2014 12:15:32 +0000 (13:15 +0100)]
docs: Libxl migration v2 stream specification

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v3: Spelling fixes

9 years agotools/xl: Mandatory flag indicating the format of the migration stream
Andrew Cooper [Fri, 5 Jun 2015 19:26:22 +0000 (20:26 +0100)]
tools/xl: Mandatory flag indicating the format of the migration stream

Introduced at this point so the python stream conversion code has a
concrete ABI to use.  Later when libxl itself starts supporting a v2
stream, it will be added to XL_MANDATORY_FLAG_ALL.

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
v2: Expand commit message

9 years agotools/libxl: Fix libxl__carefd_opened() to be more useful with an invalid fd
Andrew Cooper [Tue, 14 Jul 2015 09:38:46 +0000 (10:38 +0100)]
tools/libxl: Fix libxl__carefd_opened() to be more useful with an invalid fd

In the case that fd is -1, preserve errno and don't attempt to set
CLOEXEC.

Note that the implementation can still fail, as it ignores fcntl()
errors and may not set CLOEXEC properly.  Update the documentation
accordingly until it is fixed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
Fixing the fnctl() error issue involves more TUITs than I currently
have.

New in v4

9 years agotools/libxl: Add save_helper_state pointers to libxl__xc_domain_{save,restore}()
Andrew Cooper [Sat, 11 Jul 2015 13:05:35 +0000 (14:05 +0100)]
tools/libxl: Add save_helper_state pointers to libxl__xc_domain_{save,restore}()

Currently, libxl__xc_domain_{save,restore}() have specific knowledge
of where the libxl__save_helper_state lives inside a
libxl__domain_{create,save}_state object.

In later changes, the logical ownership of the
libxl__save_helper_state will change and will no longer be
d{c,s}s->shs.

No functional change.

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>
CC: Wei Liu <wei.liu2@citrix.com>
---
New in v3

9 years agotools/libxl: Extra management APIs for the save helper
Andrew Cooper [Tue, 9 Jun 2015 11:41:06 +0000 (12:41 +0100)]
tools/libxl: Extra management APIs for the save helper

With migration v2, there are several moving parts needing to be
juggled at once.  This requires the error handling logic to be able to
query the state of each moving part, possibly before they have been
started, and be able to cancel them.

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>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v4: Don't force _init() to be mandatory
v3: Adjust helper_{stop,failed,done} to use libxl__save_helper_inuse()
v2: Add an _init() function which allows _inuse() to be safe to call even
    before the save helper has started.