def __init__(self, cpu_model, extra_flags=set([])): virtual_flags = set( map(virt_utils.Flag, params.get("guest_spec_flags", "").split())) self.hw_flags = set( map(virt_utils.Flag, params.get("host_spec_flags", "").split())) self.qemu_support_flags = get_all_qemu_flags() self.host_support_flags = set( map(virt_utils.Flag, virt_utils.get_cpu_flags())) self.quest_cpu_model_flags = (get_guest_host_cpuflags(cpu_model) - virtual_flags) self.supported_flags = (self.qemu_support_flags & self.host_support_flags) self.cpumodel_unsupport_flags = (self.supported_flags - self.quest_cpu_model_flags) self.host_unsupported_flags = (self.quest_cpu_model_flags - self.host_support_flags) self.all_possible_guest_flags = (self.quest_cpu_model_flags - self.host_unsupported_flags) self.all_possible_guest_flags |= self.cpumodel_unsupport_flags self.guest_flags = (self.quest_cpu_model_flags - self.host_unsupported_flags) self.guest_flags |= extra_flags self.host_all_unsupported_flags = set([]) self.host_all_unsupported_flags |= self.qemu_support_flags self.host_all_unsupported_flags -= (self.host_support_flags | virtual_flags)
def __init__(self, cpu_model, extra_flags=set([])): virtual_flags = set(map(virt_utils.Flag, params.get("guest_spec_flags", "").split())) self.hw_flags = set(map(virt_utils.Flag, params.get("host_spec_flags", "").split())) self.qemu_support_flags = get_all_qemu_flags() self.host_support_flags = set(map(virt_utils.Flag, virt_utils.get_cpu_flags())) self.quest_cpu_model_flags = (get_guest_host_cpuflags(cpu_model) - virtual_flags) self.supported_flags = (self.qemu_support_flags & self.host_support_flags) self.cpumodel_unsupport_flags = (self.supported_flags - self.quest_cpu_model_flags) self.host_unsupported_flags = (self.quest_cpu_model_flags - self.host_support_flags) self.all_possible_guest_flags = (self.quest_cpu_model_flags - self.host_unsupported_flags) self.all_possible_guest_flags |= self.cpumodel_unsupport_flags self.guest_flags = (self.quest_cpu_model_flags - self.host_unsupported_flags) self.guest_flags |= extra_flags self.host_all_unsupported_flags = set([]) self.host_all_unsupported_flags |= self.qemu_support_flags self.host_all_unsupported_flags -= (self.host_support_flags | virtual_flags)
def run_once(self): """ Try to access different resources which are restricted by cgroup. """ logging.info('Starting cpuflags testing') def check_cpuflags_work(flags): """ Check which flags work. @param vm: Virtual machine. @param path: Path of cpuflags_test @param flags: Flags to test. @return: Tuple (Working, not working, not tested) flags. """ pass_Flags = [] not_tested = [] not_working = [] for f in flags: try: for tc in virt_utils.kvm_map_flags_to_test[f]: utils.run("./cpuflags-test --%s" % (tc)) pass_Flags.append(f) except error.CmdError: not_working.append(f) except KeyError: not_tested.append(f) return (pass_Flags, not_working, not_tested) def run_stress(timeout, flags, smp): """ Run stress on vm for timeout time. """ ret = False flags = check_cpuflags_work(flags) try: utils.run( "./cpuflags-test --stress %s%s" % (smp, virt_utils.kvm_flags_to_stresstests(flags[0])), timeout) except error.CmdError: ret = True return ret os.chdir(self.srcdir) run_stress(60, set(map(virt_utils.Flag, virt_utils.get_cpu_flags())), 4)
def run_once(self): """ Try to access different resources which are restricted by cgroup. """ logging.info('Starting cpuflags testing') def check_cpuflags_work(flags): """ Check which flags work. @param vm: Virtual machine. @param path: Path of cpuflags_test @param flags: Flags to test. @return: Tuple (Working, not working, not tested) flags. """ pass_Flags = [] not_tested = [] not_working = [] for f in flags: try: for tc in virt_utils.kvm_map_flags_to_test[f]: utils.run("./cpuflags-test --%s" % (tc)) pass_Flags.append(f) except error.CmdError: not_working.append(f) except KeyError: not_tested.append(f) return (pass_Flags, not_working, not_tested) def run_stress(timeout, flags, smp): """ Run stress on vm for timeout time. """ ret = False flags = check_cpuflags_work(flags) try: utils.run("./cpuflags-test --stress %s%s" % (smp, virt_utils.kvm_flags_to_stresstests(flags[0])), timeout) except error.CmdError: ret = True return ret os.chdir(self.srcdir) run_stress(60, set(map(virt_utils.Flag, virt_utils.get_cpu_flags())), 4)
def parse_qemu_cpucommand(cpumodel): """ Parse qemu cpu params. @param cpumodel: Cpu model command. @return: All flags which guest must have. """ flags = cpumodel.split(",") cpumodel = flags[0] qemu_model_flag = get_guest_host_cpuflags(cpumodel) host_support_flag = set( map(virt_utils.Flag, virt_utils.get_cpu_flags())) real_flags = qemu_model_flag & host_support_flag for f in flags[1:]: if f[0].startswith("+"): real_flags |= set([get_flags_full_name(f[1:])]) if f[0].startswith("-"): real_flags -= set([get_flags_full_name(f[1:])]) return real_flags
def parse_qemu_cpucommand(cpumodel): """ Parse qemu cpu params. @param cpumodel: Cpu model command. @return: All flags which guest must have. """ flags = cpumodel.split(",") cpumodel = flags[0] qemu_model_flag = get_guest_host_cpuflags(cpumodel) host_support_flag = set(map(virt_utils.Flag, virt_utils.get_cpu_flags())) real_flags = qemu_model_flag & host_support_flag for f in flags[1:]: if f[0].startswith("+"): real_flags |= set([get_flags_full_name(f[1:])]) if f[0].startswith("-"): real_flags -= set([get_flags_full_name(f[1:])]) return real_flags