libxl: handle errors from xc_sharing_* info functions

On a 32 bit hypervisor xl info currently reports:
sharing_freed_memory   : 72057594037927935
sharing_used_memory    : 72057594037927935

Eat the ENOSYS and turn it into 0. Log and propagate other errors.

I don't have a 32 bit system handy, so tested on x86_64 with a libxc
hacked to return -ENOSYS and -EINVAL.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
libfsimage: add ext4 support for CentOS 5.x

CentOS 5.x forked e2fs ext4 support into a different package called
e4fs, and so headers and library names changed from ext2fs to ext4fs.
Check if ext4fs/ext2fs.h and -lext4fs work, and use that instead of
ext2fs to build libfsimage. This patch assumes that if the ext4fs
library is present it should always be used instead of ext2fs.

This patch includes a rework of the ext2fs check, a new ext4fs check
and a minor modification in libfsimage to use the correct library.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
libxl: fix usage of backend parameter and run_hotplug_scripts

vif interfaces allows the user to specify the domain that should run
the backend (also known as driver domain) using the 'backend'
parameter. This is not compatible with run_hotplug_scripts=1, since
libxl can only run the hotplug scripts from the Domain 0.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xl: error if vif backend!=0 is used with run_hotplug_scripts

Print an error and exit if backend!=0 is used in conjunction with
run_hotplug_scripts. Currently libxl can only execute hotplug scripts
from the toolstack domain (the same domain xl is running from).

Added a description and workaround of this issue on
xl-network-configuration.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xl: do not leak cpupool names.

Valgrind reports:
==3076== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==3076==    at 0x402458C: malloc (vg_replace_malloc.c:270)
==3076==    by 0x406F86D: libxl_cpupoolid_to_name (libxl_utils.c:102)
==3076==    by 0x8058742: parse_config_data (xl_cmdimpl.c:639)
==3076==    by 0x805BD56: create_domain (xl_cmdimpl.c:1838)
==3076==    by 0x805DAED: main_create (xl_cmdimpl.c:3903)
==3076==    by 0x804D39D: main (xl.c:285)

And indeed there are several places where xl uses
libxl_cpupoolid_to_name as a boolean to test if the pool name is
valid and leaks the name if it is. Introduce an is_valid helper and
use that instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Juergen Gross<juergen.gross@ts.fujitsu.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xentop.c: Change curses painting behavior to avoid flicker

Currently, xentop calls clear() before drawing the screen and calling
refresh().  This causes the entire screen to be repainted from scratch
on each call to refresh().  It is inefficient and causes visible flicker
when using xentop.

This patch fixes this by calling erase() instead of clear() which overwrites
the current screen with blanks instead.  The screen is then drawn as usual
in the top() function and refresh() is called.  This method allows curses
to only repaint the characters that have changed since the last call
to refresh(), thus avoiding the flicker and sending fewer characters to
the terminal.

In the event the screen becomes corrupted, this patch accepts a CTRL-L
keystroke from the user which will call clear() and force a repaint of
the entire screen.

Signed-off-by: Jason McCarver <slam@parasite.cc>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
docs: flesh out xl.cfg documentation, correct typos, reorganize

Some highlights:
 * Correct some markup errors:
       Around line 663:
           '=item' outside of any '=over'
       Around line 671:
           You forgot a '=back' before '=head3'
 * Add documentation for msitranslate, power_mgnt, acpi_s3, aspi_s4,
   gfx_passthru, nomigrate, etc.
 * Reorganize items in "unclassified" sections like cpuid,
   gfx_passthru to where they belong
 * Correct link L<> references so they can be resolved within the
   document
 * Remove placeholders for deprecated options device_model and vif2
 * Remove placeholder for "sched" and "node", as these are options for
   cpupool configuration. Perhaps cpupool configuration deserves
   a section in this document.
 * Rename "global" options to "general"
 * Add section headers to group general VM options.

Signed-off-by: Matt Wilson <msw@amazon.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
libxl: Fix missing dependency in api check rule

Without this, the api check cpp run might happen before the various
autogenerated files which are #include by libxl.h are ready.

We need to remove the api-ok file from AUTOINCS to avoid a circular
dependency.  Instead, we list it explicitly as a dependency of the
object files.  The result is that the api check is the last thing to
be done before make considers the preparation done and can start work
on compiling .c files into .o's.

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
libxl: Tolerate xl config files missing trailing newline

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
amd iommu: use base platform MSI implementation

Given that here, other than for VT-d, the MSI interface gets surfaced
through a normal PCI device, the code should use as much as possible of
the "normal" MSI support code.

Further, the code can (and should) follow the "normal" MSI code in
distinguishing the maskable and non-maskable cases at the IRQ
controller level rather than checking the respective flag in the
individual actors.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Wang <wei.wang2@amd.com>
Acked-by: Keir Fraser <keir@xen.org>
VT-d: use msi_compose_msg()

... instead of open coding it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Xiantao Zhang <xiantao.zhang@intel.com>
Acked-by: Keir Fraser <keir@xen.org>
x86/hvm: don't use indirect calls without need

Direct calls perform better, so we should prefer them and use indirect
ones only when there indeed is a need for indirection.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
x86/hvm: constify static data where possible

In a few cases this also extends to making them static in the first
place.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
x86/hvm: mark save/restore registration code __init

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>