debuggers.hg

changeset 20877:6a5d8284b6e6

libxc: Unbreak HVM live migration after 0b138a019292.

0b138a019292 was a little too ambitious replacing xc_map_foreign_batch
with xc_map_foreign_pages in xc_domain_restore. With HVM, some of the
mappings are expected to fail (as "XTAB" pages).

Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 21 09:03:20 2010 +0000 (2010-01-21)
parents aa00760933df
children acd7d3f06d9a
files tools/libxc/xc_domain_restore.c
line diff
     1.1 --- a/tools/libxc/xc_domain_restore.c	Thu Jan 21 09:03:00 2010 +0000
     1.2 +++ b/tools/libxc/xc_domain_restore.c	Thu Jan 21 09:03:20 2010 +0000
     1.3 @@ -1171,6 +1171,8 @@ static int apply_batch(int xc_handle, ui
     1.4      unsigned long *page = NULL;
     1.5      int nraces = 0;
     1.6      struct domain_info_context *dinfo = &ctx->dinfo;
     1.7 +    int* pfn_err = NULL;
     1.8 +    int rc = -1;
     1.9  
    1.10      unsigned long mfn, pfn, pagetype;
    1.11  
    1.12 @@ -1186,12 +1188,14 @@ static int apply_batch(int xc_handle, ui
    1.13      }
    1.14  
    1.15      /* Map relevant mfns */
    1.16 -    region_base = xc_map_foreign_pages(
    1.17 -        xc_handle, dom, PROT_WRITE, region_mfn, j);
    1.18 +    pfn_err = calloc(j, sizeof(*pfn_err));
    1.19 +    region_base = xc_map_foreign_bulk(
    1.20 +        xc_handle, dom, PROT_WRITE, region_mfn, pfn_err, j);
    1.21  
    1.22      if ( region_base == NULL )
    1.23      {
    1.24          ERROR("map batch failed");
    1.25 +        free(pfn_err);
    1.26          return -1;
    1.27      }
    1.28  
    1.29 @@ -1204,12 +1208,18 @@ static int apply_batch(int xc_handle, ui
    1.30              /* a bogus/unmapped page: skip it */
    1.31              continue;
    1.32  
    1.33 +        if (pfn_err[i])
    1.34 +        {
    1.35 +            ERROR("unexpected PFN mapping failure");
    1.36 +            goto err_mapped;
    1.37 +        }
    1.38 +
    1.39          ++curpage;
    1.40  
    1.41          if ( pfn > dinfo->p2m_size )
    1.42          {
    1.43              ERROR("pfn out of range");
    1.44 -            return -1;
    1.45 +            goto err_mapped;
    1.46          }
    1.47  
    1.48          pfn_type[pfn] = pagetype;
    1.49 @@ -1257,7 +1267,7 @@ static int apply_batch(int xc_handle, ui
    1.50          {
    1.51              ERROR("Bogus page type %lx page table is out of range: "
    1.52                    "i=%d p2m_size=%lu", pagetype, i, dinfo->p2m_size);
    1.53 -            return -1;
    1.54 +            goto err_mapped;
    1.55          }
    1.56  
    1.57          if ( pagebuf->verify )
    1.58 @@ -1288,13 +1298,17 @@ static int apply_batch(int xc_handle, ui
    1.59                                 | MMU_MACHPHYS_UPDATE, pfn) )
    1.60          {
    1.61              ERROR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn);
    1.62 -            return -1;
    1.63 +            goto err_mapped;
    1.64          }
    1.65      } /* end of 'batch' for loop */
    1.66  
    1.67 -    munmap(region_base, j*PAGE_SIZE);
    1.68 +    rc = nraces;
    1.69  
    1.70 -    return nraces;
    1.71 +  err_mapped:
    1.72 +    munmap(region_base, j*PAGE_SIZE);
    1.73 +    free(pfn_err);
    1.74 +
    1.75 +    return rc;
    1.76  }
    1.77  
    1.78  int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,