CA-78628: avoid double-escaping PBD.plug/unplug errors

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-77758: always unplug the PCI device on shutdown (including performing an FLR)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-77758: manage the other-config:pci key using the same RBAC mechanism as the other-config "folders"

This makes the 'other_pcidevs_of_vm' function idempotent, so xapi can use it for regenerating xenopsd configuration.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76725: translate the XenAPI actions_after_crash=preserve into xenopsd on_crash=Pause

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76725: add a list of per-VM "action requests" to the diagnstics dump

This highlights any domains which have outstanding actions which have
not been processed (e.g. due to a bug)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76725: log message improvements

'ran too quickly' should be 'crashed too quickly'

Crashes and unexpected domain suspends are strange enough to justify 'warn' rather than 'debug'

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Fix windows serial debugging: the key was other_config:hvm_serial, not platform:hvm_serial

Although platform:hvm_serial makes more sense than other_config.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Merge commit 'ea98b2fee918417593cf74d2910ab3627c11ccd7'
CA-76600: preserve /vm and /vss over localhost migrate

Rather than having the higher-level software special case localhost
migrate, we use reference counting to decide when to delete /vm
and /vss. When we create a new domain for a specific UUID, we
record the domain in
  /vm/<uuid>/domains/<domid> = <local domain path>

In domain destroy, we delete /vm and /vss if the domains directory
is empty.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76600: preserve the rtc/timeoffset over migrate

Unfortunately the rtc/timeoffset can be changed dynamically by
the guest (via qemu) but isn't stored in the domain save record.
Therefore we need to both update our domain persistent state
in xenopsd (for migrate/resume) *and* update our VM config in
the higher-level toolstack (ie xapi) for start.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Merge commit '05e2a62bf90fabf22e62d3c9419cc89bbb2c4793'
Merge commit '8f400ee1bf93535d8c6f8b4e372f4d93776cdd25'
Merge commit '2d08161ccc3a055ff70df569390862f3384fe54c'
[xapi] clean up xenopsd VMs marked as "Suspended" on restart

Normally a xapi suspend or migrate will clean up these xenopsd VMs inline
but a badly-timed xapi restart can leave them lying around. Therefore
on_xapi_restart will perform a xenopsd VM.shutdown and VM.remove on any
Suspended Vms it finds.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
[xenops] VM.destroy_device_model and VM.destroy now work on VMs even if the domain has been destroyed already

Now these functions are idempotent, it should be easier to write robust cleanup code.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
[xenops] if migration receive fails, call VM.shutdown and VM.remove to clean up

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
[xapi] if a VM is left Suspended after a migration failure, power it off

Unfortunately the domain is not actually saved to disk so cannot be properly resumed (yet)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
[xenops] VM's last_start_time must be preserved over migrate

Otherwise the guest agent updates from xenstore will be considered stale

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-78569: when creating a XenAPI VM for dom0, use the memory_* values from xenopsd if they exist

This means that memory_* will be preserved over pool.join.

It's also a step in the right direction to trust the on-host service (xenopsd) as authoritative for host-specific data.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76523: on spontaneous VM shutdown, do not reset ha_always_run

The convention is that VM.ha_always_run should be reset when an API
call is received (the API call overrides the current policy) but
an internal VM shutdown is treated as a VM failure, and HA restarts it.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>