xen-org/xen-api — pull request #1260 by jonludlam (2013-05-24 12:50:24+00:00)
Title: CA-98606: Reduce impact of duplicated base_mirror key

There's a rather fundamental race in the SMAPIv1 backends with
the storage motion code. Fortunately the race only really affects
a cosmetic issue - whether VDIs temporarily show up in the GUI
while storage motion is going on. The bug exhibits as the
VDI of the VM containing a 'base_mirror' key in the sm_config
field.

Unfortunately this problem becomes worse when a subsequent SXM
operation is attempted - at this point the operation will fail
as we try to put a new base_mirror key in, getting a Duplicate_key
error.

This changeset fixes this such that we simply overwrite the
existing key. This doesn't change the cosmetic problem that the
VDIs will be missing from the GUI, but it does mean you can now
migrate the VM again.

Additionally this changeset fixes more minor problems:

- on cancelling an SXM operation the base_mirror key was left
- the existence of more than one blob on a VM caused the migration
to fail
- the blobs couldn't be sent anyway due to missing the content-length
header in the HTTP PUT operation.

Signed-off-by: Jon Ludlam