[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 08/21] libs/guest: introduce a helper to apply a cpu policy to a domain
Such helper is very similar to the existing xc_set_domain_cpu_policy interface, but takes an opaque xc_cpu_policy_t instead of arrays of CPUID leaves and MSRs. No callers of the interface introduced in this patch. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 161dafd234b..d82c99b2f0d 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2601,6 +2601,8 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int idx, xc_cpu_policy_t policy); int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, xc_cpu_policy_t policy); +int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, + const xc_cpu_policy_t policy); /* Manipulate a policy via architectural representations. */ int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t policy, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c index a8133d5cd3f..48351f1c4c6 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -812,6 +812,46 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, return rc; } +int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, + const xc_cpu_policy_t policy) +{ + uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1; + unsigned int nr_leaves, nr_msrs; + xen_cpuid_leaf_t *leaves = NULL; + xen_msr_entry_t *msrs = NULL; + int rc; + + rc = allocate_buffers(xch, &nr_leaves, &leaves, &nr_msrs, &msrs); + if ( rc ) + { + errno = -rc; + return -1; + } + + rc = xc_cpu_policy_serialise(xch, policy, leaves, &nr_leaves, + msrs, &nr_msrs); + if ( rc ) + goto out; + + rc = xc_set_domain_cpu_policy(xch, domid, nr_leaves, leaves, nr_msrs, msrs, + &err_leaf, &err_subleaf, &err_msr); + if ( rc ) + { + ERROR("Failed to set domain %u policy (%d = %s)", domid, -rc, + strerror(-rc)); + if ( err_leaf != -1 ) + ERROR("CPUID leaf %u subleaf %u", err_leaf, err_subleaf); + if ( err_msr != -1 ) + ERROR("MSR index %#x\n", err_msr); + goto out; + } + + out: + free(leaves); + free(msrs); + return rc; +} + int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t p, xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, xen_msr_entry_t *msrs, uint32_t *nr_msrs) -- 2.30.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |