[node-patches] Change in ovirt-node[master]: virt: Fix virtualization detection

fabiand at fedoraproject.org fabiand at fedoraproject.org
Mon Mar 11 10:46:03 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: virt: Fix virtualization detection
......................................................................

virt: Fix virtualization detection

Previously the logic to detect if virt. support was basically available
was broken.
This is now fixed - It can be detected if hardware supporting
virtualization is available and enabled.

rhbz#916823

Change-Id: I0be858555a5ba7af74911925568ac85a0f4edb45
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/utils/virt.py
1 file changed, 20 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/20/12920/1

diff --git a/scripts/tui/src/ovirt/node/utils/virt.py b/scripts/tui/src/ovirt/node/utils/virt.py
index 314841f..8b5e40e 100644
--- a/scripts/tui/src/ovirt/node/utils/virt.py
+++ b/scripts/tui/src/ovirt/node/utils/virt.py
@@ -31,24 +31,19 @@
 
 def hardware_is_available():
     """Determins if virtualization hardware is available.
+    This does not mean that virtualization is also enabled.
 
     Returns:
         True if there is hardware virtualization hardware available
     """
-    has_virtualization = False
+    is_available = False
 
-    has_module = False
-    with open("/proc/modules") as modules:
-        for line in modules:
-            has_module = (line.startswith("kvm_intel") or
-                          line.startswith("kvm_amd"))
-            if has_module:
-                break
-
-    if has_module and os.path.exists("/dev/kvm"):
-        has_virtualization = True
-
-    return has_virtualization
+    with open("/proc/cpuinfo") as cpuinfo:
+        for line in cpuinfo:
+            if line.startswith("flags"):
+                if "vmx" in line or "svm" in line:
+                    is_available = True
+    return is_available
 
 
 def hardware_is_enabled():
@@ -58,12 +53,19 @@
         True if there is hardware virtualization hardware available and enabled
     """
     is_enabled = False
+
     if hardware_is_available():
-        with open("/proc/cpuinfo") as cpuinfo:
-            for line in cpuinfo:
-                if line.startswith("flags"):
-                    if "vmx" in line or "svm" in line:
-                        is_enabled = True
+        has_module = False
+        with open("/proc/modules") as modules:
+            for line in modules:
+                has_module = (line.startswith("kvm_intel") or
+                              line.startswith("kvm_amd"))
+                if has_module:
+                    break
+
+        if has_module and os.path.exists("/dev/kvm"):
+            is_enabled = True
+
     return is_enabled
 
 


--
To view, visit http://gerrit.ovirt.org/12920
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0be858555a5ba7af74911925568ac85a0f4edb45
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list