direct-io.hg

view extras/mini-os/events.c @ 7172:9c6b39746b78

Fix localhost live migration. We were overvigorously wiping out the store
entries when a domain closed and on save, which meant that the /vm entries
disappeared when a localhost migration occurred. XendCheckpoint has had extra
exception handling and logging added. It also now calls back through
XendDomain.restore_,which has the correct locking semantics to prevent race
conditions during migration.

Added assertions to XendCheckpoint to ensure that the channels are set after
XendDomainInfo.restore. I don't see why they would not be, and the old code
meant that in the case that they were not, IntroduceDomain would not be called
on the new domain, breaking Xend restart.

relocate calls through XendDomain.domain_restore_fd rather than directly to
XendCheckpoint to isolate XendCheckpoint from the rest of the world, and to
allow XendDomain to pass itself into XendCheckpoint for a callback.

Simplify the XendCheckpoint / XendDomainInfo interlock, giving only two
states, OK and TERMINATED. If XendCheckpoint asks for a suspend, but sees a
shutdown, it is valid for it to proceed -- either way the domain has stopped.
Higher level tools may wish to disallow this, but at the very least, there is
no sense in waiting for a suspend that will never come.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Tue Oct 04 11:14:50 2005 +0100 (2005-10-04)
parents 06d84bf87159
children 198828cc103b
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
4 * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
5 ****************************************************************************
6 *
7 * File: events.c
8 * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
9 * Changes: Grzegorz Milos (gm281@cam.ac.uk)
10 *
11 * Date: Jul 2003, changes Jun 2005
12 *
13 * Environment: Xen Minimal OS
14 * Description: Deals with events recieved on event channels
15 *
16 ****************************************************************************
17 */
19 #include <os.h>
20 #include <mm.h>
21 #include <hypervisor.h>
22 #include <events.h>
23 #include <lib.h>
25 static ev_action_t ev_actions[NR_EVS];
26 void default_handler(int port, struct pt_regs *regs);
29 /*
30 * Demux events to different handlers.
31 */
32 int do_event(u32 port, struct pt_regs *regs)
33 {
34 ev_action_t *action;
35 if (port >= NR_EVS) {
36 printk("Port number too large: %d\n", port);
37 return 0;
38 }
40 action = &ev_actions[port];
41 action->count++;
43 if (!action->handler)
44 goto out;
46 if (action->status & EVS_DISABLED)
47 goto out;
49 /* call the handler */
50 action->handler(port, regs);
52 clear_evtchn(port);
54 out:
55 return 1;
57 }
59 void bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *) )
60 {
61 if(ev_actions[port].handler)
62 printk("WARN: Handler for port %d already registered, replacing\n",
63 port);
65 ev_actions[port].handler = handler;
66 ev_actions[port].status &= ~EVS_DISABLED;
68 /* Finally unmask the port */
69 unmask_evtchn(port);
70 }
72 int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) )
73 {
74 evtchn_op_t op;
75 int ret = 0;
77 /* Try to bind the virq to a port */
78 op.cmd = EVTCHNOP_bind_virq;
79 op.u.bind_virq.virq = virq;
81 if ( HYPERVISOR_event_channel_op(&op) != 0 )
82 {
83 ret = 1;
84 printk("Failed to bind virtual IRQ %d\n", virq);
85 goto out;
86 }
87 bind_evtchn(op.u.bind_virq.port, handler);
88 out:
89 return ret;
90 }
94 /*
95 * Initially all events are without a handler and disabled
96 */
97 void init_events(void)
98 {
99 int i;
101 /* inintialise event handler */
102 for ( i = 0; i < NR_EVS; i++ )
103 {
104 ev_actions[i].status = EVS_DISABLED;
105 ev_actions[i].handler = default_handler;
106 }
107 }
109 void default_handler(int port, struct pt_regs *regs) {
110 printk("[Port %d] - event received\n", port);
111 }