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

[Xen-changelog] [xen master] libxc: check in xc_get_tot_pages() that the proper domain is reported



commit 5dcd0dcb85941bd92336e01ae3f8c44730099c96
Author:     Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
AuthorDate: Tue Dec 2 16:18:08 2014 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Thu Dec 4 12:08:19 2014 +0000

    libxc: check in xc_get_tot_pages() that the proper domain is reported
    
    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@xxxxxxxxxx>
    Reviewed-by: Don Slutz <dslutz@xxxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxc/xc_private.c |    6 ++++--
 1 files 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,
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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