debuggers.hg

changeset 22295:835b06768104

libxc: add xc_domain_memory_exchange_pages to wrap XENMEM_exchange

Generalised from exchange_page in xc_offline_page.c

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 17:14:07 2010 +0100 (2010-10-18)
parents 5ec79c06b18a
children 90a64629f7c0
files tools/libxc/xc_domain.c tools/libxc/xc_offline_page.c tools/libxc/xenctrl.h
line diff
     1.1 --- a/tools/libxc/xc_domain.c	Mon Oct 18 16:54:42 2010 +0100
     1.2 +++ b/tools/libxc/xc_domain.c	Mon Oct 18 17:14:07 2010 +0100
     1.3 @@ -728,6 +728,37 @@ int xc_domain_populate_physmap_exact(xc_
     1.4      return err;
     1.5  }
     1.6  
     1.7 +int xc_domain_memory_exchange_pages(xc_interface *xch,
     1.8 +                                    int domid,
     1.9 +                                    unsigned long nr_in_extents,
    1.10 +                                    unsigned int in_order,
    1.11 +                                    xen_pfn_t *in_extents,
    1.12 +                                    unsigned long nr_out_extents,
    1.13 +                                    unsigned int out_order,
    1.14 +                                    xen_pfn_t *out_extents)
    1.15 +{
    1.16 +    int rc;
    1.17 +
    1.18 +    struct xen_memory_exchange exchange = {
    1.19 +        .in = {
    1.20 +            .nr_extents   = nr_in_extents,
    1.21 +            .extent_order = in_order,
    1.22 +            .domid        = domid
    1.23 +        },
    1.24 +        .out = {
    1.25 +            .nr_extents   = nr_out_extents,
    1.26 +            .extent_order = out_order,
    1.27 +            .domid        = domid
    1.28 +        }
    1.29 +    };
    1.30 +    set_xen_guest_handle(exchange.in.extent_start, in_extents);
    1.31 +    set_xen_guest_handle(exchange.out.extent_start, out_extents);
    1.32 +
    1.33 +    rc = xc_memory_op(xch, XENMEM_exchange, &exchange);
    1.34 +
    1.35 +    return rc;
    1.36 +}
    1.37 +
    1.38  static int xc_domain_pod_target(xc_interface *xch,
    1.39                                  int op,
    1.40                                  uint32_t domid,
     2.1 --- a/tools/libxc/xc_offline_page.c	Mon Oct 18 16:54:42 2010 +0100
     2.2 +++ b/tools/libxc/xc_offline_page.c	Mon Oct 18 17:14:07 2010 +0100
     2.3 @@ -512,35 +512,6 @@ static int clear_pte(xc_interface *xch, 
     2.4                        __clear_pte, mfn);
     2.5  }
     2.6  
     2.7 -static int exchange_page(xc_interface *xch, xen_pfn_t mfn,
     2.8 -                     xen_pfn_t *new_mfn, int domid)
     2.9 -{
    2.10 -    int rc;
    2.11 -    xen_pfn_t out_mfn;
    2.12 -
    2.13 -	struct xen_memory_exchange exchange = {
    2.14 -		.in = {
    2.15 -			.nr_extents   = 1,
    2.16 -			.extent_order = 0,
    2.17 -			.domid        = domid
    2.18 -		},
    2.19 -		.out = {
    2.20 -			.nr_extents   = 1,
    2.21 -			.extent_order = 0,
    2.22 -			.domid        = domid
    2.23 -		}
    2.24 -    };
    2.25 -    set_xen_guest_handle(exchange.in.extent_start, &mfn);
    2.26 -    set_xen_guest_handle(exchange.out.extent_start, &out_mfn);
    2.27 -
    2.28 -    rc = xc_memory_op(xch, XENMEM_exchange, &exchange);
    2.29 -
    2.30 -    if (!rc)
    2.31 -        *new_mfn = out_mfn;
    2.32 -
    2.33 -    return rc;
    2.34 -}
    2.35 -
    2.36  /*
    2.37   * Check if a page can be exchanged successfully
    2.38   */
    2.39 @@ -704,7 +675,9 @@ int xc_exchange_page(xc_interface *xch, 
    2.40          goto failed;
    2.41      }
    2.42  
    2.43 -    rc = exchange_page(xch, mfn, &new_mfn, domid);
    2.44 +    rc = xc_domain_memory_exchange_pages(xch, domid,
    2.45 +					 1, 0, &mfn,
    2.46 +					 1, 0, &new_mfn);
    2.47  
    2.48      if (rc)
    2.49      {
     3.1 --- a/tools/libxc/xenctrl.h	Mon Oct 18 16:54:42 2010 +0100
     3.2 +++ b/tools/libxc/xenctrl.h	Mon Oct 18 17:14:07 2010 +0100
     3.3 @@ -829,6 +829,15 @@ int xc_domain_populate_physmap_exact(xc_
     3.4  #define xc_domain_memory_populate_physmap(x, d, nr, eo, mf, es) \
     3.5      xc_domain_populate_physmap_exact(x, d, nr, eo, mf, es)
     3.6  
     3.7 +int xc_domain_memory_exchange_pages(xc_interface *xch,
     3.8 +                                    int domid,
     3.9 +                                    unsigned long nr_in_extents,
    3.10 +                                    unsigned int in_order,
    3.11 +                                    xen_pfn_t *in_extents,
    3.12 +                                    unsigned long nr_out_extents,
    3.13 +                                    unsigned int out_order,
    3.14 +                                    xen_pfn_t *out_extents);
    3.15 +
    3.16  int xc_domain_set_pod_target(xc_interface *xch,
    3.17                               uint32_t domid,
    3.18                               uint64_t target_pages,