Message ID | 20210323095849.37858-6-roger.pau@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | libs/guest: new CPUID/MSR interface | expand |
On 23.03.2021 10:58, Roger Pau Monne wrote: > Such helper is based on the existing functions to fetch a CPUID and > MSR policies, but uses the xc_cpu_policy_t type to return the data to > the caller. > > No user of the interface introduced on the patch. > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> with again a minor remark (plus of course the same that I made for patch 4): > --- a/tools/include/xenctrl.h > +++ b/tools/include/xenctrl.h > @@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy); > /* Retrieve a system policy, or get/set a domains policy. */ > 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); Generally I'd expect domid_t to be used for domain IDs. Jan
On Tue, Mar 30, 2021 at 05:37:02PM +0200, Jan Beulich wrote: > On 23.03.2021 10:58, Roger Pau Monne wrote: > > Such helper is based on the existing functions to fetch a CPUID and > > MSR policies, but uses the xc_cpu_policy_t type to return the data to > > the caller. > > > > No user of the interface introduced on the patch. > > > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > > Reviewed-by: Jan Beulich <jbeulich@suse.com> > with again a minor remark (plus of course the same that I made for > patch 4): > > > --- a/tools/include/xenctrl.h > > +++ b/tools/include/xenctrl.h > > @@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy); > > /* Retrieve a system policy, or get/set a domains policy. */ > > 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); > > Generally I'd expect domid_t to be used for domain IDs. Me too, but xenctrl.h seems to consistently use uint32_t for domain ids. I'm fine to use domid_t here, but I assumed there was a reason for using uint32_t uniformly there. Thanks, Roger.
On 31/03/2021 12:06, Roger Pau Monné wrote: > On Tue, Mar 30, 2021 at 05:37:02PM +0200, Jan Beulich wrote: >> On 23.03.2021 10:58, Roger Pau Monne wrote: >>> Such helper is based on the existing functions to fetch a CPUID and >>> MSR policies, but uses the xc_cpu_policy_t type to return the data to >>> the caller. >>> >>> No user of the interface introduced on the patch. >>> >>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> >> Reviewed-by: Jan Beulich <jbeulich@suse.com> >> with again a minor remark (plus of course the same that I made for >> patch 4): >> >>> --- a/tools/include/xenctrl.h >>> +++ b/tools/include/xenctrl.h >>> @@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy); >>> /* Retrieve a system policy, or get/set a domains policy. */ >>> 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); >> Generally I'd expect domid_t to be used for domain IDs. > Me too, but xenctrl.h seems to consistently use uint32_t for domain > ids. I'm fine to use domid_t here, but I assumed there was a reason > for using uint32_t uniformly there. There was a tools-wide change making everything uint32_t a while ago, but libxc itself has never used domid_t. IIRC, it was to do with problems concerning the INVALID_DOMID constant. ~Andrew
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index fc8e4b28781..8b8b30a2764 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy); /* Retrieve a system policy, or get/set a domains policy. */ 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_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c index 3710fb63839..75ac70996ac 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -777,3 +777,37 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int idx, free(msrs); return rc; } + +int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t policy) +{ + 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_get_domain_cpu_policy(xch, domid, &nr_leaves, leaves, &nr_msrs, + msrs); + if ( rc ) + { + PERROR("Failed to obtain domain %u policy", domid); + rc = -1; + goto out; + } + + rc = deserialize_policy(xch, policy, nr_leaves, leaves, nr_msrs, msrs); + if ( rc ) + errno = -rc; + + out: + free(leaves); + free(msrs); + return rc; +}
Such helper is based on the existing functions to fetch a CPUID and MSR policies, but uses the xc_cpu_policy_t type to return the data to the caller. No user of the interface introduced on the patch. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- tools/include/xenctrl.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)