ia64/xen-unstable

changeset 14702:920f762ca42d

Fix the ia64 build after save/restore cleanups.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author kfraser@localhost.localdomain
date Tue Apr 03 09:03:03 2007 +0100 (2007-04-03)
parents 870133a06f43
children 4f67d849e788
files tools/libxc/ia64/xc_ia64_linux_restore.c
line diff
     1.1 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c	Mon Apr 02 17:34:00 2007 +0100
     1.2 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c	Tue Apr 03 09:03:03 2007 +0100
     1.3 @@ -14,8 +14,14 @@
     1.4  
     1.5  #define PFN_TO_KB(_pfn) ((_pfn) << (PAGE_SHIFT - 10))
     1.6  
     1.7 -/* total number of pages used by the current guest */
     1.8 -static unsigned long max_pfn;
     1.9 +/* number of pfns this guest has (i.e. number of entries in the P2M) */
    1.10 +static unsigned long p2m_size;
    1.11 +
    1.12 +/* number of 'in use' pfns in the guest (i.e. #P2M entries with a valid mfn) */
    1.13 +static unsigned long nr_pfns;
    1.14 +
    1.15 +/* largest possible value of nr_pfns (i.e. domain's maximum memory size) */
    1.16 +static unsigned long max_nr_pfns;
    1.17  
    1.18  static ssize_t
    1.19  read_exact(int fd, void *buf, size_t count)
    1.20 @@ -57,9 +63,9 @@ read_page(int xc_handle, int io_fd, uint
    1.21  
    1.22  int
    1.23  xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
    1.24 -                 unsigned long nr_pfns, unsigned int store_evtchn,
    1.25 -                 unsigned long *store_mfn, unsigned int console_evtchn,
    1.26 -                 unsigned long *console_mfn)
    1.27 +                 unsigned long p2msize, unsigned long maxnrpfns,
    1.28 +                 unsigned int store_evtchn, unsigned long *store_mfn,
    1.29 +                 unsigned int console_evtchn, unsigned long *console_mfn)
    1.30  {
    1.31      DECLARE_DOMCTL;
    1.32      int rc = 1, i;
    1.33 @@ -79,10 +85,13 @@ xc_linux_restore(int xc_handle, int io_f
    1.34      /* A temporary mapping of the guest's start_info page. */
    1.35      start_info_t *start_info;
    1.36  
    1.37 -    max_pfn = nr_pfns;
    1.38 +    p2m_size = p2msize;
    1.39 +    max_nr_pfns = maxnrpfns;
    1.40  
    1.41 -    DPRINTF("xc_linux_restore start: max_pfn = %ld\n", max_pfn);
    1.42 +    /* For info only */
    1.43 +    nr_pfns = 0;
    1.44  
    1.45 +    DPRINTF("xc_linux_restore start: p2m_size = %lx\n", p2m_size);
    1.46  
    1.47      if (!read_exact(io_fd, &ver, sizeof(unsigned long))) {
    1.48  	ERROR("Error when reading version");
    1.49 @@ -99,29 +108,29 @@ xc_linux_restore(int xc_handle, int io_f
    1.50          return 1;
    1.51      }
    1.52  
    1.53 -    if (xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
    1.54 +    if (xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_nr_pfns)) != 0) {
    1.55          errno = ENOMEM;
    1.56          goto out;
    1.57      }
    1.58  
    1.59      /* Get pages.  */
    1.60 -    page_array = malloc(max_pfn * sizeof(unsigned long));
    1.61 +    page_array = malloc(p2m_size * sizeof(unsigned long));
    1.62      if (page_array == NULL) {
    1.63          ERROR("Could not allocate memory");
    1.64          goto out;
    1.65      }
    1.66  
    1.67 -    for ( i = 0; i < max_pfn; i++ )
    1.68 +    for ( i = 0; i < p2m_size; i++ )
    1.69          page_array[i] = i;
    1.70  
    1.71 -    if ( xc_domain_memory_populate_physmap(xc_handle, dom, max_pfn,
    1.72 +    if ( xc_domain_memory_populate_physmap(xc_handle, dom, p2m_size,
    1.73                                             0, 0, page_array) )
    1.74      {
    1.75          ERROR("Failed to allocate memory for %ld KB to dom %d.\n",
    1.76 -              PFN_TO_KB(max_pfn), dom);
    1.77 +              PFN_TO_KB(p2m_size), dom);
    1.78          goto out;
    1.79      }
    1.80 -    DPRINTF("Allocated memory by %ld KB\n", PFN_TO_KB(max_pfn));
    1.81 +    DPRINTF("Allocated memory by %ld KB\n", PFN_TO_KB(p2m_size));
    1.82  
    1.83      if (!read_exact(io_fd, &domctl.u.arch_setup, sizeof(domctl.u.arch_setup))) {
    1.84          ERROR("read: domain setup");
    1.85 @@ -131,9 +140,9 @@ xc_linux_restore(int xc_handle, int io_f
    1.86      /* Build firmware (will be overwritten).  */
    1.87      domctl.domain = (domid_t)dom;
    1.88      domctl.u.arch_setup.flags &= ~XEN_DOMAINSETUP_query;
    1.89 -    domctl.u.arch_setup.bp = ((nr_pfns - 3) << PAGE_SHIFT)
    1.90 +    domctl.u.arch_setup.bp = ((p2m_size - 3) << PAGE_SHIFT)
    1.91                             + sizeof (start_info_t);
    1.92 -    domctl.u.arch_setup.maxmem = (nr_pfns - 3) << PAGE_SHIFT;
    1.93 +    domctl.u.arch_setup.maxmem = (p2m_size - 3) << PAGE_SHIFT;
    1.94      
    1.95      domctl.cmd = XEN_DOMCTL_arch_setup;
    1.96      if (xc_domctl(xc_handle, &domctl))
    1.97 @@ -158,8 +167,6 @@ xc_linux_restore(int xc_handle, int io_f
    1.98  	if (gmfn == INVALID_MFN)
    1.99  		break;
   1.100  
   1.101 -       //DPRINTF("xc_linux_restore: page %lu/%lu at %lx\n", gmfn, max_pfn, pfn);
   1.102 -
   1.103  	if (read_page(xc_handle, io_fd, dom, gmfn) < 0)
   1.104  		goto out;
   1.105      }
   1.106 @@ -281,7 +288,7 @@ xc_linux_restore(int xc_handle, int io_f
   1.107      /* Uncanonicalise the suspend-record frame number and poke resume rec. */
   1.108      start_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   1.109                                        PROT_READ | PROT_WRITE, gmfn);
   1.110 -    start_info->nr_pages = max_pfn;
   1.111 +    start_info->nr_pages = p2m_size;
   1.112      start_info->shared_info = shared_info_frame << PAGE_SHIFT;
   1.113      start_info->flags = 0;
   1.114      *store_mfn = start_info->store_mfn;