<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 01/10/2014 03:34 PM, Rodrigo
      Trujillo wrote:<br>
    </div>
    <blockquote
cite="mid:1389375282-6677-3-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
      type="cite">
      <pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:rodrigo.trujillo@linux.vnet.ibm.com">&lt;rodrigo.trujillo@linux.vnet.ibm.com&gt;</a>
---
 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) &lt; 0)
</pre>
    </blockquote>
    <br>
    <font face="DejaVu Sans Mono">We usually use FeatureTests to
      identify qemu/libvirt capabilities.<br>
      Isn't there a way to create a feature test for this case instead
      of verifying the libvirt version?<br>
      <br>
      <br>
    </font>
  </body>
</html>