CA-95053: VM.start should check if a host has enough memory

Though it should fall back to just trying anyway in case of
failure as memory checks are notoriously hard to get right.

This patch is based on a similar one by Jerome Maloberti.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-106034: update device_watches when domain appears/disappears

When a domain appears, we need to initialise the entry in device_watches for
that domid. When a domain disappears, we need to remove the entry in
device_watches for that domid.

This was overlooked in the refactoring of CA-102259 -- the old semantics of
add_domU_watches and remove_domU_watches was not preserved as the watches map
was split into a set of domain watches and a map of device_watches.

Acked-by: Jonathan Davies <Jonathan.Davies@eu.citrix.com>
Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Merge pull request #1221 from mcclurmc/ca106034-xenstore-watches-clearwater

CA-106034: update device_watches when domain appears/disappears
CA-106080: DB upgrade rules update license_params.sku_type

The previous upgrade rules for the DB only modified license_params.edition
(advanced,enterprise,platinum -> per-socket, enterprise-xd -> xendesktop). We
also need to modify sku_type, because v6d will return current_edition =
previous sku_type on the case of an expired license. This is an edge case for
when a license expires just prior to a host upgrade, with no valid licenses on
the license server after upgrade.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
CA-101699: Run VM.copy on the master

The VDI.copy subtask(s) created by VM.copy will be forwarded to suitable
hosts, so it's debatable whether we need to forward VM.copy at all.

Before this change the VM.copy task was forwarded based on source SR(s)
only, which is definitely wrong - in the case where a VM is being copied
from shared storage to local storage, the VM.copy task would be
forwarded to a random host (with slaves preferred) and then the VDI.copy
task(s) would be forwarded again to the host connected to the local
storage.

Besides kicking off VDI.copy tasks, VM.copy mostly just creates objects
in the database and watches for events on those VDI.copy tasks, both of
which are most efficient on the master.

Maybe when the database is split up across hosts it will make more sense
to forward the VM.copy task to a host which can see both the source and
destination SRs.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Don't serialise VM.copy per host

VDI.copy is the CPU-intensive task so there's no need to serialise
VM.copy per host, especially now that VM.copy always runs on the master.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Allow VDI.copy if a VDI is only attached RO

Attempting to copy a VDI which is being written to can confuse
sparse_dd, however if a disk is only attached RO it's safe to copy it.

Signed-off-by: John Else <john.else@citrix.com>
Move test_ca98944.ml

This can be used as a basis for more VDI.allowed_operations tests so
let's give it a more generic name.

Signed-off-by: John Else <john.else@citrix.com>
CA-101699: Add unit tests for the allowed_operations changes

Signed-off-by: John Else <john.else@citrix.com>
CA-97427: Create error in vm_plan for VMs with VDI's using IntelliCache
while computing evacuation plan.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
CA-101175: Replace Event.next by Event.from

Signed-off-by: Vincent Bernardoff <vincent.bernardoff@citrix.com>
CA-101175: Event.from timeout now 30 seconds, only watch for the specific tasks

Signed-off-by: Vincent Bernardoff <vincent.bernardoff@citrix.com>
Merge pull request #1231 from siddharthv/CA-97427-CW

CA-97427: Create error in vm_plan for VMs with VDI's using IntelliCache while computing evacuation plan.
Add 'vgpu' option to vga platform key
CA-100685: When domain disappears during VM shutdown operation, just go ahead instead of rasing any cancellation error

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Revert Storage_interface.query_result.features to a (string list)

This means storage_interface.ml is now identical to the Tampa version.
The features are parsed into (string, int64) pairs at the xapi level
instead of at the SMAPI level.

Signed-off-by: John Else <john.else@citrix.com>
Move some boilerplate into the Test_highlevel functors

No actual functional changes to the tests, just lots of moving things
into and out of modules.

This change causes the function (val test : unit -> unit) to be
automatically generated by Test_highlevel.Make

Signed-off-by: John Else <john.else@citrix.com>
Update Test_highlevel docs

Signed-off-by: John Else <john.else@citrix.com>
Add some tests for the SM driver feature parsing code

Signed-off-by: John Else <john.else@citrix.com>
Re-use some code, and fix lookup of content_id in vdi_info_from_db

Signed-off-by: John Else <john.else@citrix.com>