1""" 2Loads KVM virtualization kernel module before a test cycle and unloads it after. 3Intended to help in qualifying KVM in the kernel by comparing runs of kernel 4tests with and without this "profiler". 5 6author: jsmiller@google.com 7""" 8 9import os, subprocess 10from autotest_lib.client.bin import kvm_control, profiler, utils 11 12 13class kvm_modload(profiler.profiler): 14 version = 4 15 16 17 def initialize(self, interval=None, options=None): 18 pass 19 20 21 def log_lsmod(self, log): 22 log.write("lsmod: \n") 23 cmd_status = utils.run("lsmod") 24 if cmd_status.stdout: 25 log.write(cmd_status.stdout) 26 log.write("\n") 27 if cmd_status.stderr: 28 log.write(cmd_status.stderr) 29 log.write("\n") 30 31 32 def start(self, test): 33 load_status = kvm_control.load_kvm() 34 self.logfile = open(os.path.join(test.profdir, "kvm_modload"), 'w') 35 self.logfile.write("Loaded KVM module with status %s.\n" % 36 repr(load_status)) 37 self.log_lsmod(self.logfile) 38 39 40 def stop(self, test): 41 unload_status = kvm_control.unload_kvm() 42 self.logfile.write("Unloaded KVM module with status %s.\n" % 43 repr(unload_status)) 44 self.log_lsmod(self.logfile) 45 self.logfile.close() 46 47 48 def report(self, test): 49 output = os.path.join(test.profdir, "kvm_modload") 50