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 <vkuznets@redhat.com>
Reviewed-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
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,