[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 13/13] x86/domctl: Implement XEN_DOMCTL_get_cpu_policy



On Fri, Jul 13, 2018 at 09:03:14PM +0100, Andrew Cooper wrote:
> +int xc_get_domain_cpu_policy(xc_interface *xch, uint32_t domid,
> +                             uint32_t *nr_leaves, xen_cpuid_leaf_t *leaves,
> +                             uint32_t *nr_msrs, xen_msr_entry_t *msrs)
> +{
> +    DECLARE_DOMCTL;
> +    DECLARE_HYPERCALL_BOUNCE(leaves,
> +                             *nr_leaves * sizeof(*leaves),
> +                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);
> +    DECLARE_HYPERCALL_BOUNCE(msrs,
> +                             *nr_msrs * sizeof(*msrs),
> +                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);
> +    int ret;
> +
> +    if ( xc_hypercall_bounce_pre(xch, leaves) )
> +        return -1;
> +
> +    if ( xc_hypercall_bounce_pre(xch, msrs) )
> +        return -1;

The ifs can be joined into a single one.

> +    domctl.cmd = XEN_DOMCTL_get_cpu_policy;
> +    domctl.domain = domid;
> +    domctl.u.cpu_policy.nr_leaves = *nr_leaves;
> +    set_xen_guest_handle(domctl.u.cpu_policy.cpuid_policy, leaves);
> +    domctl.u.cpu_policy.nr_msrs = *nr_msrs;
> +    set_xen_guest_handle(domctl.u.cpu_policy.msr_policy, msrs);

The fields can be set at declaration time, leaving just the _handle
calls here.

> +    ret = do_domctl(xch, &domctl);
> +
> +    xc_hypercall_bounce_post(xch, leaves);
> +    xc_hypercall_bounce_post(xch, msrs);
> +
> +    if ( !ret )
> +    {
> +        *nr_leaves = domctl.u.cpu_policy.nr_leaves;
> +        *nr_msrs = domctl.u.cpu_policy.nr_msrs;
> +    }
> +
> +    return ret;
> +}
> +
>  struct cpuid_domain_info
>  {
>      enum
> diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
> index 1c14d93..dd39268 100644
> --- a/tools/misc/xen-cpuid.c
> +++ b/tools/misc/xen-cpuid.c
> @@ -3,6 +3,8 @@
>  #include <err.h>
>  #include <getopt.h>
>  #include <string.h>
> +#include <errno.h>
> +#include <limits.h>
>  
>  #include <xenctrl.h>
>  
> @@ -309,11 +311,13 @@ int main(int argc, char **argv)
>  {
>      enum { MODE_UNKNOWN, MODE_INFO, MODE_DETAIL, MODE_INTERPRET, MODE_POLICY 
> }
>      mode = MODE_UNKNOWN;
> +    int domid = -1;

Using domid_t and DOMID_INVALID would be better IMO.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.