CA-83076: avoid xapi and xenopsd both "owning" the Vbd.backend xenopsd field

The xapi/xenopsd separatation needs to be strictly as follows:

1. all the static VM metadata (Vm.t, Vbd.t, Vif.t, Pci.t) is owned and
   updated by xapi, whenever the user requests it via the XenAPI

2. all the dynamic VM state (Vm.state, Vbd.state, Vif.state, Pci.state)
   is owned and updated by xenopsd. Xapi will receive events on this
   and update some data in the pool database.

In particular a xenopsd API call (Vbd.insert, Vbd.eject) must not write
any static metadata directly, since this will conflict with parallel
updates from xapi.

Furthermore all dynamic VM state updates from xenopsd need to be "complete"
and not require correlating with static VM state. For example the disk
"backend" which is currently associated with a CDROM must be completely
described in the Vbd.state.

The XenAPI VBD.insert/VBD.eject control flow is now:

1. xapi calls xenopsd with VBD.insert/eject
2. xenopsd performs the xenstore-level operation (including stashing away
   the VDI in xenstore)
3. xenopsd generates an event on the VBD
4. xapi receives the VBD event and calls VBD.stat
5. xapi sets VBD.{empty, VDI} in the pool database based on the VBD.stat
   results
6. xapi inserts a barrier event to ensure all events are processed

After step (5), a XenAPI event will be generated which will be received
by the event.from in xapi_xenopsd, which will cause xapi to push the
new Vbd.t configuration to xenopsd, ensuring that the insert/eject will
take effect on next reboot.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-83040: choose_suspend_sr ignores SRs not shared with host

When a VM was migrated within the pool from local storage to local storage, the
suspend SR was not reset, which caused suspend to fail because the VM's
suspend_SR was not visible to the host on which it was being suspended. We fix
the problem by modifying choose_suspend_sr to ignore a VM's suspend_SR field if
that SR has no PBD linking it with the VM's resident host.

Another commit will follow which blanks out the suspend_SR field on a VM when
it's suspend SR will no longer be visible after a migrate.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
whitespace: delete trailing space

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
CA-83040: fix suspend_SR on intra-pool storage migrate

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
CA-83040: fix suspend_SR on VM metadata import

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
CA-83076: quicktest now checks that VBDs have currently_attached = true after VM.start

It's useful to explicitly check this -- it's surprising how far you can get with a broken VBD.stat

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-83076: add the same xenstore key in VBD.plug as we do in VBD.insert

Without this VBD.stat is unable to determine the VDI from the VBD, breaking
VBD hotplug.

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

check_sr_exists_for_host had some nested-if spaghetti logic that was
unessessary. We simplify it by just calling host_has_pbd_for_sr directly, since
that function returns false if the SR isn't valid.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
Merge commit '6d5eb1806e500a6af9cc18bc0e80cd72adcd39b3'
Merge commit '259dd8f2e3a827a3dfe8485f7f8e0d3959da51c0'