CP-5817: Productise removal of lvm2-environment-device.patch

Part of the change for rolling back lvm2-environment-device.patch.
Removed code that exports special environment variable to direct LVM
to look for an abbreviated device cache.

The second part of the change (actual removal of lvm patch) is under
guest-packages.

Signed-off-by: Chandrikas Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Zheng Li <zheng.li@eu.citrix.com>

GitHub: closes #28 on xapi-project/sm
CP-5831: Productise removal of lvm2-lvchange-idempotent.patch

Part of changes required to remove lvm2-lvchange-idempotent.patch.
LVM throws an error if an LV that is already RO is set to RO again
or an RW lv is set to RW. Added additional check on XS side to check
LV status before changing access permissions.

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

GitHub: closes #26 on xapi-project/sm
CA-118781: revert init order changes

Unfortunately we have to revert the previous 7018eaa and 7ac48731 on
the stricter initialization order.

This is due to some spaghetti calling pattern in our code. In VDI class
and its children, we have the following calling stack:

   Child.__init__ -> Parent.__init__ -> Child.load

When Child.load is called, it assumes that some attributes have already
been initialized, but at this point neither Child.__init__ nor
Parent.__init__ has completed their execution. This code pattern
forces us to initialize those particular attributes in the Child class's
__init___ method before ever calling  Parent.__init__.

This is not pretty, but changing this pattern demands many other changes.
To unblock trunk integration, here we reverted the previous changes.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CA-118781: Avoid the dangling "path" attribute of class VDI

The self.path attribute is referenced in VDI class's attach
method but it was not defined/initialized anywhere in class.
The correctness then depends on the children classes always do
the right thing (i.e. do not forget to init the path attribute
if they will ever call parent class's attach method directly
or indirectly).

This is considered as a ERRROR level issue by pylint. As a
fix, here we conditionally set self.path in the __init__
method based on whether a uuid argument is passed to the
initializer or not. For VDI classes whose physical
paths/locations have no direct connection with their UUID
string values (e.g. ISOSR, udevSR and SHMSR), they will not
pass any uuid to the parent class's initialiser and will be
responsible for setup the correct self.path/self.location
value by themselves. We want to make sure that their
customized value won't get overwritten here.

Also fixed the indentation suggested by Vinneth.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge for CA-116802

GitHub: closes #46 on xapi-project/sm
CA-116160: Python exception in HBA SR create.

len() on dictionary iterkeys is not valid in Python 2.6.
Replaced it with len() directly on the dictionary.

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

GitHub: closes #47 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>

GitHub: closes #44 on xapi-project/sm
CA-119833: snapwatchd fails to link on some systems

snapwatchd fails to link a shared .so with -shared:

  /usr/bin/ld: xslib.o: relocation R_X86_64_32 against `.rodata.str1.1'
  can not be used when making a shared object
  xslib.o: could not read symbols: Bad value

We need to explicitly compile our objects as position-independent
code with -fPIC

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #49 on xapi-project/sm
[CA-118876] & [SCTX-1536]: Always use the back-up VHD footer.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>

GitHub: closes #51 on xapi-project/sm
[CP-5830]: Productise removal of lvm2-master-mode.patch

Removed the --master switch from lvm commands. We now use two separate
lvm conf files for master and slave nodes. Appropriate conf file is
chosen through an environment variable.

This changeset includes the fix made for [CA-116958] in addition to the
original work done for patch removal.

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

GitHub: closes #48 on xapi-project/sm
CA-116545: SR detach could fail during a Find Open process check

This could happen if one pid, out of a list of pids, cease to exist.
Ignoring the error helps us move forward through the list checking
for any pid / file handles

    Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
    Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
    GitHub: closes #39 on xapi-project/sm