From: Andrew Cooper Date: Tue, 9 Jan 2024 11:09:07 +0000 (+0000) Subject: runner: Collect the host virt capabilities X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=04ebde85213dda873fb2336e3607daa8a55e856b;p=xtf.git runner: Collect the host virt capabilities Use the test environment and variation to calculate a set of required virt capabilities. Signed-off-by: Andrew Cooper --- diff --git a/xtf-runner b/xtf-runner index 138f3b1..4143131 100755 --- a/xtf-runner +++ b/xtf-runner @@ -61,6 +61,17 @@ all_environments = pv_environments | hvm_environments class RunnerError(Exception): """ Errors relating to xtf-runner itself """ + +def env_to_virt_caps(env): + """ Identify which virt cap(s) are needed for an environment """ + if env in hvm_environments: + return {"hvm"} + caps = {"pv"} + if env == "pv32pae": + caps |= {"pv32"} + return caps + + class TestInstance(object): """ Object representing a single test. """ @@ -75,6 +86,9 @@ class TestInstance(object): raise RunnerError("Test '{0}' has variations, but none specified" .format(self.name)) + self.req_caps = env_to_virt_caps(self.env) + self.req_caps |= {"hap", "shadow"} & set((self.variation, )) + def vm_name(self): """ Return the VM name as `xl` expects it. """ return repr(self) @@ -259,6 +273,29 @@ def get_all_test_info(): return _all_test_info +# Cached virt caps +_virt_caps = set() + +def get_virt_caps(): + """ Query Xen for the virt capabilities of the host """ + global _virt_caps + + if not _virt_caps: # Cache on first request + + # Filter down to caps we're happy for tests to use + caps = {"pv", "hvm", "hap", "shadow"} + caps &= set(check_output(["xl", "info", "virt_caps"]).split()) + + # Synthesize a pv32 virt cap by looking at xen_caps + if ("pv" in caps and + "xen-3.0-x86_32p" in check_output(["xl", "info", "xen_caps"])): + caps |= {"pv32"} + + _virt_caps = caps + + return _virt_caps + + def tests_from_selection(cats, envs, tests): """Given a selection of possible categories, environment and tests, return all tests within the provided parameters.