direct-io.hg

changeset 4853:b78b16c06b85

bitkeeper revision 1.1389.15.14 (428242a6WycHvjFblUGQbKtJd94NPg)

Many files:
Merge interface changes from previous 'Split out context fetching into
separate DOM0 op' and 'xen,tools: pincpu use vcpu and cpumap_t' checkins.
xc_linux_save.c:
Undo incorrect change from previous patch.
xc.h, xc_domain.c:
Cleanup whitespace.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed May 11 17:36:38 2005 +0000 (2005-05-11)
parents a68686aaebc3
children 2c883d988a41
files tools/libxc/xc.h tools/libxc/xc_core.c tools/libxc/xc_domain.c tools/libxc/xc_linux_save.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py xen/common/dom0_ops.c xen/include/public/dom0_ops.h
line diff
     1.1 --- a/tools/libxc/xc.h	Wed May 11 15:05:07 2005 +0000
     1.2 +++ b/tools/libxc/xc.h	Wed May 11 17:36:38 2005 +0000
     1.3 @@ -87,22 +87,22 @@ typedef struct xc_core_header {
     1.4  
     1.5  
     1.6  long xc_ptrace(enum __ptrace_request request, 
     1.7 -	       u32  domid,
     1.8 -	       long addr, 
     1.9 -	       long data);
    1.10 +               u32  domid,
    1.11 +               long addr, 
    1.12 +               long data);
    1.13  
    1.14  long xc_ptrace_core(enum __ptrace_request request, 
    1.15 -		    u32 domid, 
    1.16 -		    long addr, 
    1.17 -		    long data);
    1.18 +                    u32 domid, 
    1.19 +                    long addr, 
    1.20 +                    long data);
    1.21  
    1.22  int xc_waitdomain(int domain, 
    1.23 -		  int *status, 
    1.24 -		  int options);
    1.25 +                  int *status, 
    1.26 +                  int options);
    1.27  
    1.28  int xc_waitdomain_core(int domain, 
    1.29 -		       int *status, 
    1.30 -		       int options);
    1.31 +                       int *status, 
    1.32 +                       int options);
    1.33  
    1.34  /*
    1.35   * DOMAIN MANAGEMENT FUNCTIONS
    1.36 @@ -110,10 +110,6 @@ int xc_waitdomain_core(int domain,
    1.37  
    1.38  typedef struct {
    1.39      u32           domid;
    1.40 -    unsigned int  flags;
    1.41 -    unsigned int  processors;
    1.42 -    unsigned int  vcpus;
    1.43 -    u16           n_vcpus;	
    1.44      unsigned int  dying:1, crashed:1, shutdown:1, 
    1.45                    paused:1, blocked:1, running:1;
    1.46      unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
    1.47 @@ -121,6 +117,7 @@ typedef struct {
    1.48      unsigned long shared_info_frame;
    1.49      u64           cpu_time;
    1.50      unsigned long max_memkb;
    1.51 +    unsigned int  vcpus;
    1.52      s32           vcpu_to_cpu[MAX_VIRT_CPUS];
    1.53      cpumap_t      cpumap[MAX_VIRT_CPUS];
    1.54  } xc_dominfo_t;
    1.55 @@ -134,8 +131,8 @@ int xc_domain_create(int xc_handle,
    1.56  
    1.57  
    1.58  int xc_domain_dumpcore(int xc_handle, 
    1.59 -		       u32 domid,
    1.60 -		       const char *corename);
    1.61 +                       u32 domid,
    1.62 +                       const char *corename);
    1.63  
    1.64  
    1.65  /**
    1.66 @@ -202,9 +199,9 @@ int xc_domain_getinfo(int xc_handle,
    1.67   * @return 0 on success, -1 on failure
    1.68   */
    1.69  int xc_domain_get_vcpu_context(int xc_handle,
    1.70 -			      u32 domid,
    1.71 -			      u32 vcpu,
    1.72 -			      vcpu_guest_context_t *ctxt);
    1.73 +                               u32 domid,
    1.74 +                               u32 vcpu,
    1.75 +                               vcpu_guest_context_t *ctxt);
    1.76  
    1.77  int xc_domain_setcpuweight(int xc_handle,
    1.78                             u32 domid,
    1.79 @@ -266,8 +263,8 @@ xc_plan9_build (int xc_handle,
    1.80                  u32 domid, 
    1.81                  const char *image_name,
    1.82                  const char *cmdline, 
    1.83 -		unsigned int control_evtchn, 
    1.84 -		unsigned long flags);
    1.85 +                unsigned int control_evtchn, 
    1.86 +                unsigned long flags);
    1.87  
    1.88  struct mem_map;
    1.89  int xc_vmx_build(int xc_handle,
    1.90 @@ -444,7 +441,7 @@ void *xc_map_foreign_batch(int xc_handle
    1.91                             unsigned long *arr, int num );
    1.92  
    1.93  int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf, 
    1.94 -		    unsigned long max_pfns);
    1.95 +                    unsigned long max_pfns);
    1.96  
    1.97  /*\
    1.98   *  GRANT TABLE FUNCTIONS
     2.1 --- a/tools/libxc/xc_core.c	Wed May 11 15:05:07 2005 +0000
     2.2 +++ b/tools/libxc/xc_core.c	Wed May 11 17:36:38 2005 +0000
     2.3 @@ -53,7 +53,10 @@ xc_domain_dumpcore(int xc_handle,
     2.4  		goto error_out;
     2.5  	}
     2.6  	
     2.7 -	for (i = 0; i < info.n_vcpus; i++) {
     2.8 +	for (i = 0; i < sizeof(info.vcpu_to_cpu) / sizeof(info.vcpu_to_cpu[0]);
     2.9 +	     i++) {
    2.10 +		if (info.vcpu_to_cpu[i] == -1)
    2.11 +			continue;
    2.12  		if (xc_domain_get_vcpu_context(xc_handle, domid, i, &ctxt[i])) {
    2.13  			PERROR("Could not get all vcpu contexts for domain");
    2.14  			goto error_out;
    2.15 @@ -63,7 +66,7 @@ xc_domain_dumpcore(int xc_handle,
    2.16  	nr_pages = info.nr_pages;
    2.17  
    2.18  	header.xch_magic = 0xF00FEBED; 
    2.19 -	header.xch_nr_vcpus = info.n_vcpus;
    2.20 +	header.xch_nr_vcpus = info.vcpus;
    2.21  	header.xch_nr_pages = nr_pages;
    2.22  	header.xch_ctxt_offset = sizeof(struct xc_core_header);
    2.23  	header.xch_index_offset = sizeof(struct xc_core_header) +
    2.24 @@ -72,7 +75,7 @@ xc_domain_dumpcore(int xc_handle,
    2.25  	    sizeof(vcpu_guest_context_t) + nr_pages * sizeof(unsigned long));
    2.26  
    2.27  	write(dump_fd, &header, sizeof(struct xc_core_header));
    2.28 -	write(dump_fd, &ctxt, sizeof(ctxt[0]) * info.n_vcpus);
    2.29 +	write(dump_fd, &ctxt, sizeof(ctxt[0]) * info.vcpus);
    2.30  
    2.31  	if ((page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL) {
    2.32  	    printf("Could not allocate memory\n");
     3.1 --- a/tools/libxc/xc_domain.c	Wed May 11 15:05:07 2005 +0000
     3.2 +++ b/tools/libxc/xc_domain.c	Wed May 11 17:36:38 2005 +0000
     3.3 @@ -115,9 +115,6 @@ int xc_domain_getinfo(int xc_handle,
     3.4          if ( (rc = do_dom0_op(xc_handle, &op)) < 0 )
     3.5              break;
     3.6          info->domid      = (u16)op.u.getdomaininfo.domain;
     3.7 -        info->processors = op.u.getdomaininfo.processors;
     3.8 -	info->n_vcpus    = op.u.getdomaininfo.n_active_vcpus;
     3.9 -	info->flags      = op.u.getdomaininfo.flags;
    3.10  
    3.11          info->dying    = !!(op.u.getdomaininfo.flags & DOMFLAGS_DYING);
    3.12          info->crashed  = !!(op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
    3.13 @@ -140,8 +137,8 @@ int xc_domain_getinfo(int xc_handle,
    3.14          memcpy(&info->cpumap, &op.u.getdomaininfo.cpumap, 
    3.15                 sizeof(info->cpumap));
    3.16  
    3.17 -       next_domid = (u16)op.u.getdomaininfo.domain + 1;
    3.18 -       info++;
    3.19 +        next_domid = (u16)op.u.getdomaininfo.domain + 1;
    3.20 +        info++;
    3.21      }
    3.22  
    3.23      if( !nr_doms ) return rc; 
    3.24 @@ -150,9 +147,9 @@ int xc_domain_getinfo(int xc_handle,
    3.25  }
    3.26  
    3.27  int xc_domain_get_vcpu_context(int xc_handle,
    3.28 -			       u32 domid,
    3.29 -			       u32 vcpu,
    3.30 -			       vcpu_guest_context_t *ctxt)
    3.31 +                               u32 domid,
    3.32 +                               u32 vcpu,
    3.33 +                               vcpu_guest_context_t *ctxt)
    3.34  {
    3.35      int rc, errno_saved;
    3.36      dom0_op_t op;
     4.1 --- a/tools/libxc/xc_linux_save.c	Wed May 11 15:05:07 2005 +0000
     4.2 +++ b/tools/libxc/xc_linux_save.c	Wed May 11 17:36:38 2005 +0000
     4.3 @@ -345,20 +345,17 @@ retry:
     4.4          xcio_error(ioctxt, "Could not get vcpu context");
     4.5      }
     4.6  
     4.7 -    if ( (info->flags & 
     4.8 -          (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT))) ==
     4.9 -         (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT)) )
    4.10 +    if ( info->shutdown && info->shutdown_reason == SHUTDOWN_suspend )
    4.11      {
    4.12  	return 0; // success
    4.13      }
    4.14  
    4.15 -    if ( info->flags & DOMFLAGS_PAUSED )
    4.16 +    if ( info->paused )
    4.17      {
    4.18  	// try unpausing domain, wait, and retest	
    4.19  	xc_domain_unpause( xc_handle, ioctxt->domain );
    4.20  
    4.21 -	xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%u)",
    4.22 -		   info->flags);
    4.23 +	xcio_error(ioctxt, "Domain was paused. Wait and re-test.");
    4.24  	usleep(10000);  // 10ms
    4.25  
    4.26  	goto retry;
    4.27 @@ -367,12 +364,12 @@ retry:
    4.28  
    4.29      if( ++i < 100 )
    4.30      {
    4.31 -	xcio_error(ioctxt, "Retry suspend domain (%u)", info->flags);
    4.32 +	xcio_error(ioctxt, "Retry suspend domain.");
    4.33  	usleep(10000);  // 10ms	
    4.34  	goto retry;
    4.35      }
    4.36  
    4.37 -    xcio_error(ioctxt, "Unable to suspend domain. (%u)", info->flags);
    4.38 +    xcio_error(ioctxt, "Unable to suspend domain.");
    4.39  
    4.40      return -1;
    4.41  }
    4.42 @@ -469,7 +466,7 @@ int xc_linux_save(int xc_handle, XcIOCon
    4.43          goto out;
    4.44      }
    4.45      
    4.46 -    nr_pfns = info.nr_pages; 
    4.47 +    nr_pfns = info.max_memkb >> PAGE_SHIFT; 
    4.48  
    4.49      /* cheesy sanity check */
    4.50      if ( nr_pfns > 1024*1024 ){
    4.51 @@ -556,8 +553,7 @@ int xc_linux_save(int xc_handle, XcIOCon
    4.52  
    4.53  	if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
    4.54  	{
    4.55 -	    xcio_error(ioctxt, "Domain appears not to have suspended: %u",
    4.56 -		       info.flags);
    4.57 +	    xcio_error(ioctxt, "Domain appears not to have suspended");
    4.58  	    goto out;
    4.59  	}
    4.60  
    4.61 @@ -923,14 +919,12 @@ int xc_linux_save(int xc_handle, XcIOCon
    4.62  		if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
    4.63  		{
    4.64  		    xcio_error(ioctxt, 
    4.65 -                               "Domain appears not to have suspended: %u",
    4.66 -			       info.flags);
    4.67 +                               "Domain appears not to have suspended");
    4.68  		    goto out;
    4.69  		}
    4.70  
    4.71  		xcio_info(ioctxt,
    4.72 -                          "SUSPEND flags %08u shinfo %08lx eip %08u "
    4.73 -                          "esi %08u\n",info.flags,
    4.74 +                          "SUSPEND shinfo %08lx eip %08u esi %08u\n",
    4.75                            info.shared_info_frame,
    4.76                            ctxt.user_regs.eip, ctxt.user_regs.esi );
    4.77              } 
     5.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed May 11 15:05:07 2005 +0000
     5.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Wed May 11 17:36:38 2005 +0000
     5.3 @@ -205,10 +205,9 @@ static PyObject *pyxc_domain_getinfo(PyO
     5.4                              Py_BuildValue("i", info[i].cpumap[j]));
     5.5          }
     5.6                   
     5.7 -        info_dict = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
     5.8 +        info_dict = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
     5.9                                    ",s:l,s:L,s:l,s:i}",
    5.10                                    "dom",       info[i].domid,
    5.11 -                                  "cpu",       info[i].cpu,
    5.12                                    "vcpus",     info[i].vcpus,
    5.13                                    "dying",     info[i].dying,
    5.14                                    "crashed",   info[i].crashed,
     6.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed May 11 15:05:07 2005 +0000
     6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed May 11 17:36:38 2005 +0000
     6.3 @@ -370,7 +370,7 @@ class XendDomainInfo:
     6.4              if self.info['shutdown']:
     6.5                  reason = shutdown_reason(self.info['shutdown_reason'])
     6.6                  sxpr.append(['shutdown_reason', reason])
     6.7 -            sxpr.append(['cpu', self.info['cpu']])
     6.8 +            sxpr.append(['cpu', self.info['vcpu_to_cpu'][0]])
     6.9              sxpr.append(['cpu_time', self.info['cpu_time']/1e9])    
    6.10              sxpr.append(['vcpus', self.info['vcpus']])
    6.11              sxpr.append(['cpumap', self.info['cpumap']])
     7.1 --- a/xen/common/dom0_ops.c	Wed May 11 15:05:07 2005 +0000
     7.2 +++ b/xen/common/dom0_ops.c	Wed May 11 17:36:38 2005 +0000
     7.3 @@ -303,13 +303,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     7.4          struct exec_domain        *ed;
     7.5          u64 cpu_time = 0;
     7.6          int vcpu_count = 0;
     7.7 -        u32 processors = 0;
     7.8          int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
     7.9  
    7.10 -#if MAX_VIRT_CPUS > 32
    7.11 -#error "update processors field in GETDOMAININFO"
    7.12 -#endif
    7.13 -
    7.14          read_lock(&domlist_lock);
    7.15  
    7.16          for_each_domain ( d )
    7.17 @@ -333,46 +328,37 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    7.18                 sizeof(op->u.getdomaininfo.vcpu_to_cpu));
    7.19          memset(&op->u.getdomaininfo.cpumap, 0,
    7.20                 sizeof(op->u.getdomaininfo.cpumap));
    7.21 -        for_each_exec_domain ( d, ed ) {
    7.22 -            op->u.getdomaininfo.vcpu_to_cpu[ed->id] = ed->processor;
    7.23 -            op->u.getdomaininfo.cpumap[ed->id]      = ed->cpumap;
    7.24 -        }
    7.25  
    7.26          /* 
    7.27           * - domain is marked as paused or blocked only if all its vcpus 
    7.28           *   are paused or blocked 
    7.29           * - domain is marked as running if any of its vcpus is running
    7.30           */
    7.31 -        
    7.32 -        for_each_exec_domain(d, ed)  
    7.33 -        { 
    7.34 -            if (!((flags & DOMFLAGS_PAUSED) && test_bit(EDF_CTRLPAUSE, &ed->flags)))
    7.35 -                flags &=  ~DOMFLAGS_PAUSED;
    7.36 -            if (!((flags & DOMFLAGS_BLOCKED) && test_bit(EDF_BLOCKED, &ed->flags)))
    7.37 -                flags &=  ~DOMFLAGS_BLOCKED;                
    7.38 -            flags |= (test_bit(EDF_RUNNING,   &ed->flags) ? DOMFLAGS_RUNNING  : 0);
    7.39 -
    7.40 -            set_bit(ed->processor, &processors);
    7.41 +        for_each_exec_domain ( d, ed ) {
    7.42 +            op->u.getdomaininfo.vcpu_to_cpu[ed->id] = ed->processor;
    7.43 +            op->u.getdomaininfo.cpumap[ed->id]      = ed->cpumap;
    7.44 +            if (!test_bit(EDF_CTRLPAUSE, &ed->flags))
    7.45 +                flags &= ~DOMFLAGS_PAUSED;
    7.46 +            if (!test_bit(EDF_BLOCKED, &ed->flags))
    7.47 +                flags &= ~DOMFLAGS_BLOCKED;
    7.48 +            if (test_bit(EDF_RUNNING, &ed->flags))
    7.49 +                flags |= DOMFLAGS_RUNNING;
    7.50              if ( ed->cpu_time > cpu_time )
    7.51                  cpu_time += ed->cpu_time;
    7.52              vcpu_count++;
    7.53          }
    7.54 -        op->u.getdomaininfo.n_active_vcpus = vcpu_count;
    7.55 +
    7.56          op->u.getdomaininfo.cpu_time = cpu_time;
    7.57 +        op->u.getdomaininfo.n_vcpu = vcpu_count;
    7.58  
    7.59 -        op->u.getdomaininfo.flags =
    7.60 +        op->u.getdomaininfo.flags = flags |
    7.61              (test_bit( DF_DYING,      &d->flags)  ? DOMFLAGS_DYING    : 0) |
    7.62              (test_bit( DF_CRASHED,    &d->flags)  ? DOMFLAGS_CRASHED  : 0) |
    7.63              (test_bit( DF_SHUTDOWN,   &d->flags)  ? DOMFLAGS_SHUTDOWN : 0) |
    7.64 -            flags;
    7.65 -
    7.66 -        op->u.getdomaininfo.flags |= 
    7.67              d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
    7.68  
    7.69 -        op->u.getdomaininfo.processors  = processors;
    7.70          op->u.getdomaininfo.tot_pages   = d->tot_pages;
    7.71          op->u.getdomaininfo.max_pages   = d->max_pages;
    7.72 -        op->u.getdomaininfo.n_vcpu      = d->shared_info->n_vcpu;
    7.73          op->u.getdomaininfo.shared_info_frame = 
    7.74              __pa(d->shared_info) >> PAGE_SHIFT;
    7.75  
    7.76 @@ -388,33 +374,29 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    7.77          struct vcpu_guest_context *c;
    7.78          struct domain             *d;
    7.79          struct exec_domain        *ed;
    7.80 -        int active_index = 0; 
    7.81 -        int exec_domain_index;
    7.82  
    7.83 -        exec_domain_index = op->u.getvcpucontext.exec_domain;
    7.84          d = find_domain_by_id(op->u.getvcpucontext.domain);
    7.85 -
    7.86          if ( d == NULL )
    7.87          {
    7.88              ret = -ESRCH;
    7.89              break;
    7.90          }
    7.91  
    7.92 -        if ( (exec_domain_index >= MAX_VIRT_CPUS) )
    7.93 +        if ( op->u.getvcpucontext.exec_domain >= MAX_VIRT_CPUS )
    7.94          {
    7.95              ret = -EINVAL;
    7.96 +            put_domain(d);
    7.97              break;
    7.98          }
    7.99          
   7.100 -        for_each_exec_domain(d, ed)
   7.101 +        ed = d->exec_domain[op->u.getvcpucontext.exec_domain];
   7.102 +        if ( ed == NULL )
   7.103          {
   7.104 -            if ( exec_domain_index == active_index ) 
   7.105 -            {
   7.106 -                op->u.getvcpucontext.exec_domain = ed->id;
   7.107 -                break;
   7.108 -            }
   7.109 -            active_index++;
   7.110 +            ret = -ESRCH;
   7.111 +            put_domain(d);
   7.112 +            break;
   7.113          }
   7.114 +
   7.115          op->u.getvcpucontext.cpu_time = ed->cpu_time;
   7.116  
   7.117          if ( op->u.getvcpucontext.ctxt != NULL )
     8.1 --- a/xen/include/public/dom0_ops.h	Wed May 11 15:05:07 2005 +0000
     8.2 +++ b/xen/include/public/dom0_ops.h	Wed May 11 17:36:38 2005 +0000
     8.3 @@ -70,7 +70,6 @@ typedef struct {
     8.4  typedef struct {
     8.5      /* IN variables. */
     8.6      domid_t  domain;                  /* NB. IN/OUT variable. */
     8.7 -    u16      n_active_vcpus;          /* # of vcpus currently active */
     8.8      /* OUT variables. */
     8.9  #define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
    8.10  #define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
    8.11 @@ -83,7 +82,6 @@ typedef struct {
    8.12  #define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code.  */
    8.13  #define DOMFLAGS_SHUTDOWNSHIFT 16
    8.14      u32      flags;
    8.15 -    u32      processors;	
    8.16      memory_t tot_pages;
    8.17      memory_t max_pages;
    8.18      memory_t shared_info_frame;       /* MFN of shared_info struct */
    8.19 @@ -348,12 +346,11 @@ typedef struct {
    8.20  #define DOM0_GETVCPUCONTEXT      37
    8.21  typedef struct {
    8.22      domid_t domain;                   /* domain to be affected */
    8.23 -    u16     exec_domain;              /* NB. IN: nth active cpu / OUT: actual cpu # */
    8.24 +    u16     exec_domain;              /* vcpu # */
    8.25      vcpu_guest_context_t *ctxt;       /* NB. IN/OUT variable. */
    8.26      u64     cpu_time;                 
    8.27  } dom0_getvcpucontext_t;
    8.28  
    8.29 -
    8.30  typedef struct {
    8.31      u32 cmd;
    8.32      u32 interface_version; /* DOM0_INTERFACE_VERSION */