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)
Merge 'CA-122950' and 'CA-107572' into xs64bit

GitHub: closes #127 on xapi-project/sm
CAR-1442: Change NFS mount options

In preparation for read caching, change actimeo=0 to acdirmin=0,acdirmax=0.
Using "actimeo=0" prevents caching file attributes which means that each read
requires a GETATTR call to the NFS server.  This prevents read caching from
being effective.  Changing the mount options to "acdirmin=0,acdirmax=0"
prevents caching directory attributes but allows caching file attributes.  This
allows read caching to be effective.

This reverts the change made to the mount options in CA-63601.  The issue in
that ticket was a transient issue, fixed by a later build, before the change to
the mount options was made.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #135 on xapi-project/blktap
CAR-1442: Enable no-O_DIRECT read caching for VDIs on EXT and NFS SRs

Pass the "-D" argument to tap-ctl when opening an EXTFileVDI or an NFSFileVDI
to allow read caching by removing O_DIRECT.

Allow disabling read caching per-SR by setting other-config:o_direct to true.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #135 on xapi-project/blktap
CA-129333: Improve debugging for snapwatchd. Add documentation for xslib wrapper.

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

(cherry picked from commit 80f2bf6ecc2cc6dfd58e316b9dbefe1563537fbf)

Imported-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

GitHub: closes #136 on xapi-project/sm
CP-5736: ISCSISR - force_tapdisk

This is a workaround to make it possible to use a domU provided iSCSI
target as a raw iSCSI SR. By using the force_tapdisk parameter during SR
creation, disks will be accessed through tapdisk aio which copies
blocks, preventing page sharing issues between guests. This is a
workaround for the bug CA-110453.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

Imported-by: Mate Lakat <mate.lakat@citrix.com>
(cherry picked from commit 8da7ba62bd92bce057ef5b9ce5919a40a2b5b42e)

GitHub: closes #138 on xapi-project/sm
CP-5736: Unit tests

Unit tests and scripts to setup the environment. See tests/README for
details.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

Imported-by: Mate Lakat <mate.lakat@citrix.com>
(cherry picked from commit de8a7cf26aa571d2f39a13b472e0539215a3cd45)

GitHub: closes #138 on xapi-project/sm
CA-120469: Fail gracefully in case rmdir returns ENOTEMPTY

Parallel vm-suspend operations on vm that has got vdi's in the same SR
could result in reference files, ignoring rmdir error (ENOTEMPTY)
instead of lsdir looks a better option.

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by:Germano Percossi <germano.percossi@citrix.com>
Imported-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

(cherry picked from commit bc1da0cf34b3213b455523109e402da106a9bc65)

GitHub: closes #139 on xapi-project/sm
CA-118899: Support UTF-8 iSCSI target names.

Signed-off-by: Rob Dobson <rob@rdobson.co.uk>
Acked-by: Thanos Makatos <thanos.makatos@citrix.co.uk>
Imported-by: Vineeth Raveendran <vineeth.thampi@citrix.com>

(cherry picked from commit 9dbd30cde957ad19ef5ba0e950d15712946975e8)

GitHub: closes #140 on xapi-project/sm
CP-8580: Add pylint configuration file.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #137 on xapi-project/sm
CP-8580: Add MAX_TIMEOUT to LUNperVDI.py

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #137 on xapi-project/sm
CP-8580: Fix undefined variables in RawHBASR.py

- Variables sr_ref and host_ref are undefined in '_add_pbd_other_config'.
  Use self.sr_ref and self.host_ref instead.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #137 on xapi-project/sm
CP-8580: Fix method issues with blktap2.py

- '_mklink' is not a class method. Hence use 'self' instead of 'cls'.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #137 on xapi-project/sm
CP-8580: Fix method issues with lcache.py

- 'from_tapdisk' is a class method. Hence use 'cls' instead of 'self'.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>

GitHub: closes #137 on xapi-project/sm