Commit Graph
100 Commits
Author SHA1 Message Date
Wei Liu c47237a3d9 flask: build policy in different locations
The flask policy can be build twice -- one for hypervisor and one for
tools.

Before this patch, everything is built inside tools/flask/policy
directory.  It is possible to have a race to write to the same output
file when running parallel builds.

Prepend output file names with FLASK_BUILD_DIR. Hypervisor and tools
build will set that variable to different directories, so that we can
be safe from races.

Adjust other bits of the build system as needed.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-11-04 14:08:10 +00:00
Wei Liu bd41a22f2d Revert "libxl: disallow enabling PoD and ALTP2M at the same time"
This reverts commit ff53c65311.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-11-03 16:13:05 +00:00
Wei Liu ff53c65311 libxl: disallow enabling PoD and ALTP2M at the same time
That combination would cause Xen to crash.

Note that although this is a security issue, is not XSA-worthy because
ALTP2M is experimental.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-11-03 10:41:40 +00:00
Wei Liu fecf584294 Config.mk: fix comment for debug option
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-11-03 10:40:44 +00:00
Wei Liu 31d41d7bc8 build: make debug option affect tools only
The debug option in Config.mk affects hypervisor, tools and stubdom by
appending different flags to CFLAGS.  Mini-os under extra is not
affected because it already has its own build system when it is
separated from xen.git.

It is undesirable because now hypervisor build is affected by both
Kconfig and debug.

Disentangle the semantics of debug by pushing relevant options to
individual sub-systems.

For hypervisor, the flags previously added by debug option is now
controlled by CONFIG_DEBUG.

