Author: gnichols
Date: 2010-05-19 17:55:35 +0000 (Wed, 19 May 2010)
New Revision: 505
Modified:
branches/v7-1.1/v7/fvtest.py
Log:
576497 - fv_* is not listed in v7 print on rhel55-server-x86_64-xen system
Modified: branches/v7-1.1/v7/fvtest.py
===================================================================
--- branches/v7-1.1/v7/fvtest.py 2010-05-19 17:54:44 UTC (rev 504)
+++ branches/v7-1.1/v7/fvtest.py 2010-05-19 17:55:35 UTC (rev 505)
@@ -24,9 +24,10 @@
import shutil
import curses
import time
+from xml.dom.minidom import getDOMImplementation, parseString
from v7.test import Test
-from v7.tags import Constants, DeviceClass
+from v7.tags import Constants, DeviceClass, Tags
from v7.hal import Hal
from v7.device import Device
from v7.command import Command, V7CommandException
@@ -34,6 +35,7 @@
from v7.certificationtest import CertificationDocument
from v7.redhatrelease import RedHatRelease
+
PASSED = 0
FAILED = 1
@@ -57,63 +59,101 @@
self.waitTime = 60 # in minutes
self.environment = Environment()
self.debug = Constants.off
- self.redHatRelease = RedHatRelease()
+ self.redHatRelease = RedHatRelease()
+
+ def __pickHypervisor(self):
+ """ Pick whether xen or kvm virtualization is to be tested """
+ self.hypervisor = Constants.kvm # default
- self.__getHypervisor()
+ # if we're running xen, then do xen
+ if self.redHatRelease.getKernelFlavor() == Constants.xen:
+ self.hypervisor = Constants.xen
+
+ def __setUpHypervisor(self):
+ """ configure the test for the specific hypervisor (kvm or xen) """
+ if self.hypervisor is None:
+ print "Error: no hypervisor set"
+ return
+
+ # check cpu flags, just to log the results.
+ self.__hasVirtualizationCPUFlags(verbose=True)
+
if self.hypervisor == Constants.xen:
+ print "Testing xen virtualization"
self.guestConfigFile = 'v7' + self.hardwarePlatform
self.guestConfigPath = os.path.join(self.environment.getGuestConfigDirectory(), self.guestConfigFile)
self.guestImageDirectory = self.environment.getGuestImageDirectory()
- elif self.hypervisor == Constants.kvm:
+ else: # assume kvm - for manual test scheduling
+ print "Testing kvm virtualization"
+ self.hypervisor = Constants.kvm
self.guestConfigFile = 'v7' + self.hardwarePlatform + ".xml"
self.guestConfigPath = os.path.join(self.environment.getKVMGuestConfigDirectory(), self.guestConfigFile)
self.guestImageDirectory = self.environment.getKVMGuestImageDirectory()
- def __getHypervisor(self):
- self.hypervisor = None
- if self.redHatRelease.getVersion() < 5 or self.redHatRelease.getKernelFlavor() == Constants.rt:
- # pre-RHEL5 or real-time kernel:, no OS support for virtualization
- return
-
+ def __isHVMCapableViaLibvirt(self):
+ """ determine if system is FV/hvm capable, via virsh from libvirt """
+ virsh = Command("virsh capabilities")
+ try:
+ virsh.run()
+ parser = parseString("".join(virsh.output))
+ elements = parser.getElementsByTagName("guest")
+ for element in elements:
+ osType = element.getElementsByTagName(Tags.os_type)[0].childNodes[0]
+ if osType.data == "hvm":
+ return True
+ return isHvm
+ except Exception, e:
+ if self.debug != Constants.off:
+ print "Note: could not parse virsh capabilities"
+ print e
+
+ def __isHVMInCapabilitiesFile(self):
+ """ try /sys/../capabilities, looking for xen FV support"""
+ try:
+ capabilities = '/sys/hypervisor/properties/capabilities'
+ capabilityFile = open(capabilities)
+ self.hypervisorCapabilities = capabilityFile.readline()
+ capabilityFile.close()
+ if Constants.hvm in self.hypervisorCapabilities:
+ return True
+ except IOError:
+ if self.debug != Constants.off:
+ print "Note: could not read " + capabilities
+
+ #otherwise
+ return False
+
+ def __hasVirtualizationCPUFlags(self, verbose=False):
+ """ check cpuinfo for virtualization flags """
cpuflags = Command("fgrep flags /proc/cpuinfo")
try:
- if self.hardwarePlatform == "ia64" or cpuflags.getString(regex="(vmx|smx|svm)", singleLine=False):
- # read the hypervisor capabilities if that file exists
- try:
- capabilityFile = open('/sys/hypervisor/properties/capabilities')
- self.hypervisorCapabilities = capabilityFile.readline()
- capabilityFile.close()
- if Constants.hvm in self.hypervisorCapabilities:
- self.hypervisor = Constants.xen
- except IOError:
- self.hypervisorCapabilities = 'none'
-
- # if not xen, plan in for kvm
- if self.hypervisor != Constants.xen:
- self.hypervisor = Constants.kvm
- except V7CommandException, e:
- pass # no virtualization support
+ flags = cpuflags.getString(regex="(vmx|smx|svm)", singleLine=False)
+ if verbose or self.debug != Constants.off:
+ print "/proc/cpuinfo has %s flag" % flags
+ return True
+ except V7CommandException:
+ if verbose or self.debug != Constants.off:
+ print "Note: /proc/cpuinfo does not have vmx, smx, or svm flags"
+
+ return False
+
+ def configureHypervisor(self):
+ # determine whether to use xen or kvm virtualization
+ self.__pickHypervisor()
+ # configure test for the righ hypervisor
+ self.__setUpHypervisor()
def plan(self, devices):
tests = list()
- if self.hypervisor == Constants.xen:
- for device in devices:
- if Constants.xen in device.getProperty("system.kernel.version"):
- self.hypervisor = Constants.xen
- test = self.makeCopy()
- test.setDevice(device)
- tests.append(test)
- return tests
-
- # otherwise
- if self.hypervisor == Constants.kvm:
- test = self.makeCopy()
- tests.append(test)
-
+ if self.redHatRelease.getVersion() >= 5 and self.redHatRelease.getKernelFlavor() != Constants.rt:
+ if self.__isHVMCapableViaLibvirt() or self.__isHVMInCapabilitiesFile() or self.__hasVirtualizationCPUFlags():
+ test = self.makeCopy()
+ tests.append(test)
return tests
def getRequiredRPMs(self):
+ self.__pickHypervisor()
rpms = ["libvirt", "libvirt-python", "python-virtinst"]
if self.hypervisor == Constants.kvm:
if "Fedora" in self.redHatRelease.getProduct():
@@ -123,6 +163,7 @@
rpms.append('kvm-tools')
elif self.redHatRelease.getVersion() is 6:
rpms.append("qemu-kvm-tools")
+ rpms.append("python-virtinst")
return rpms
def verifyGuest(self):
@@ -191,6 +232,7 @@
os.remove(filename + ".tar.bz2")
# move it to the right place
shutil.move(unpackedFilename, os.path.join(destinationDirectory, filename))
+ print "Moved: " + unpackedFilename + " to " + os.path.join(destinationDirectory, filename)
restorecon = Command("/sbin/restorecon -v " + os.path.join(destinationDirectory, filename))
restorecon.echo()
print "Downloaded " + filename + " to " + destinationDirectory
@@ -431,6 +473,8 @@
def run(self):
+ # determine whether to use xen or kvm virtualization
+ self.configureHypervisor()
# verify the guest, start if necessary
if not self.verifyGuest():
return FAILED