2 Utilities useful to client control files that test KVM.
5 from autotest_lib
.client
.bin
import utils
6 from autotest_lib
.client
.common_lib
import error
10 Determines the kvm architecture kernel module that should be loaded.
12 @return: "kvm_amd", "kvm_intel", or raise TestError exception
15 for line
in open("/proc/cpuinfo"):
17 if "AuthenticAMD" in line
:
19 elif "GenuineIntel" in line
:
20 arch_type
= "kvm_intel"
22 if arch_type
== "kvm_amd" and "svm" in line
:
24 if arch_type
== "kvm_intel" and "vmx" in line
:
26 raise error
.TestError("CPU Must be AMD or Intel, and must be KVM ready.")
31 Loads the appropriate KVM kernel modules
33 kvm_status
= utils
.system('modprobe kvm')
34 kvm_amdintel_status
= utils
.system("modprobe " + kvm_arch
)
38 return kvm_amdintel_status
42 Unloads the appropriate KVM kernel modules
44 kvm_amdintel_status
= utils
.system("rmmod " + kvm_arch
)
45 kvm_status
= utils
.system('rmmod kvm')
49 return kvm_amdintel_status
52 kvm_arch
= get_kvm_arch()