Eliminate a few DB calls from Nm.bring_pif_up

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-74937: Reset master (remote DB) connection for any dom0 IP address change

This prevents the master connection from getting "stuck" when:
1. A slave has two NICs, with management on eth0.
2. An IP address is put on eth1, and management is moved to it.
3. The IP address of eth0 is removed.

After step 1, the slave has a master connection with as local (socket)
address the IP of eth0. After step 2, the master connection is reset, but
it may still get the same local address (eth0's IP), since there are now
two routes to the master, and it is up to dom0's kernel to pick one.
After step 3, however, this routes breaks, but the master connection was
not reset. This patch causes the connection to be reset in this case as well.

In the "stuck" state, DB calls may still arrive at the master (and other slave
operations may still work), but the master would send replies to the old IP,
which would never arrive. I believe the slave would eventually realise this
and reset the connection, but only after a very long timeout. I think that
the situation is different when the master goes offline, because the MAC layer
would cause the TCP connection to break immediately, after which the slave
automatically resets the master connection, and keeps trying until the master
is back.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-76646: migrate and ballooning now work properly

When reserving memory for a domain we use one of 3 values:
1. the ideal amount of memory if the domain was starting from scratch.
   This is 'ideal' in the sense that it should be the amount the VM
   will eventually end up with after the ballooning daemon rebalances
   memory on the machine.
2. the exact amount of memory it suspended with.
3. an upper bound on the amount the VM can use during a live migration.
   This is different to (2) because the domain is still running while
   the memory is reserved.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-76926: properly unescape Storage_interface.Backend_error into XenAPI errors

Like with xenops, we filter all client calls through a function
  transform_storage_exn
which re-raises the storage interface exception as an appropriate XenAPI
interface exception.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
As of xen-unstable.hg 779c0ef9682, libxenguest will destroy the domain on resume failure

We therefore detect this and clean up the xenstore trees.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Merge commit 'fc6cc238e447528d1ed16a085f8da675e224b525'
CA-73047: fix a file descriptor leak in is_cmdline_valid

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-77015: Ignore storage errors in Xenops.VM.destroy, as we used to do.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-77015: As well as catching the exception, make sure the task isn't marked as failed

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-78622: in PCI device state resync code, look at the PCI devices on the Host, not those on the VM

Otherwise we never find the PCI device which has just become attached.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-78622: when refreshing a VM state, refresh the PCI devices as well as VBDs and VIFs

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-78622: in the HVM PCI plug case, create a fake frontend so the device watching code notices and watches the backend

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-78622: when assigning PCI devices for GPU passthrough, persist the choice in VM.other_config:vgpu_pci

This allows the xenopsd metadata to be regenerated without accidentally assigning additional, unused PCI devices.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
CA-78286: restore the error handling when snapshot'ing type=raw LVHD VDIs

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Merge commit 'a9a37cc481a2fccd469e8bfc113089c7454d877f'
CA-78677: Take into account that String.split on "" does not return [] but [""]

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Merge branch 'master' of git://hg.uk.xensource.com/carbon/trunk/xen-api
Merge commit 'ce227b3356de59b0f18adc55901b1139a8252652'
CA-76603: Get PIF MTU from bridge, not interface

This is because there is not always an interface, e.g. in the
case of bonds on ovs.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Merge remote-tracking branch 'origin/cooper2'

Conflicts:
	ocaml/xenops/xenops_server.ml
	ocaml/xenops/xenops_server_xen.ml