]> xenbits.xensource.com Git - xen.git/log
xen.git
12 years agolibxl: do not blunder on if bootloader fails
Ian Jackson [Mon, 23 Jul 2012 12:09:36 +0000 (13:09 +0100)]
libxl: do not blunder on if bootloader fails

If the bootloader failed, we would call the creation failure callback
but _also_ blunder on trying to recreate the domain, due to a missing
"return".

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reported-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agodocs/cmdline: Add some more entries
Andrew Cooper [Sun, 22 Jul 2012 15:37:25 +0000 (16:37 +0100)]
docs/cmdline: Add some more entries

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agodocs/cmdline: Remove ia64 specific arguments
Andrew Cooper [Sun, 22 Jul 2012 15:36:59 +0000 (16:36 +0100)]
docs/cmdline: Remove ia64 specific arguments

grep claims that all of these command line arguments no longer exist
in the xen source tree.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agodocs/cmdline: Tweak some markdown formatting
Andrew Cooper [Sun, 22 Jul 2012 15:36:30 +0000 (16:36 +0100)]
docs/cmdline: Tweak some markdown formatting

Some for readability, and some to escape underscores.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agox86/numa: Remove warning about small NUMA nodes
Andrew Cooper [Thu, 19 Jul 2012 14:47:28 +0000 (15:47 +0100)]
x86/numa: Remove warning about small NUMA nodes

This logic came with the other NUMA logic from Linux 2.6.16 in c/s
11893:f312c2d01d8b.  It appears that the Xen memory management
subsystem does not suffer from the expressed problems.  Furthermore,
NUMA nodes with no memory are now quite easy to find, and are not BIOS
bugs in the SRAT ACPI table.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agox86/numa: Correct assumption that each NUMA node has memory
Andrew Cooper [Thu, 19 Jul 2012 14:46:51 +0000 (15:46 +0100)]
x86/numa: Correct assumption that each NUMA node has memory

It is now quite easy to buy servers with incorrectly populated DIMMs,
especially with AMD Magny-Cours and Interlagos systems which have two
NUMA nodes per socket.

Currently, Xen will assign all CPUs on nodes without memory to node 0,
which leads to interestingly wrong NUMA information, causing numa
aware functionality such as alloc_domheap_pages() to get things very
wrong.

This patch splits the current logic to accept NUMA nodes without
memory, which corrects the accounting of CPUs to online NUMA nodes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agovt-d: fix wrong addr in IOTLB invalidation descriptor
Yang Zhang [Thu, 19 Jul 2012 14:46:02 +0000 (15:46 +0100)]
vt-d: fix wrong addr in IOTLB invalidation descriptor

According to vt-d specs, the addr in IOTLB invalidation descriptor
should be 4K page aligned.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agoXen/MCE: stick all 1's to MCi_CTL of vMCE
Liu, Jinsong [Thu, 19 Jul 2012 14:45:22 +0000 (15:45 +0100)]
Xen/MCE: stick all 1's to MCi_CTL of vMCE

This patch is a middle-work patch, prepare for future new vMCE model.
It remove mci_ctl array, and keep MCi_CTL all 1's.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agonestedhvm: initialize pfec for l1 pagetable walk
Christoph Egger [Thu, 19 Jul 2012 10:15:58 +0000 (11:15 +0100)]
nestedhvm: initialize pfec for l1 pagetable walk

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
12 years agox86/mm/p2m: use NX bit in p2m entries.
Christoph Egger [Thu, 19 Jul 2012 10:09:39 +0000 (11:09 +0100)]
x86/mm/p2m: use NX bit in p2m entries.

In p2m_type_to_flags() honor _PAGE_NX_BIT for grant type mappings.
This brings this code in line with PV and EPT.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
12 years agoxen/arm: disable the event optimization in the gic
Stefano Stabellini [Tue, 17 Jul 2012 16:33:31 +0000 (17:33 +0100)]
xen/arm: disable the event optimization in the gic

Currently we have an optimization in the GIC driver that allows us not
to request maintenance interrupts for Xen events. The basic idea is that
every time we are about to inject a new interrupt or event into a guest,
we check whether we can remove some old event irqs from one or more LRs.
We can do this because we know when a guest finishes processing event
notifications: it sets the evtchn_upcall_pending bit to 0.

However it is unsafe: the guest resets evtchn_upcall_pending before
EOI'ing the event irq, therefore a small window of time exists when Xen
could jump in and remove the event irq from the LR register before the
guest has EOI'ed it.

This is not a good practice according to the GIC manual.
Remove the optimization for now.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxen/arm: gic and vgic fixes
Stefano Stabellini [Tue, 17 Jul 2012 16:33:30 +0000 (17:33 +0100)]
xen/arm: gic and vgic fixes

- the last argument of find_next_bit is the maximum number of bits, not
the maximum number of bytes;

- use list_for_each_entry_safe instead of list_for_each_entry in
gic_restore_pending_irqs because we are actually deleting entries in the
loop.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxen/arm: implement do_hvm_op for ARM
Stefano Stabellini [Tue, 17 Jul 2012 16:33:29 +0000 (17:33 +0100)]
xen/arm: implement do_hvm_op for ARM

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm/vgic: initialize pending_irqs.lr_queue
Stefano Stabellini [Tue, 17 Jul 2012 16:22:07 +0000 (17:22 +0100)]
arm/vgic: initialize pending_irqs.lr_queue

Properly initialize all the pending_irqs.lr_queue like we do for
inflight.
Check whether we already have the irq in lr_queue before adding it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm/vgic: vgic: support irq enable/disable
Stefano Stabellini [Tue, 17 Jul 2012 16:22:06 +0000 (17:22 +0100)]
arm/vgic: vgic: support irq enable/disable

If vgic_vcpu_inject_irq is called (for example by a device emulator like
vtimer.c) but the corresponding irq is not enabled in the virtual gicd
just queue it in the inflight_irqs list.

When the irq is enabled make sure to call gic_set_guest_irq.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm/gic: support injecting IRQs even to VCPUs not currently running
Stefano Stabellini [Tue, 17 Jul 2012 16:22:05 +0000 (17:22 +0100)]
arm/gic: support injecting IRQs even to VCPUs not currently running

The lr_pending list belongs to the vgic rather than the gic, so move it
there.

gic_set_guest_irq should take into account whether the vcpu is currently
running and if it is not it should add the irq to the right lr_pending
list.

When restoring the gic state we need to go through the lr_pending list
because it is possible that some irqs have been "injected" while the
vcpu wasn't running.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm/gic: fix gic context switch
Stefano Stabellini [Tue, 17 Jul 2012 16:22:04 +0000 (17:22 +0100)]
arm/gic: fix gic context switch

