[CA-129187] & [CA-116748]: remove xs path to ignore error if path does not exist

Also modified the way exception is raised, use Exception class
instead of string

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #90 on xapi-project/sm
CA-114341: check return value of LVHD plugins

Initially the return value of the call to the plugin was checked (when
the plugin was called via the xe command), and when xe was replaced the
check was removed. It is unclear why this happened (no justification in
the commit messages), so it might be an omission.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-114341: GC: acquire VDI lock non-blocking

The GC needs to acquire the SR and VDI locks in the reverse order
VDI.activate/deactivate do, which leads to temporary deadlock that is
resolved when the VDI.activate/deactivate give up. This patch makes the
GC to simply try to acquire the VDI lock, if it fails to do so it skips
the VDI, and that leads to the GC releasing the SR lock.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge CA-114341

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #84 on xapi-project/sm
CA-122205: Continuation to the previous commits

Tests have uncovered additional failures, expanding error handler
to catch ENOENT againt OSError and EIO against CommandException

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #94 on xapi-project/sm
CA-117628: allow LVM metadata updates when running through plug-in

This patch uses the LVM configuration file that allows metadata updates when
running LVM commands on the master through the plug-in.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-117628: don't ignore result of VHD footer zeroing errors

Although this commit is not required for fixing the issue, it is still
important as we were previously ignoring the result of it and detected the
actual error much later on.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge CA-117628

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #93 on xapi-project/sm
CA-122205: More race conditions.

dmsetup table LV called from _checkActive could error out
if GC running in parallel has removed the LV.

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

GitHub: closes #95 on xapi-project/sm
Revert changes made for CA-122205

Roll back fixes that ignore journal unavailability exceptions.
Issue being fixed under CA-129800 by correcting the original changes
made for CP-5818. Commits being reverted are:

* 2171f7d: "CA-122205: More race conditions."
* 4e92794: "CA-122205: Continuation to the previous commits"
* 84dcbf4: "CA-122205: Addressing build errors, also backing out blktap2 changes"
* 68286d1: "CA-122205: Resolve race between VDI.activate and GC."

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

GitHub: closes #96 on xapi-project/sm
CA-129800: Use VDI id in journal names.

Use VDI id (origUuid) in journal file names instead of clone/leaf id.
This makes it possible to detect existence of journal files for a
certain VDI without needing to open and read the files for
additional information.

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

GitHub: closes #98 on xapi-project/sm
CA-114341: explicitly use keyword argument

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-114341: don't try to reacquire the lock

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge CA-114341

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>

Github: closes #97 on xapi-project/sm
revert CA-114341 patches

The CA-114341 patches fail to pass the BST as some curious locking
issues appear. It's not yet clear whether these patches are just wrong
or whether they uncover an existing issue. I'm removing them for now to
unblock the BST and the merge into trunk.

This patch reverts the following commits:
* 8c1c069c: "CA-114341: don't try to reacquire the lock"
* 1f5db2b3: "CA-114341: explicitly use keyword argument"
* a47ceebb: "CA-114341: GC: acquire VDI lock non-blocking"

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #99 on xapi-project/sm
Revert "CA-114341: check return value of LVHD plugins"

This reverts commit 4bdb01aa761d73519c2e14410a3e63f291918524. We revert
the commit because it uncovers an existing bug (fixing it is not
trivial) and makes the BVT and BST fail, blocking the merge of
trunk-storage into trunk.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

GitHub: closes #100 on xapi-project/sm
CA-126097: Handle vm-clone when VBD is attached.

A clone operation was never performed when the VM is running, as a result
there is no need to pause/unpause tapdisk during the clone operation. With
storage motion in place, there is a change in this behaviour. vm-copy attaches
and activates the VBD, a clone operation during the phase could result
in VHDs in inconsistent state.

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #101 on xapi-project/sm
CA-115938: Repair VHD footer in case of a corruption

During a coalesce operation, parent VHDs could end up with corrupt footers
in case of Out of Storage errors. The fix try a repair parent after a
failed coalesced operation. The scenario where runAbortable kills the vhd
coalesce process is also covered.

Signed-off-by: Vineeth Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #102 on xapi-project/sm
Revert "Revert "CA-114341: check return value of LVHD plugins""

This reverts commit 7d104f5720b444c67e1303b107d4532a8532e925.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Revert "revert CA-114341 patches"

This reverts commit 5d1fe87240d43e2c31bce5dade4f6261d234b0f5.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>