@@ -225,10 +225,10 @@ def preprocess(test, params, env):
# Get the KVM kernel module version and write it as a keyval
logging.debug("Fetching KVM module version...")
if os.path.exists("/dev/kvm"):
- try:
- kvm_version = open("/sys/module/kvm/version").read().strip()
- except:
- kvm_version = os.uname()[2]
+ kvm_ver_cmd = params.get("kvm_ver_cmd", "cat /sys/module/kvm/version")
+ s, kvm_version = commands.getstatusoutput(kvm_ver_cmd)
+ if s != 0:
+ kvm_version = "Unknown"
else:
kvm_version = "Unknown"
logging.debug("KVM module not loaded")
@@ -239,11 +239,11 @@ def preprocess(test, params, env):
logging.debug("Fetching KVM userspace version...")
qemu_path = kvm_utils.get_path(test.bindir, params.get("qemu_binary",
"qemu"))
- version_line = commands.getoutput("%s -help | head -n 1" % qemu_path)
- matches = re.findall("[Vv]ersion .*?,", version_line)
- if matches:
- kvm_userspace_version = " ".join(matches[0].split()[1:]).strip(",")
- else:
+ def_qemu_ver_cmd = "%s -help | head -n 1 | awk '{ print $5}'" % qemu_path
+ kvm_userspace_ver_cmd = params.get("kvm_userspace_ver_cmd",
+ def_qemu_ver_cmd)
+ s, kvm_userspace_version = commands.getstatusoutput(kvm_userspace_ver_cmd)
+ if s != 0:
kvm_userspace_version = "Unknown"
logging.debug("Could not fetch KVM userspace version")
logging.debug("KVM userspace version: %s" % kvm_userspace_version)