CP-8320: Initial commit for xs64bit

Changes based on sm.hg tip 29f9f9595fb7

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CP 8320: Improved formatting in README and INSTALL files

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
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
CA-115035: mpath-boot and multipathed host other-config keys missing

Before upgrading to the new kernel, the output of
multipath -k"show maps"
and
echo "show maps" |multipathd -k
were different.

Now they are the same but previous code in mpathcount.py was
relying exclusively on the wrong output in the previous version.

Now it is fixed in both cases

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

(cherry picked from commit ede80beecc85793f2f83371ab58a6f94df3e0620)
Imported-by: Germano Percossi <germano.percossi@citrix.com> for [CA-130639]

GitHub: closes #125 on xapi-project/sm
CA-107031: IntelliCache cleanup script fails when VDI is not in XAPI database

Signed-off-by: Andrei Lifchits <andrei.lifchits@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

GitHub: closes #124 on xapi-project/sm
CA-107572: Ignore UUID not found exception during SR scan

VM migration failed because XAPI throw VDI UUID not found exception.
The VDI was already removed, the fix will catch the exception and discard it.

Signed-off-by: Sisimon Soman <sisimon.soman@citrix.com>
Acked-by: Thanos Makatos <thanos.makatos@citrix.com
Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

(cherry picked from commit d4100048f6a101e62e3d6d677d2ca7213a2016e0)
CA-122950: Ignore invalid VDI handle exceptions in SR.scan

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Zheng Li <zheng.log@citrix.com>
Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

(cherry picked from commit c75ea33750ae71a20da0db753282b831f69cc5ea)