direct-io.hg

changeset 7942:bdab22f56efe

Fix 'belt + braces' check in xc_linux_save and improve error handling
for live migrate (this includes making shadow enable idempotent).

Signed-off-by: Steven Hand <steven@xensource.com>
author smh22@firebug.cl.cam.ac.uk
date Mon Nov 21 16:40:16 2005 +0100 (2005-11-21)
parents 112a769787d2
children ff18a169e866
files tools/libxc/xc_linux_save.c tools/libxc/xg_save_restore.h xen/arch/x86/shadow32.c
line diff
     1.1 --- a/tools/libxc/xc_linux_save.c	Mon Nov 21 16:10:19 2005 +0100
     1.2 +++ b/tools/libxc/xc_linux_save.c	Mon Nov 21 16:40:16 2005 +0100
     1.3 @@ -798,6 +798,7 @@ int xc_linux_save(int xc_handle, int io_
     1.4      pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
     1.5  
     1.6      if ((pfn_type == NULL) || (pfn_batch == NULL)) {
     1.7 +        ERR("failed to alloc memory for pfn_type and/or pfn_batch arays."); 
     1.8          errno = ENOMEM;
     1.9          goto out;
    1.10      }
    1.11 @@ -817,7 +818,7 @@ int xc_linux_save(int xc_handle, int io_
    1.12          for (i = 0; i < max_pfn; i++) {
    1.13  
    1.14              mfn = live_p2m[i];
    1.15 -            if((live_m2p[mfn] != i) && (mfn != 0xffffffffUL)) { 
    1.16 +            if((mfn != 0xffffffffUL) && (live_m2p[mfn] != i)) { 
    1.17                  DPRINTF("i=0x%x mfn=%lx live_m2p=%lx\n", i, 
    1.18                          mfn, live_m2p[mfn]);
    1.19                  err++;
    1.20 @@ -912,7 +913,7 @@ int xc_linux_save(int xc_handle, int io_
    1.21                         unless its sent sooner anyhow */
    1.22  
    1.23                      set_bit(n, to_fix);
    1.24 -                    if(iter > 1)
    1.25 +                    if( (iter > 1) && IS_REAL_PFN(n) )
    1.26                          DPRINTF("netbuf race: iter %d, pfn %x. mfn %lx\n",
    1.27                                  iter, n, pfn_type[batch]);
    1.28                      continue;
    1.29 @@ -1157,6 +1158,13 @@ int xc_linux_save(int xc_handle, int io_
    1.30  
    1.31   out:
    1.32  
    1.33 +    if (live) {
    1.34 +        if(xc_shadow_control(xc_handle, dom, DOM0_SHADOW_CONTROL_OP_OFF, 
    1.35 +                             NULL, 0, NULL ) < 0) { 
    1.36 +            DPRINTF("Warning - couldn't disable shadow mode");
    1.37 +        }
    1.38 +    }
    1.39 +    
    1.40      if (live_shinfo)
    1.41          munmap(live_shinfo, PAGE_SIZE);
    1.42      
     2.1 --- a/tools/libxc/xg_save_restore.h	Mon Nov 21 16:10:19 2005 +0100
     2.2 +++ b/tools/libxc/xg_save_restore.h	Mon Nov 21 16:40:16 2005 +0100
     2.3 @@ -125,6 +125,12 @@ static int get_platform_info(int xc_hand
     2.4  /* Number of entries in the pfn_to_mfn_frame_list_list */
     2.5  #define P2M_FLL_ENTRIES (((max_pfn)+(ulpp*ulpp)-1)/(ulpp*ulpp))
     2.6  
     2.7 +/* Current guests allow 8MB 'slack' in their P2M */
     2.8 +#define NR_SLACK_ENTRIES   ((8 * 1024 * 1024) / PAGE_SIZE)
     2.9 +
    2.10 +/* Is the given PFN within the 'slack' region at the top of the P2M? */
    2.11 +#define IS_REAL_PFN(_pfn)  ((max_pfn - (_pfn)) > NR_SLACK_ENTRIES) 
    2.12 +
    2.13  /* Returns TRUE if the PFN is currently mapped */
    2.14  #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
    2.15  
     3.1 --- a/xen/arch/x86/shadow32.c	Mon Nov 21 16:10:19 2005 +0100
     3.2 +++ b/xen/arch/x86/shadow32.c	Mon Nov 21 16:40:16 2005 +0100
     3.3 @@ -920,9 +920,9 @@ int __shadow_mode_enable(struct domain *
     3.4      struct vcpu *v;
     3.5      int new_modes = (mode & ~d->arch.shadow_mode);
     3.6  
     3.7 -    // Gotta be adding something to call this function.
     3.8 -    ASSERT(new_modes);
     3.9 -
    3.10 +    if(!new_modes) /* Nothing to do - return success */
    3.11 +        return 0; 
    3.12 +        
    3.13      // can't take anything away by calling this function.
    3.14      ASSERT(!(d->arch.shadow_mode & ~mode));
    3.15