ia64/xen-unstable

changeset 13940:aa00ced0a10a

[XEND][POWERPC] move ppc memory allocation to libxc. Sync XendDomainInfo.py with xen-unstable.hg.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Sun Jan 21 08:17:02 2007 -0500 (2007-01-21)
parents 09b3fd488726
children b071a2610abc
files tools/libxc/powerpc64/xc_linux_build.c
line diff
     1.1 --- a/tools/libxc/powerpc64/xc_linux_build.c	Sun Jan 21 08:15:39 2007 -0500
     1.2 +++ b/tools/libxc/powerpc64/xc_linux_build.c	Sun Jan 21 08:17:02 2007 -0500
     1.3 @@ -142,7 +142,41 @@ static void free_page_array(xen_pfn_t *p
     1.4      free(page_array);
     1.5  }
     1.6  
     1.7 +static int check_memory_config(int rma_log, unsigned int mem_mb)
     1.8 +{
     1.9 +    u64 mem_kb = (mem_mb << 10);
    1.10 +    u64 rma_kb = (1 << rma_log) >> 10;
    1.11  
    1.12 +    switch(rma_log)
    1.13 +    {
    1.14 +        case 26:
    1.15 +        case 27:
    1.16 +        case 28:
    1.17 +        case 30:
    1.18 +        case 34:
    1.19 +        case 38:
    1.20 +            if (mem_kb < rma_kb) {
    1.21 +                DPRINTF("Domain memory must be at least %dMB\n", 
    1.22 +                        (1 << rma_log)>>20);
    1.23 +                break;
    1.24 +            }
    1.25 +
    1.26 +            if (mem_kb % (16 << 10)) {
    1.27 +                DPRINTF("Domain memory %dMB must be a multiple of 16MB\n",
    1.28 +                        mem_mb);
    1.29 +                       
    1.30 +                break;
    1.31 +            }
    1.32 +
    1.33 +            /* rma_log and mem_mb OK */
    1.34 +            return 0;
    1.35 +
    1.36 +        default:
    1.37 +            DPRINTF("Invalid rma_log (%d)\n", rma_log);
    1.38 +    }
    1.39 +
    1.40 +    return 1;
    1.41 +}
    1.42  
    1.43  int xc_linux_build(int xc_handle,
    1.44                     uint32_t domid,
    1.45 @@ -168,6 +202,9 @@ int xc_linux_build(int xc_handle,
    1.46      unsigned long start_info_addr;
    1.47      unsigned long rma_pages;
    1.48      unsigned long shadow_mb;
    1.49 +    u32 remaining_kb;
    1.50 +    u32 extent_order;
    1.51 +    u64 nr_extents;
    1.52      int rma_log = 26;  /* 64MB RMA */
    1.53      int rc = 0;
    1.54      int op;
    1.55 @@ -184,6 +221,37 @@ int xc_linux_build(int xc_handle,
    1.56          goto out;
    1.57      }
    1.58  
    1.59 +    /* validate rma_log and domain memory config */
    1.60 +    if (check_memory_config(rma_log, mem_mb)) {
    1.61 +        rc = -1;
    1.62 +        goto out;
    1.63 +    }
    1.64 +    
    1.65 +    /* alloc RMA */
    1.66 +    if (xc_alloc_real_mode_area(xc_handle, domid, rma_log)) {
    1.67 +        rc = -1;
    1.68 +        goto out;
    1.69 +    }
    1.70 +
    1.71 +    /* subtract already allocated RMA to determine remaining KB to alloc */
    1.72 +    remaining_kb = (nr_pages - rma_pages) * (PAGE_SIZE / 1024);
    1.73 +    DPRINTF("totalmem - RMA = %dKB\n", remaining_kb);
    1.74 +
    1.75 +    /* to allocate in 16MB chunks, we need to determine the order of 
    1.76 +     * the number of PAGE_SIZE pages contained in 16MB. */
    1.77 +    extent_order = 24 - 12; /* extent_order = log2((1 << 24) - (1 << 12)) */
    1.78 +    nr_extents = (remaining_kb / (PAGE_SIZE/1024)) >> extent_order;
    1.79 +    DPRINTF("allocating memory in %llu chunks of %luMB\n", nr_extents,
    1.80 +            (((1 << extent_order) >> 10) * PAGE_SIZE) >> 10);
    1.81 +
    1.82 +    /* now allocate the remaining memory as large-order allocations */
    1.83 +    DPRINTF("increase_reservation(%u, %llu, %u)\n", domid, nr_extents, extent_order);
    1.84 +    if (xc_domain_memory_increase_reservation(xc_handle, domid, nr_extents, 
    1.85 +                                              extent_order, 0, NULL)) {
    1.86 +        rc = -1;
    1.87 +        goto out;
    1.88 +    }
    1.89 +
    1.90      if (get_rma_page_array(xc_handle, domid, &page_array, rma_pages)) {
    1.91          rc = -1;
    1.92          goto out;