gic_save/restore_state should also save and restore lr_mask and
event_mask too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm/vtimer: do not let the guest interact with the physical timer
Stefano Stabellini [Tue, 17 Jul 2012 16:22:04 +0000 (17:22 +0100)]
arm/vtimer: do not let the guest interact with the physical timer

The guest can read the physical counter but it shouldn't be able to
cause interrupts of the physical timer to go to the hypervisor.
Trap physical timer reads/writes in vtimer.c instead.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxsm/flask: avoid struct page lookup in mmu_normal_update
Daniel De Graaf [Mon, 9 Jul 2012 09:10:27 +0000 (10:10 +0100)]
xsm/flask: avoid struct page lookup in mmu_normal_update

Since the mmu_normal_update hook is called even when mapping MFNs
without an associated struct page, attempting to use the struct page
to map between GFN and MFN will cause crashes. Use get_gfn_query
instead.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
12 years agoxsm/flask: fix memory AVC formatting
Daniel De Graaf [Mon, 9 Jul 2012 09:09:44 +0000 (10:09 +0100)]
xsm/flask: fix memory AVC formatting

A space was missing in the format string.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
12 years agonestedsvm: fix DRn handling
Christoph Egger [Mon, 9 Jul 2012 09:09:03 +0000 (10:09 +0100)]
nestedsvm: fix DRn handling

Always use l1 vmcb to handle DRn access. This avoids to interfere
with l1 hypervisor's DRn handling when it doesn't intercept DRn.
Fixes Hyper-V hang.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agolibxl: explicitly check for libmath in autoconf
Dario Faggioli [Fri, 6 Jul 2012 12:17:45 +0000 (13:17 +0100)]
libxl: explicitly check for libmath in autoconf

As well as explicitly add -lm to libxl's Makefile.

This is because next patch uses floating point arithmetic, and
it is better to state it clearly that we need libmath (just in
case we find a libc  that wants that to be explicitly enforced).

Notice that autoconf should be rerun after applying this change.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- s/libmath/libm/ in error message ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: introduce some node map helpers
Dario Faggioli [Fri, 6 Jul 2012 12:17:44 +0000 (13:17 +0100)]
libxl: introduce some node map helpers

To allow for allocating a node specific libxl_bitmap (as it
is for cpu number and maps). Helper unctions to convert a node
map it its coresponding cpu map and vice versa are also
implemented.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: expand the libxl_bitmap API a bit
Dario Faggioli [Fri, 6 Jul 2012 12:17:43 +0000 (13:17 +0100)]
libxl: expand the libxl_bitmap API a bit

