CA-105130: udev does not automatically refresh dev/disk/by-id

udev maintains symlinks into /dev/disk/by-id refreshing to
the latest available path to the same disk.
When the last added path is removed, the link is removed as
well, instead of being just updated to the previous path.

Recent versions of udev (e.g. in CentOS 6.4) do not show
this behaviour but our current version (095) needs to be triggered.

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

GitHub: closes #19 on xapi-project/sm
CP-5330: Start iSCSI properly.

Recent iSCSI package (iscsi-initiator-utils) has a different way to start
(there is no more the open-iscsi script). Also use service to start
the service properly.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Zheng Li <zheng.li@citrix.com>
CP-5330: Settle udev with proper command

The old udevsettle has been replaced with 'udevadm settle'.
This makes it backward compatible.
Moreover, the try block is very big and we do not handle specific
exceptions but we need to log them, at least.

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Zheng Li <zheng.li@citrix.com>
CP-5330: Ignore innocuous errors from iscsiadm

When asked for open sessions, recent versions of iscsiadm return a code
different than 0 if list is empty.
Our function exn_on_failure raises an exception if return code is not
zero, so we must trap the exception and continue because an empty list
is fine.

The exception could be handled in a better way but our
exception system needs to be made better.

This patch does not affect old iscsiadm behaviour

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Zheng Li <zheng.li@citrix.com>
CP-5330: Update scsi_id call

Because scsi_id call syntax has changed, now we use the new syntax and,
if failed, fallback to the old syntax.
Another failure raises an exception.

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Zheng Li <zheng.li@citrix.com>
Merge changes for CP-5330

GitHub: closes #18 on xapi-project/sm
CP-5330: Replace open-iscsi-auth.patch with discoverydb solution

This is part of the CP-5330 work to get rid of our customized patches
against open-iscsi and to use the stock version open-iscsi of upstream.
This changset replace open-iscsi-auth.patch with the mechanics provided
by the discoverydb mode, to allow CHAP authentication while doing iscsi
targets discovery.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Suggested-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CP-5330: Remove dependencies on iscsid-mpath.conf/iscsid-default.conf

This is part of the CP-5330 work to get rid of our customized patches
against open-iscsi and to use the stock version open-iscsi of upstream.

Previously we ship two customized versions of /etc/iscsi.conf only for
the purpose of switching one single configuration variable:
"replacement_timeout" (depending on whether multipath is enabled or not).

This is overkilled, and demand us to ship a customized build of open-iscsi.
As suggested by @robertbreker, the same effect can be possibly archived
by tweaking timeouts in the multipath layer, namely dev_loss_cmo etc.,
which we've already done in our multipath package.

This is a patch to remove SM's dependency on iscsi-mpath.conf and
iscsi-default.conf. One can still make use of them optionally by
manually creating these two files. This is useful if a customer still
needs a customized setting for some reason or for debugging purpose,
and the code is also backward compatible this way.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Suggested-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
CP-5330: Dynamic set replacement_timeout during iscsi session establishment

Instead of linking/patching iscsid.conf statically, we now set
replacement_timeout dynamically whenever we establish a new iscsi session. As
part of the CP-5330 effort, this helps us to avoid monkey patching the upstream
open-iscsi.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Suggested-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Merge changes for CP-5330

GitHub: closes #25 on xapi-project/sm
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: close #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
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.

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

GitHub: closes #29 on xapi-project/sm
CP-5818: Productise removal of lvm2-lvcreate-inactive-flag.patch

Snapshot creation process uses a temp file with all snapshot information in
the name of the file. Since this name is too long and not liked my mapper,
the file is created in an inactive mode. Changed the logic to create a file
with shorter name and all informaton is written inside the file. Inactive flag
for lvcreate is no longer required.

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

GitHub: closes #31 on xapi-project/sm
CA-113840: Add support for the Adaptec Raid Driver

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

Github closes: #21 on xapi-projects/sm
CA-115712: Add support for the Cisco fnic FCoE driver

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

Github closes: #32 on xapi-projects/sm
Merge branch 'master', remote-tracking branch 'upstream/master'