ia64/xen-unstable

changeset 14095:e21834bc78f2

hvm: Fix save/restore to handle missing pages.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Feb 23 16:17:00 2007 +0000 (2007-02-23)
parents 91427cadfa48
children 58086aa7c70a
files tools/libxc/xc_hvm_restore.c tools/libxc/xc_hvm_save.c
line diff
     1.1 --- a/tools/libxc/xc_hvm_restore.c	Fri Feb 23 16:16:36 2007 +0000
     1.2 +++ b/tools/libxc/xc_hvm_restore.c	Fri Feb 23 16:17:00 2007 +0000
     1.3 @@ -104,22 +104,19 @@ int xc_hvm_restore(int xc_handle, int io
     1.4      v_end = memsize << 20;
     1.5      nr_pages = (unsigned long) memsize << (20 - PAGE_SHIFT);
     1.6  
     1.7 -    DPRINTF("xc_hvm_restore:dom=%d, nr_pages=0x%lx, store_evtchn=%d, *store_mfn=%ld, pae=%u, apic=%u.\n", 
     1.8 +    DPRINTF("xc_hvm_restore:dom=%d, nr_pages=0x%lx, store_evtchn=%d, "
     1.9 +            "*store_mfn=%ld, pae=%u, apic=%u.\n", 
    1.10              dom, nr_pages, store_evtchn, *store_mfn, pae, apic);
    1.11  
    1.12 -    
    1.13      if(!get_platform_info(xc_handle, dom,
    1.14                            &max_mfn, &hvirt_start, &pt_levels)) {
    1.15          ERROR("Unable to get platform info.");
    1.16          return 1;
    1.17      }
    1.18  
    1.19 -    DPRINTF("xc_hvm_restore start: nr_pages = %lx, max_pfn = %lx, max_mfn = %lx, hvirt_start=%lx, pt_levels=%d\n",
    1.20 -            nr_pages,
    1.21 -            max_pfn,
    1.22 -            max_mfn,
    1.23 -            hvirt_start,
    1.24 -            pt_levels);
    1.25 +    DPRINTF("xc_hvm_restore start: nr_pages = %lx, max_pfn = %lx, "
    1.26 +            "max_mfn = %lx, hvirt_start=%lx, pt_levels=%d\n",
    1.27 +            nr_pages, max_pfn, max_mfn, hvirt_start, pt_levels);
    1.28  
    1.29      if (mlock(&ctxt, sizeof(ctxt))) {
    1.30          /* needed for build dom0 op, but might as well do early */
    1.31 @@ -220,6 +217,9 @@ int xc_hvm_restore(int xc_handle, int io
    1.32              void *page;
    1.33  
    1.34              pfn = region_pfn_type[i];
    1.35 +            if ( pfn & XEN_DOMCTL_PFINFO_LTAB_MASK )
    1.36 +                continue;
    1.37 +
    1.38              if ( pfn > max_pfn )
    1.39              {
    1.40                  ERROR("pfn out of range");
     2.1 --- a/tools/libxc/xc_hvm_save.c	Fri Feb 23 16:16:36 2007 +0000
     2.2 +++ b/tools/libxc/xc_hvm_save.c	Fri Feb 23 16:17:00 2007 +0000
     2.3 @@ -265,7 +265,7 @@ int xc_hvm_save(int xc_handle, int io_fd
     2.4  {
     2.5      xc_dominfo_t info;
     2.6  
     2.7 -    int rc = 1, i, last_iter, iter = 0;
     2.8 +    int rc = 1, i, j, last_iter, iter = 0;
     2.9      int live  = (flags & XCFLAGS_LIVE);
    2.10      int debug = (flags & XCFLAGS_DEBUG);
    2.11      int sent_last_iter, skip_this_iter;
    2.12 @@ -289,7 +289,7 @@ int xc_hvm_save(int xc_handle, int io_fd
    2.13      /* base of the region in which domain memory is mapped */
    2.14      unsigned char *region_base = NULL;
    2.15  
    2.16 -    uint32_t nr_pfns, rec_size, nr_vcpus;
    2.17 +    uint32_t rec_size, nr_vcpus;
    2.18  
    2.19      /* power of 2 order of max_pfn */
    2.20      int order_nr;
    2.21 @@ -360,7 +360,8 @@ int xc_hvm_save(int xc_handle, int io_fd
    2.22          goto out;
    2.23      }
    2.24  
    2.25 -    DPRINTF("saved hvm domain info:max_memkb=0x%lx, max_mfn=0x%lx, nr_pages=0x%lx\n", info.max_memkb, max_mfn, info.nr_pages); 
    2.26 +    DPRINTF("saved hvm domain info:max_memkb=0x%lx, max_mfn=0x%lx, "
    2.27 +            "nr_pages=0x%lx\n", info.max_memkb, max_mfn, info.nr_pages); 
    2.28  
    2.29      if (live) {
    2.30          ERROR("hvm domain doesn't support live migration now.\n");
    2.31 @@ -373,10 +374,6 @@ int xc_hvm_save(int xc_handle, int io_fd
    2.32              goto out;
    2.33          }
    2.34  
    2.35 -        /* excludes vga acc mem */
    2.36 -        /* XXX will need to check whether acceleration is enabled here! */
    2.37 -        nr_pfns = info.nr_pages - 0x800;
    2.38 -
    2.39          last_iter = 0;
    2.40          DPRINTF("hvm domain live migration debug start: logdirty enable.\n");
    2.41      } else {
    2.42 @@ -390,20 +387,15 @@ int xc_hvm_save(int xc_handle, int io_fd
    2.43              ERROR("HVM Domain appears not to have suspended");
    2.44              goto out;
    2.45          }
    2.46 -
    2.47 -        nr_pfns = info.nr_pages; 
    2.48      }
    2.49  
    2.50 -    DPRINTF("after 1st handle hvm domain nr_pfns=0x%x, nr_pages=0x%lx, max_memkb=0x%lx, live=%d.\n",
    2.51 -            nr_pfns,
    2.52 -            info.nr_pages,
    2.53 -            info.max_memkb,
    2.54 -            live);
    2.55 +    DPRINTF("after 1st handle hvm domain nr_pages=0x%lx, "
    2.56 +            "max_memkb=0x%lx, live=%d.\n",
    2.57 +            info.nr_pages, info.max_memkb, live);
    2.58  
    2.59      /* Calculate the highest PFN of "normal" memory:
    2.60 -     * HVM memory is sequential except for the VGA and MMIO holes, and
    2.61 -     * we have nr_pfns of it (which now excludes the cirrus video RAM) */
    2.62 -    max_pfn = nr_pfns; 
    2.63 +     * HVM memory is sequential except for the VGA and MMIO holes. */
    2.64 +    max_pfn = info.nr_pages;
    2.65      /* Skip the VGA hole from 0xa0000 to 0xc0000 */
    2.66      max_pfn += 0x20;   
    2.67      /* Skip the MMIO hole: 256MB just below 4GB */
    2.68 @@ -556,9 +548,16 @@ int xc_hvm_save(int xc_handle, int io_fd
    2.69                  goto out;
    2.70              }
    2.71  
    2.72 -            if (ratewrite(io_fd, region_base, PAGE_SIZE * batch) != PAGE_SIZE * batch) {
    2.73 -                ERROR("ERROR when writting to state file (4)");
    2.74 -                goto out;
    2.75 +            for ( j = 0; j < batch; j++ )
    2.76 +            {
    2.77 +                if ( pfn_batch[j] & XEN_DOMCTL_PFINFO_LTAB_MASK )
    2.78 +                    continue;
    2.79 +                if ( ratewrite(io_fd, region_base + j*PAGE_SIZE,
    2.80 +                               PAGE_SIZE) != PAGE_SIZE )
    2.81 +                {
    2.82 +                    ERROR("ERROR when writing to state file (4)");
    2.83 +                    goto out;
    2.84 +                }
    2.85              }
    2.86  
    2.87              sent_this_iter += batch;