CA-147816: Create a tap disk for every kind of udev device

Commit a121c306 was about creating a tap disk when passing a physical
cd device to a guest.
For that purpose, we checked that the value of sr.sm_config['type'] was
equal to 'cd'.

With CA-147816, we also want a tap disk in case of a USB device.
However, sr.sm_config['type'] is equal to 'block' in this case, which
may be too general; for instance, we do not want to create a tap disk
for a storage array.
Moreover, there is no easy way to know that we are dealing with a USB
device.

According to the XenServer 6.2 administration guide, a udev SR only
handles cd and usb devices.
This fix relies on this assumption, since a tap disk is now created if
the SR handles udev devices.

Signed-off-by: Flavien Quesnel <flavien.quesnel@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
CA-147816: [UnitTest] Update and refactor unit tests

Update and refactor unit tests introduced by 3060073a to reflect the
changes from a121c306 to c0f26bf4.

Signed-off-by: Flavien Quesnel <flavien.quesnel@citrix.com>
Merge branch 'CA-147816' into xs64bit

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

GitHub: closes #228 on xapi-project/sm
CA-129230: Output of SM is truncated in logs (by syslog)

Problem: If an exception other than SR.SRException was raised in
SRCommand.run(), it was only caught and logged into SMlog by LVHD.
All other SR drivers let it pass to xapi, which in turn truncated
the traceback / exception message, making it difficult to debug.

Fix: There is now a single, driver agnostic point inside
SRCommand.run() that logs all exceptions to SMlog. Traceback
is not truncated. NOTE: All individual lines are limited to 989
characters.

Signed-off-by: Kostas Ladopoulos <Konstantinos.Ladopoulos@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
CA-129230: [UnitTest] Three Unit Tests regarding the fix

Signed-off-by: Kostas Ladopoulos <Konstantinos.Ladopoulos@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
Merge branch 'CA-129230' into xs64bit

Signed-off-by: Kostas Ladopoulos <Konstantinos.Ladopoulos@citrix.com>

GitHub: closes #227 on xapi-project/sm
Revert "Merge branch 'CA-129230' into xs64bit"

This reverts the content of merge 9e28639b:
- fdac607a (CA-129230: [UnitTest] Three..)
- ca832ba7 (CA-129230: Output of SM is ..)

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
CP-10069: disable read caching if license-restricted

Read caching is disabled if license does not allow it.

VDI.attach_from_config does not contain a XAPI session, because this is
called by HA before XAPI starts. We don't use read caching for static
VDIs because it does not make sense, we only occasionally write data to
such VDIs.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
[squashed commits]
Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Felipe Franciosi <felipe.franciosi@citrix.com>

GitHub: closes #229 on xapi-project/sm