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>
Reinstate some code that went missing during the Great Xenopsd Merge

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Rename Mirror.active -> Mirror.list, and move the type definitions into the submodule

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Remove content_id from the receive_start call

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Change receive_finalize/receive_cancel to use vdi rather than content_id

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Persist the storage migration state to disk

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Use receive_finalize rather than DP.destroy

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Implement Mirror.list

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.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>
Add mirror tests to sm-test binary

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Several changes:

* Make localhost storage migrate work (deadlock problem with DP.destroy)
* Make intra-pool migrate work (don't use importexport for intra-pool)
* Report back error state of mirroring from Mirror.list

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Ensure that storage migrate works even if the vm is rebooted during the process

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Implement VIF mapping in import.ml.

Merged-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Signed-off-by: Jerome Maloberti <jerome.maloberti@citrix.com>

Conflicts:

	ocaml/xapi/xapi_vm_migrate.ml
Pass the VIF map to xenops.

Merged-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Signed-off-by: Jerome Maloberti <jerome.maloberti@citrix.com>

Conflicts:

	ocaml/xapi/xapi_vm_migrate.ml
Implements the VIF mapping in xenops.

Signed-off-by: Jerome Maloberti <jerome.maloberti@citrix.com>