From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH 05 of 10 v2] libxc: allow for explicitly specifying node-affinity Date: Fri, 21 Dec 2012 15:19:46 +0000 Message-ID: <50D47E12.3040803@eu.citrix.com> References: <61299b4cdc2abbdf9bfb.1355944041@Solace> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <61299b4cdc2abbdf9bfb.1355944041@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli Cc: Marcus Granado , Dan Magenheimer , Ian Campbell , Anil Madhavapeddy , Andrew Cooper , Juergen Gross , Ian Jackson , "xen-devel@lists.xen.org" , Jan Beulich , Daniel De Graaf , Matt Wilson List-Id: xen-devel@lists.xenproject.org On 19/12/12 19:07, Dario Faggioli wrote: > By providing the proper get/set interface and wiring them > to the new domctl-s from the previous commit. > > Signed-off-by: Dario Faggioli > Acked-by: Juergen Gross I haven't done a detailed review, but everything looks OK: Acked-by: George Dunlap > > diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c > --- a/tools/libxc/xc_domain.c > +++ b/tools/libxc/xc_domain.c > @@ -110,6 +110,83 @@ int xc_domain_shutdown(xc_interface *xch > } > > > +int xc_domain_node_setaffinity(xc_interface *xch, > + uint32_t domid, > + xc_nodemap_t nodemap) > +{ > + DECLARE_DOMCTL; > + DECLARE_HYPERCALL_BUFFER(uint8_t, local); > + int ret = -1; > + int nodesize; > + > + nodesize = xc_get_nodemap_size(xch); > + if (!nodesize) > + { > + PERROR("Could not get number of nodes"); > + goto out; > + } > + > + local = xc_hypercall_buffer_alloc(xch, local, nodesize); > + if ( local == NULL ) > + { > + PERROR("Could not allocate memory for setnodeaffinity domctl hypercall"); > + goto out; > + } > + > + domctl.cmd = XEN_DOMCTL_setnodeaffinity; > + domctl.domain = (domid_t)domid; > + > + memcpy(local, nodemap, nodesize); > + set_xen_guest_handle(domctl.u.nodeaffinity.nodemap.bitmap, local); > + domctl.u.nodeaffinity.nodemap.nr_elems = nodesize * 8; > + > + ret = do_domctl(xch, &domctl); > + > + xc_hypercall_buffer_free(xch, local); > + > + out: > + return ret; > +} > + > +int xc_domain_node_getaffinity(xc_interface *xch, > + uint32_t domid, > + xc_nodemap_t nodemap) > +{ > + DECLARE_DOMCTL; > + DECLARE_HYPERCALL_BUFFER(uint8_t, local); > + int ret = -1; > + int nodesize; > + > + nodesize = xc_get_nodemap_size(xch); > + if (!nodesize) > + { > + PERROR("Could not get number of nodes"); > + goto out; > + } > + > + local = xc_hypercall_buffer_alloc(xch, local, nodesize); > + if ( local == NULL ) > + { > + PERROR("Could not allocate memory for getnodeaffinity domctl hypercall"); > + goto out; > + } > + > + domctl.cmd = XEN_DOMCTL_getnodeaffinity; > + domctl.domain = (domid_t)domid; > + > + set_xen_guest_handle(domctl.u.nodeaffinity.nodemap.bitmap, local); > + domctl.u.nodeaffinity.nodemap.nr_elems = nodesize * 8; > + > + ret = do_domctl(xch, &domctl); > + > + memcpy(nodemap, local, nodesize); > + > + xc_hypercall_buffer_free(xch, local); > + > + out: > + return ret; > +} > + > int xc_vcpu_setaffinity(xc_interface *xch, > uint32_t domid, > int vcpu, > diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h > --- a/tools/libxc/xenctrl.h > +++ b/tools/libxc/xenctrl.h > @@ -521,6 +521,32 @@ int xc_watchdog(xc_interface *xch, > uint32_t id, > uint32_t timeout); > > +/** > + * This function explicitly sets the host NUMA nodes the domain will > + * have affinity with. > + * > + * @parm xch a handle to an open hypervisor interface. > + * @parm domid the domain id one wants to set the affinity of. > + * @parm nodemap the map of the affine nodes. > + * @return 0 on success, -1 on failure. > + */ > +int xc_domain_node_setaffinity(xc_interface *xch, > + uint32_t domind, > + xc_nodemap_t nodemap); > + > +/** > + * This function retrieves the host NUMA nodes the domain has > + * affinity with. > + * > + * @parm xch a handle to an open hypervisor interface. > + * @parm domid the domain id one wants to get the node affinity of. > + * @parm nodemap the map of the affine nodes. > + * @return 0 on success, -1 on failure. > + */ > +int xc_domain_node_getaffinity(xc_interface *xch, > + uint32_t domind, > + xc_nodemap_t nodemap); > + > int xc_vcpu_setaffinity(xc_interface *xch, > uint32_t domid, > int vcpu,