debuggers.hg

changeset 22294:5ec79c06b18a

libxc: wrappers for XENMEM {increase,decrease}_reservation and populate_physmap

Currently the wrappers for these hypercalls swallow partial success
and return failure to the caller.

In order to use these functions more widely instead of open-coding
uses of XENMEM_* and xc_memory_op add variants which return the actual
hypercall result.

Therefore add the following functions:
xc_domain_increase_reservation
xc_domain_decrease_reservation
xc_domain_populate_physmap
and implement the existing semantics using these new functions as
xc_domain_increase_reservation_exact
xc_domain_decrease_reservation_exact
xc_domain_populate_physmap_exact
replacing the existing xc_domain_memory_* functions.

Use these new functions to replace all open coded uses of
XENMEM_increase_reservation, XENMEM_decrease_reservation and
XENMEM_populate_physmap.

Also rename xc_domain_memory_*_pod_target to xc_domain_*_pod_target
for consistency.

Temporarily add a compatibility macro for
xc_domain_memory_populate_physmap to allow time for qemu to catch up.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Ian Campbell <ian.campbell@citrix.com>
date Mon Oct 18 16:54:42 2010 +0100 (2010-10-18)
parents 7bf2ba59c737
children 835b06768104
files tools/libxc/ia64/xc_ia64_hvm_build.c tools/libxc/ia64/xc_ia64_linux_restore.c tools/libxc/xc_dom_ia64.c tools/libxc/xc_dom_x86.c tools/libxc/xc_domain.c tools/libxc/xc_domain_restore.c tools/libxc/xc_hvm_build.c tools/libxc/xc_private.c tools/libxc/xenctrl.h tools/libxl/libxl.c tools/python/xen/lowlevel/xc/xc.c
line diff
     1.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Mon Oct 18 16:53:04 2010 +0100
     1.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Mon Oct 18 16:54:42 2010 +0100
     1.3 @@ -903,7 +903,7 @@ xc_ia64_setup_shared_info(xc_interface *
     1.4   * In this function, we will allocate memory and build P2M/M2P table for VTI
     1.5   * guest.  Frist, a pfn list will be initialized discontiguous, normal memory
     1.6   * begins with 0, GFW memory and other five pages at their place defined in
     1.7 - * xen/include/public/arch-ia64.h xc_domain_memory_populate_physmap() called
     1.8 + * xen/include/public/arch-ia64.h xc_domain_populate_physmap_exact() called
     1.9   * five times, to set parameter 'extent_order' to different value, this is
    1.10   * convenient to allocate discontiguous memory with different size.
    1.11   */
    1.12 @@ -966,7 +966,7 @@ setup_guest(xc_interface *xch, uint32_t 
    1.13           pfn++)
    1.14          pfn_list[i++] = pfn;
    1.15  
    1.16 -    rc = xc_domain_memory_populate_physmap(xch, dom, nr_pages, 0, 0,
    1.17 +    rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages, 0, 0,
    1.18                                             &pfn_list[0]);
    1.19      if (rc != 0) {
    1.20          PERROR("Could not allocate normal memory for Vti guest.");
    1.21 @@ -979,7 +979,7 @@ setup_guest(xc_interface *xch, uint32_t 
    1.22      for (i = 0; i < GFW_PAGES; i++) 
    1.23          pfn_list[i] = (GFW_START >> PAGE_SHIFT) + i;
    1.24  
    1.25 -    rc = xc_domain_memory_populate_physmap(xch, dom, GFW_PAGES,
    1.26 +    rc = xc_domain_populate_physmap_exact(xch, dom, GFW_PAGES,
    1.27                                             0, 0, &pfn_list[0]);
    1.28      if (rc != 0) {
    1.29          PERROR("Could not allocate GFW memory for Vti guest.");
    1.30 @@ -995,7 +995,7 @@ setup_guest(xc_interface *xch, uint32_t 
    1.31      pfn_list[nr_special_pages] = memmap_info_pfn;
    1.32      nr_special_pages++;
    1.33  
    1.34 -    rc = xc_domain_memory_populate_physmap(xch, dom, nr_special_pages,
    1.35 +    rc = xc_domain_populate_physmap_exact(xch, dom, nr_special_pages,
    1.36                                             0, 0, &pfn_list[0]);
    1.37      if (rc != 0) {
    1.38          PERROR("Could not allocate IO page or store page or buffer io page.");
     2.1 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c	Mon Oct 18 16:53:04 2010 +0100
     2.2 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c	Mon Oct 18 16:54:42 2010 +0100
     2.3 @@ -49,7 +49,7 @@ populate_page_if_necessary(xc_interface 
     2.4      if (xc_ia64_p2m_present(p2m_table, gmfn))
     2.5          return 0;
     2.6  
     2.7 -    return xc_domain_memory_populate_physmap(xch, dom, 1, 0, 0, &gmfn);
     2.8 +    return xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &gmfn);
     2.9  }
    2.10  
    2.11  static int
    2.12 @@ -112,7 +112,7 @@ xc_ia64_recv_unallocated_list(xc_interfa
    2.13          }
    2.14      }
    2.15      if (nr_frees > 0) {
    2.16 -        if (xc_domain_memory_decrease_reservation(xch, dom, nr_frees,
    2.17 +        if (xc_domain_decrease_reservation_exact(xch, dom, nr_frees,
    2.18                                                    0, pfntab) < 0) {
    2.19              PERROR("Could not decrease reservation");
    2.20              goto out;
    2.21 @@ -546,7 +546,7 @@ xc_ia64_hvm_domain_setup(xc_interface *x
    2.22      };
    2.23      unsigned long nr_pages = sizeof(pfn_list) / sizeof(pfn_list[0]);
    2.24  
    2.25 -    rc = xc_domain_memory_populate_physmap(xch, dom, nr_pages,
    2.26 +    rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages,
    2.27                                             0, 0, &pfn_list[0]);
    2.28      if (rc != 0)
    2.29          PERROR("Could not allocate IO page or buffer io page.");
     3.1 --- a/tools/libxc/xc_dom_ia64.c	Mon Oct 18 16:53:04 2010 +0100
     3.2 +++ b/tools/libxc/xc_dom_ia64.c	Mon Oct 18 16:54:42 2010 +0100
     3.3 @@ -186,7 +186,7 @@ int arch_setup_meminit(struct xc_dom_ima
     3.4          dom->p2m_host[pfn] = start + pfn;
     3.5  
     3.6      /* allocate guest memory */
     3.7 -    rc = xc_domain_memory_populate_physmap(dom->xch, dom->guest_domid,
     3.8 +    rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid,
     3.9                                             nbr, 0, 0,
    3.10                                             dom->p2m_host);
    3.11      return rc;
     4.1 --- a/tools/libxc/xc_dom_x86.c	Mon Oct 18 16:53:04 2010 +0100
     4.2 +++ b/tools/libxc/xc_dom_x86.c	Mon Oct 18 16:54:42 2010 +0100
     4.3 @@ -733,7 +733,7 @@ int arch_setup_meminit(struct xc_dom_ima
     4.4          DOMPRINTF("Populating memory with %d superpages", count);
     4.5          for ( pfn = 0; pfn < count; pfn++ )
     4.6              extents[pfn] = pfn << SUPERPAGE_PFN_SHIFT;
     4.7 -        rc = xc_domain_memory_populate_physmap(dom->xch, dom->guest_domid,
     4.8 +        rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid,
     4.9                                                 count, SUPERPAGE_PFN_SHIFT, 0,
    4.10                                                 extents);
    4.11          if ( rc )
    4.12 @@ -762,7 +762,7 @@ int arch_setup_meminit(struct xc_dom_ima
    4.13              allocsz = dom->total_pages - i;
    4.14              if ( allocsz > 1024*1024 )
    4.15                  allocsz = 1024*1024;
    4.16 -            rc = xc_domain_memory_populate_physmap(
    4.17 +            rc = xc_domain_populate_physmap_exact(
    4.18                  dom->xch, dom->guest_domid, allocsz,
    4.19                  0, 0, &dom->p2m_host[i]);
    4.20          }
     5.1 --- a/tools/libxc/xc_domain.c	Mon Oct 18 16:53:04 2010 +0100
     5.2 +++ b/tools/libxc/xc_domain.c	Mon Oct 18 16:54:42 2010 +0100
     5.3 @@ -579,12 +579,12 @@ int xc_domain_get_tsc_info(xc_interface 
     5.4  }
     5.5  
     5.6  
     5.7 -int xc_domain_memory_increase_reservation(xc_interface *xch,
     5.8 -                                          uint32_t domid,
     5.9 -                                          unsigned long nr_extents,
    5.10 -                                          unsigned int extent_order,
    5.11 -                                          unsigned int mem_flags,
    5.12 -                                          xen_pfn_t *extent_start)
    5.13 +int xc_domain_increase_reservation(xc_interface *xch,
    5.14 +                                   uint32_t domid,
    5.15 +                                   unsigned long nr_extents,
    5.16 +                                   unsigned int extent_order,
    5.17 +                                   unsigned int mem_flags,
    5.18 +                                   xen_pfn_t *extent_start)
    5.19  {
    5.20      int err;
    5.21      struct xen_memory_reservation reservation = {
    5.22 @@ -598,6 +598,22 @@ int xc_domain_memory_increase_reservatio
    5.23      set_xen_guest_handle(reservation.extent_start, extent_start);
    5.24  
    5.25      err = xc_memory_op(xch, XENMEM_increase_reservation, &reservation);
    5.26 +
    5.27 +    return err;
    5.28 +}
    5.29 +
    5.30 +int xc_domain_increase_reservation_exact(xc_interface *xch,
    5.31 +                                         uint32_t domid,
    5.32 +                                         unsigned long nr_extents,
    5.33 +                                         unsigned int extent_order,
    5.34 +                                         unsigned int mem_flags,
    5.35 +                                         xen_pfn_t *extent_start)
    5.36 +{
    5.37 +    int err;
    5.38 +
    5.39 +    err = xc_domain_increase_reservation(xch, domid, nr_extents,
    5.40 +                                         extent_order, mem_flags, extent_start);
    5.41 +
    5.42      if ( err == nr_extents )
    5.43          return 0;
    5.44  
    5.45 @@ -613,11 +629,11 @@ int xc_domain_memory_increase_reservatio
    5.46      return err;
    5.47  }
    5.48  
    5.49 -int xc_domain_memory_decrease_reservation(xc_interface *xch,
    5.50 -                                          uint32_t domid,
    5.51 -                                          unsigned long nr_extents,
    5.52 -                                          unsigned int extent_order,
    5.53 -                                          xen_pfn_t *extent_start)
    5.54 +int xc_domain_decrease_reservation(xc_interface *xch,
    5.55 +                                   uint32_t domid,
    5.56 +                                   unsigned long nr_extents,
    5.57 +                                   unsigned int extent_order,
    5.58 +                                   xen_pfn_t *extent_start)
    5.59  {
    5.60      int err;
    5.61      struct xen_memory_reservation reservation = {
    5.62 @@ -637,6 +653,21 @@ int xc_domain_memory_decrease_reservatio
    5.63      }
    5.64  
    5.65      err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
    5.66 +
    5.67 +    return err;
    5.68 +}
    5.69 +
    5.70 +int xc_domain_decrease_reservation_exact(xc_interface *xch,
    5.71 +                                         uint32_t domid,
    5.72 +                                         unsigned long nr_extents,
    5.73 +                                         unsigned int extent_order,
    5.74 +                                         xen_pfn_t *extent_start)
    5.75 +{
    5.76 +    int err;
    5.77 +
    5.78 +    err = xc_domain_decrease_reservation(xch, domid, nr_extents,
    5.79 +                                         extent_order, extent_start);
    5.80 +
    5.81      if ( err == nr_extents )
    5.82          return 0;
    5.83  
    5.84 @@ -651,12 +682,12 @@ int xc_domain_memory_decrease_reservatio
    5.85      return err;
    5.86  }
    5.87  
    5.88 -int xc_domain_memory_populate_physmap(xc_interface *xch,
    5.89 -                                      uint32_t domid,
    5.90 -                                      unsigned long nr_extents,
    5.91 -                                      unsigned int extent_order,
    5.92 -                                      unsigned int mem_flags,
    5.93 -                                      xen_pfn_t *extent_start)
    5.94 +int xc_domain_populate_physmap(xc_interface *xch,
    5.95 +                               uint32_t domid,
    5.96 +                               unsigned long nr_extents,
    5.97 +                               unsigned int extent_order,
    5.98 +                               unsigned int mem_flags,
    5.99 +                               xen_pfn_t *extent_start)
   5.100  {
   5.101      int err;
   5.102      struct xen_memory_reservation reservation = {
   5.103 @@ -668,6 +699,21 @@ int xc_domain_memory_populate_physmap(xc
   5.104      set_xen_guest_handle(reservation.extent_start, extent_start);
   5.105  
   5.106      err = xc_memory_op(xch, XENMEM_populate_physmap, &reservation);
   5.107 +
   5.108 +    return err;
   5.109 +}
   5.110 +
   5.111 +int xc_domain_populate_physmap_exact(xc_interface *xch,
   5.112 +                                     uint32_t domid,
   5.113 +                                     unsigned long nr_extents,
   5.114 +                                     unsigned int extent_order,
   5.115 +                                     unsigned int mem_flags,
   5.116 +                                     xen_pfn_t *extent_start)
   5.117 +{
   5.118 +    int err;
   5.119 +
   5.120 +    err = xc_domain_populate_physmap(xch, domid, nr_extents,
   5.121 +                                     extent_order, mem_flags, extent_start);
   5.122      if ( err == nr_extents )
   5.123          return 0;
   5.124  
   5.125 @@ -682,13 +728,13 @@ int xc_domain_memory_populate_physmap(xc
   5.126      return err;
   5.127  }
   5.128  
   5.129 -static int xc_domain_memory_pod_target(xc_interface *xch,
   5.130 -                                       int op,
   5.131 -                                       uint32_t domid,
   5.132 -                                       uint64_t target_pages,
   5.133 -                                       uint64_t *tot_pages,
   5.134 -                                       uint64_t *pod_cache_pages,
   5.135 -                                       uint64_t *pod_entries)
   5.136 +static int xc_domain_pod_target(xc_interface *xch,
   5.137 +                                int op,
   5.138 +                                uint32_t domid,
   5.139 +                                uint64_t target_pages,
   5.140 +                                uint64_t *tot_pages,
   5.141 +                                uint64_t *pod_cache_pages,
   5.142 +                                uint64_t *pod_entries)
   5.143  {
   5.144      int err;
   5.145  
   5.146 @@ -701,7 +747,7 @@ static int xc_domain_memory_pod_target(x
   5.147  
   5.148      if ( err < 0 )
   5.149      {
   5.150 -        DPRINTF("Failed %s_memory_target dom %d\n",
   5.151 +        DPRINTF("Failed %s_pod_target dom %d\n",
   5.152                  (op==XENMEM_set_pod_target)?"set":"get",
   5.153                  domid);
   5.154          errno = -err;
   5.155 @@ -719,37 +765,37 @@ static int xc_domain_memory_pod_target(x
   5.156  
   5.157      return err;
   5.158  }
   5.159 -                                       
   5.160 +
   5.161  
   5.162 -int xc_domain_memory_set_pod_target(xc_interface *xch,
   5.163 -                                    uint32_t domid,
   5.164 -                                    uint64_t target_pages,
   5.165 -                                    uint64_t *tot_pages,
   5.166 -                                    uint64_t *pod_cache_pages,
   5.167 -                                    uint64_t *pod_entries)
   5.168 +int xc_domain_set_pod_target(xc_interface *xch,
   5.169 +                             uint32_t domid,
   5.170 +                             uint64_t target_pages,
   5.171 +                             uint64_t *tot_pages,
   5.172 +                             uint64_t *pod_cache_pages,
   5.173 +                             uint64_t *pod_entries)
   5.174  {
   5.175 -    return xc_domain_memory_pod_target(xch,
   5.176 -                                       XENMEM_set_pod_target,
   5.177 -                                       domid,
   5.178 -                                       target_pages,
   5.179 -                                       tot_pages,
   5.180 -                                       pod_cache_pages,
   5.181 -                                       pod_entries);
   5.182 +    return xc_domain_pod_target(xch,
   5.183 +                                XENMEM_set_pod_target,
   5.184 +                                domid,
   5.185 +                                target_pages,
   5.186 +                                tot_pages,
   5.187 +                                pod_cache_pages,
   5.188 +                                pod_entries);
   5.189  }
   5.190  
   5.191 -int xc_domain_memory_get_pod_target(xc_interface *xch,
   5.192 -                                    uint32_t domid,
   5.193 -                                    uint64_t *tot_pages,
   5.194 -                                    uint64_t *pod_cache_pages,
   5.195 -                                    uint64_t *pod_entries)
   5.196 +int xc_domain_get_pod_target(xc_interface *xch,
   5.197 +                             uint32_t domid,
   5.198 +                             uint64_t *tot_pages,
   5.199 +                             uint64_t *pod_cache_pages,
   5.200 +                             uint64_t *pod_entries)
   5.201  {
   5.202 -    return xc_domain_memory_pod_target(xch,
   5.203 -                                       XENMEM_get_pod_target,
   5.204 -                                       domid,
   5.205 -                                       -1,
   5.206 -                                       tot_pages,
   5.207 -                                       pod_cache_pages,
   5.208 -                                       pod_entries);
   5.209 +    return xc_domain_pod_target(xch,
   5.210 +                                XENMEM_get_pod_target,
   5.211 +                                domid,
   5.212 +                                -1,
   5.213 +                                tot_pages,
   5.214 +                                pod_cache_pages,
   5.215 +                                pod_entries);
   5.216  }
   5.217  
   5.218  int xc_domain_max_vcpus(xc_interface *xch, uint32_t domid, unsigned int max)
     6.1 --- a/tools/libxc/xc_domain_restore.c	Mon Oct 18 16:53:04 2010 +0100
     6.2 +++ b/tools/libxc/xc_domain_restore.c	Mon Oct 18 16:54:42 2010 +0100
     6.3 @@ -147,7 +147,7 @@ static int uncanonicalize_pagetable(
     6.4  
     6.5      /* Allocate the requisite number of mfns. */
     6.6      if ( nr_mfns &&
     6.7 -         (xc_domain_memory_populate_physmap(xch, dom, nr_mfns, 0, 0,
     6.8 +         (xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0, 0,
     6.9                                              ctx->p2m_batch) != 0) )
    6.10      { 
    6.11          ERROR("Failed to allocate memory for batch.!\n"); 
    6.12 @@ -888,7 +888,7 @@ static int apply_batch(xc_interface *xch
    6.13  
    6.14      /* Now allocate a bunch of mfns for this batch */
    6.15      if ( nr_mfns &&
    6.16 -         (xc_domain_memory_populate_physmap(xch, dom, nr_mfns, 0,
    6.17 +         (xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0,
    6.18                                              0, ctx->p2m_batch) != 0) )
    6.19      { 
    6.20          ERROR("Failed to allocate memory for batch.!\n"); 
    6.21 @@ -1529,15 +1529,7 @@ int xc_domain_restore(xc_interface *xch,
    6.22  
    6.23          if ( nr_frees > 0 )
    6.24          {
    6.25 -            struct xen_memory_reservation reservation = {
    6.26 -                .nr_extents   = nr_frees,
    6.27 -                .extent_order = 0,
    6.28 -                .domid        = dom
    6.29 -            };
    6.30 -            set_xen_guest_handle(reservation.extent_start, tailbuf.u.pv.pfntab);
    6.31 -
    6.32 -            if ( (frc = xc_memory_op(xch, XENMEM_decrease_reservation,
    6.33 -                                     &reservation)) != nr_frees )
    6.34 +            if ( (frc = xc_domain_decrease_reservation(xch, dom, nr_frees, 0, tailbuf.u.pv.pfntab)) != nr_frees )
    6.35              {
    6.36                  PERROR("Could not decrease reservation : %d", frc);
    6.37                  goto out;
     7.1 --- a/tools/libxc/xc_hvm_build.c	Mon Oct 18 16:53:04 2010 +0100
     7.2 +++ b/tools/libxc/xc_hvm_build.c	Mon Oct 18 16:54:42 2010 +0100
     7.3 @@ -203,7 +203,7 @@ static int setup_guest(xc_interface *xch
     7.4       * Under 2MB mode, we allocate pages in batches of no more than 8MB to 
     7.5       * ensure that we can be preempted and hence dom0 remains responsive.
     7.6       */
     7.7 -    rc = xc_domain_memory_populate_physmap(
     7.8 +    rc = xc_domain_populate_physmap_exact(
     7.9          xch, dom, 0xa0, 0, 0, &page_array[0x00]);
    7.10      cur_pages = 0xc0;
    7.11      stat_normal_pages = 0xc0;
    7.12 @@ -233,20 +233,16 @@ static int setup_guest(xc_interface *xch
    7.13                                SUPERPAGE_1GB_NR_PFNS << PAGE_SHIFT) )
    7.14          {
    7.15              long done;
    7.16 -            xen_pfn_t sp_extents[count >> SUPERPAGE_1GB_SHIFT];
    7.17 -            struct xen_memory_reservation sp_req = {
    7.18 -                .nr_extents   = count >> SUPERPAGE_1GB_SHIFT,
    7.19 -                .extent_order = SUPERPAGE_1GB_SHIFT,
    7.20 -                .domid        = dom
    7.21 -            };
    7.22 +            unsigned long nr_extents = count >> SUPERPAGE_1GB_SHIFT;
    7.23 +            xen_pfn_t sp_extents[nr_extents];
    7.24  
    7.25 -            if ( pod_mode )
    7.26 -                sp_req.mem_flags = XENMEMF_populate_on_demand;
    7.27 +            for ( i = 0; i < nr_extents; i++ )
    7.28 +                sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_1GB_SHIFT)];
    7.29  
    7.30 -            set_xen_guest_handle(sp_req.extent_start, sp_extents);
    7.31 -            for ( i = 0; i < sp_req.nr_extents; i++ )
    7.32 -                sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_1GB_SHIFT)];
    7.33 -            done = xc_memory_op(xch, XENMEM_populate_physmap, &sp_req);
    7.34 +            done = xc_domain_populate_physmap(xch, dom, nr_extents, SUPERPAGE_1GB_SHIFT,
    7.35 +                                              pod_mode ? XENMEMF_populate_on_demand : 0,
    7.36 +                                              sp_extents);
    7.37 +
    7.38              if ( done > 0 )
    7.39              {
    7.40                  stat_1gb_pages += done;
    7.41 @@ -275,20 +271,16 @@ static int setup_guest(xc_interface *xch
    7.42              if ( ((count | cur_pages) & (SUPERPAGE_2MB_NR_PFNS - 1)) == 0 )
    7.43              {
    7.44                  long done;
    7.45 -                xen_pfn_t sp_extents[count >> SUPERPAGE_2MB_SHIFT];
    7.46 -                struct xen_memory_reservation sp_req = {
    7.47 -                    .nr_extents   = count >> SUPERPAGE_2MB_SHIFT,
    7.48 -                    .extent_order = SUPERPAGE_2MB_SHIFT,
    7.49 -                    .domid        = dom
    7.50 -                };
    7.51 +                unsigned long nr_extents = count >> SUPERPAGE_2MB_SHIFT;
    7.52 +                xen_pfn_t sp_extents[nr_extents];
    7.53  
    7.54 -                if ( pod_mode )
    7.55 -                    sp_req.mem_flags = XENMEMF_populate_on_demand;
    7.56 +                for ( i = 0; i < nr_extents; i++ )
    7.57 +                    sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_2MB_SHIFT)];
    7.58  
    7.59 -                set_xen_guest_handle(sp_req.extent_start, sp_extents);
    7.60 -                for ( i = 0; i < sp_req.nr_extents; i++ )
    7.61 -                    sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_2MB_SHIFT)];
    7.62 -                done = xc_memory_op(xch, XENMEM_populate_physmap, &sp_req);
    7.63 +                done = xc_domain_populate_physmap(xch, dom, nr_extents, SUPERPAGE_2MB_SHIFT,
    7.64 +                                                  pod_mode ? XENMEMF_populate_on_demand : 0,
    7.65 +                                                  sp_extents);
    7.66 +
    7.67                  if ( done > 0 )
    7.68                  {
    7.69                      stat_2mb_pages += done;
    7.70 @@ -302,7 +294,7 @@ static int setup_guest(xc_interface *xch
    7.71          /* Fall back to 4kB extents. */
    7.72          if ( count != 0 )
    7.73          {
    7.74 -            rc = xc_domain_memory_populate_physmap(
    7.75 +            rc = xc_domain_populate_physmap_exact(
    7.76                  xch, dom, count, 0, 0, &page_array[cur_pages]);
    7.77              cur_pages += count;
    7.78              stat_normal_pages += count;
    7.79 @@ -313,10 +305,8 @@ static int setup_guest(xc_interface *xch
    7.80       * adjust the PoD cache size so that domain tot_pages will be
    7.81       * target_pages - 0x20 after this call. */
    7.82      if ( pod_mode )
    7.83 -        rc = xc_domain_memory_set_pod_target(xch,
    7.84 -                                             dom,
    7.85 -                                             target_pages - 0x20,
    7.86 -                                             NULL, NULL, NULL);
    7.87 +        rc = xc_domain_set_pod_target(xch, dom, target_pages - 0x20,
    7.88 +                                      NULL, NULL, NULL);
    7.89  
    7.90      if ( rc != 0 )
    7.91      {
    7.92 @@ -344,7 +334,7 @@ static int setup_guest(xc_interface *xch
    7.93      for ( i = 0; i < NR_SPECIAL_PAGES; i++ )
    7.94      {
    7.95          xen_pfn_t pfn = special_pfn(i);
    7.96 -        rc = xc_domain_memory_populate_physmap(xch, dom, 1, 0, 0, &pfn);
    7.97 +        rc = xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &pfn);
    7.98          if ( rc != 0 )
    7.99          {
   7.100              PERROR("Could not allocate %d'th special page.", i);
     8.1 --- a/tools/libxc/xc_private.c	Mon Oct 18 16:53:04 2010 +0100
     8.2 +++ b/tools/libxc/xc_private.c	Mon Oct 18 16:54:42 2010 +0100
     8.3 @@ -675,14 +675,14 @@ unsigned long xc_make_page_below_4G(
     8.4      xen_pfn_t old_mfn = mfn;
     8.5      xen_pfn_t new_mfn;
     8.6  
     8.7 -    if ( xc_domain_memory_decrease_reservation(
     8.8 +    if ( xc_domain_decrease_reservation_exact(
     8.9          xch, domid, 1, 0, &old_mfn) != 0 )
    8.10      {
    8.11          DPRINTF("xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
    8.12          return 0;
    8.13      }
    8.14  
    8.15 -    if ( xc_domain_memory_increase_reservation(
    8.16 +    if ( xc_domain_increase_reservation_exact(
    8.17          xch, domid, 1, 0, XENMEMF_address_bits(32), &new_mfn) != 0 )
    8.18      {
    8.19          DPRINTF("xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
     9.1 --- a/tools/libxc/xenctrl.h	Mon Oct 18 16:53:04 2010 +0100
     9.2 +++ b/tools/libxc/xenctrl.h	Mon Oct 18 16:54:42 2010 +0100
     9.3 @@ -785,38 +785,62 @@ int xc_domain_get_tsc_info(xc_interface 
     9.4  
     9.5  int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
     9.6  
     9.7 -int xc_domain_memory_increase_reservation(xc_interface *xch,
     9.8 -                                          uint32_t domid,
     9.9 -                                          unsigned long nr_extents,
    9.10 -                                          unsigned int extent_order,
    9.11 -                                          unsigned int mem_flags,
    9.12 -                                          xen_pfn_t *extent_start);
    9.13 +int xc_domain_increase_reservation(xc_interface *xch,
    9.14 +                                   uint32_t domid,
    9.15 +                                   unsigned long nr_extents,
    9.16 +                                   unsigned int extent_order,
    9.17 +                                   unsigned int mem_flags,
    9.18 +                                   xen_pfn_t *extent_start);
    9.19  
    9.20 -int xc_domain_memory_decrease_reservation(xc_interface *xch,
    9.21 -                                          uint32_t domid,
    9.22 -                                          unsigned long nr_extents,
    9.23 -                                          unsigned int extent_order,
    9.24 -                                          xen_pfn_t *extent_start);
    9.25 +int xc_domain_increase_reservation_exact(xc_interface *xch,
    9.26 +                                         uint32_t domid,
    9.27 +                                         unsigned long nr_extents,
    9.28 +                                         unsigned int extent_order,
    9.29 +                                         unsigned int mem_flags,
    9.30 +                                         xen_pfn_t *extent_start);
    9.31 +
    9.32 +int xc_domain_decrease_reservation(xc_interface *xch,
    9.33 +                                   uint32_t domid,
    9.34 +                                   unsigned long nr_extents,
    9.35 +                                   unsigned int extent_order,
    9.36 +                                   xen_pfn_t *extent_start);
    9.37 +
    9.38 +int xc_domain_decrease_reservation_exact(xc_interface *xch,
    9.39 +                                         uint32_t domid,
    9.40 +                                         unsigned long nr_extents,
    9.41 +                                         unsigned int extent_order,
    9.42 +                                         xen_pfn_t *extent_start);
    9.43  
    9.44 -int xc_domain_memory_populate_physmap(xc_interface *xch,
    9.45 -                                      uint32_t domid,
    9.46 -                                      unsigned long nr_extents,
    9.47 -                                      unsigned int extent_order,
    9.48 -                                      unsigned int mem_flags,
    9.49 -                                      xen_pfn_t *extent_start);
    9.50 +int xc_domain_populate_physmap(xc_interface *xch,
    9.51 +                               uint32_t domid,
    9.52 +                               unsigned long nr_extents,
    9.53 +                               unsigned int extent_order,
    9.54 +                               unsigned int mem_flags,
    9.55 +                               xen_pfn_t *extent_start);
    9.56 +
    9.57 +int xc_domain_populate_physmap_exact(xc_interface *xch,
    9.58 +                                     uint32_t domid,
    9.59 +                                     unsigned long nr_extents,
    9.60 +                                     unsigned int extent_order,
    9.61 +                                     unsigned int mem_flags,
    9.62 +                                     xen_pfn_t *extent_start);
    9.63  
    9.64 -int xc_domain_memory_set_pod_target(xc_interface *xch,
    9.65 -                                    uint32_t domid,
    9.66 -                                    uint64_t target_pages,
    9.67 -                                    uint64_t *tot_pages,
    9.68 -                                    uint64_t *pod_cache_pages,
    9.69 -                                    uint64_t *pod_entries);
    9.70 +/* Temporary for compatibility */
    9.71 +#define xc_domain_memory_populate_physmap(x, d, nr, eo, mf, es) \
    9.72 +    xc_domain_populate_physmap_exact(x, d, nr, eo, mf, es)
    9.73  
    9.74 -int xc_domain_memory_get_pod_target(xc_interface *xch,
    9.75 -                                    uint32_t domid,
    9.76 -                                    uint64_t *tot_pages,
    9.77 -                                    uint64_t *pod_cache_pages,
    9.78 -                                    uint64_t *pod_entries);
    9.79 +int xc_domain_set_pod_target(xc_interface *xch,
    9.80 +                             uint32_t domid,
    9.81 +                             uint64_t target_pages,
    9.82 +                             uint64_t *tot_pages,
    9.83 +                             uint64_t *pod_cache_pages,
    9.84 +                             uint64_t *pod_entries);
    9.85 +
    9.86 +int xc_domain_get_pod_target(xc_interface *xch,
    9.87 +                             uint32_t domid,
    9.88 +                             uint64_t *tot_pages,
    9.89 +                             uint64_t *pod_cache_pages,
    9.90 +                             uint64_t *pod_entries);
    9.91  
    9.92  int xc_domain_ioport_permission(xc_interface *xch,
    9.93                                  uint32_t domid,
    10.1 --- a/tools/libxl/libxl.c	Mon Oct 18 16:53:04 2010 +0100
    10.2 +++ b/tools/libxl/libxl.c	Mon Oct 18 16:54:42 2010 +0100
    10.3 @@ -2948,11 +2948,11 @@ retry_transaction:
    10.4      }
    10.5  
    10.6      new_target_memkb -= videoram;
    10.7 -    rc = xc_domain_memory_set_pod_target(ctx->xch, domid,
    10.8 +    rc = xc_domain_set_pod_target(ctx->xch, domid,
    10.9              new_target_memkb / 4, NULL, NULL, NULL);
   10.10      if (rc != 0) {
   10.11          LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
   10.12 -                "xc_domain_memory_set_pod_target domid=%d, memkb=%d "
   10.13 +                "xc_domain_set_pod_target domid=%d, memkb=%d "
   10.14                  "failed rc=%d\n", domid, new_target_memkb / 4,
   10.15                  rc);
   10.16          abort = 1;
    11.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Oct 18 16:53:04 2010 +0100
    11.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Oct 18 16:54:42 2010 +0100
    11.3 @@ -1635,8 +1635,8 @@ static PyObject *pyxc_domain_set_target_
    11.4  
    11.5      mem_pages = mem_kb / 4; 
    11.6  
    11.7 -    if (xc_domain_memory_set_pod_target(self->xc_handle, dom, mem_pages,
    11.8 -                                        NULL, NULL, NULL) != 0)
    11.9 +    if (xc_domain_set_pod_target(self->xc_handle, dom, mem_pages,
   11.10 +				 NULL, NULL, NULL) != 0)
   11.11          return pyxc_error_to_exception(self->xc_handle);
   11.12      
   11.13      Py_INCREF(zero);