By adding copying and *_is_full/*_is_empty facilities.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: rename libxl_cpumap to libxl_bitmap
Dario Faggioli [Fri, 6 Jul 2012 12:17:42 +0000 (13:17 +0100)]
libxl: rename libxl_cpumap to libxl_bitmap

And leave to the caller the burden of knowing and remembering what kind
of bitmap each instance of libxl_bitmap is.

This is basically just some s/libxl_cpumap/libxl_bitmap/ (and some other
related interface name substitution, e.g., libxl_for_each_cpu) in a bunch
of files, with no real functional change involved.

A specific allocation helper is introduced, besides libxl_bitmap_alloc().
It is called libxl_cpu_bitmap_alloc() and is meant at substituting the old
libxl_cpumap_alloc(). It is just something easier to use in cases where one
wants to allocate a libxl_bitmap that is going to serve as a cpu map.

This is because we want to be able to deal with both cpu and NUMA node
maps, but we don't want to duplicate all the various helpers and wrappers.

While at it, add the usual initialization function, common to all libxl
data structures.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.eu.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxl: add more NUMA information to `xl info -n'
Dario Faggioli [Fri, 6 Jul 2012 12:17:42 +0000 (13:17 +0100)]
xl: add more NUMA information to `xl info -n'

So that the user knows how much memory there is on each node and
how far they are from each others.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl,libxc: introduce libxl_get_numainfo()
Dario Faggioli [Fri, 6 Jul 2012 12:17:41 +0000 (13:17 +0100)]
libxl,libxc: introduce libxl_get_numainfo()

Make some NUMA node information available to the toolstack. Achieve
this by means of xc_numainfo(), which exposes memory size and amount
of free memory of each node, as well as the relative distances of
each node to all the others.

For properly exposing distances we need the IDL to support arrays.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: add a new Array type to the IDL
Ian Campbell [Fri, 6 Jul 2012 12:17:40 +0000 (13:17 +0100)]
libxl: add a new Array type to the IDL

And make all the required infrastructure updates to enable this.

Since there are currently no uses of this type there is no change to
the generated code.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agohotplug/Linux: do not leak lockfiles
Ian Jackson [Thu, 5 Jul 2012 11:40:25 +0000 (12:40 +0100)]
hotplug/Linux: do not leak lockfiles

25590:bb250383a4f5 introduced a new locking scheme.  Unfortunately it
leaves behind files in /var/run/xen-hotplug.  These are spotted as
regressions by the autotester.

Fix this.  This involves changing the locking protocol to allow
lockfiles to be deleted (as removing lockfiles is unsafe with a naive
flock-based algorithm).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools: honour --libdir when it is passed to ./configure
Matt Wilson [Thu, 5 Jul 2012 10:00:28 +0000 (11:00 +0100)]
tools: honour --libdir when it is passed to ./configure

Currently shared libraries are automatically installed into /usr/lib
or /usr/lib64, depending on the supplied --prefix value and
$(XEN_TARGET_ARCH). Some systems, like recent Debian and Ubuntu releases,
do not use /usr/lib64, but instead /usr/lib/x86_64-linux-gnu.

With this change, packagers can supply the desired location for shared
libraries on the ./configure command line. Packagers need to note that
the default behaviour on 64-bit Linux systems will be to install shared
libraries in /usr/lib, not /usr/lib64, unless a --libdir value is provided
to ./configure.

Additionally, the libfsimage plugins are now loaded explicitly from
$LIBDIR/fs, removing platform-based decision trees in code.

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 -- resolve rejects in configure by rerunning autogen.sh. Dropped changes
to remove m4/default_lib.m4 and update m4/pkg.m4 since they cause LIBDIR=/lib
instead of /usr/lib. Reran ./autogen.sh after that too ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agotools/m4: add AC_LANG_SOURCE to fix autoconf warnings
Olaf Hering [Wed, 4 Jul 2012 14:46:17 +0000 (15:46 +0100)]
tools/m4: add AC_LANG_SOURCE to fix autoconf warnings

I see these warnings with autoconf 2.68, add AC_LANG_SOURCE as suggested
by upstream documentation.

...
 # bash autogen.sh
configure.ac:141: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
m4/pthread.m4:21: AX_CHECK_PTHREAD is expanded from...
configure.ac:141: the top level
configure.ac:142: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
m4/ptyfuncs.m4:1: AX_CHECK_PTYFUNCS is expanded from...
configure.ac:142: the top level
configure.ac:141: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
m4/pthread.m4:21: AX_CHECK_PTHREAD is expanded from...
configure.ac:141: the top level
configure.ac:142: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
m4/ptyfuncs.m4:1: AX_CHECK_PTYFUNCS is expanded from...
configure.ac:142: the top level

Please rerun autoconf after applying this.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agotools/configure.ac: add version check for glib2
Olaf Hering [Wed, 4 Jul 2012 14:46:16 +0000 (15:46 +0100)]
tools/configure.ac: add version check for glib2

xen-unstable fails to build in a SLES10SP4 environment since a long time
because the included version of glib is slightly older than the required
glib version. According to the glib docs version 2.12 includes base64
support, but SLES10 is shipped with glib 2.8.6:

qemu-timer-common.o: In function `init_get_clock':
/usr/src/packages/BUILD/xen-4.2.25432/non-dbg/tools/qemu-xen-dir/qemu-timer-common.c:57:
undefined reference to `clock_gettime'
qga/guest-agent-commands.o: In function `qmp_guest_file_write':
qga/guest-agent-commands.c:249: undefined reference to `g_base64_decode'
qga/guest-agent-commands.o: In function `qmp_guest_file_read':
qga/guest-agent-commands.c:224: undefined reference to `g_base64_encode'
collect2: ld returned 1 exit status
make[3]: *** [qemu-ga] Error 1

Add a version check to toplevel configure to require at least glib 2.12.
This makes sure configure can detect the condition early instead of
failing later in the middle of tools build when qemu-upstream errors
out.

Please rerun autoconf after applying this.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxl: Allow use of /dev/null with xl create to enable command-line definition
W. Michael Petullo [Wed, 4 Jul 2012 14:46:15 +0000 (15:46 +0100)]
xl: Allow use of /dev/null with xl create to enable command-line definition

xm allows specifying /dev/null as the domain configuration argument to its
create option; add same functionality to xl. xl treats the configuration
argument /dev/null as a special case.  This allows specifying an entire
domain configuration on the command line.

Signed-off-by: W. Michael Petullo <mike@flyn.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ported to xen-unstable from 4.1 ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agohotplug/Linux: use flock based locking
Zhigang Wang [Wed, 4 Jul 2012 14:46:14 +0000 (15:46 +0100)]
hotplug/Linux: use flock based locking

In the normal case of a single domain booting with one disk, the disk hotplug
script will fire once. In this case taking out the lock will never cause a
sleep because there's no other concurrent invocations. If a domain has 4 disks
configured, then the hotplug script will fire 4 times, all 4 invocations at
pretty much the same time. If there is even a little load on the system, the
locking function in the shell script will sleep for a few seconds - as many as
5 seconds, or potentially even time out & fail completely.

If say 4 or even more domains each with 4 disks start up at once, that's 16
invocations of the hotplug script running at once. There will be a lot of
sleep's done & because of the very coarse 1 second granularity the delay can
add up significantly.

The change to using flock() removes the arbitrary 1 second sleep, so the very
instant once hotplug script finishes, another can start & there is no repeated
attempts & failures to lock which would add more delay.

In addition the current locking implementation would allow two processes get
the lock simultaneously if one decided the other had timed out.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agopygrub: cope better with big files in the guest.
M A Young [Wed, 4 Jul 2012 14:46:14 +0000 (15:46 +0100)]
pygrub: cope better with big files in the guest.

Only read the first megabyte of a configuration file (grub etc.) and read the
kernel and ramdisk files from the guest in one megabyte pieces so pygrub
doesn't use a lot of memory if the files are large.  With --not-really option
check that the chosen kernel and ramdisk files exist.  If there are problems
writing the copy of the kernel or ramdisk, delete the copied files and exit in
case they have filled the filesystem.

Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
Acked-by: Matt Wilson <msw@amazon.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>
12 years agoxen: event channel remapping for emulated MSIs
Stefano Stabellini [Tue, 3 Jul 2012 12:39:01 +0000 (13:39 +0100)]
xen: event channel remapping for emulated MSIs

Linux PV on HVM guests remap all the MSIs onto event channels,
including MSIs corresponding to QEMU's emulated devices.  This patch
makes sure that we handle correctly the case of emulated MSI that have
been remapped, sending a pirq to the guest instead.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Tested-by: Deep Debroy <ddebroy@gmail.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agoxen: Fix off-by-one error when parsing command line arguments
Andrew Cooper [Tue, 3 Jul 2012 12:38:19 +0000 (13:38 +0100)]
xen: Fix off-by-one error when parsing command line arguments

As Xen currently stands, it will attempt to interpret the first few
bytes of the initcall section as a struct kernel_param.

The reason that this not caused problems is because in the overflow
case, param->name is actually a function pointer to the first
initcall, and intepreting it as string is very unlikely to match an
ASCII command line parameter name.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
12 years agoxen: add assertion in default_vcpu0_location to protect against broken masks
Ian Campbell [Tue, 3 Jul 2012 09:52:33 +0000 (10:52 +0100)]
xen: add assertion in default_vcpu0_location to protect against broken masks

When setting up the cpu sibling/etc masks on ARM I accidentally and
incorrectly omitted a CPU from it's own sibling mask which caused this
function to return an invalid cpu number which caused errors later when we
tried to access per_cpu data for that invalid cpu.

Add an assert to catch this in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: fix typo s/approprately/appropriately/g
Ian Campbell [Tue, 3 Jul 2012 09:52:32 +0000 (10:52 +0100)]
arm: fix typo s/approprately/appropriately/g

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: move PSR flag definitions into interface, for tools use.
Ian Campbell [Tue, 3 Jul 2012 09:52:31 +0000 (10:52 +0100)]
arm: move PSR flag definitions into interface, for tools use.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: unwind allocations etc on arch_domain_create_failure
Ian Campbell [Tue, 3 Jul 2012 09:52:30 +0000 (10:52 +0100)]
arm: unwind allocations etc on arch_domain_create_failure

This involves adding the necessary teardown/free functions for some modules.

Don't initialise full arch domain state for the idle domain, it's not needed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: the hyp timer seems to work in newer model versions, default to using it.
Ian Campbell [Tue, 3 Jul 2012 09:52:29 +0000 (10:52 +0100)]
arm: the hyp timer seems to work in newer model versions, default to using it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: context switch virtual timer registers
Ian Campbell [Tue, 3 Jul 2012 09:52:29 +0000 (10:52 +0100)]
arm: context switch virtual timer registers

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: gic.lock can be taken in interrupt context, so lock appropriately.
Ian Campbell [Tue, 3 Jul 2012 09:52:28 +0000 (10:52 +0100)]
arm: gic.lock can be taken in interrupt context, so lock appropriately.

In particular it is taken by gic_set_guest_irq which is called by
vgic_vcpu_inject_irq

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: Upgrade guest barriers to Outer-Shareable. Enable Protected Table Walk.
Ian Campbell [Tue, 3 Jul 2012 09:52:27 +0000 (10:52 +0100)]
arm: Upgrade guest barriers to Outer-Shareable. Enable Protected Table Walk.

Upgrading barriers is conservative and may not be necessary.

Protected Table Walk traps stage 1 page tables which refer to device memory
(per stage 2) using a non-device mapping. This generally indicates a guest
error but trapping it as a fault for now helps us know if something odd is
going on.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: enable data-cache at the same time as enabling the MMU, not before
Ian Campbell [Tue, 3 Jul 2012 09:52:26 +0000 (10:52 +0100)]
arm: enable data-cache at the same time as enabling the MMU, not before

With enough warnings enabled the model seemed to be complaining that pages
cached before paging was enabled had been mapped with to inconsistent sets of
attributes. I'm not convinced that isn't a model issue, nor am I convinced
this has really fixed anything, but it seems sensible enough.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: map GICV in all domains, not just dom0.
Ian Campbell [Tue, 3 Jul 2012 09:52:25 +0000 (10:52 +0100)]
arm: map GICV in all domains, not just dom0.

This requires that we allocate all p2m pages from domheap without a particular
dom because max pages is not setup yet so there is no allocation available to
us.

At some point we should create a separate p2m allocation (similar to x86's shadow allocation) and use that.

Also we seem to have been calling p2m_alloc_table twice for dom0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: make vgic lock safe for use in interrupt context.
Ian Campbell [Tue, 3 Jul 2012 09:52:25 +0000 (10:52 +0100)]
arm: make vgic lock safe for use in interrupt context.

In particular vgic_vcpu_inject_irq can be called in both interrupt and regular
context.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: split pending SPIs (global) out from pending PPIs and SGIs (per CPU)
Ian Campbell [Tue, 3 Jul 2012 09:52:24 +0000 (10:52 +0100)]
arm: split pending SPIs (global) out from pending PPIs and SGIs (per CPU)

This tracks SPIs in struct arch_domain and PPIs+SGIs in struct arch_vcpu which
seems more logical.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: use correct attributes for mappings in copy_from_paddr()
Ian Campbell [Tue, 3 Jul 2012 09:52:23 +0000 (10:52 +0100)]
arm: use correct attributes for mappings in copy_from_paddr()

The DTB is in RAM (hence bufferable), kernel is in flash and therefor requires
a device type mapping (hence dev shared).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: implement vcpu_show_execution_state
Ian Campbell [Tue, 3 Jul 2012 09:52:22 +0000 (10:52 +0100)]
arm: implement vcpu_show_execution_state

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: implement vpl011 (UART) emulator.
Ian Campbell [Tue, 3 Jul 2012 09:52:21 +0000 (10:52 +0100)]
arm: implement vpl011 (UART) emulator.

This is not interended to provide a full emulation, but rather just enough to
satisfy the use made by Linux' boot time decompressor code (which is too early
for DT etc)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoarm: allow p2m to be created with specific MATTR.
Ian Campbell [Tue, 3 Jul 2012 09:52:20 +0000 (10:52 +0100)]
arm: allow p2m to be created with specific MATTR.

Rename p2m_create_entry to p2m_create_table since it can now only be used to
insert non-leaf entries into the page table.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
12 years agox86/hvm: fix BUFIOREQ evtchn init for a stubdom
Anthony PERARD [Tue, 3 Jul 2012 07:48:28 +0000 (09:48 +0200)]
x86/hvm: fix BUFIOREQ evtchn init for a stubdom

This is a missing part from the previous patch that add the BUFIOREQ_EVTCHN
parameter. This patch changes the ownership of the buifioreq event channel to
the stubdom (when HVM_PARAM_DM_DOMAIN is set within the stubdom).

This patch introduces an helper to replace a xen port.

This fix the initialization of QEMU inside the stubdomain.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Add error handling to first invocation of hvm_replace_event_channel().
Adjust type of hvm_replace_event_channel()'s second parameter.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
12 years agoxl: ensure handle_domain & preserve_domain update the global domid not a shadow
Ian Campbell [Mon, 2 Jul 2012 10:40:45 +0000 (11:40 +0100)]
xl: ensure handle_domain & preserve_domain update the global domid not a shadow

xl keeps the current domid in a global variable, however it also has various
functions (including the two above) which take a domid parameter which shadows
this.

This fixes the issue introduced by 25563:dbf54d93ac40 "xl: initialise domid to
an explicitly invalid value" but does not tackle the wider problem.

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 Campbell <ian.campbell@citrix.com>
12 years agoQEMU_TAG update
Ian Jackson [Fri, 29 Jun 2012 16:57:07 +0000 (17:57 +0100)]
QEMU_TAG update

12 years agoxl: Clarify 'xend is running' error message
George Dunlap [Fri, 29 Jun 2012 16:36:50 +0000 (17:36 +0100)]
xl: Clarify 'xend is running' error message

* Give reason for check (unpredictable results)
* Give a better recommendation (shut down xend)
* Make it clear that -f is overriding a safety check.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: refactor stdvga opinon support.
Zhou Peng [Fri, 29 Jun 2012 16:32:20 +0000 (17:32 +0100)]
libxl: refactor stdvga opinon support.

Be ready to add and describe new vga interface

Signed-off-by: Zhou Peng <ailvpeng25@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoQEMU_TAG update
Ian Jackson [Fri, 29 Jun 2012 16:03:59 +0000 (17:03 +0100)]
QEMU_TAG update

12 years agoMAINTAINTERS: update xen-devel email address
Andrew Cooper [Fri, 29 Jun 2012 14:47:59 +0000 (15:47 +0100)]
MAINTAINTERS: update xen-devel email address

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl: initialise domid to an explicitly invalid value
Ian Campbell [Fri, 29 Jun 2012 07:58:22 +0000 (08:58 +0100)]
xl: initialise domid to an explicitly invalid value

also ensure it is invalid whenever we destroy the domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agolibxl: log on failure in cpupool_info and libxl__domain_cpupool
Ian Campbell [Fri, 29 Jun 2012 07:58:19 +0000 (08:58 +0100)]
libxl: log on failure in cpupool_info and libxl__domain_cpupool

Also in cpupool_info propagate the failure value from
libxl_cpumap_alloc.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agolibxl: correct type of cpupool variable.
Ian Campbell [Fri, 29 Jun 2012 07:57:11 +0000 (08:57 +0100)]
libxl: correct type of cpupool variable.

libxl__domain_cpupool returns int and can return ERROR_* so we need to
use a signed type.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agolibxl: initialise cpupoolinfo in libxl__domain_scheduler
Ian Campbell [Fri, 29 Jun 2012 07:57:11 +0000 (08:57 +0100)]
libxl: initialise cpupoolinfo in libxl__domain_scheduler

If libxl_cpupool_info fails then we would call
libxl_cpupoolinfo_dispose on an uninitialised struct, and possibly
free an invalid pointer.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agoxl: rename "list-vm" command to "vm-list"
Matt Wilson [Fri, 29 Jun 2012 14:42:27 +0000 (15:42 +0100)]
xl: rename "list-vm" command to "vm-list"

All of the other "list" verbs are of the form "$noun-list". For
example: "pci-list", "vcpu-list", "network-list", "block-list", etc.

Additionally, many people have well trained muscle memory from years
of typing "xm li". "xl li" was ambiguous due to "xl list-vm", thus
resulting in "command not implemented".

Finally, this command was missing from the xl man page.

Signed-off-by: Matt Wilson <msw@amazon.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agodocs: various typos
Tim Deegan [Thu, 28 Jun 2012 15:57:26 +0000 (16:57 +0100)]
docs: various typos

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
12 years agoautoconf: correctly parse *_INCLUDES and *_LIB env vars
Roger Pau Monne [Fri, 29 Jun 2012 14:31:57 +0000 (15:31 +0100)]
autoconf: correctly parse *_INCLUDES and *_LIB env vars

Parse those options correctly, since the "+=" operator is not valid.
Also added CPPFLAGS, so headers checks don't give strange results.

Please rerun configure after applying.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Cc: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: make libxl-save-helper depend on the autogenerated code targets
Ian Campbell [Fri, 29 Jun 2012 10:24:10 +0000 (11:24 +0100)]
libxl: make libxl-save-helper depend on the autogenerated code targets

Fixes this build failure:
  In file included from libxl_save_helper.c:44:
  libxl.h:346:26: error: _libxl_types.h: No such file or directory

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>
12 years agolibxl: libxl__xs_transaction_commit should always clear the transaction.
Ian Campbell [Fri, 29 Jun 2012 10:19:02 +0000 (11:19 +0100)]
libxl: libxl__xs_transaction_commit should always clear the transaction.

This includes the EAGAIN case.

Users are of the form:

   xs_transaction_t t = 0;

   for (;;) {
        rc = libxl__xs_transaction_start(gc, &t);

rc = stuff
if (rc) goto out;
...more...

        rc = libxl__xs_transaction_commit(gc, &t);
        if (!rc) break;
        if (rc<0) goto out;
    }
  ...
 out:

So in EAGAIN (commit -> +1) we will go round the loop again and call start
which leads to:
    xl: libxl_xshelp.c:174: libxl__xs_transaction_start: Assertion `!*t' failed.

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>
12 years agolibxl: further fixups re LIBXL_DOMAIN_TYPE
Ian Jackson [Thu, 28 Jun 2012 17:43:28 +0000 (18:43 +0100)]
libxl: further fixups re LIBXL_DOMAIN_TYPE

* Abolish the macro LIBXL__DOMAIN_IS_TYPE which had incorrect error
  handling.  At every call site, replace it with an open-coded call to
  libxl_domain_type and check against LIBXL_DOMAIN_TYPE_INVALID.

* This involves adding an `out:' to libxl_domain_unpause.

* In libxl_domain_destroy and do_pci_add, do not `default: abort();'
  if the domain type cannot be found.  Instead switch on
  LIBXL_DOMAIN_TYPE_INVALID specifically and do some actual error
  handling.

* In libxl__primary_console_find, remove a spurious default clause
  from the domain type switch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: do not leak an event struct on ignored ao progress
Ian Jackson [Thu, 28 Jun 2012 17:43:28 +0000 (18:43 +0100)]
libxl: do not leak an event struct on ignored ao progress

On entry to libxl__ao_progress_report, the caller has allocated an
event.  If the progress report is to be ignored, we need to free it.

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>
12 years agolibxl: do not leak spawned middle children
Ian Jackson [Thu, 28 Jun 2012 17:43:27 +0000 (18:43 +0100)]
libxl: do not leak spawned middle children

libxl__spawn_spawn would, when libxl__spawn_detach was called, make
the spawn become idle immediately.  However it still has a child
process which needs to be waited for: the `detachable' spawned
child.

This is wrong because the ultimate in-libxl caller may return to the
application, with a child process still forked but not reaped libxl
contrary to the documented behaviour of libxl.

Instead, replace libxl__spawn_detach with libxl__spawn_initiate_detach
which is asynchronous.  The detachable spawned children are abolished;
instead, we defer calling back to the in-libxl user until the middle
child has been reaped.

Also, remove erroneous comment suggesting that `death' callback
parameter to libxl__ev_child_fork may be NULL.  It may not, and there
are no callers which pass NULL.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: do not leak dms->saved_state
Ian Jackson [Thu, 28 Jun 2012 17:43:27 +0000 (18:43 +0100)]
libxl: do not leak dms->saved_state

This was allocated using asprintf but never freed.  Use GCSPRINTF.

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>
12 years agoxl: Handle return value from libxl_domain_suspend correctly
Ian Jackson [Thu, 28 Jun 2012 17:43:26 +0000 (18:43 +0100)]
xl: Handle return value from libxl_domain_suspend correctly

libxl_domain_suspend returns a libxl error code.  So it must be
wrapped with MUST and not CHK_ERRNO.

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>
12 years agolibxl: Get compiler to warn about gc_opt==NULL
Ian Jackson [Thu, 28 Jun 2012 17:43:26 +0000 (18:43 +0100)]
libxl: Get compiler to warn about gc_opt==NULL

Since it used to be legal to pass gc_opt==NULL, and there are various
patches floating about and under development which do so, add a
compiler annotation which makes the build fail when that is done.

This turns a runtime crash into a build failure, and should ensure
that we don't accidentally commit a broken combination of patches.

This is something of an annoying approach because it adds a macro
invocation to the RHS of every declaration of a function taking a
gc_opt.  So it should be reverted after Xen 4.2rc1.

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>
12 years agolibxl: Do not pass NULL as gc_opt; introduce NOGC
Ian Jackson [Thu, 28 Jun 2012 17:43:25 +0000 (18:43 +0100)]
libxl: Do not pass NULL as gc_opt; introduce NOGC

In 25182:6c3345d7e9d9 the practice of passing NULL to gc-using memory
allocation functions was introduced.  However, the arrangements there
were not correct as committed, because the error handling and logging
depends on getting a ctx from the gc - so an allocation error would in
fact result in libxl dereferencing NULL.

Instead, provide a special dummy gc in the ctx, called `nogc_gc'.  It
is marked out specially by having alloc_maxsize==-1, which is
otherwise invalid.

Functions which need to actually look into the gc use the new test
function gc_is_real (whose purpose is mainly clarity of the code) to
check whether the gc is the dummy one, and do nothing if it is.  And
we provide a helper macro NOGC which uses the in-scope real gc to find
the ctx and hence the dummy gc (and which replaces the previous
#define NOGC NULL).

Change all callers which pass 0 or NULL to an allocation function to
use NOGC or &ctx->nogc_gc, as applicable in the context.

We add a comment near the definition of LIBXL_INIT_GC pointing out
that it isn't any more the only place a libxl__gc struct is
initialised, for the benefit of anyone changing the contents of gc's
in the future.

Also, actually document that libxl__ptr_add is legal with ptr==NULL,
and change a couple of calls not to check for NULL argument.

Reported-by: Bamvor Jian Zhang <bjzhang@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Bamvor Jian Zhang <bjzhang@suse.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl: Add a gc to libxl_cpumap_alloc, ..._to_hex_string
Ian Jackson [Thu, 28 Jun 2012 17:43:25 +0000 (18:43 +0100)]
libxl: Add a gc to libxl_cpumap_alloc, ..._to_hex_string

In the next patch we are going to change the definition of NOGC to
require a local variable libxl__gc *gc.  And this means that passing 0
to libxl__calloc is going to be wrong.

libxl_cpumap_alloc doesn't have a gc but passes 0 to libxl_calloc
Fix this by:
 - introducing an `out' label and an rc variable
 - replacing the returns with  rc = ERROR_BLAH; goto out;
 - adding uses of GC_INIT and GC_FREE.
 - changing NULL to NOGC in the call to libxl__calloc

Likewise fix libxl_cpumap_to_hex_string by:
 - adding a libxl_ctx* parameter and updating the one call site
 - adding uses of GC_INIT and GC_FREE.
 - changing NULL to NOGC in the call to libxl__zalloc

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Dario Faggioli <raistlin@linux.it>
Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl: Add a gc to libxl_get_cpu_topology
Ian Jackson [Thu, 28 Jun 2012 17:43:25 +0000 (18:43 +0100)]
libxl: Add a gc to libxl_get_cpu_topology

In the next-but-one patch we are going to change the definition of
NOGC to require a local variable libxl__gc *gc.

libxl_get_cpu_topology doesn't have one but does use NOGC.
Fix this by:
 - introducing an `out' label
 - replacing the only call to `return' with a suitable assignment
   to ret and a `goto out'.
 - adding uses of GC_INIT and GC_FREE.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl: Make libxl__domain_save_device_model asynchronous
Ian Jackson [Thu, 28 Jun 2012 17:43:24 +0000 (18:43 +0100)]
libxl: Make libxl__domain_save_device_model asynchronous

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: prepare for asynchronous writing of qemu save file
Ian Jackson [Thu, 28 Jun 2012 17:43:24 +0000 (18:43 +0100)]
libxl: prepare for asynchronous writing of qemu save file

* Combine the various calls to libxl__device_model_savefile into one
  at the start of libxl__domain_suspend, storing the result in the
  dss.  Consequently a few functions take a dss instead of some or all
  of their other arguments.

* Make libxl__domain_save_device_model's API into an asynchronous
  style which takes a callback.  The function is, however, still
  synchronous; it will be made actually async in the next patch.

* Consequently make libxl__remus_domain_checkpoint_callback into an
  asynchronous callback.

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>
12 years agolibxl: datacopier: provide "prefix data" facility
Ian Jackson [Thu, 28 Jun 2012 17:43:23 +0000 (18:43 +0100)]
libxl: datacopier: provide "prefix data" facility

This will be used to write the qemu data banner to the save/migration
stream.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: wait for qemu to acknowledge logdirty command
Ian Jackson [Thu, 28 Jun 2012 17:43:23 +0000 (18:43 +0100)]
libxl: wait for qemu to acknowledge logdirty command

The current migration code in libxl instructs qemu to start or stop
logdirty, but it does not wait for an acknowledgement from qemu before
continuing.  This might lead to memory corruption (!)

Fix this by waiting for qemu to acknowledge the command.

Unfortunately the necessary ao arrangements for waiting for this
command are unique because qemu has a special protocol for this
particular operation.

Also, this change means that the switch_qemu_logdirty callback
implementation in libxl can no longer synchronously produce its return
value, as it now needs to wait for xenstore.  So we tell the
marshalling code generator that it is a message which does not need a
reply.  This turns the callback function called by the marshaller into
one which returns void; the callback function arranges to later
explicitly sends the reply to the helper, when the xs watch triggers
and the appropriate value is read from xenstore.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: provide libxl__xs_*_checked and libxl__xs_transaction_*
Ian Jackson [Thu, 28 Jun 2012 17:43:22 +0000 (18:43 +0100)]
libxl: provide libxl__xs_*_checked and libxl__xs_transaction_*

These useful utility functions make dealing with xenstore a little
less painful.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: rename libxl_dom:save_helper to physmap_path
Ian Jackson [Thu, 28 Jun 2012 17:43:22 +0000 (18:43 +0100)]
libxl: rename libxl_dom:save_helper to physmap_path

"save_helper" isn't very descriptive.  Also it is now confusing
because it reads like it might refer to the libxl-save-helper
executable which runs xc_domain_save and xc_domain_restore.

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>
12 years agolibxl: domain save/restore: run in a separate process
Ian Jackson [Thu, 28 Jun 2012 17:43:21 +0000 (18:43 +0100)]
libxl: domain save/restore: run in a separate process

libxenctrl expects to be able to simply run the save or restore
operation synchronously.  This won't work well in a process which is
trying to handle multiple domains.

The options are:

 - Block such a whole process (eg, the whole of libvirt) while
   migration completes (or until it fails).

 - Create a thread to run xc_domain_save and xc_domain_restore on.
   This is quite unpalatable.  Multithreaded programming is error
   prone enough without generating threads in libraries, particularly
   if the thread does some very complex operation.

 - Fork and run the operation in the child without execing.  This is
   no good because we would need to negotiate with the caller about
   fds we would inherit (and we might be a very large process).

 - Fork and exec a helper.

Of these options the latter is the most palatable.

Consequently:

 * A new helper program libxl-save-helper (which does both save and
   restore).  It will be installed in /usr/lib/xen/bin.  It does not
   link against libxl, only libxc, and its error handling does not
   need to be very advanced.  It does contain a plumbing through of
   the logging interface into the callback stream.

 * A small ad-hoc protocol between the helper and libxl which allows
   log messages and the libxc callbacks to be passed up and down.
   Protocol doc comment is in libxl_save_helper.c.

 * To avoid a lot of tedium the marshalling boilerplate (stubs for the
   helper and the callback decoder for libxl) is generated with a
   small perl script.

 * Implement new functionality to spawn the helper, monitor its
   output, provide responses, and check on its exit status.

 * The functions libxl__xc_domain_restore_done and
   libxl__xc_domain_save_done now turn out to want be called in the
   same place.  So make their state argument a void* so that the two
   functions are type compatible.

The domain save path still writes the qemu savefile synchronously.
This will need to be fixed in a subsequent patch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: domain save: API changes for asynchrony
Ian Jackson [Thu, 28 Jun 2012 17:43:21 +0000 (18:43 +0100)]
libxl: domain save: API changes for asynchrony

Change the internal and external APIs for domain save (suspend) to be
capable of asynchronous operation.  The implementation remains
synchronous.  The interfaces surrounding device model saving are still
synchronous.

Public API changes:

 * libxl_domain_save takes an ao_how.

 * libxl_domain_remus_start takes an ao_how.  If the
   libxl_domain_remus_info is NULL, we abort rather than returning an
   error.

 * The `suspend_callback' function passed to libxl_domain_save is
   never called by the existing implementation in libxl.  Abolish it.

 * libxl_domain_save takes its flags parameter as an argument.
   Thus libxl_domain_suspend_info is abolished.

 * XL_SUSPEND_* flags renamed to LIBXL_SAVE_*.

 * Callers in xl updated.

Internal code restructuring:

 * libxl__domain_suspend_state member types and names rationalised.

 * libxl__domain_suspend renamed from libxl__domain_suspend_common.
   (_common here actually meant "internal function").

 * libxl__domain_suspend takes a libxl__domain_suspend_state, which
   where the parameters to the operation are filled in by the caller.

 * xc_domain_save is now called via libxl__xc_domain_save which can
   itself become asynchronous.

 * Consequently, libxl__domain_suspend is split into two functions at
   the callback boundary; the second half is
   libxl__xc_domain_save_done.

 * libxl__domain_save_device_model is now called by the actual
   implementation rather than by the public wrapper.  It is already in
   its proper place in the domain save execution sequence.  So
   officially make it part of that execution sequence, renaming it to
   domain_save_device_model.

 * Effectively, rewrite the public wrapper functions
   libxl_domain_suspend and libxl_domain_remus_start.

 * Remove a needless #include <xenctrl.h>

 * libxl__domain_suspend aborts on unexpected domain types rather
   than mysteriously returning EINVAL.

 * struct save_callbacks moved from the stack to the dss.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: domain restore: reshuffle, preparing for ao
Ian Jackson [Thu, 28 Jun 2012 17:43:20 +0000 (18:43 +0100)]
libxl: domain restore: reshuffle, preparing for ao

We are going to arrange that libxl, instead of calling
xc_domain_restore, calls a stub function which forks and execs a
helper program, so that restore can be asynchronous rather than
blocking the whole toolstack.

This stub function will be called libxl__xc_domain_restore.

However, its prospective call site is unsuitable for a function which
needs to make a callback, and is buried in two nested single-call-site
functions which are logically part of the domain creation procedure.

So we first abolish those single-call-site functions, integrate their
contents into domain creation in their proper temporal order, and
break out libxl__xc_domain_restore ready for its reimplementation.

No functional change - just the following reorganisation:

* Abolish libxl__domain_restore_common, as it had only one caller.
  Move its contents into (what was) domain_restore.

* There is a new stage function domcreate_rebuild_done containing what
  used to be the bulk of domcreate_bootloader_done, since
  domcreate_bootloader_done now simply starts the restore (or does the
  rebuild) and arranges to call the next stage.

* Move the contents of domain_restore into its correct place in the
  domain creation sequence.  We put it inside
  domcreate_bootloader_done, which now either calls
  libxl__xc_domain_restore which will call the new function
  domcreate_rebuild_done, or calls domcreate_rebuild_done directly.

* Various general-purpose local variables (`i' etc.) and convenience
  alias variables need to be shuffled about accordingly.

* Consequently libxl__toolstack_restore needs to gain external linkage
  as it is now in a different file to its user.

* Move the xc_domain_save callbacks struct from the stack into
  libxl__domain_create_state.

In general the moved code remains almost identical.  Two returns in
what used to be libxl__domain_restore_common have been changed to set
the return value and "goto out", and the call sites for the abolished
and new functions have been adjusted.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: domain save: rename variables etc.
Ian Jackson [Thu, 28 Jun 2012 17:43:20 +0000 (18:43 +0100)]
libxl: domain save: rename variables etc.

Preparatory work for making domain suspend asynchronous:

* Rename `struct suspendinfo' to `libxl__domain_suspend_state'
  and move it to libxl_internal.h.

* Rename variables `si' to `dss'.

* Change the stack-allocated state and callbacks from
    struct suspendinfo si;
    struct save_callbacks callbacks;
    struct restore_callbacks callbacks;
  to
    libxl__domain_suspend_state dss[1];
    struct save_callbacks callbacks[1];
    struct restore_callbacks callbacks[1];
  so that it may be referred to as a pointer variable everywhere.

* Rename the variable `flags' (in libxl__domain_suspend_state) to
  `xcflags', to help distinguish it from the other `flags' which is
  passed in from the calling application in libxl_domain_suspend_info.
  Abolish the local variable in libxl__domain_suspend_common, as it
  can use the one in the dss.

* Move the prototypes of suspend-related functions in libxl_internal.h
  to after the definition of the state struct.

* Replace several ctx variables with gc variables and
  consequently references to ctx with CTX.  Change references
  to `dss->gc' in the functional code to simply `gc'.

* Use LOG* rather than LIBXL__LOG* in a number of places.

* In libxl__domain_save_device_model use `rc' instead of `ret'.

* Introduce and use `gc' and `domid' in
  libxl__domain_suspend_common_callback.

* Wrap some long lines.

* Add an extra pair of parens for clarity in a flag test.

* Remove two pointless casts from void* to a struct*.

No functional change whatsoever.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxc: Do not segfault if (e.g.) switch_qemu_logdirty fails
Ian Jackson [Thu, 28 Jun 2012 17:43:19 +0000 (18:43 +0100)]
libxc: Do not segfault if (e.g.) switch_qemu_logdirty fails

In xc_domain_save the local variable `ob' is initialised to NULL.
There are then various startup actions.  Some of these `goto out' on
failure; for example the call to callbacks->switch_qemu_logdirty on
l.978.  However, out is used both by success and error paths.  So it
attempts (l.2043) to flush the current output buffer.  If ob has not
yet been assigned a non-NULL value, this segfaults.  So make the call
to outbuf_flush conditional on ob.

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>
12 years agolibxc: xc_domain_restore, make toolstack_restore const-correct
Ian Jackson [Thu, 28 Jun 2012 17:43:19 +0000 (18:43 +0100)]
libxc: xc_domain_restore, make toolstack_restore const-correct

Update the one provider of this callback, in libxl.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: allow setting more than 31 vcpus
Yang Zhang [Thu, 28 Jun 2012 16:51:56 +0000 (17:51 +0100)]
libxl: allow setting more than 31 vcpus

In current implementation, it uses integer to record current avail
cpus and this only allows user to specify 31 vcpus.  In following
patch, it uses cpumap instead integer which make more sense than
before. Also there is no limit to the max vcpus.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: allow to allocate cpumap with specific size
Yang Zhang [Thu, 28 Jun 2012 16:47:13 +0000 (17:47 +0100)]
libxl: allow to allocate cpumap with specific size

Currently, libxl_cpumap_alloc()allocate the cpumap with size of number
of physical cpus. In some place, we may want to allocate specific size
of cpumap.  This patch allow to pass a argument to specific the size
that you want to allocate. If pass 0, it means the size is equal to
number of physical cpus.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxen,pod: Only sweep in an emergency, and only for 4k pages
George Dunlap [Thu, 28 Jun 2012 14:18:05 +0000 (15:18 +0100)]
xen,pod: Only sweep in an emergency, and only for 4k pages

Testing has shown that doing sweeps for superpages slows down boot
significantly, but does not result in a significantly higher number of
superpages after boot.  Early sweeping for 4k pages causes superpages
to be broken up unnecessarily.

Only sweep if we're really out of memory.

v2:
 - Move unrelated code-motion hunk to another patch
v3:
 - Remove now-unused reclaim_super from pod struct

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
12 years agoxen,pod: Zero-check recently populated pages (checklast)
George Dunlap [Thu, 28 Jun 2012 14:18:03 +0000 (15:18 +0100)]
xen,pod: Zero-check recently populated pages (checklast)

When demand-populating pages due to guest accesses, check recently populated
pages to see if we can reclaim them for the cache.  This should keep the PoD
cache filled when the start-of-day scrubber is going through.

The number 128 was chosen by experiment.  Windows does its page
scrubbing in parallel; while a small nubmer like 4 works well for
single VMs, it breaks down as multiple vcpus are scrubbing different
pages in parallel.  Increasing to 128 works well for higher numbers of
vcpus.

v2:
 - Wrapped some long lines
 - unsigned int for index, unsigned long for array
v3:
 - Use PAGE_ORDER_2M instead of 9
 - Removed inappropriate use of p2m_pod_zero_check_superpage() return value

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
12 years agoxen,pod: Try to reclaim superpages when ballooning down
George Dunlap [Thu, 28 Jun 2012 14:18:00 +0000 (15:18 +0100)]
xen,pod: Try to reclaim superpages when ballooning down

Windows balloon drivers can typically only get 4k pages from the kernel,
and so hand them back at that level.  Try to regain superpages by checking
the superpage frame that the 4k page is in to see if we can reclaim the whole
thing for the PoD cache.

This also modifies p2m_pod_zero_check_superpage() to return SUPERPAGE_PAGES on
success.

v2:
 - Rewritten to simply to the check as in demand-fault case, without needing
   to know that the p2m entry is a superpage.
 - Also, took out the re-writing of the reclaim loop, leaving it optimized for
   4k pages (by far the most common case), and simplifying the patch.
v3:
 - Add SoB

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
12 years agodocs: Use lists.xen.org not lists.xensource.com
Ian Campbell [Thu, 28 Jun 2012 15:11:59 +0000 (16:11 +0100)]
docs: Use lists.xen.org not lists.xensource.com

[ Also s/greatful/grateful/, twice -iwj ]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agohgignore/gitignore: add xen/arch/x86/boot/reloc.bin, .lnk
Ian Jackson [Thu, 28 Jun 2012 14:59:24 +0000 (15:59 +0100)]
hgignore/gitignore: add xen/arch/x86/boot/reloc.bin, .lnk

25479:61dfb3da56b0 added a .PRECIOUS which causes these files to be
left over more often.  They should have been ignored already, though.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoQEMU_TAG update
Ian Jackson [Thu, 28 Jun 2012 14:49:53 +0000 (15:49 +0100)]
QEMU_TAG update

12 years agolibxl: disable msitranslate by default
Stefano Stabellini [Thu, 28 Jun 2012 14:47:34 +0000 (15:47 +0100)]
libxl: disable msitranslate by default

msitranslate is known to cause problems with some device drivers,
because it sets the real device in MSI mode while making the guest think
is actually in legacy interrupts mode. Some drivers are able to spot this
inconsistency and break (Nvidia drivers for example).

Disable msitranslate by default.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: do not ignore the per-device msitranslate and power_mgmt opts
Stefano Stabellini [Thu, 28 Jun 2012 14:45:59 +0000 (15:45 +0100)]
libxl: do not ignore the per-device msitranslate and power_mgmt opts

Do not ignore the per-device msitranslate and power_mgmt options: they
need to be appended to the bdf.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>