debuggers.hg

view xen/common/notifier.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 1b49bfd3b0d7
children
line source
1 /******************************************************************************
2 * common/notifier.c
3 *
4 * Routines to manage notifier chains for passing status changes to any
5 * interested routines.
6 *
7 * Original code from Linux kernel 2.6.27 (Alan Cox <Alan.Cox@linux.org>)
8 */
10 #include <xen/config.h>
11 #include <xen/init.h>
12 #include <xen/notifier.h>
14 /**
15 * notifier_chain_register - Add notifier to a raw notifier chain
16 * @nh: Pointer to head of the raw notifier chain
17 * @n: New entry in notifier chain
18 *
19 * Adds a notifier to a raw notifier chain.
20 * All locking must be provided by the caller.
21 */
22 void notifier_chain_register(
23 struct notifier_head *nh, struct notifier_block *n)
24 {
25 struct list_head *chain = &nh->head.chain;
26 struct notifier_block *nb;
28 while ( chain->next != &nh->head.chain )
29 {
30 nb = list_entry(chain->next, struct notifier_block, chain);
31 if ( n->priority > nb->priority )
32 break;
33 chain = chain->next;
34 }
36 list_add(&n->chain, chain);
37 }
39 /**
40 * notifier_chain_unregister - Remove notifier from a raw notifier chain
41 * @nh: Pointer to head of the raw notifier chain
42 * @n: Entry to remove from notifier chain
43 *
44 * Removes a notifier from a raw notifier chain.
45 * All locking must be provided by the caller.
46 */
47 void notifier_chain_unregister(
48 struct notifier_head *nh, struct notifier_block *n)
49 {
50 list_del(&n->chain);
51 }
53 /**
54 * notifier_call_chain - Informs the registered notifiers about an event.
55 * @nh: Pointer to head of the raw notifier chain
56 * @val: Value passed unmodified to notifier function
57 * @v: Pointer passed unmodified to notifier function
58 * @pcursor: If non-NULL, position in chain to start from. Also updated on
59 * return to indicate how far notifications got before stopping.
60 *
61 * Calls each function in a notifier chain in turn. The functions run in an
62 * undefined context. All locking must be provided by the caller.
63 *
64 * If the return value of the notifier can be and'ed with %NOTIFY_STOP_MASK
65 * then notifier_call_chain() will return immediately, with teh return value of
66 * the notifier function which halted execution. Otherwise the return value is
67 * the return value of the last notifier function called.
68 */
69 int notifier_call_chain(
70 struct notifier_head *nh, unsigned long val, void *v,
71 struct notifier_block **pcursor)
72 {
73 int ret = NOTIFY_DONE;
74 struct list_head *cursor;
75 struct notifier_block *nb;
76 bool_t reverse = !!(val & NOTIFY_REVERSE);
78 cursor = &(pcursor && *pcursor ? *pcursor : &nh->head)->chain;
80 do {
81 cursor = reverse ? cursor->prev : cursor->next;
82 nb = list_entry(cursor, struct notifier_block, chain);
83 if ( cursor == &nh->head.chain )
84 break;
85 ret = nb->notifier_call(nb, val, v);
86 } while ( !(ret & NOTIFY_STOP_MASK) );
88 if ( pcursor )
89 *pcursor = nb;
91 return ret;
92 }