debuggers.hg

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