ia64/xen-unstable

changeset 2147:949f21fc9e77

bitkeeper revision 1.1159.1.24 (4117b6a1euBrYZVVvGdpODhTzq8iNA)

Fix migrate to cope with domains that are paused.
author iap10@labyrinth.cl.cam.ac.uk
date Mon Aug 09 17:38:41 2004 +0000 (2004-08-09)
parents 99bda1b6ff7f
children 5ca8e45604f4 d5848b157343
files tools/libxc/xc_linux_save.c
line diff
     1.1 --- a/tools/libxc/xc_linux_save.c	Mon Aug 09 15:57:24 2004 +0000
     1.2 +++ b/tools/libxc/xc_linux_save.c	Mon Aug 09 17:38:41 2004 +0000
     1.3 @@ -240,6 +240,55 @@ static int analysis_phase( int xc_handle
     1.4      return -1;
     1.5  }
     1.6  
     1.7 +
     1.8 +int suspend_and_state( int xc_handle, XcIOContext *ioctxt,		      
     1.9 +		       dom0_op_t *op,
    1.10 +		       full_execution_context_t *ctxt )
    1.11 +{
    1.12 +    int i=0;
    1.13 +    
    1.14 +    xcio_suspend_domain(ioctxt);
    1.15 +
    1.16 +retry:
    1.17 +
    1.18 +    if ( xc_domain_getfullinfo( xc_handle, ioctxt->domain, op, ctxt) )
    1.19 +    {
    1.20 +	xcio_error(ioctxt, "Could not get full domain info");
    1.21 +	return -1;
    1.22 +    }
    1.23 +
    1.24 +    if ( (op->u.getdomaininfo.flags & 
    1.25 +	  ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
    1.26 +	 == ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
    1.27 +    {
    1.28 +	return 0; // success
    1.29 +    }
    1.30 +
    1.31 +    if ( op->u.getdomaininfo.flags & DOMFLAGS_PAUSED )
    1.32 +    {
    1.33 +	// try unpausing domain, wait, and retest	
    1.34 +	xc_domain_unpause( xc_handle, ioctxt->domain );
    1.35 +
    1.36 +	xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%lx)",
    1.37 +		   op->u.getdomaininfo.flags);
    1.38 +	usleep(10000);  // 10ms
    1.39 +
    1.40 +	goto retry;
    1.41 +    }
    1.42 +
    1.43 +
    1.44 +    if( ++i < 3 )
    1.45 +    {
    1.46 +	usleep(10000);  // 10ms	
    1.47 +	goto retry;
    1.48 +    }
    1.49 +
    1.50 +    xcio_error(ioctxt, "Unable to suspend domain. (%lx)",
    1.51 +	       op->u.getdomaininfo.flags);
    1.52 +
    1.53 +    return -1;
    1.54 +}
    1.55 +
    1.56  int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
    1.57  {
    1.58      dom0_op_t op;
    1.59 @@ -407,23 +456,17 @@ int xc_linux_save(int xc_handle, XcIOCon
    1.60  
    1.61          last_iter = 1;
    1.62  
    1.63 -	xcio_suspend_domain(ioctxt);
    1.64 -
    1.65 -	if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
    1.66 -	{
    1.67 -	    xcio_error(ioctxt, "Could not get full domain info");
    1.68 -	    goto out;
    1.69 -	}
    1.70 -
    1.71 -	if ( (op.u.getdomaininfo.flags & 
    1.72 -	     ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
    1.73 -	     != ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
    1.74 +	if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
    1.75  	{
    1.76  	    xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
    1.77  		       op.u.getdomaininfo.flags);
    1.78  	    goto out;
    1.79  	}
    1.80  
    1.81 +	printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
    1.82 +	       op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
    1.83 +	       ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
    1.84 +
    1.85      }
    1.86  
    1.87      /* calculate the power of 2 order of nr_pfns, e.g.
    1.88 @@ -779,26 +822,18 @@ int xc_linux_save(int xc_handle, XcIOCon
    1.89                  DPRINTF("Start last iteration\n");
    1.90                  last_iter = 1;
    1.91  
    1.92 -		xcio_suspend_domain(ioctxt);
    1.93 -		
    1.94 -		if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
    1.95 +		if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
    1.96  		{
    1.97 -		    xcio_error(ioctxt, "Could not get full domain info");
    1.98 -		    goto out;
    1.99 -		}
   1.100 -		
   1.101 -		if ( (op.u.getdomaininfo.flags & 
   1.102 -		      ( DOMFLAGS_SHUTDOWN |
   1.103 -			(SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
   1.104 -		     != ( DOMFLAGS_SHUTDOWN |
   1.105 -			  (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
   1.106 -		{
   1.107 -		    xcio_error(ioctxt, 
   1.108 -			       "Domain appears not to have suspended: %lx",
   1.109 +		    xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
   1.110  			       op.u.getdomaininfo.flags);
   1.111  		    goto out;
   1.112  		}
   1.113  
   1.114 +		printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
   1.115 +		       op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
   1.116 +		       ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
   1.117 +
   1.118 +
   1.119              } 
   1.120  
   1.121              if ( xc_shadow_control( xc_handle, domid,