CP-8320: Build using the git sm repo

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-106886: Don't update vhd-blocks during SR.scan

Don't bother updating the vhd-blocks in the XAPI database as this is
owned by the GC and there's no synchronisation for this.

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

GitHub: closes #119 on xapi-project/sm
(cherry picked from commit 083722c17dcc8a29371ae2a4fd00c6a87ce3275d)
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>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 4bdb01aa761d73519c2e14410a3e63f291918524)
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>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit a47ceebbbab678079f72851d7fd87afb0de3cf97)
CA-114341: explicitly use keyword argument

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

(cherry picked from commit 1f5db2b390da485ecd77f7e4d985f65450e87e11)
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>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 8c1c069c58817c5e7152fe2f0286f554c65763e6)
CA-114341: increase lock retry count

The current value of lock retry is too small and results in VDI.activate
giving up trying to acquire the lock too early. Doubling this value
seems to rectify the problem.

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

(cherry picked from commit d1767c42b04363d982959f4a91e041939cadb93e)
Merge branch 'CA-114341' into xs64bit

GitHub: closes #122 on xapi-project/sm
[CA-106120] & [CA-107155]: Remove stale references of the host to the VDI in VDI.attach.

This is a combination of two commits from trunk, 436156902d9f and
4f89c29f1917.
The latter is required to fix a regression introduced by the former.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Andrei Lifchits <andrei.lifchits@citrix.com>
Reviewed-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #123 on xapi-project/sm
CA-122445: get_current_initiator_name fails to parse initiatorname.iscsi file on Debian

On Debian, the /etc/iscsi/initiatorname.iscsi file has comments telling you
what to do with the InitiatorName parameter;  the previous code would try
to interpret this comment as the InitiatorName setting and fail to parse it.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com
Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

(cherry picked from commit 6c45c1717a2c842b1e7e3878628032e0412dd467)

GitHub: closes #118 on xapi-project/sm
CA-123640: clarify use of LEAFCLSC_OFFLINE

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

(cherry picked from commit e005acb0588e52e0d8a8cae8d4d57da20f06be81)

GitHub: closes #116 on xapi-project/sm
CA-119099: Don't rely on existence of mount point for SR auto-attach

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

(cherry picked from commit b643275944d5912305bd9ff2e3f1ee5a0d16b803)

GitHub: closes #126 on xapi-project/sm
CA-95928: Xapi lists and attempts to mount directories as isos

Signed-off-by: Sugandha Aggarwal <sugandha.aggarwal@citrix.com>
Acked-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Vineeth Raveendran <vineeth.thampi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #130 on xapi-project/sm
CA-99235: Keep trying to remove the tag forever

In the error handling path of VDI.activate, if the connection with the
master is lost, the slave cannot remove the tag from sm-config. When the
connection is restored, the VDI is left in undefined state. To avoid
this we keep trying to remove the tag until we succeed (the connection
with the host has been restored).

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Vineeth Thampi <vineeth.thampi@citrix.com>
Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

(cherry picked from commit e32cc329cdd62ec157dc5337c95b06556de62ebd)

GitHub: closes #132 on xapi-project/sm