ia64/xen-unstable

changeset 1309:2d0465936335

bitkeeper revision 1.869 (40859ef9aFFaEpjd21oxJfT1ZpI7MQ)

domain = -2 for most recently created domain
author ach61@labyrinth.cl.cam.ac.uk
date Tue Apr 20 22:06:49 2004 +0000 (2004-04-20)
parents 0eac2a407546
children a5796a62cdca
files xen/arch/i386/pdb-stub.c xen/common/domain.c xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/i386/pdb-stub.c	Mon Apr 19 14:54:52 2004 +0000
     1.2 +++ b/xen/arch/i386/pdb-stub.c	Tue Apr 20 22:06:49 2004 +0000
     1.3 @@ -344,7 +344,21 @@ pdb_process_command (char *ptr, struct p
     1.4  	{
     1.5  	    struct task_struct *p;
     1.6  
     1.7 -	    p = find_domain_by_id(pdb_ctx.domain);
     1.8 +	    if (pdb_ctx.domain == -2)
     1.9 +	    {
    1.10 +	        p = find_last_domain();
    1.11 +	    }
    1.12 +	    else
    1.13 +	    {
    1.14 +	        p = find_domain_by_id(pdb_ctx.domain);
    1.15 +	    }
    1.16 +	    if (p == NULL)
    1.17 +	    {
    1.18 +	        printk ("pdb error: unknown domain [0x%x]\n", pdb_ctx.domain);
    1.19 +	        strcpy (pdb_out_buffer, "E01");
    1.20 +		pdb_ctx.domain = -1;
    1.21 +		goto exit;
    1.22 +	    }
    1.23  	    if (p->mm.shadow_mode)
    1.24  	        pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table);
    1.25  	    else
    1.26 @@ -357,6 +371,14 @@ pdb_process_command (char *ptr, struct p
    1.27  	    unsigned long domain_ptbr;
    1.28  
    1.29  	    p = find_domain_by_id(pdb_ctx.domain);
    1.30 +	    if (p == NULL)
    1.31 +	    {
    1.32 +	        printk ("pdb error: unknown domain [0x%x][0x%x]\n", 
    1.33 +			pdb_ctx.domain, pdb_ctx.process);
    1.34 +	        strcpy (pdb_out_buffer, "E01");
    1.35 +		pdb_ctx.domain = -1;
    1.36 +		goto exit;
    1.37 +	    }
    1.38  	    if (p->mm.shadow_mode)
    1.39  	        domain_ptbr = pagetable_val(p->mm.shadow_table);
    1.40  	    else
    1.41 @@ -364,7 +386,7 @@ pdb_process_command (char *ptr, struct p
    1.42  	    put_task_struct(p);
    1.43  
    1.44  	    pdb_ctx.ptbr = domain_ptbr;
    1.45 -	    /* pdb_ctx.ptbr = pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process); */
    1.46 +	    /*pdb_ctx.ptbr=pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process);*/
    1.47  	}
    1.48  
    1.49  	pdb_ctx.valid = 0;
    1.50 @@ -634,6 +656,7 @@ pdb_process_command (char *ptr, struct p
    1.51      }
    1.52      }
    1.53  
    1.54 +exit:
    1.55      /* reply to the request */
    1.56      pdb_put_packet (pdb_out_buffer, ack);
    1.57  
     2.1 --- a/xen/common/domain.c	Mon Apr 19 14:54:52 2004 +0000
     2.2 +++ b/xen/common/domain.c	Tue Apr 20 22:06:49 2004 +0000
     2.3 @@ -60,6 +60,7 @@ struct task_struct *do_createdomain(domi
     2.4  
     2.5      p->domain    = dom_id;
     2.6      p->processor = cpu;
     2.7 +    p->create_time = NOW();
     2.8  
     2.9      memcpy(&p->thread, &idle0_task.thread, sizeof(p->thread));
    2.10  
    2.11 @@ -141,6 +142,28 @@ struct task_struct *find_domain_by_id(do
    2.12  }
    2.13  
    2.14  
    2.15 +/* return the most recent domain created */
    2.16 +struct task_struct *find_last_domain(void)
    2.17 +{
    2.18 +    struct task_struct *p, *plast;
    2.19 +    unsigned long flags;
    2.20 +
    2.21 +    read_lock_irqsave(&tasklist_lock, flags);
    2.22 +    plast = task_list;
    2.23 +    p = plast->next_list;
    2.24 +    while ( p != NULL )
    2.25 +    {
    2.26 +	if ( p->create_time > plast->create_time )
    2.27 +	    plast = p;
    2.28 +        p = p->next_list;
    2.29 +    }
    2.30 +    get_task_struct(plast);
    2.31 +    read_unlock_irqrestore(&tasklist_lock, flags);
    2.32 +
    2.33 +    return plast;
    2.34 +}
    2.35 +
    2.36 +
    2.37  void kill_domain_with_errmsg(const char *err)
    2.38  {
    2.39      printk("DOM%llu FATAL ERROR: %s\n", current->domain, err);
     3.1 --- a/xen/include/xen/sched.h	Mon Apr 19 14:54:52 2004 +0000
     3.2 +++ b/xen/include/xen/sched.h	Tue Apr 20 22:06:49 2004 +0000
     3.3 @@ -150,6 +150,7 @@ struct task_struct
     3.4      mm_segment_t addr_limit;
     3.5  
     3.6      char name[MAX_DOMAIN_NAME];
     3.7 +    s_time_t create_time;
     3.8  
     3.9      struct thread_struct thread;
    3.10      struct task_struct *next_list, *next_hash;
    3.11 @@ -239,6 +240,7 @@ extern int construct_dom0(struct task_st
    3.12  extern int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *);
    3.13  
    3.14  struct task_struct *find_domain_by_id(domid_t dom);
    3.15 +struct task_struct *find_last_domain(void);
    3.16  extern void release_task(struct task_struct *);
    3.17  extern void __kill_domain(struct task_struct *p);
    3.18  extern void kill_domain(void);