aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/domain.c
diff options
context:
space:
mode:
authorkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>2003-02-24 17:56:39 +0000
committerkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>2003-02-24 17:56:39 +0000
commit2b1c361bee7ecb1dc6d68b8ddadbaaf85f03587f (patch)
tree515cb0e4c0f07cd3720525dc69cc6a6e850655ff /xen/common/domain.c
parent704f9b012699742823381c48873de8e18f660366 (diff)
downloadxen-2b1c361bee7ecb1dc6d68b8ddadbaaf85f03587f.tar.gz
xen-2b1c361bee7ecb1dc6d68b8ddadbaaf85f03587f.tar.bz2
xen-2b1c361bee7ecb1dc6d68b8ddadbaaf85f03587f.zip
bitkeeper revision 1.96 (3e5a5cd7-6YCRyx9vceH0j_ljuOe-Q)
hypervisor-ifs: new file Many files: Allow forced killing of domains with 'kill_domain -f'. task_structs now reference counted. .del-network.h~823d28e86ebe9d9b: Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/network.h .del-hypervisor-if.h~d1f6a7dd4307ddfe: Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/hypervisor-if.h .del-block.h~81aa08f4e2012da6: Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/block.h
Diffstat (limited to 'xen/common/domain.c')
-rw-r--r--xen/common/domain.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 5e862ada6d..89efe59f64 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -40,6 +40,8 @@ struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu)
if (!p) goto newdomain_out;
memset(p, 0, sizeof(*p));
+ atomic_set(&p->refcnt, 1);
+
p->domain = dom_id;
p->processor = cpu;
@@ -82,6 +84,7 @@ struct task_struct *find_domain_by_id(unsigned int dom)
read_lock_irq(&tasklist_lock);
do {
if ( (p->domain == dom) ) {
+ get_task_struct(p); /* increment the refcnt for caller */
read_unlock_irq(&tasklist_lock);
return (p);
}
@@ -117,27 +120,27 @@ void kill_domain(void)
}
-long kill_other_domain(unsigned int dom)
+long kill_other_domain(unsigned int dom, int force)
{
- struct task_struct *p = &idle0_task;
+ struct task_struct *p;
unsigned long cpu_mask = 0;
- long ret = -ESRCH;
- read_lock_irq(&tasklist_lock);
- do {
- if ( p->domain == dom )
- {
- cpu_mask = mark_guest_event(p, _EVENT_DIE);
- ret = 0;
- break;
- }
- }
- while ( (p = p->next_task) != &idle0_task );
- read_unlock_irq(&tasklist_lock);
+ p = find_domain_by_id(dom);
+ if ( p == NULL ) return -ESRCH;
- hyp_event_notify(cpu_mask);
+ if ( force )
+ {
+ cpu_mask = mark_hyp_event(p, _HYP_EVENT_DIE);
+ hyp_event_notify(cpu_mask);
+ }
+ else
+ {
+ cpu_mask = mark_guest_event(p, _EVENT_DIE);
+ guest_event_notify(cpu_mask);
+ }
- return ret;
+ free_task_struct(p);
+ return 0;
}