From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] libxc: check in xc_get_tot_pages() that the proper domain is reported Date: Tue, 2 Dec 2014 13:43:26 -0500 Message-ID: <20141202184326.GJ32385@laptop.dumpdata.com> References: <1417533488-15787-1-git-send-email-vkuznets@redhat.com> <20141202160444.GI5768@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20141202160444.GI5768@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: Andrew Jones , Ian Campbell , Stefano Stabellini , Ian Jackson , xen-devel@lists.xen.org, Vitaly Kuznetsov List-Id: xen-devel@lists.xenproject.org On Tue, Dec 02, 2014 at 04:04:44PM +0000, Wei Liu wrote: > On Tue, Dec 02, 2014 at 04:18:08PM +0100, Vitaly Kuznetsov wrote: > > XEN_DOMCTL_getdomaininfo, which is being used by xc_domain_getinfo(), has > > strange interface: it reports first domain which has domid >= requested domid > > so all callers are supposed to check that the proper domain(s) was queried > > by checking domid. xc_get_tot_pages() doesn't do that. In case the requested > > domain was destroyed it will report first domain with domid > requested domid > > which is apparently misleading as there is no way xc_get_tot_pages() callers > > can figure out that they got tot_pages for some other domain. > > > > Signed-off-by: Vitaly Kuznetsov > > Acked-by: Wei Liu Lets add another Ack to this party.. Release-Acked-by: Konrad Rzeszutek Wilk > > > --- > > tools/libxc/xc_private.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c > > index 1c214dd..e2441ad 100644 > > --- a/tools/libxc/xc_private.c > > +++ b/tools/libxc/xc_private.c > > @@ -613,8 +613,10 @@ int xc_get_pfn_list(xc_interface *xch, > > long xc_get_tot_pages(xc_interface *xch, uint32_t domid) > > { > > xc_dominfo_t info; > > - return (xc_domain_getinfo(xch, domid, 1, &info) != 1) ? > > - -1 : info.nr_pages; > > + if ( (xc_domain_getinfo(xch, domid, 1, &info) != 1) || > > + (info.domid != domid) ) > > + return -1; > > + return info.nr_pages; > > } > > > > int xc_copy_to_domain_page(xc_interface *xch, > > -- > > 1.9.3 > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel