CP-6628 - Nuke xenguest and dumpcore, because of the latest change to the libxc API
Merge commit 'f9bea1fb594778a57d775b990712887ea42838b9'
Merge commit 'b5eba8fa2a35acbddaaeb21744b4c4cac76706cc'
Handle invalid edition on xapi startup

We changed the editions in a later version of XenServer. If an old xapi
restarts during an upgrade, we may have an invalid edition in the database. If
the edition found in the database isn't in the list of allowed editions, we
instead use the "default edition" (the "lowest" edition returned by
V6client.get_editions).

CA-121350

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>

fix
Refactor License_init.initialise

Clean up initialise, and move xcp-mode error handler into initialise, since we
now call V6client functions from initialise.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Add dependency injection for V6client to License_init

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Add Pool_role_shared.set_pool_role_test for unit testing

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Add unit tests for CA-121350

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Add some packages and paths to merlin file

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
CA-101571: Allow the vcpu params weight and cap value to be set independently
Signed-off-by: Ravi Pandey <ravi.pandey@citrix.com>
We shouldn't be printf'ing things

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Refactor xapi.ml for unit testing

Move main loop to xapi_main.ml so we don't run it when we run unit tests.
Extract function for initializing unix domain sockets.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
WIP unit tests: start http_svr, enable logging

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
VDI.copy: add extra arguments for deltas, and copying "into"

VDI.copy now takes arguments:
 vdi: the disk to copy
 base: if present, we will copy differences from here only
 SR: if no "into" VDI is provided, a fresh VDI will be created
     in this SR
 into: if present, the existing disk we will write the blocks into

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
xe vdi-copy: add new arguments base-vdi-uuid and into-vdi-uuid

We also make sr-uuid optional, since only one of sr-uuid and
into-vdi-uuid should be provided.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
VDI.copy: add implementation for 'base' and 'into' arguments

If 'base' is provided then we will perform a delta-copy.
If 'into' is provided then we will copy into this existing VDI,
  otherwise we will create a fresh VDI in the SR given by 'sr'

However:
* if 'into' is read-only then we will fail with VDI_READONLY
* if 'into' is too small then we will fail with VDI_TOO_SMALL
* if 'base' is provided but the destination VDI (either 'into'
  or the fresh one we created in 'sr') does not support spareness
  then we fail with VDI_NOT_SPARSE

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
quicktest: add a test for new VDI.copy functionality

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-122467: Fix for setting the right value of memory_actual after vm is started

There is a race condition between vm_start and monitor thread.
The monitor thread runs every 5s and updates the memory changes of the
VMs if any. It does that only if the VM's resident_on value is set to
localhost.
Currently, the memory changes are being seen by monitor thread while
VM is starting but since the start operation has'nt yet set the
resident_on, the monitor thread doesn't do anything.
However, the in-memory cache of monitor thread already has the vm_memory
changes for that VM. This needs to be removed, so that monitor thread
updates it next time when the resident_on value of the VM is set by
start operation.
Signed-off-by: Ravi Pandey <ravi.pandey@citrix.com>
Set pool role to Master during unit tests

Make sure pool role is correctly set during startup. Since Context's initial
database is created at module init time, we need to do this even before the
unit test harness can positively set the pool role. We check that this is a
unit test context by checking that the executable's name is not 'xapi'. If it's
not, we assume unit test.

This commit also modifies config_misc to return a default string for the Xen
version if we're running in unit test mode and get an error that we can't
connect to the xc interface.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Unit tests can make API calls and persist DB to disk

Suite now initialises xapi's http-svr, http handlers, and domain sockets. The
mock database is set to persist to disk, and can persist between invocations of
make_context_with_new_db (but by default it creates a fresh database each
time). Test case test_ca12350 has been modified to take advantage of these
improvements.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>