]> xenbits.xensource.com Git - people/pauldu/xen.git/commitdiff
libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 30 Mar 2015 14:46:38 +0000 (10:46 -0400)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 30 Mar 2015 15:07:30 +0000 (16:07 +0100)
The commit a8f8a590e02d2d2b717257c0bd9a8b396103bdf4
"libxc: Check xc_domain_maximum_gpfn for negative return values"
introduced an regression in tools outside libxc (migrate v2)
which wanted the unfiltered GPFN value. Said commit added
a wrapper which added +1 if there were no errors.

To make it work pre-commit a8f8a59 we add an xc_domain_nr_gpfns
which will add +1 if there are no errors (and change all in-tree
callers to use it). The xc_domain_maximum_gpfn will return the
unfiltered GPFN value.

Suggested-by: Ian Campbell <ian.campbell@citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxc/include/xenctrl.h
tools/libxc/xc_core_arm.c
tools/libxc/xc_core_x86.c
tools/libxc/xc_domain.c
tools/libxc/xc_domain_save.c

index 4e9537eb48cccd4273542baf2a484313c4719efa..552ace8f19e0ae15e9d776901c377c12f6f6bd40 100644 (file)
@@ -1317,6 +1317,8 @@ int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
 
 int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
 
+int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
+
 int xc_domain_increase_reservation(xc_interface *xch,
                                    uint32_t domid,
                                    unsigned long nr_extents,
index c3f5868044d2160bb91eceb8e69698839f3669a1..57d4715636e0df2a41e1357d81cde71b109557a3 100644 (file)
@@ -45,7 +45,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
     xen_pfn_t p2m_size = 0;
     xc_core_memory_map_t *map;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
         return -1;
 
     map = malloc(sizeof(*map));
index 4552e432b3954d63dedb8539b7c9e54ece143a8e..93ebcbbc4df971860ae1dd7f24a5a2cc3545cb0e 100644 (file)
@@ -50,7 +50,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
     xen_pfn_t p2m_size = 0;
     xc_core_memory_map_t *map;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
         return -1;
 
     map = malloc(sizeof(*map));
@@ -85,7 +85,7 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc
     int err;
     int i;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &dinfo->p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 )
     {
         ERROR("Could not get maximum GPFN!");
         goto out;
@@ -212,7 +212,7 @@ int
 xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
                               xen_pfn_t *gpfn)
 {
-    return xc_domain_maximum_gpfn(xch, domid, gpfn);
+    return xc_domain_nr_gpfns(xch, domid, gpfn);
 }
 
 /*
index da88e08fd277695c5a2454c4c461f5e88594ec06..dc62eff35ed5aa5340a272df37cc21cb1b8204b1 100644 (file)
@@ -795,12 +795,22 @@ int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
 
     if ( rc >= 0 )
     {
-        *gpfns = rc + 1;
+        *gpfns = rc;
         rc = 0;
     }
     return rc;
 }
 
+int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
+{
+    int rc = xc_domain_maximum_gpfn(xch, domid, gpfns);
+
+    if ( rc >= 0 )
+        *gpfns += 1;
+
+    return rc;
+}
+
 int xc_domain_increase_reservation(xc_interface *xch,
                                    uint32_t domid,
                                    unsigned long nr_extents,
index b611c07524b7396f321ab2b8e53149b451497457..cef6995cce325c0740c2bfae5de28dc9c7f04991 100644 (file)
@@ -939,7 +939,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
     }
 
     /* Get the size of the P2M table */
-    if ( xc_domain_maximum_gpfn(xch, dom, &dinfo->p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, dom, &dinfo->p2m_size) < 0 )
     {
         ERROR("Could not get maximum GPFN!");
         goto out;