snapwatchd: Compile shared library with -fPIC

Import: trunk-ring0-cp-6236/sm.hg 82d2e5eff4e5974149af5851cb88d12abfe7432f
Imported-by: malcolmc
Merge-ticket: spike64
Fix supp pack compilation on 64bit
EA-1112, CP-3749: Fix iSCSI sysfs paths for 3.x kernel

Refactored iSCSI sysfs path calls into iscsilib which provides the correct path
depending on the kernel version (2.6 or 3.x).
EA-1112, CP-3916: Fix HBA sysfs paths for 3.x kernel.

Sysfs entries for these devices have gained another sub-directory. What was
once .../device/block:sdx/..., is now .../device/block/sdx/... . Refactored out
the extraction of the block device names to handle 3.x kernels (and remain
backward compatable with 2.6 kernels).

Also removed misleading comment about keeping devscan.py in sync with its
counterpart in host-installer.hg. This file is no longer in host-installer.hg.
CA-107356: Fix tapdisk unpause issue in case of VM migration failed.

VDI has driver name set to nbd in case VM migration failed. While
unpause tapdisk, it was always using mirror driver name. In a snapshot
failure scenario, the fix will pass None as driver name to unpause
tapdisk.

Signed-off-by: Sisimon Soman <sisimon.soman@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
CA-87112: Fix LVM space leak during VDI.create

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-123175: Filter iSCSI dom0 boot disk LUN.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-116748: Fix VSS for 64 bit.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Vineeth Thampi <vineeth.thampi@citrix.com>
[CA-133887] & [CA-116748]: python 2.4 does not have os.SEEK_SET, use 0

os.SEEK_SET was introduced in python 2.5, use 0 instead.

Signed-off-by: Vineeth Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-108915: Deprecate mpathHBA so dev_loss_tmo can be configured by DMP

SM calls the script /opt/xensource/sm/mpathHBA if a host has at least one
multipathed HBA SR. The script mpathHBA goes through all fc-ports and specifies
dev_loss_tmo (and the deprecated variant lpfc_nodev_tmo) as MPATH_TIMEOUT=30s.
This is not good because some users need to modify this timeout value in order
to accommodate controller failover events.

In recent versions of DM Multipath dev_loss_tmo can be configured as a
configuration option in /etc/multipath.conf. This commit removes
/opt/xensource/sm/mpathHBA so DMP can set the dev_loss_tmo value which users
configure in multipath.conf.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

Manual Import
Import: trunk/sm.git 6e37a85ef88b97c84c6177eccc652e3528bf9b59
Imported-by: robertbre
Merge-ticket: CA-133787
CP-5050: Notify XAPI about critical coalesce errors

The rate XAPI is notified is throttled to avoid spamming (currently
defaults to one message per hour, per SR). This rate can be overridden
by setting the "coalesce-error-rate" key in an SR's other-config.

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

Manual Import
Import: trunk/sm.git 34452aaddca8ad6225f1bf8f606ad6c61ff70b94
Imported-by: vineetht
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>

Manual Import
Import: trunk-storage/sm.git 86bfb3fabcabfdebefb8fe9119552be8c4bd4392
Imported-by: vineetht
CA-127463: After a snapshot failure, VHDs are left in PAUSED state

In the event of a snapshot failure, both tapdisk and VHDs are left in
paused state. During the recovery cycle using journaler mechanism, the
VHDs are brought back to a stable state, but further vdi deactivate will
fail with VHDs in paused state. Currently there is no mechanism to
unpause the VHDs and the tapdisk.

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

Manual Import
Import: trunk/sm.git 8f18acee8fef721f7bc9a0079f3594d5d24eccba
Imported-by: vineetht
CA-127209: Disk may not have enough space to do a parent inflate

In case when the clone operation failed for Out of Storage, disk may not
have enough space to do a inflate parent keeping the full sized child.
The order of operation should be to delete the children, and then go for
a parent inflate

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

Manual Import
Import: trunk/sm.git fe4512ce968552517b1a4b0d45367e84ae534008
Imported-by: vineetht
CA-122253: Improve error reporting for LVM-based SR snapshots

Return the actual error instead of returning errors that might have
occurred in the error-handling path.

This commit was previously reverted (see commit
0d2d903d7541070ec97028a1b201109f4070bcb3) as we had to merge into trunk
and we didn't have enough time to test it.

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

Manual Import
Import: trunk/sm.git 72c07540dca69a6135eb839b0365b372b8b1bfc3
Imported-by: vineetht
CP-7396: Ensure tapdisk reports metrics to rrdd.

- Register tapdisk with rrdd as a plugin when we open a new tapdisk.
- Deregister tapdisk with rrdd before we detach the tapdisk.

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

Manual Import
Import: trunk/sm.git a5bd32505282e60c5b0e7604e560b23ac54397a9
Imported-by: vineetht
[CA-128364] & [CP-7396]: Fix tapdisk rrd plugin deregister call.

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

Manual Import
Import: trunk-storage/sm.git 86ba7010087a1a049983306a94ae4b6af00205c4
Imported-by: vineetht
[CA-102329] & [CA-120162]: don't fail VDI.delete on innocuous GC kick errors

This is a combination of two separate commits (CA-120162 requires CA-102329).

VDI.delete: avoid duplicate GC restarts

In VDI.delete, there is a race condition where two threads attempt to
re-start a running GC/coalesce daemon, because re-starting the
GC/coalesce is done by blindly writing a value to a file (see IPC.py).
If one thread finds that there is re-start pending, there's no need to
issue another GC/coalesce re-start.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Zheng Li <zheng.li@citrix.com>

CA-120162: don't fail if the GC can't be kicked

When a VDI.delete needs to abort the GC and restart it, a deadlock might
occur which leads to reporting that VDI.delete failed while it has
partially succeeded, as the actual deletion of the VDI will happen
sooner or later. Fixing the deadlock is not straightforward, so the best
effort solution is to simply ignore such failures.

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

Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@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>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>