[Ovirt-devel] [PATCH node] Checks for hardware support for virtualization.

Darryl L. Pierce
Thu, 26 Feb 2009 20:13:31 -0000

NOTE: This patch incorporates changes suggested by pmyers. If hardware
      virtualization is not available, the system updates /etc/issue*
      with a message. It then appends to that whether hardware virtual-
      ization is possible with the current hardware.

If hardware support is not found then an error is logged calling out
that hardware virt is not supported.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 scripts/ovirt-post |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 068c709..2f0483b 100755
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -11,6 +11,30 @@
 . /etc/init.d/ovirt-functions

 start() {
+    BACKUP=$(mktemp)
+    ISSUE=/etc/issue
+    ISSUE_NET=/etc/issue.net
+    egrep -v "[Vv]irtualization hardware" $ISSUE > $BACKUP
+    cp -f $BACKUP $ISSUE
+    hwvirt=$(virsh capabilities)
+    if [[ $hwvirt =~ kvm ]]; then
+	log "Hardware virtualization detected"
+    else
+	log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+	log "!!! Hardware Virtualization Is Unavailable !!!"
+	log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+
+	echo "Virtualization hardware is unavailable." >> $ISSUE
+
+	flags=$(cat /proc/cpuinfo | grep "^flags")
+	if [[ $flags =~ vmx ]] || [[ $flags =~ svm ]]; then
+	    echo "(Virtualization hardware was detected but is disabled)"
>> $ISSUE
+	else
+	    echo "(No virtualization hardware was detected on this system)"
>> $ISSUE
+	fi
+    fi
+    cp -f $ISSUE $ISSUE_NET