CP-9366: Watch the "control" xenstore node, and update VM-metrics "other".

Now when qemu writes a feature-flag into the control node, xapi will
notice and so will trigger the existing code that can copy those entries
into the "other" vm guest metrics parameter.

That code used to do nothing unless it found a version for the PV
drivers. These are absent for HVM Linux guests with no guest agent, so
now even if there is no PV driver version we do the minimum work
needed to update "other", including creating the VM guest metrics
record if needed.

Also, now we set the guest metrics record to null on VM start.
This avoids problems of some of its data being wrong (left over from
last time the VM ran, or from the VM's parent if it is a clone) but
being trusted because its last_updated is more recent than VM start
time due to an item in "other" being set before (say) the networks
field is updated.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
(cherry picked from commit 223be77fe377abeb8bfffd2bbf828566c0691cb4)

Conflicts:

	ocaml/xenops/xenops_server_xen.ml
CP-9366: Check HVM feature-flags not just PV drivers

Use these flags to determine the allowed_operations list which is
only advisory.  When it comes to attempting an operation, do not
require the feature-suspend or feature-shutdown flag: attempt the
operation anyway and it is up to the guest whether it cooperates.
The feature-vcpu-hotplug flag is needed for that operation though.

Changes:
* xapi_vm_lifecycle check_operation_error uses the flags to check
  whether we can perform a given operation. (Also checks for PV
  drivers to support old guest agents that do not write the flags.)
* In xapi_host.ml the pre-evacuation check no longer checks for PV
  drivers to learn whether a VM can be migrated.  It was already
  calling Xapi_vm_lifecycle.get_operation_error.
* Appropriate errors are defined: one for each of three features.
* Datamodel: removed vm_missing_pv_drivers from vm_pool_migrate
  error list
* Removed code that raises an Unimplemented exception for HVM
  guests when attempting vCPU hotplug. This allows the code that
  decides based on the feature-flag to work properly.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
(cherry picked from commit 43592b1185789a96ef9728ab761a0940639cc7cf)

Conflicts:

	ocaml/xapi/xapi_vm_lifecycle.ml
	ocaml/xenops/xenops_server_xen.ml
CP-9366: Require feature-suspend for HVM in host evacuation plan.

CA-146028 should be fixed by this commit.

This reverts part of the behaviour-change (but not code-change) of
my commit 43592b1185789a96ef9728ab761a0940639cc7cf

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
(cherry picked from commit 308c81b58f0033dd1966a7b4118802b05233cc0a)
CP-9366: Require HVM feature-flags (or PV drivers) strictly.

When attempting a lifecycle operation on an HVM guest, we now
require any relevant feature-flag (or PV drivers) in the same way
as when calculating the allowed_operations list.

This undoes another part of the behaviour-change (but not
code-change) of my earlier commit
43592b1185789a96ef9728ab761a0940639cc7cf

This returns behaviour for HVM Windows without guest-agent
(without PV drivers) to the same as before any CP-9366 changes.

In a future change we might make this configurable.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
(cherry picked from commit e965a2ee8c71498ec2bce1cf2b607e8990903ce0)
CP-9366: Destroy the VM guest metrics discarded on VM start.

Fix a xapi database leak: on VM start we were just setting the
VM's guest metrics record to Ref.null thus orphaning the old
record.  Now we also destroy it.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
(cherry picked from commit b52a18785ed98ee2fda1c857f09a1c75d5b88c3d)
CP-9366: HVM feature-suspend is obsolete in trunk, so remove check.

Suspend and related operations do not need cooperation from HVM
guests in trunk, so we can remove this part of the check that has
just been forward-ported from the xs64bit (XenServer 6.5) branch
in commit 33d2839e41cd34f5a0730e14e3a193da63f35c49

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
CP-9366: Remove redundant update_allowed_operations calls.

Also use VM.update_allowed_operations rather than imitating it
with separate calls to the specific update_allowed_operations
functions for VM, VBDs and VIFs.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
Merge pull request #1978 from thomassa/trunk-hvm-feature-flags

CP-9366: Use HVM feature-flags instead of checking PV drivers.