For tools, flags are moved from config/*.mk into tools/Rules.mk.

For stubdom, because it unilaterally sets debug=y before including
top-level Config.mk, we only need to move the debug build set of flags
into stubdom Makefile.

Specifically there are some considerations on what flags are picked:

1. we don't need -fno-optimize-sibling-calls anymore because gcc doc
   indicates that it is not enabled for -O1, which we already set in the
   debug build.
2. for tools we use -O0 -g3 in Rules.mk because they already take
   precedence over the flags set in config/*.mk.
3. for hypervisor we don't add -fno-omit-frame-pointer to debug build
   because that's controlled by CONFIG_FRAME_POINTER.

This patch doesn't intend to tune those flags, but to provide identical
set of effective flags as before.  The debug option in Config.mk will
only affect tools components after this patch is applied.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-11-03 10:40:39 +00:00
Wei Liu e1d1c68ea8 xen: disable debug build
Xen debug build is controlled by Kconfig.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-11-03 10:40:33 +00:00
Wei Liu 668e4edf92 stubdom: make GMP aware that it's being cross-compiled
Append --build and --host flags to GMP's configure script so that it
knows it is being cross-compiled.

This should fix the issue that GMP doesn't compile with gcc 6, because
configure script won't try to test the host environment anymore.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-10-31 10:33:07 +00:00
Wei Liu 6f9b62ca57 libacpi: require ACPI_BUILD_DIR to be set
It's better to have a explicit error than a build failure returned by
gcc.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-10-24 18:21:33 +01:00
Wei Liu a134aeaa17 libxl: initialise nr_dom_vcpus to fix 4a6070ea9
Clang complains nr_dom_vcpus may be used uninitialised after
4a6070ea9.

The real issue is vinfo can be NULL and nr_dom_vcpus remains
uninitialised if previous call fails.

Initialise nr_dom_vcpus to 0 at the beginning of the loop to fix the
issue.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2016-10-24 11:53:20 +01:00
Wei Liu 0beaeccdd6 Revert "timer: process softirq during dumping timer info"
This reverts commit ed7e33747d.

Assertion is triggered:
(XEN) Assertion '!in_irq() && local_irq_is_enabled()' failed at softirq.c:57

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-10-21 18:21:23 +01:00
Wei Liu 8b4664265b Config.mk: use non-debug build for 4.8
Set debug ?= n in preparation for late RCs and eventual release.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-10-20 14:00:47 +01:00
Wei Liu f9acf51a16 libxl: remove explicit rule for libxl_arm_acpi.o
After 9c635883 ("ARM64: fix libxl build, do not include
../../xen/include") there is nothing special needed to build
libxl_arm_acpi.o. Remove the explicit rule, use predefined one.

Build tested on ARM64.

Suggested-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2016-10-18 18:00:46 +01:00
Wei Liu 05e379bd27 libacpi: add back the "G" in "GNU" in licence header
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-10-17 11:46:18 +01:00
Wei Liu 344da4f3ad libacpi: fix arm64 build
The arm64 build for libacpi was broken due to two reasons:

1. ACPI_BUILD_DIR was appended twice to dsdt_anycpu_arm.c.
2. The inclusion of firmware/Rules.mk overrided XEN_TARGET_ARCH, which
   made CONFIG_ARM disappear.

Fix those by:

1. Correctly generate full path for dsdt_anaycpu_arm.c.
2. Include tools/Rules.mk instead, because libacpi/Makefile doesn't rely
   on settings in firmware/Rules.mk.

While at it, use CONFIG_ARM_64 instead of CONFIG_ARM as it is more
accurate.

Reported-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-10-17 11:46:02 +01:00
Wei Liu b5283627de tools: check liblzma in configure for rombios
We upgraded ipxe in 38ab99b2 ("ipxe: update to new commit"). That
version of ipxe requires liblzma to build.

Check that in configure and document this in README.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-10-13 12:27:55 +01:00
Wei Liu 38ab99b26b ipxe: update to newer commit
The current commit in tree is rather old. It has come to a point that
cherry-picking commits from upstream isn't trivial anymore.

There is long term plan to track ipxe upstream, but for 4.8 release, we
should just update ipxe to a newer commit (they are using rolling
release model now).

Forward-port the one boot prompt patch that is still relevant and retire
the rest which are already in upstream.

Reported-by: Juergen Schinker <ba1020@homie.homelinux.net>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-10-12 15:26:18 +01:00
Wei Liu 0a9d8a57e1 Kconfig: use tab instead of space
Previously in d6be2cfc ("xen: make clear gcov support limitation in
Kconfig") and db6c2264 ("xen: add a gcov Kconfig option"), space was
used to indent Kconfig text. Change that to use tab instead.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2016-10-10 12:52:55 +01:00
Wei Liu 031655daea libxl: fix issues in 38cd0664
A few issues were introduced in 38cd0664 ("libxl/arm: Add the size of
ACPI tables to maxmem"):

1. d_config was not properly initialised and disposed of.
2. using libxl_retrieve_domain_configuration caused thread to
   deadlock itself.

Fix those issues by:

1. properly initialise and dispose of d_config.
2. switch to use libxl__get_domain_configuration.

Note that in theory we can refactor libxl_retrieve_domain_configuration
a bit to get a function without locking, but up until the calculation of
extra memory only relies on static configuration, hence we use the
stored configuration only.

Reported-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-10-04 10:53:41 +01:00
Wei Liu 4b997d7aa8 svm/emulate: remove duplicated const specifier
Clang complains:

emulate.c:65:3: error: duplicate 'const' declaration specifier
      [-Werror,-Wduplicate-decl-specifier]
} const opc_tab[INSTR_MAX_COUNT] = {
  ^

Remove that const to fix the issue.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-09-30 16:54:28 +01:00
Wei Liu a6c5e71346 libxc: use PRI_xen_pfn in xc_dom_load_acpi
This fixes compilation on ARM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
2016-09-28 23:24:28 +01:00
Wei Liu d7c34a18a9 libxc: fix out of range shift in populate_acpi_pages
unsigned int is only 4-byte long and "4" is treated as int. The shift
would overflow.

Use unsigned long type, calculate the bits to shift before shifting
instead of shifting twice.

Caught by clang compilation test.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-28 16:51:50 +01:00
Wei Liu da9207c864 Config.mk: update mini-os commit
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-09-28 12:12:13 +01:00
Wei Liu 8fec44f23c Fix issues introduced in 3a7f872a
3a7f872a ("tools: lift BUILD_BUG_ON to a tools header file") was taken
out from an rather old half finished branch by dropping unrelated
changes.  Unfortunately two issues sneaked in.

1. Hvmloader should be standalone. Revert the changes to hvmloader.
2. The define guard in libs.h was erroneously deleted. Add that back.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-20 14:05:11 +01:00
Wei Liu 3a7f872ae4 tools: lift BUILD_BUG_ON to a tools header file
Only define BUILD_BUG_ON when there isn't one already, because mini-os
currently leaks that.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-19 17:03:20 +01:00
Wei Liu d5e9965ee4 Revert "tools: remove blktap2 related code and documentation"
This reverts commit 3f0ae679f2.
2016-09-08 16:15:59 +01:00
Wei Liu d383c07e8b Revert "tools: remove blktap2 source code"
This reverts commit 44b2829a8b.
2016-09-08 16:15:47 +01:00
Wei Liu d6be2cfccf xen: make clear gcov support limitation in Kconfig
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-09-07 07:30:03 +01:00
Wei Liu 12b3174d94 xen: replace TEST_COVERAGE with CONFIG_GCOV
The sole purpose of TEST_COVERAGE macro is to guard the availability of
gcov sysctl. Now we have a proper CONFIG_GCOV, use it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-09-07 07:30:03 +01:00
Wei Liu afb118e719 gcov: collect more sections to constructor list
The version of gcc (4.9.2) I use put constructors into .init_array*
section(s). Collect those sections into constructor list as well.

Modify both arm and x86 scripts to keep them in sync.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-09-07 07:30:03 +01:00
Wei Liu 8695b55620 xen: indicate gcov in log messages
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2016-09-07 07:30:03 +01:00
Wei Liu 8c8b6fb023 Config.mk: update OVMF commit
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-09-06 12:54:47 +01:00
Wei Liu 755e623dee Config.mk: update seabios to 1.9.3 release
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-09-06 12:50:59 +01:00
Wei Liu 44b2829a8b tools: remove blktap2 source code
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-06 11:02:36 +01:00
Wei Liu 3f0ae679f2 tools: remove blktap2 related code and documentation
Blktap2 is effectively dead code for a few years.

Notable changes in this patch:

0. Unhook blktap2 from build system
1. Now libxl no longer supports TAP disk backend, appropriate assertions
   are added and some code paths now return ERROR_FAIL
2. Tap is no longer a supported backend in doc
3. Remove relevant entries in MAINTAINERS

A patch to actually remove blktap2 directory will come later.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: George Dunlap <George.Dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-06 11:02:19 +01:00
Wei Liu b2f2ced591 tools/firmware: Rename bios.bin to seabios.bin
bios.bin as a name is far too generic.  Rename it to seabios.bin.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ wei: fix up conflict, rerun autogen.sh ]
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-09-05 11:53:16 +01:00
Wei Liu eb502cb30c libxl: update flex output files for DSA 3653-2
We updated flex output files in 4b314c89 ("libxl: update flex output
files") for DSA 3653-1 / CVE-2016-6354. But Debian security team
discovered the fix to flex was incomplete and issued DSA 3653-2. We need
to update our flex output files accordingly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-05 11:53:16 +01:00
Wei Liu 158dd1bdca tools: delete gtraceview and gtracestat
There has not been any substantial update to them since 2011. My quick
check shows that they don't work.

Just delete them. It would be easy to resurrect them from git log should
people still need them.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-09-02 14:28:35 +01:00
Wei Liu db6c2264e6 xen: add a gcov Kconfig option
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
2016-08-31 16:37:47 +01:00
Wei Liu dcf22aa0dc xen: fix gcov compilation
Currently enabling gcov in hypervisor won't build because although
26c9d03d ("gcov: Adding support for coverage information") claimed that
%.init.o files were excluded from applying compilation options, it was
in fact not true.

Fix that by filtering out the options correctly. Because the dependency
of stub.o in x86 EFI build can't be eliminated easily and we prefer a
generalised method going forward, we introduce nogcov-y to explicitly
mark objects that don't need to build with gcov support.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <JBeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-31 16:37:37 +01:00
Wei Liu 0ebbfa4f69 arm64: use "b" to branch to start_xen
The cbz instruction has range limitation. When compiled with gcov
support the object is larger so cbz can't handle that anymore. The error
message is like:

aarch64-linux-gnu-ld    -EL  -T xen.lds -N prelink.o \
    /local/work/xen.git/xen/common/symbols-dummy.o -o /local/work/xen.git/xen/.xen-syms.0
prelink.o: In function `launch':
/local/work/xen.git/xen/arch/arm/arm64/head.S:602:(.text+0x408): relocation truncated to fit: R_AARCH64_CONDBR19 against symbol `start_xen' defined in .init.text section in prelink.o

Use "b" instead.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
2016-08-31 16:37:23 +01:00
Wei Liu 8b53aa66e6 arm: acpi/boot.c is only used during initialisation
That file should contain code and data used during initialisation only.

Mark it as such in build system and correctly annotate enabled_cpus.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
2016-08-31 16:37:23 +01:00
Wei Liu 4b314c89be libxl: update flex output files
Libxl ships output files from flex (libxlu_*_l.{c,h}). We use the flex
shipped in Debian to generate those files. Debian just patched their
flex (DSA 3653-1) to fix CVE-2016-6354, which is a buffer overrun bug.

Note that libxl is _NOT_ vulnerable to that CVE. See below for Ian's
analysis to security@xen.

It would still be nice that we update our shipped flex output files to
avoid confusion.

===QUOTE===

The bug is that with input >16K[1] flex would usually fail to resize
the input buffer, and then overrun it.

I have read the code in libxlu_cfg_l.c to try to understand the
implications for libxl.

AFAICT
 - libxl always does config file reading _from the file_ itself, and
   provides flex with a string or buffer.
 - so we always call whatever_yy_scan_bytes, not any other flex setup
   function to set up a `buffer' (as flex calls it)
 - yy_scan_bytes calls yy_scan_buffer to set up the buffer
 - yy_scan_buffer sets b->yy_fill_buffer
 - The effect of this is that yy_get_next_buffer will always
   return early, rather than continuing on to the vulnerable code.

So I think libxl is not vulnerable, regardless of the contents of the
configuration file.

[1] the default buffer size, or whatever other buffer size is
configured (but we don't change it)

===ENDQUOTE===

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-30 14:14:53 +01:00
Wei Liu fb3cc17962 libxl: only return {OVMF,SEABIOS}_PATH if available
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-24 12:44:19 +01:00
Wei Liu ea27761b5d tools: only define {OVMF,SEABIOS}_PATH when they are enabled
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-24 12:43:49 +01:00
Wei Liu 94d3b9990b hvmloader: use bound checking in get_module_entry
Coverity complains:

overflow_before_widen: Potentially overflowing expression
info->nr_modules * 32U with type unsigned int (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type uint64_t (64 bits, unsigned).

The overflow is unlikely to happen in reality because we only expect a
few modules.

Fix that by converting the check to use bound checking to placate
Coverity.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-22 14:20:19 +01:00
Wei Liu 80a59905fd hvmloader: correctly copy signature to info structures
The original code used sizeof(info->signature) as the size parameter for
memcpy, which was wrong.

Fix that by using structure assignment.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-22 14:20:09 +01:00
Wei Liu a55ad65d3a Config.mk: update mini-os commit
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2016-08-12 16:37:24 +01:00
Wei Liu 072e670997 libxc: use DPRINTF in xc_domain_dumpcore_via_callback
That line doesn't reveal much information to ordinary users.

Change that to debug output.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-11 15:40:38 +01:00
Wei Liu 8e370ef503 libxl: fix declaration of libxl_primary_console_exec_0x040700
Add missing "int".

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 16:12:29 +01:00
Wei Liu 0cd19069c8 xl: use xenconsole startup protocol
If user asks xl to automatically connect to console when creating a
guest, use the new startup protocol before trying to unpause domain so
that we don't lose any console output.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:44:32 +01:00
Wei Liu f2333d5f9f docs: document xenconsole startup protocol
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:42:34 +01:00
Wei Liu 731df78226 libxl: libxl_{primary_,}console_exec now take notify_fd argument
The new argument will be passed down to xenconsole process, which then
uses it to notify readiness.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:42:13 +01:00
Wei Liu 88502c075a libxl: factor out libxl__console_tty_path
No other user yet.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:41:40 +01:00
Wei Liu 373f99d2ea tools/console: introduce --start-notify-fd option for console client
The console client will write 0x00 to that fd before entering console
loop to indicate its readiness.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:41:27 +01:00
Wei Liu 9fc57406d5 tools/console: fix help string in client
There is no short '-t' option.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-08 11:39:05 +01:00
Wei Liu e125fb0e4f systemd: remove hard-coded pid file in xendriverdomain service
Per the discussion in [0], the hard-coded pid file can be removed
completely. Systemd has no trouble figuring out the pid of devd all by
itself.

[0]: https://lists.xen.org/archives/html/xen-devel/2016-07/msg01393.html

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-08-02 17:03:10 +01:00
Wei Liu 88d6145982 xsm: don't require configuring tools to build xen xsm blob
Starting from 08cffe66 ("xsm: add a default policy to .init.data") we
can attach a xsm policy blob to hypervisor. To build that policy blob
now hypervisor build system needs to enter tools directory.

The expectation for hypervisor and tools build systems is different. We
don't want xen build system to depend on configure but we want tools
build system to. That commit broke this expectation because it required
users to run configure before building hypervisor. This broke ARM build
because ARM developers normally build hypervisor and tools separately
(and possibly on different platforms). It can also break x86 if
developers don't run configure before building hypervisor with XSM on.

To fix it, move major part of tools/flask/policy/Makefile into
Makefile.common and create tools only Makefile to include that common
Makefile. Hypervisor Makefile will use Makefile.common to build xsm
policy.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Tested-by: Julien Grall <julien.grall@arm.com>
2016-08-01 09:06:07 +01:00
Wei Liu 368574c0b7 xenstore: add assertion in database dumping code
If memfile is NULL, the signal handler won't be installed, hence fopen
won't dereference NULL. Coverity is not smart enough to figure that out
unfortunately.

Add an assertion to prevent coverity from complaining.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:09:25 +01:00
Wei Liu 7d87d31d33 xenstore: send error earlier in do_mkdir
XenServer's coverity instance complains that a few lines below
create_node dereferences NULL if name == NULL. It however fails to
figure out that if node is NULL, errno won't be ENOENT, so do_mkdir
should have bailed before create_node.

That said, it would be good if we don't need to go through the hops.  We
can bail earlier if name is NULL.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:09:21 +01:00
Wei Liu df59218807 oxenstored: honour XEN_RUN_DIR
Move default the pid file under XEN_RUN_DIR. Note that it changes the
location from /var/run to /var/run/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-07-20 16:08:28 +01:00
Wei Liu dedb221889 libxenstat: honour XEN_RUN_DIR
This is because libxl uses XEN_RUN_DIR to generate the socket path for
libxenstat while libxenstat itself uses hard-coded path, which is not
necessarily the same path as XEN_RUN_DIR.  The default configuration
happened to work because XEN_RUN_DIR defaulted to /var/run/xen, which
matched the hard-coded path.

We should make libxenstat use XEN_RUN_DIR so that it works with
non-default configuration.

Generate a _paths.h because it is required to make this change work.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:08:14 +01:00
Wei Liu 56f9010bfa hotplug/Linux: honour XEN_RUN_DIR
Store various PID files under XEN_RUN_DIR. Note that this change the
default location from /var/run to /var/run/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:08:14 +01:00
Wei Liu e5be44cda8 hotplug/NetBSD: honour XEN_RUN_DIR
Store xldevd.pid under XEN_RUN_DIR. Note that this will change the
default location from /var/run to /var/run/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:08:12 +01:00
Wei Liu 3c99c5e4c4 hotplug/FreeBSD: honour XEN_RUN_DIR
Store xldevd.pid under XEN_RUN_DIR. Note that the default location would
change from /var/run to /var/run/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:07:28 +01:00
Wei Liu 6f35915ec0 tools/helper: honour XEN_RUN_DIR in init-xenstore-domain.c
Place the PID file under XEN_RUN_DIR. Note that this change the default
location from /var/run to /var/run/xen.

Generate a _paths.h as that is required to make this change work.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:07:24 +01:00
Wei Liu 51a0ae4fd5 xenconsoled: honour XEN_RUN_DIR
Place the PID file under XEN_RUN_DIR by default. Note this change the
default location from /var/run to /var/run/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 16:07:10 +01:00
Wei Liu 3e71c27052 xl: rename variable pause to pause_after_migration
Gcc 4.4.4 complained that the "pause" variable introduced in 22b430e0
("xl: add option to leave domain paused after migration") shadowed
pause(2) declaration in unistd.h.

Rename "pause" to "pause_after_migration" to fix this issue.

Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-20 13:21:58 +01:00
Wei Liu 2f7c3c94e9 libxl: constify src parameter of libxl_nocpuid.c:libxl_cpuid_policy_list_copy
In 11316d31 ("libxl: constify copy and length calculation functions") I
forgot to take care of libxl_nocpuid.c which also contains an
implementation of libxl_cpuid_policy_list_copy. That broke ARM build.

Fix it by constifying the src parameter.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-13 14:24:02 +01:00
Wei Liu 56bac262e0 libxl: only issue cpu-add call to QEMU for not present CPU
Calculate the final bitmap for CPUs to add to avoid having annoying
error messages complaining those CPUs are already present. Example
message is like (wrapped):

libxl: error: libxl_qmp.c:287:qmp_handle_error_response: received an
error message from QMP server: Unable to add CPU: 0, it already exists

We can also properly handle error from QMP now.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-12 12:49:41 +01:00
Wei Liu 01f3193e2e libxl: update vcpus bitmap in retrieved guest config
... because the available vcpu bitmap can change during domain life time
due to cpu hotplug and unplug.

For QEMU upstream, we interrogate QEMU for the number of vcpus. For
others, we look directly into xenstore for information.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-12 12:49:41 +01:00
Wei Liu 324bd8f5dc libxl: introduce libxl__qmp_query_cpus
It interrogates QEMU for CPUs and update the bitmap accordingly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-12 12:49:41 +01:00
Wei Liu b173750d2b libxl: libxl_domain_need_memory shouldn't modify b_info
This function is used to return the memory needed for a guest. It's not
in a position to modify the b_info passed in (note the _setdefault
function).

Constify the passed in b_info, use a copy to do the calculation. Mark
the change in API in libxl.h.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-12 12:49:41 +01:00
Wei Liu 11316d31d6 libxl: constify copy and length calculation functions
These functions are not supposed to modify the passed in parameters.
Reflect that in function declarations.

Mark the change in APIs in libxl.h

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-12 12:49:41 +01:00
Wei Liu db59dbc46e libxl/netbsd: check num_exec in hotplug function
This basically replicates the same logic in libxl_linux.c but with one
change -- only test num_exec == 0 in nic hotplug case because NetBSD let
QEMU call a script itself. Without this patch libxl will loop
indefinitely trying to execute hotplug script.

Reported-by: John Nemeth <jnemeth@cue.bc.ca>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2016-07-06 18:22:53 +01:00
Wei Liu 33c18b709a libxl: debug output for args and env when invoking hotplug script
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-07-06 18:21:37 +01:00
Wei Liu a6288d5bb8 xen: make available hvm_fep to non-debug build as well
Originally hvm_fep was guarded by NDEBUG, which means it was only
available to debug builds.

However there is value in having it in non-debug builds as well. Users
can use it to run tests in a setup that replicates a production
environment.

Make it clear with a sync_console style warning that this option can't
be used in production setup. Update command line documentation
accordingly. Finally mark Xen as tainted when this feature is used.

Add a kconfig option under x86 to configure hvm_fep.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
2016-06-23 17:00:33 +01:00
Wei Liu 509019f42d xen/console: use warning infrastructure for sync console warning
Move the warning text to a static variable and marked that as initconst
data. Call warning_add in console_init_preirq. Finally remove all
unused bits.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-06-23 16:57:14 +01:00
Wei Liu ee3fd57acd xen: add warning infrastructure
Use an array to keep track of warning text, provide a function to add
warning text to track.  Print warnings (if any) in console_endboot.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-06-23 16:57:14 +01:00
Wei Liu 0630892faf libxl: fix an error path that uses uninitialised rc in libxl_set_memory_target
ecdc6fd8 ("libxl: Fix libxl_set_memory_target return value") failed to
initialised rc in one failure path. Fix it in this patch.

Also fixed an indentation issue while I was there.

CID: 1362695

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-20 14:47:02 +01:00
Wei Liu 9e5e193046 xen/kernel: document 'C' in print_tainted
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-06-20 14:25:12 +01:00
Wei Liu 67a5ab831d oxenstored: honour XEN_RUN_STORED in systemd C stub
Generate a _paths.h for that and add proper dependency.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-17 11:27:21 +01:00
Wei Liu 44e6ba4b33 oxenstored: honour XEN_RUN_STORED and XEN_CONFIG_DIR
Only contain changes to ocaml source code. C stub files will be handled
separately.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-17 11:27:21 +01:00
Wei Liu 0e3e738605 ocaml/libxs: honour XEN_RUN_STORED
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-17 11:27:21 +01:00
Wei Liu 33bcbdb330 ocaml/libxs: generate a paths.ml
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-17 11:27:21 +01:00
Wei Liu 5994480f20 hotplug/FreeBSD: honour XEN_RUN_STORED
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-17 11:27:21 +01:00
Wei Liu 153db2f820 libxenstore: honour XEN_RUN_STORED
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-17 11:27:21 +01:00
Wei Liu ba53cec7cd hotplug/Linux: honour XEN_RUN_STORED
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-17 11:27:21 +01:00
Wei Liu 7d82f09765 build: introduce XEN_RUN_STORED
It defaults to /var/run/xenstored. It will be used later to remove some
hard-coded paths in tree. There should be no visible change to default
configuration.

Install and remove it in respective Makefile targets.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-17 11:27:21 +01:00
Wei Liu d7f64ff4e0 docs: honour XEN_DUMP_DIR
Use configure to generate xl.cfg and xl manpage. Add the generated files
to gitignore.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-17 11:27:21 +01:00
Wei Liu d337764d9b tools: bump some library version numbers to 4.8
It is a pretty safe thing to do and would avoid accidentally overwrite
the old libraries when doing development.

Bump all version numbers that are currently 4.7 to 4.8. That includes
libxc, libxlu, libxl and libvchan.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 18:32:10 +01:00
Wei Liu 9b394b7eff xl: remus/colo: only initialise ha variable when necessary
The original code is wrong because the common case is no HA enabled.  It
should have been set to NULL first.

Instead of setting ha to NULL, move it to the scope where it is used.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 16:22:15 +01:00
Wei Liu fcf3f57eee tools: remove hard-coded /var/lib/xen in Makefile
Now all conversations are done, remove the hard-coded paths.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00
Wei Liu 938b2b4033 libxl: honour XEN_LIB_DIR
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
;wq
2016-06-14 14:31:27 +01:00
Wei Liu 540cecf0cf hotplug/Linux: honour XEN_LIB_DIR
Use configure to generate sysconfig.xendomains file.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00
Wei Liu 102ddb11f2 tools: install and remove XEN_LIB_DIR in Makefile
The intention of using wild card in uninstall target is to remove both
xen and xenstored directories. Change that to two runes that explicitly
remove each of those directories.

Note that the runes that use hard-coded paths are kept for now to keep
the tree bisectable as I replace hard-coded paths component by
component.  Those runes will be removed eventually.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00
Wei Liu 15f1a11d66 build: introduce and export XEN_LIB_DIR
This variable defaults to /var/lib/xen. It will be used to substitute
various hard-coded paths in tools.

The new variable points to $localstatedir/lib/xen, which defaults to
/var/lib/xen, so there is no change in default configuration.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00
Wei Liu a4fa83e568 oxenstored: honour XEN_LOG_DIR defined by configure
We generate a corresponding constant (in lower case) in paths.ml. Use
that in source code to get rid of hard-coded path.

Note that with this patch the default location for xenstored*.log is
changed from /var/log to /var/log/xen.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-14 14:31:27 +01:00
Wei Liu 6b007a6df1 oxenstored: generate a paths module
That file includes all paths generated by configure. It will be used to
get rid of hard-coded paths in code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
2016-06-14 14:31:27 +01:00
Wei Liu c84a1fa2e6 oxenstored: honour XEN_{LOG,RUN}_DIR in oxenstored.conf
Generate oxenstored.conf with configure. This involves modifying
tools/configure.ac and rerun autogen.sh.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00
Wei Liu 10055f661e libxl: log file name in failure in libxl__create_qemu_logfile
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-06-14 14:31:27 +01:00