Import patch 32fbe661230e6f8328b962559350efcc20a88b2d from xen-api-libs

Originally from Euan Harris

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>