On 01/10/2014 03:34 PM, Rodrigo Trujillo wrote:
As Kimchi supports a large range of Linux distributions and libvirt
versions may differ. Libvirt functionalities may not be available,
what requires different implementations of kimchi code. This patch
implements a function to help identify libvirt version.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
---
 src/kimchi/utils.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index af245c6..64edc1c 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -27,6 +27,7 @@ import urllib2


 from cherrypy.lib.reprconf import Parser
+from libvirt import getVersion


 from kimchi import config
@@ -96,3 +97,16 @@ def check_url_path(path):
         return False

     return True
+
+
+def is_libvirt_version_lesser(version):
+    """
+    Receives an string as version (ex: '0.7.1' or '1.1.2') and compares with
+    system libvirt version.
+    Returns booleanr: True if libvirt version lesser than given version
+                      False if libvirt version is greater or equal
+    """
+    # Versions numbers are integers: 1000000*major + 1000*minor + release
+    ver = version.split('.')
+    test_version = 1000000*int(ver[0]) + 1000*int(ver[1]) + int(ver[2])
+    return (cmp(getVersion(), test_version) < 0)

We usually use FeatureTests to identify qemu/libvirt capabilities.
Isn't there a way to create a feature test for this case instead of verifying the libvirt version?