ia64/xen-unstable

changeset 14771:b0aaa113a60f

libxc: Clarify xc_mmu interface and make it private.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Apr 06 22:48:25 2007 +0100 (2007-04-06)
parents aeb9a84e46d9
children 7cc1d532f9ee
files tools/libxc/xc_domain_restore.c tools/libxc/xc_private.c tools/libxc/xc_private.h tools/libxc/xenctrl.h
line diff
     1.1 --- a/tools/libxc/xc_domain_restore.c	Fri Apr 06 22:32:57 2007 +0100
     1.2 +++ b/tools/libxc/xc_domain_restore.c	Fri Apr 06 22:48:25 2007 +0100
     1.3 @@ -284,7 +284,7 @@ int xc_domain_restore(int xc_handle, int
     1.4      /* Our mapping of the current region (batch) */
     1.5      char *region_base;
     1.6  
     1.7 -    xc_mmu_t *mmu = NULL;
     1.8 +    struct xc_mmu *mmu = NULL;
     1.9  
    1.10      /* used by debug verify code */
    1.11      unsigned long buf[PAGE_SIZE/sizeof(unsigned long)];
    1.12 @@ -386,7 +386,9 @@ int xc_domain_restore(int xc_handle, int
    1.13      for ( pfn = 0; pfn < p2m_size; pfn++ )
    1.14          p2m[pfn] = INVALID_P2M_ENTRY;
    1.15  
    1.16 -    if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) {
    1.17 +    mmu = xc_alloc_mmu_updates(xc_handle, dom);
    1.18 +    if ( mmu == NULL )
    1.19 +    {
    1.20          ERROR("Could not initialise for MMU updates");
    1.21          goto out;
    1.22      }
    1.23 @@ -629,8 +631,8 @@ int xc_domain_restore(int xc_handle, int
    1.24       * Ensure we flush all machphys updates before potential PAE-specific
    1.25       * reallocations below.
    1.26       */
    1.27 -    if (!hvm && xc_finish_mmu_updates(xc_handle, mmu)) {
    1.28 -        ERROR("Error doing finish_mmu_updates()");
    1.29 +    if (!hvm && xc_flush_mmu_updates(xc_handle, mmu)) {
    1.30 +        ERROR("Error doing flush_mmu_updates()");
    1.31          goto out;
    1.32      }
    1.33  
    1.34 @@ -810,8 +812,8 @@ int xc_domain_restore(int xc_handle, int
    1.35              }
    1.36          }
    1.37  
    1.38 -        if (xc_finish_mmu_updates(xc_handle, mmu)) {
    1.39 -            ERROR("Error doing finish_mmu_updates()");
    1.40 +        if (xc_flush_mmu_updates(xc_handle, mmu)) {
    1.41 +            ERROR("Error doing xc_flush_mmu_updates()");
    1.42              goto out;
    1.43          }
    1.44      }
     2.1 --- a/tools/libxc/xc_private.c	Fri Apr 06 22:32:57 2007 +0100
     2.2 +++ b/tools/libxc/xc_private.c	Fri Apr 06 22:48:25 2007 +0100
     2.3 @@ -145,7 +145,7 @@ int xc_mmuext_op(
     2.4      return ret;
     2.5  }
     2.6  
     2.7 -static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu)
     2.8 +static int flush_mmu_updates(int xc_handle, struct xc_mmu *mmu)
     2.9  {
    2.10      int err = 0;
    2.11      DECLARE_HYPERCALL;
    2.12 @@ -180,9 +180,9 @@ static int flush_mmu_updates(int xc_hand
    2.13      return err;
    2.14  }
    2.15  
    2.16 -xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom)
    2.17 +struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom)
    2.18  {
    2.19 -    xc_mmu_t *mmu = malloc(sizeof(xc_mmu_t));
    2.20 +    struct xc_mmu *mmu = malloc(sizeof(*mmu));
    2.21      if ( mmu == NULL )
    2.22          return mmu;
    2.23      mmu->idx     = 0;
    2.24 @@ -190,7 +190,7 @@ xc_mmu_t *xc_init_mmu_updates(int xc_han
    2.25      return mmu;
    2.26  }
    2.27  
    2.28 -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
    2.29 +int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu,
    2.30                        unsigned long long ptr, unsigned long long val)
    2.31  {
    2.32      mmu->updates[mmu->idx].ptr = ptr;
    2.33 @@ -202,7 +202,7 @@ int xc_add_mmu_update(int xc_handle, xc_
    2.34      return 0;
    2.35  }
    2.36  
    2.37 -int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu)
    2.38 +int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu)
    2.39  {
    2.40      return flush_mmu_updates(xc_handle, mmu);
    2.41  }
     3.1 --- a/tools/libxc/xc_private.h	Fri Apr 06 22:32:57 2007 +0100
     3.2 +++ b/tools/libxc/xc_private.h	Fri Apr 06 22:48:25 2007 +0100
     3.3 @@ -168,4 +168,16 @@ void bitmap_byte_to_64(uint64_t *lp, con
     3.4  /* Optionally flush file to disk and discard page cache */
     3.5  void discard_file_cache(int fd, int flush);
     3.6  
     3.7 +#define MAX_MMU_UPDATES 1024
     3.8 +struct xc_mmu {
     3.9 +    mmu_update_t updates[MAX_MMU_UPDATES];
    3.10 +    int          idx;
    3.11 +    domid_t      subject;
    3.12 +};
    3.13 +/* Structure returned by xc_alloc_mmu_updates must be free()'ed by caller. */
    3.14 +struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom);
    3.15 +int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu,
    3.16 +                   unsigned long long ptr, unsigned long long val);
    3.17 +int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu);
    3.18 +
    3.19  #endif /* __XC_PRIVATE_H__ */
     4.1 --- a/tools/libxc/xenctrl.h	Fri Apr 06 22:32:57 2007 +0100
     4.2 +++ b/tools/libxc/xenctrl.h	Fri Apr 06 22:48:25 2007 +0100
     4.3 @@ -666,21 +666,6 @@ int xc_sysctl(int xc_handle, struct xen_
     4.4  
     4.5  int xc_version(int xc_handle, int cmd, void *arg);
     4.6  
     4.7 -/*
     4.8 - * MMU updates.
     4.9 - */
    4.10 -#define MAX_MMU_UPDATES 1024
    4.11 -struct xc_mmu {
    4.12 -    mmu_update_t updates[MAX_MMU_UPDATES];
    4.13 -    int          idx;
    4.14 -    domid_t      subject;
    4.15 -};
    4.16 -typedef struct xc_mmu xc_mmu_t;
    4.17 -xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
    4.18 -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
    4.19 -                   unsigned long long ptr, unsigned long long val);
    4.20 -int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
    4.21 -
    4.22  int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);
    4.23  
    4.24  /*