ia64/xen-unstable

changeset 1510:50ebf96e89bf

bitkeeper revision 1.987 (40d595643wZIEtMwb3hHvNEGMAu8gQ)

Fix the getdomaininfo dom0_op.
author kaf24@scramble.cl.cam.ac.uk
date Sun Jun 20 13:47:16 2004 +0000 (2004-06-20)
parents 4fe70431c2d1
children 3bcb3ae4e038
files tools/examples/xc_dom_control.py tools/xc/lib/xc.h tools/xc/lib/xc_domain.c tools/xc/lib/xc_linux_build.c tools/xc/lib/xc_netbsd_build.c tools/xc/py/Xc.c tools/xenmgr/lib/XendDomainInfo.py xen/common/dom0_ops.c xen/common/domain.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/xen/sched.h
line diff
     1.1 --- a/tools/examples/xc_dom_control.py	Sun Jun 20 09:01:56 2004 +0000
     1.2 +++ b/tools/examples/xc_dom_control.py	Sun Jun 20 13:47:16 2004 +0000
     1.3 @@ -88,10 +88,13 @@ elif cmd == 'list':
     1.4      print 'Dom  Name             Mem(kb)  CPU  State  Time(ms)'
     1.5      for domain in xc.domain_getinfo():
     1.6  
     1.7 -	run = (domain['running'] and 'r') or '-'		# domain['running'] ? run='r' : run='-'
     1.8 -	stop = (domain['stopped'] and 's') or '-'		# domain['stopped'] ? stop='s': stop='-'
     1.9 +	run   = (domain['running'] and 'r') or '-'
    1.10 +        block = (domain['blocked'] and 'b') or '-'
    1.11 +	stop  = (domain['stopped'] and 's') or '-'
    1.12 +	susp  = (domain['suspended'] and 'S') or '-'
    1.13 +	crash = (domain['crashed'] and 'c') or '-'
    1.14  
    1.15 -        domain['state'] = run + stop
    1.16 +        domain['state'] = run + block + stop + susp + crash
    1.17          domain['cpu_time'] = domain['cpu_time']/1e6
    1.18  
    1.19          print "%(dom)-4d %(name)-16s %(mem_kb)7d %(cpu)3d %(state)5s %(cpu_time)8d" % domain
     2.1 --- a/tools/xc/lib/xc.h	Sun Jun 20 09:01:56 2004 +0000
     2.2 +++ b/tools/xc/lib/xc.h	Sun Jun 20 13:47:16 2004 +0000
     2.3 @@ -25,8 +25,8 @@ int xc_interface_close(int xc_handle);
     2.4  typedef struct {
     2.5      u32           domid;
     2.6      unsigned int  cpu;
     2.7 -    int           has_cpu;
     2.8 -    int           stopped;
     2.9 +    unsigned int  dying:1, crashed:1, suspended:1, 
    2.10 +                  stopped:1, blocked:1, running:1;
    2.11      unsigned long nr_pages;
    2.12      unsigned long shared_info_frame;
    2.13      u64           cpu_time;
     3.1 --- a/tools/xc/lib/xc_domain.c	Sun Jun 20 09:01:56 2004 +0000
     3.2 +++ b/tools/xc/lib/xc_domain.c	Sun Jun 20 13:47:16 2004 +0000
     3.3 @@ -93,11 +93,13 @@ int xc_domain_getinfo(int xc_handle,
     3.4  
     3.5          info->cpu     =
     3.6              (op.u.getdomaininfo.flags>>DOMFLAGS_CPUSHIFT) & DOMFLAGS_CPUMASK;
     3.7 -        info->has_cpu =
     3.8 -            (op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) == DOMSTATE_RUNNING;
     3.9 -        info->stopped = 
    3.10 -            (op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK)
    3.11 -            == DOMSTATE_SUSPENDED;
    3.12 +
    3.13 +        info->dying     = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
    3.14 +        info->crashed   = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
    3.15 +        info->suspended = (op.u.getdomaininfo.flags & DOMFLAGS_SUSPENDED);
    3.16 +        info->stopped   = (op.u.getdomaininfo.flags & DOMFLAGS_STOPPED);
    3.17 +        info->blocked   = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
    3.18 +        info->running   = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
    3.19  
    3.20          info->nr_pages = op.u.getdomaininfo.tot_pages;
    3.21          info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
     4.1 --- a/tools/xc/lib/xc_linux_build.c	Sun Jun 20 09:01:56 2004 +0000
     4.2 +++ b/tools/xc/lib/xc_linux_build.c	Sun Jun 20 13:47:16 2004 +0000
     4.3 @@ -436,7 +436,7 @@ int xc_linux_build(int xc_handle,
     4.4          PERROR("Could not get info on domain");
     4.5          goto error_out;
     4.6      }
     4.7 -    if ( ((op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) != DOMSTATE_PAUSED) ||
     4.8 +    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
     4.9           (ctxt->pt_base != 0) )
    4.10      {
    4.11          ERROR("Domain is already constructed");
     5.1 --- a/tools/xc/lib/xc_netbsd_build.c	Sun Jun 20 09:01:56 2004 +0000
     5.2 +++ b/tools/xc/lib/xc_netbsd_build.c	Sun Jun 20 13:47:16 2004 +0000
     5.3 @@ -258,7 +258,7 @@ int xc_netbsd_build(int xc_handle,
     5.4          PERROR("Could not get info on domain");
     5.5          goto error_out;
     5.6      }
     5.7 -    if ( ((op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) != DOMSTATE_PAUSED) ||
     5.8 +    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
     5.9           (op.u.getdomaininfo.ctxt->pt_base != 0) )
    5.10      {
    5.11          ERROR("Domain is already constructed");
     6.1 --- a/tools/xc/py/Xc.c	Sun Jun 20 09:01:56 2004 +0000
     6.2 +++ b/tools/xc/py/Xc.c	Sun Jun 20 13:47:16 2004 +0000
     6.3 @@ -167,14 +167,18 @@ static PyObject *pyxc_domain_getinfo(PyO
     6.4          PyList_SetItem(
     6.5              list, i, 
     6.6              Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
     6.7 -                          "dom",      info[i].domid,
     6.8 -                          "cpu",      info[i].cpu,
     6.9 -                          "running",  info[i].has_cpu,
    6.10 -                          "stopped",  info[i].stopped,
    6.11 -                          "mem_kb",   info[i].nr_pages*4,
    6.12 -                          "cpu_time", info[i].cpu_time,
    6.13 -                          "name",     info[i].name,
    6.14 -                          "maxmem_kb",info[i].max_memkb
    6.15 +                          "dom",       info[i].domid,
    6.16 +                          "cpu",       info[i].cpu,
    6.17 +                          "dying",     info[i].dying,
    6.18 +                          "crashed",   info[i].crashed,
    6.19 +                          "suspended", info[i].suspended,
    6.20 +                          "stopped",   info[i].stopped,
    6.21 +                          "blocked",   info[i].blocked,
    6.22 +                          "running",   info[i].running,
    6.23 +                          "mem_kb",    info[i].nr_pages*4,
    6.24 +                          "cpu_time",  info[i].cpu_time,
    6.25 +                          "name",      info[i].name,
    6.26 +                          "maxmem_kb", info[i].max_memkb
    6.27                  ));
    6.28      }
    6.29  
    6.30 @@ -1053,8 +1057,12 @@ static PyMethodDef pyxc_methods[] = {
    6.31        "         domain-id space was reached.\n"
    6.32        " dom      [int]: Identifier of domain to which this info pertains\n"
    6.33        " cpu      [int]:  CPU to which this domain is bound\n"
    6.34 +      " dying    [int]:  Bool - is the domain dying?\n"
    6.35 +      " crashed  [int]:  Bool - has the domain crashed?\n"
    6.36 +      " suspended[int]:  Bool - has the domain suspended itself?\n"
    6.37 +      " stopped  [int]:  Bool - is the domain stopped by control software?\n"
    6.38 +      " blocked  [int]:  Bool - is the domain blocked waiting for an event?\n"
    6.39        " running  [int]:  Bool - is the domain currently running?\n"
    6.40 -      " stopped  [int]:  Bool - is the domain suspended?\n"
    6.41        " mem_kb   [int]:  Memory reservation, in kilobytes\n"
    6.42        " cpu_time [long]: CPU time consumed, in nanoseconds\n"
    6.43        " name     [str]:  Identifying name\n" },
     7.1 --- a/tools/xenmgr/lib/XendDomainInfo.py	Sun Jun 20 09:01:56 2004 +0000
     7.2 +++ b/tools/xenmgr/lib/XendDomainInfo.py	Sun Jun 20 13:47:16 2004 +0000
     7.3 @@ -111,9 +111,12 @@ class XendDomainInfo:
     7.4                  ['name', self.name],
     7.5                  ['memory', self.memory] ]
     7.6          if self.info:
     7.7 -            run = (self.info['running'] and 'r') or '-'
     7.8 -            stop = (self.info['stopped'] and 's') or '-'
     7.9 -            state = run + stop
    7.10 +            run   = (self.info['running'] and 'r') or '-'
    7.11 +            block = (self.info['blocked'] and 'b') or '-'
    7.12 +            stop  = (self.info['stopped'] and 's') or '-'
    7.13 +            susp  = (self.info['suspended'] and 'S') or '-'
    7.14 +            crash = (self.info['crashed'] and 'c') or '-'
    7.15 +            state = run + block + stop + susp + crash
    7.16              sxpr.append(['cpu', self.info['cpu']])
    7.17              sxpr.append(['state', state])
    7.18              sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
     8.1 --- a/xen/common/dom0_ops.c	Sun Jun 20 09:01:56 2004 +0000
     8.2 +++ b/xen/common/dom0_ops.c	Sun Jun 20 13:47:16 2004 +0000
     8.3 @@ -46,7 +46,7 @@ static void read_msr_for(void *unused)
     8.4  long do_dom0_op(dom0_op_t *u_dom0_op)
     8.5  {
     8.6      long ret = 0;
     8.7 -    dom0_op_t curop,*op=&curop;
     8.8 +    dom0_op_t curop, *op = &curop;
     8.9  
    8.10      if ( !IS_PRIV(current) )
    8.11          return -EPERM;
    8.12 @@ -70,12 +70,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    8.13  
    8.14      case DOM0_BUILDDOMAIN:
    8.15      {
    8.16 -        struct domain * p = find_domain_by_id(op->u.builddomain.domain);
    8.17 +        struct domain *d = find_domain_by_id(op->u.builddomain.domain);
    8.18          ret = -EINVAL;
    8.19 -        if ( p != NULL )
    8.20 +        if ( d != NULL )
    8.21          {
    8.22 -            ret = final_setup_guestos(p, &op->u.builddomain);
    8.23 -            put_domain(p);
    8.24 +            ret = final_setup_guestos(d, &op->u.builddomain);
    8.25 +            put_domain(d);
    8.26          }
    8.27      }
    8.28      break;
    8.29 @@ -112,11 +112,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    8.30  
    8.31      case DOM0_CREATEDOMAIN:
    8.32      {
    8.33 -        struct domain *p;
    8.34 +        struct domain    *d;
    8.35          static domid_t    domnr = 0;
    8.36          static spinlock_t domnr_lock = SPIN_LOCK_UNLOCKED;
    8.37 -        unsigned int pro;
    8.38 -        domid_t dom;
    8.39 +        unsigned int      pro;
    8.40 +        domid_t           dom;
    8.41 +
    8.42          ret = -ENOMEM;
    8.43  
    8.44          /* Search for an unused domain identifier. */
    8.45 @@ -128,36 +129,36 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    8.46                  dom = domnr = 1;
    8.47              spin_unlock(&domnr_lock);
    8.48  
    8.49 -            if ( (p = find_domain_by_id(dom)) == NULL )
    8.50 +            if ( (d = find_domain_by_id(dom)) == NULL )
    8.51                  break;
    8.52 -            put_domain(p);
    8.53 +            put_domain(d);
    8.54          }
    8.55  
    8.56 -        if (op->u.createdomain.cpu == -1 )
    8.57 +        if ( op->u.createdomain.cpu == -1 )
    8.58              pro = (unsigned int)dom % smp_num_cpus;
    8.59          else
    8.60              pro = op->u.createdomain.cpu % smp_num_cpus;
    8.61  
    8.62 -        p = do_createdomain(dom, pro);
    8.63 -        if ( p == NULL ) 
    8.64 +        d = do_createdomain(dom, pro);
    8.65 +        if ( d == NULL ) 
    8.66              break;
    8.67  
    8.68          if ( op->u.createdomain.name[0] )
    8.69          {
    8.70 -            strncpy(p->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
    8.71 -            p->name[MAX_DOMAIN_NAME - 1] = '\0';
    8.72 +            strncpy(d->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
    8.73 +            d->name[MAX_DOMAIN_NAME - 1] = '\0';
    8.74          }
    8.75  
    8.76 -        ret = alloc_new_dom_mem(p, op->u.createdomain.memory_kb);
    8.77 +        ret = alloc_new_dom_mem(d, op->u.createdomain.memory_kb);
    8.78          if ( ret != 0 ) 
    8.79          {
    8.80 -            domain_kill(p);
    8.81 +            domain_kill(d);
    8.82              break;
    8.83          }
    8.84  
    8.85          ret = 0;
    8.86          
    8.87 -        op->u.createdomain.domain = p->domain;
    8.88 +        op->u.createdomain.domain = d->domain;
    8.89          copy_to_user(u_dom0_op, op, sizeof(*op));
    8.90      }
    8.91      break;
    8.92 @@ -187,26 +188,26 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    8.93              ret = -EINVAL;
    8.94          else
    8.95          {
    8.96 -            struct domain * p = find_domain_by_id(dom);
    8.97 +            struct domain *d = find_domain_by_id(dom);
    8.98              int cpu = op->u.pincpudomain.cpu;
    8.99              
   8.100              ret = -ESRCH;
   8.101              
   8.102 -            if ( p != NULL )
   8.103 +            if ( d != NULL )
   8.104              {
   8.105                  if ( cpu == -1 )
   8.106                  {
   8.107 -                    clear_bit(DF_CPUPINNED, &p->flags);
   8.108 +                    clear_bit(DF_CPUPINNED, &d->flags);
   8.109                  }
   8.110                  else
   8.111                  {
   8.112 -                    domain_pause(p);
   8.113 -                    set_bit(DF_CPUPINNED, &p->flags);
   8.114 +                    domain_pause(d);
   8.115 +                    set_bit(DF_CPUPINNED, &d->flags);
   8.116                      cpu = cpu % smp_num_cpus;
   8.117 -                    p->processor = cpu;
   8.118 -                    domain_unpause(p);
   8.119 +                    d->processor = cpu;
   8.120 +                    domain_unpause(d);
   8.121                  }
   8.122 -                put_domain(p);
   8.123 +                put_domain(d);
   8.124                  ret = 0;
   8.125              }      
   8.126          }
   8.127 @@ -230,20 +231,20 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.128      case DOM0_GETMEMLIST:
   8.129      {
   8.130          int i;
   8.131 -        struct domain *p = find_domain_by_id(op->u.getmemlist.domain);
   8.132 +        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
   8.133          unsigned long max_pfns = op->u.getmemlist.max_pfns;
   8.134          unsigned long pfn;
   8.135          unsigned long *buffer = op->u.getmemlist.buffer;
   8.136          struct list_head *list_ent;
   8.137  
   8.138          ret = -EINVAL;
   8.139 -        if ( p != NULL )
   8.140 +        if ( d != NULL )
   8.141          {
   8.142              ret = 0;
   8.143  
   8.144 -            spin_lock(&p->page_list_lock);
   8.145 -            list_ent = p->page_list.next;
   8.146 -            for ( i = 0; (i < max_pfns) && (list_ent != &p->page_list); i++ )
   8.147 +            spin_lock(&d->page_list_lock);
   8.148 +            list_ent = d->page_list.next;
   8.149 +            for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
   8.150              {
   8.151                  pfn = list_entry(list_ent, struct pfn_info, list) - 
   8.152                      frame_table;
   8.153 @@ -255,12 +256,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.154                  buffer++;
   8.155                  list_ent = frame_table[pfn].list.next;
   8.156              }
   8.157 -            spin_unlock(&p->page_list_lock);
   8.158 +            spin_unlock(&d->page_list_lock);
   8.159  
   8.160              op->u.getmemlist.num_pfns = i;
   8.161              copy_to_user(u_dom0_op, op, sizeof(*op));
   8.162              
   8.163 -            put_domain(p);
   8.164 +            put_domain(d);
   8.165          }
   8.166      }
   8.167      break;
   8.168 @@ -268,126 +269,118 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.169      case DOM0_GETDOMAININFO:
   8.170      { 
   8.171          full_execution_context_t *c;
   8.172 -        struct domain       *p;
   8.173 +        struct domain            *d;
   8.174          unsigned long             flags;
   8.175 -        int                       i, dump_state = 0;
   8.176 +        int                       i;
   8.177  
   8.178          read_lock_irqsave(&tasklist_lock, flags);
   8.179  
   8.180 -        for_each_domain ( p )
   8.181 +        for_each_domain ( d )
   8.182          {
   8.183 -            if ( p->domain >= op->u.getdomaininfo.domain )
   8.184 +            if ( d->domain >= op->u.getdomaininfo.domain )
   8.185                  break;
   8.186          }
   8.187  
   8.188 -        if ( p == NULL )
   8.189 +        if ( (d == NULL) || !get_domain(d) )
   8.190          {
   8.191 +            read_unlock_irqrestore(&tasklist_lock, flags);
   8.192              ret = -ESRCH;
   8.193 -            goto gdi_out;
   8.194 +            break;
   8.195          }
   8.196 -        else
   8.197 -        {
   8.198 -            op->u.getdomaininfo.domain = p->domain;
   8.199 -            strcpy(op->u.getdomaininfo.name, p->name);
   8.200 +
   8.201 +        op->u.getdomaininfo.flags =
   8.202 +            (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
   8.203 +
   8.204 +        domain_pause(d);
   8.205  
   8.206 -            /* These are kind of in order of 'importance'. */
   8.207 -            if ( test_bit(DF_CRASHED, &p->flags) )
   8.208 -                op->u.getdomaininfo.flags = DOMSTATE_CRASHED;
   8.209 -            else if ( test_bit(DF_SUSPENDED, &p->flags) )
   8.210 -                op->u.getdomaininfo.flags = DOMSTATE_SUSPENDED;
   8.211 -            else if ( test_bit(DF_STOPPED, &p->flags) )
   8.212 -                op->u.getdomaininfo.flags = DOMSTATE_PAUSED;
   8.213 -            else if ( test_bit(DF_BLOCKED, &p->flags) )
   8.214 -                op->u.getdomaininfo.flags = DOMSTATE_BLOCKED;
   8.215 -            else if ( test_bit(DF_RUNNING, &p->flags) )
   8.216 +        op->u.getdomaininfo.domain = d->domain;
   8.217 +        strcpy(op->u.getdomaininfo.name, d->name);
   8.218 +        
   8.219 +        op->u.getdomaininfo.flags |=
   8.220 +            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING     : 0) |
   8.221 +            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED   : 0) |
   8.222 +            (test_bit(DF_SUSPENDED, &d->flags) ? DOMFLAGS_SUSPENDED : 0) |
   8.223 +            (test_bit(DF_STOPPED,   &d->flags) ? DOMFLAGS_STOPPED   : 0) |
   8.224 +            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED   : 0);
   8.225 +
   8.226 +        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
   8.227 +        op->u.getdomaininfo.flags |= 
   8.228 +            d->suspend_code << DOMFLAGS_SUSPCODESHIFT;
   8.229 +
   8.230 +        op->u.getdomaininfo.tot_pages   = d->tot_pages;
   8.231 +        op->u.getdomaininfo.max_pages   = d->max_pages;
   8.232 +        op->u.getdomaininfo.cpu_time    = d->cpu_time;
   8.233 +        op->u.getdomaininfo.shared_info_frame = 
   8.234 +            __pa(d->shared_info) >> PAGE_SHIFT;
   8.235 +
   8.236 +        if ( op->u.getdomaininfo.ctxt != NULL )
   8.237 +        {
   8.238 +            if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
   8.239              {
   8.240 -                op->u.getdomaininfo.flags = DOMSTATE_RUNNING;
   8.241 -                dump_state = 1;
   8.242 -            }
   8.243 -            else
   8.244 -            {
   8.245 -                op->u.getdomaininfo.flags = DOMSTATE_RUNNABLE;
   8.246 -                dump_state = 1;
   8.247 +                ret = -ENOMEM;
   8.248 +                goto gdi_out;
   8.249              }
   8.250  
   8.251 -            op->u.getdomaininfo.flags |= p->processor << DOMFLAGS_CPUSHIFT;
   8.252 -            op->u.getdomaininfo.flags |= p->stop_code << DOMFLAGS_GUESTSHIFT;
   8.253 -
   8.254 -            op->u.getdomaininfo.tot_pages   = p->tot_pages;
   8.255 -            op->u.getdomaininfo.max_pages   = p->max_pages;
   8.256 -            op->u.getdomaininfo.cpu_time    = p->cpu_time;
   8.257 -            op->u.getdomaininfo.shared_info_frame = 
   8.258 -                __pa(p->shared_info) >> PAGE_SHIFT;
   8.259 -
   8.260 -            if ( dump_state && (op->u.getdomaininfo.ctxt != NULL) )
   8.261 -            {
   8.262 -                if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
   8.263 -                {
   8.264 -                    ret = -ENOMEM;
   8.265 -                    goto gdi_out;
   8.266 -                }
   8.267 -
   8.268 -                rmb(); /* Ensure that we see saved register state. */
   8.269 -                c->flags = 0;
   8.270 -                memcpy(&c->cpu_ctxt, 
   8.271 -                       &p->shared_info->execution_context,
   8.272 -                       sizeof(p->shared_info->execution_context));
   8.273 -                if ( test_bit(DF_DONEFPUINIT, &p->flags) )
   8.274 -                    c->flags |= ECF_I387_VALID;
   8.275 -                memcpy(&c->fpu_ctxt,
   8.276 -                       &p->thread.i387,
   8.277 -                       sizeof(p->thread.i387));
   8.278 -                memcpy(&c->trap_ctxt,
   8.279 -                       p->thread.traps,
   8.280 -                       sizeof(p->thread.traps));
   8.281 +            c->flags = 0;
   8.282 +            memcpy(&c->cpu_ctxt, 
   8.283 +                   &d->shared_info->execution_context,
   8.284 +                   sizeof(d->shared_info->execution_context));
   8.285 +            if ( test_bit(DF_DONEFPUINIT, &d->flags) )
   8.286 +                c->flags |= ECF_I387_VALID;
   8.287 +            memcpy(&c->fpu_ctxt,
   8.288 +                   &d->thread.i387,
   8.289 +                   sizeof(d->thread.i387));
   8.290 +            memcpy(&c->trap_ctxt,
   8.291 +                   d->thread.traps,
   8.292 +                   sizeof(d->thread.traps));
   8.293  #ifdef ARCH_HAS_FAST_TRAP
   8.294 -                if ( (p->thread.fast_trap_desc.a == 0) &&
   8.295 -                     (p->thread.fast_trap_desc.b == 0) )
   8.296 -                    c->fast_trap_idx = 0;
   8.297 -                else
   8.298 -                    c->fast_trap_idx = 
   8.299 -                        p->thread.fast_trap_idx;
   8.300 +            if ( (d->thread.fast_trap_desc.a == 0) &&
   8.301 +                 (d->thread.fast_trap_desc.b == 0) )
   8.302 +                c->fast_trap_idx = 0;
   8.303 +            else
   8.304 +                c->fast_trap_idx = 
   8.305 +                    d->thread.fast_trap_idx;
   8.306  #endif
   8.307 -                c->ldt_base = p->mm.ldt_base;
   8.308 -                c->ldt_ents = p->mm.ldt_ents;
   8.309 -                c->gdt_ents = 0;
   8.310 -                if ( GET_GDT_ADDRESS(p) == GDT_VIRT_START )
   8.311 -                {
   8.312 -                    for ( i = 0; i < 16; i++ )
   8.313 -                        c->gdt_frames[i] = 
   8.314 -                            l1_pgentry_to_pagenr(p->mm.perdomain_pt[i]);
   8.315 -                    c->gdt_ents = 
   8.316 -                        (GET_GDT_ENTRIES(p) + 1) >> 3;
   8.317 -                }
   8.318 -                c->guestos_ss  = p->thread.guestos_ss;
   8.319 -                c->guestos_esp = p->thread.guestos_sp;
   8.320 -                c->pt_base   = 
   8.321 -                    pagetable_val(p->mm.pagetable);
   8.322 -                memcpy(c->debugreg, 
   8.323 -                       p->thread.debugreg, 
   8.324 -                       sizeof(p->thread.debugreg));
   8.325 -                c->event_callback_cs  =
   8.326 -                    p->event_selector;
   8.327 -                c->event_callback_eip =
   8.328 -                    p->event_address;
   8.329 -                c->failsafe_callback_cs  = 
   8.330 -                    p->failsafe_selector;
   8.331 -                c->failsafe_callback_eip = 
   8.332 -                    p->failsafe_address;
   8.333 +            c->ldt_base = d->mm.ldt_base;
   8.334 +            c->ldt_ents = d->mm.ldt_ents;
   8.335 +            c->gdt_ents = 0;
   8.336 +            if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
   8.337 +            {
   8.338 +                for ( i = 0; i < 16; i++ )
   8.339 +                    c->gdt_frames[i] = 
   8.340 +                        l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
   8.341 +                c->gdt_ents = 
   8.342 +                    (GET_GDT_ENTRIES(d) + 1) >> 3;
   8.343 +            }
   8.344 +            c->guestos_ss  = d->thread.guestos_ss;
   8.345 +            c->guestos_esp = d->thread.guestos_sp;
   8.346 +            c->pt_base   = 
   8.347 +                pagetable_val(d->mm.pagetable);
   8.348 +            memcpy(c->debugreg, 
   8.349 +                   d->thread.debugreg, 
   8.350 +                   sizeof(d->thread.debugreg));
   8.351 +            c->event_callback_cs  =
   8.352 +                d->event_selector;
   8.353 +            c->event_callback_eip =
   8.354 +                d->event_address;
   8.355 +            c->failsafe_callback_cs  = 
   8.356 +                d->failsafe_selector;
   8.357 +            c->failsafe_callback_eip = 
   8.358 +                d->failsafe_address;
   8.359  
   8.360 -                if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
   8.361 -                    ret = -EINVAL;
   8.362 +            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
   8.363 +                ret = -EINVAL;
   8.364  
   8.365 -                if ( c != NULL )
   8.366 -                    kfree(c);
   8.367 -            }
   8.368 +            if ( c != NULL )
   8.369 +                kfree(c);
   8.370          }
   8.371  
   8.372          if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
   8.373              ret = -EINVAL;
   8.374  
   8.375      gdi_out:
   8.376 -        read_unlock_irqrestore(&tasklist_lock, flags);
   8.377 +        domain_unpause(d);
   8.378 +        put_domain(d);
   8.379      }
   8.380      break;
   8.381  
   8.382 @@ -396,17 +389,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.383          struct pfn_info *page;
   8.384          unsigned long pfn = op->u.getpageframeinfo.pfn;
   8.385          domid_t dom = op->u.getpageframeinfo.domain;
   8.386 -        struct domain *p;
   8.387 +        struct domain *d;
   8.388  
   8.389          ret = -EINVAL;
   8.390  
   8.391          if ( unlikely(pfn >= max_page) || 
   8.392 -             unlikely((p = find_domain_by_id(dom)) == NULL) )
   8.393 +             unlikely((d = find_domain_by_id(dom)) == NULL) )
   8.394              break;
   8.395  
   8.396          page = &frame_table[pfn];
   8.397  
   8.398 -        if ( likely(get_page(page, p)) )
   8.399 +        if ( likely(get_page(page, d)) )
   8.400          {
   8.401              ret = 0;
   8.402  
   8.403 @@ -434,7 +427,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.404              put_page(page);
   8.405          }
   8.406  
   8.407 -        put_domain(p);
   8.408 +        put_domain(d);
   8.409  
   8.410          copy_to_user(u_dom0_op, op, sizeof(*op));
   8.411      }
   8.412 @@ -544,13 +537,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.413  
   8.414      case DOM0_SHADOW_CONTROL:
   8.415      {
   8.416 -        struct domain *p; 
   8.417 +        struct domain *d; 
   8.418          ret = -ESRCH;
   8.419 -        p = find_domain_by_id( op->u.shadow_control.domain );
   8.420 -        if ( p )
   8.421 +        d = find_domain_by_id(op->u.shadow_control.domain);
   8.422 +        if ( d != NULL )
   8.423          {
   8.424 -            ret = shadow_mode_control(p, &op->u.shadow_control );
   8.425 -            put_domain(p);
   8.426 +            ret = shadow_mode_control(d, &op->u.shadow_control);
   8.427 +            put_domain(d);
   8.428              copy_to_user(u_dom0_op, op, sizeof(*op));
   8.429          } 
   8.430      }
   8.431 @@ -559,7 +552,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.432      case DOM0_SCHED_ID:
   8.433      {
   8.434          op->u.sched_id.sched_id = sched_id();
   8.435 -
   8.436          copy_to_user(u_dom0_op, op, sizeof(*op));
   8.437          ret = 0;        
   8.438      }
   8.439 @@ -567,48 +559,48 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.440  
   8.441      case DOM0_SETDOMAINNAME:
   8.442      {
   8.443 -        struct domain *p; 
   8.444 -        p = find_domain_by_id( op->u.setdomainname.domain );
   8.445 -        if ( p )
   8.446 +        struct domain *d; 
   8.447 +        ret = -ESRCH;
   8.448 +        d = find_domain_by_id( op->u.setdomainname.domain );
   8.449 +        if ( d != NULL )
   8.450          {
   8.451 -            strncpy(p->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
   8.452 -            put_domain(p);
   8.453 +            strncpy(d->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
   8.454 +            put_domain(d);
   8.455 +            ret = 0;
   8.456          }
   8.457 -        else 
   8.458 -            ret = -ESRCH;
   8.459      }
   8.460      break;
   8.461  
   8.462      case DOM0_SETDOMAININITIALMEM:
   8.463      {
   8.464 -        struct domain *p; 
   8.465 +        struct domain *d; 
   8.466          ret = -ESRCH;
   8.467 -        p = find_domain_by_id( op->u.setdomaininitialmem.domain );
   8.468 -        if ( p )
   8.469 +        d = find_domain_by_id(op->u.setdomaininitialmem.domain);
   8.470 +        if ( d != NULL )
   8.471          { 
   8.472              /* should only be used *before* domain is built. */
   8.473 -            if ( ! test_bit(DF_CONSTRUCTED, &p->flags) )
   8.474 +            if ( !test_bit(DF_CONSTRUCTED, &d->flags) )
   8.475                  ret = alloc_new_dom_mem( 
   8.476 -                    p, op->u.setdomaininitialmem.initial_memkb );
   8.477 +                    d, op->u.setdomaininitialmem.initial_memkb );
   8.478              else
   8.479                  ret = -EINVAL;
   8.480 -            put_domain(p);
   8.481 +            put_domain(d);
   8.482          }
   8.483      }
   8.484      break;
   8.485  
   8.486      case DOM0_SETDOMAINMAXMEM:
   8.487      {
   8.488 -        struct domain *p; 
   8.489 -        p = find_domain_by_id( op->u.setdomainmaxmem.domain );
   8.490 -        if ( p )
   8.491 +        struct domain *d; 
   8.492 +        ret = -ESRCH;
   8.493 +        d = find_domain_by_id( op->u.setdomainmaxmem.domain );
   8.494 +        if ( d != NULL )
   8.495          {
   8.496 -            p->max_pages = 
   8.497 +            d->max_pages = 
   8.498                  (op->u.setdomainmaxmem.max_memkb+PAGE_SIZE-1)>> PAGE_SHIFT;
   8.499 -            put_domain(p);
   8.500 +            put_domain(d);
   8.501 +            ret = 0;
   8.502          }
   8.503 -        else 
   8.504 -            ret = -ESRCH;
   8.505      }
   8.506      break;
   8.507  
   8.508 @@ -619,31 +611,31 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.509          int num = op->u.getpageframeinfo2.num;
   8.510          domid_t dom = op->u.getpageframeinfo2.domain;
   8.511          unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
   8.512 -        struct domain *p;
   8.513 +        struct domain *d;
   8.514          unsigned long l_arr[GPF2_BATCH];
   8.515          ret = -ESRCH;
   8.516  
   8.517 -        if ( unlikely((p = find_domain_by_id(dom)) == NULL) )
   8.518 +        if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
   8.519              break;
   8.520  
   8.521 -        if ( unlikely(num>1024) )
   8.522 +        if ( unlikely(num > 1024) )
   8.523          {
   8.524              ret = -E2BIG;
   8.525              break;
   8.526          }
   8.527   
   8.528 -        ret = 0;    
   8.529 -        for(n=0;n<num;)
   8.530 +        ret = 0;
   8.531 +        for( n = 0; n < num; )
   8.532          {
   8.533              int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
   8.534  
   8.535 -            if( copy_from_user( l_arr, &s_ptr[n], k*sizeof(unsigned long) ) )
   8.536 +            if ( copy_from_user(l_arr, &s_ptr[n], k*sizeof(unsigned long)) )
   8.537              {
   8.538                  ret = -EINVAL;
   8.539                  break;
   8.540              }
   8.541       
   8.542 -            for(j=0;j<k;j++)
   8.543 +            for( j = 0; j < k; j++ )
   8.544              {      
   8.545                  struct pfn_info *page;
   8.546                  unsigned long mfn = l_arr[j];
   8.547 @@ -653,7 +645,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.548  
   8.549                  page = &frame_table[mfn];
   8.550    
   8.551 -                if ( likely(get_page(page, p)) )
   8.552 +                if ( likely(get_page(page, d)) )
   8.553                  {
   8.554                      unsigned long type = 0;
   8.555                      switch( page->type_and_flags & PGT_type_mask )
   8.556 @@ -682,17 +674,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   8.557  
   8.558              }
   8.559  
   8.560 -            if( copy_to_user( &s_ptr[n], l_arr, k*sizeof(unsigned long) ) )
   8.561 +            if ( copy_to_user(&s_ptr[n], l_arr, k*sizeof(unsigned long)) )
   8.562              {
   8.563                  ret = -EINVAL;
   8.564                  break;
   8.565              }
   8.566  
   8.567 -            n+=j;     
   8.568 +            n += j;
   8.569          }
   8.570  
   8.571 -        put_domain(p);
   8.572 -
   8.573 +        put_domain(d);
   8.574      }
   8.575      break;
   8.576  
     9.1 --- a/xen/common/domain.c	Sun Jun 20 09:01:56 2004 +0000
     9.2 +++ b/xen/common/domain.c	Sun Jun 20 13:47:16 2004 +0000
     9.3 @@ -204,12 +204,7 @@ void domain_suspend(u8 reason)
     9.4          machine_restart(0);
     9.5      }
     9.6  
     9.7 -    current->stop_code = reason;
     9.8 -    memcpy(&current->shared_info->execution_context, 
     9.9 -           get_execution_context(), 
    9.10 -           sizeof(execution_context_t));
    9.11 -    unlazy_fpu(current);
    9.12 -    wmb(); /* All CPUs must see saved info when suspended. */
    9.13 +    current->suspend_code = reason;
    9.14      set_bit(DF_SUSPENDED, &current->flags);
    9.15  
    9.16      d = find_domain_by_id(0);
    10.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Sun Jun 20 09:01:56 2004 +0000
    10.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Sun Jun 20 13:47:16 2004 +0000
    10.3 @@ -83,18 +83,16 @@ typedef struct {
    10.4      /* IN variables. */
    10.5      domid_t  domain;                  /*  0 */ /* NB. IN/OUT variable. */
    10.6      /* OUT variables. */
    10.7 -#define DOMSTATE_CRASHED     0 /* Crashed domain; frozen for postmortem.     */
    10.8 -#define DOMSTATE_SUSPENDED   1 /* Domain voluntarily halted it execution.    */
    10.9 -#define DOMSTATE_PAUSED      2 /* Currently paused (forced non-schedulable). */
   10.10 -#define DOMSTATE_BLOCKED     3 /* Currently blocked pending a wake-up event. */
   10.11 -#define DOMSTATE_RUNNABLE    4 /* Currently runnable.                        */
   10.12 -#define DOMSTATE_RUNNING     5 /* Currently running.                         */
   10.13 -#define DOMFLAGS_STATEMASK   7 /* One of the DOMSTATE_??? values.            */
   10.14 -#define DOMFLAGS_STATESHIFT  0
   10.15 -#define DOMFLAGS_CPUMASK   255 /* CPU to which this domain is bound.         */
   10.16 -#define DOMFLAGS_CPUSHIFT    3
   10.17 -#define DOMFLAGS_GUESTMASK 255 /* DOMSTATE_STOPPED -> Guest-supplied code.   */
   10.18 -#define DOMFLAGS_GUESTSHIFT 11
   10.19 +#define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
   10.20 +#define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
   10.21 +#define DOMFLAGS_SUSPENDED (1<<2) /* Domain voluntarily halted it execution. */
   10.22 +#define DOMFLAGS_STOPPED   (1<<3) /* Currently stopped by control software.  */
   10.23 +#define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
   10.24 +#define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
   10.25 +#define DOMFLAGS_CPUMASK      255 /* CPU to which this domain is bound.      */
   10.26 +#define DOMFLAGS_CPUSHIFT       8
   10.27 +#define DOMFLAGS_SUSPCODEMASK 255 /* DOMSTATE_SUSPENDED guest-supplied code. */
   10.28 +#define DOMFLAGS_SUSPCODESHIFT 16
   10.29      u32      flags;                   /*  4 */
   10.30      u8       name[MAX_DOMAIN_NAME];   /*  8 */
   10.31      full_execution_context_t *ctxt;   /* 24 */ /* NB. IN/OUT variable. */
    11.1 --- a/xen/include/xen/sched.h	Sun Jun 20 09:01:56 2004 +0000
    11.2 +++ b/xen/include/xen/sched.h	Sun Jun 20 13:47:16 2004 +0000
    11.3 @@ -96,7 +96,7 @@ struct domain
    11.4  
    11.5      /* Scheduling. */
    11.6      struct list_head run_list;
    11.7 -    int              stop_code;     /* stop code from OS (if DF_STOPPED). */
    11.8 +    int              suspend_code;  /* code value from OS (if DF_SUSPENDED). */
    11.9      s_time_t         lastschd;      /* time this domain was last scheduled */
   11.10      s_time_t         lastdeschd;    /* time this domain was last descheduled */
   11.11      s_time_t         cpu_time;      /* total CPU time received till now */