[patch 33/47] kernel: Shutdown Actions Interface
From: Michael Holzheu <[EMAIL PROTECTED]> In case of a kernel panic it is currently possible to specify that a dump should be created, the system should be rebooted or stopped. Virtual sysfs files under the directory /sys/firmware/ are used for that configuration. In addition to that, there are kernel parameters 'vmhalt', 'vmpoff' and 'vmpanic', which can be used to specify z/VM commands, which are automatically executed in case of halt, power off or a kernel panic. This patch combines both functionalities and allows to specify the z/VM CP commands also via sysfs attributes. In addition to that, it enhances the existing handling of shutdown triggers (e.g. halt or panic) and associated shutdown actions (e.g. dump or reipl) and makes it more flexible. Signed-off-by: Michael Holzheu <[EMAIL PROTECTED]> Signed-off-by: Martin Schwidefsky <[EMAIL PROTECTED]> --- arch/s390/kernel/ipl.c | 923 ++- arch/s390/kernel/setup.c | 103 - arch/s390/kernel/smp.c | 27 - include/asm-s390/ipl.h |4 4 files changed, 595 insertions(+), 462 deletions(-) Index: quilt-2.6/arch/s390/kernel/ipl.c === --- quilt-2.6.orig/arch/s390/kernel/ipl.c +++ quilt-2.6/arch/s390/kernel/ipl.c @@ -2,7 +2,7 @@ * arch/s390/kernel/ipl.c *ipl/reipl/dump support for Linux on s390. * - *Copyright (C) IBM Corp. 2005,2006 + *Copyright IBM Corp. 2005,2007 *Author(s): Michael Holzheu <[EMAIL PROTECTED]> * Heiko Carstens <[EMAIL PROTECTED]> * Volker Sameske <[EMAIL PROTECTED]> @@ -31,6 +31,43 @@ #define IPL_FCP_DUMP_STR "fcp_dump" #define IPL_NSS_STR"nss" +#define DUMP_CCW_STR "ccw" +#define DUMP_FCP_STR "fcp" +#define DUMP_NONE_STR "none" + +/* + * Four shutdown trigger types are supported: + * - panic + * - halt + * - power off + * - reipl + */ +#define ON_PANIC_STR "on_panic" +#define ON_HALT_STR"on_halt" +#define ON_POFF_STR"on_poff" +#define ON_REIPL_STR "on_reboot" + +struct shutdown_action; +struct shutdown_trigger { + char *name; + struct shutdown_action *action; +}; + +/* + * Five shutdown action types are supported: + */ +#define SHUTDOWN_ACTION_IPL_STR"ipl" +#define SHUTDOWN_ACTION_REIPL_STR "reipl" +#define SHUTDOWN_ACTION_DUMP_STR "dump" +#define SHUTDOWN_ACTION_VMCMD_STR "vmcmd" +#define SHUTDOWN_ACTION_STOP_STR "stop" + +struct shutdown_action { + char *name; + void (*fn) (struct shutdown_trigger *trigger); + int (*init) (void); +}; + static char *ipl_type_str(enum ipl_type type) { switch (type) { @@ -54,10 +91,6 @@ enum dump_type { DUMP_TYPE_FCP = 4, }; -#define DUMP_NONE_STR "none" -#define DUMP_CCW_STR"ccw" -#define DUMP_FCP_STR"fcp" - static char *dump_type_str(enum dump_type type) { switch (type) { @@ -99,30 +132,6 @@ enum dump_method { DUMP_METHOD_FCP_DIAG, }; -enum shutdown_action { - SHUTDOWN_REIPL, - SHUTDOWN_DUMP, - SHUTDOWN_STOP, -}; - -#define SHUTDOWN_REIPL_STR "reipl" -#define SHUTDOWN_DUMP_STR "dump" -#define SHUTDOWN_STOP_STR "stop" - -static char *shutdown_action_str(enum shutdown_action action) -{ - switch (action) { - case SHUTDOWN_REIPL: - return SHUTDOWN_REIPL_STR; - case SHUTDOWN_DUMP: - return SHUTDOWN_DUMP_STR; - case SHUTDOWN_STOP: - return SHUTDOWN_STOP_STR; - default: - return NULL; - } -} - static int diag308_set_works = 0; static int reipl_capabilities = IPL_TYPE_UNKNOWN; @@ -140,8 +149,6 @@ static enum dump_method dump_method = DU static struct ipl_parameter_block *dump_block_fcp; static struct ipl_parameter_block *dump_block_ccw; -static enum shutdown_action on_panic_action = SHUTDOWN_STOP; - static struct sclp_ipl_info sclp_ipl_info; int diag308(unsigned long subcode, void *addr) @@ -200,8 +207,8 @@ static ssize_t sys_##_prefix##_##_name## static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \ const char *buf, size_t len)\ { \ - if (sscanf(buf, _fmt_in, _value) != 1) \ - return -EINVAL; \ + strncpy(_value, buf, sizeof(_value) - 1); \ + strstrip(_value); \ return len; \ } \ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \ @@ -240,33 +247,6 @@ static __init enum ipl_type get_ipl_type return IPL_TYPE_FCP; } -void __init
[patch 33/47] kernel: Shutdown Actions Interface
From: Michael Holzheu [EMAIL PROTECTED] In case of a kernel panic it is currently possible to specify that a dump should be created, the system should be rebooted or stopped. Virtual sysfs files under the directory /sys/firmware/ are used for that configuration. In addition to that, there are kernel parameters 'vmhalt', 'vmpoff' and 'vmpanic', which can be used to specify z/VM commands, which are automatically executed in case of halt, power off or a kernel panic. This patch combines both functionalities and allows to specify the z/VM CP commands also via sysfs attributes. In addition to that, it enhances the existing handling of shutdown triggers (e.g. halt or panic) and associated shutdown actions (e.g. dump or reipl) and makes it more flexible. Signed-off-by: Michael Holzheu [EMAIL PROTECTED] Signed-off-by: Martin Schwidefsky [EMAIL PROTECTED] --- arch/s390/kernel/ipl.c | 923 ++- arch/s390/kernel/setup.c | 103 - arch/s390/kernel/smp.c | 27 - include/asm-s390/ipl.h |4 4 files changed, 595 insertions(+), 462 deletions(-) Index: quilt-2.6/arch/s390/kernel/ipl.c === --- quilt-2.6.orig/arch/s390/kernel/ipl.c +++ quilt-2.6/arch/s390/kernel/ipl.c @@ -2,7 +2,7 @@ * arch/s390/kernel/ipl.c *ipl/reipl/dump support for Linux on s390. * - *Copyright (C) IBM Corp. 2005,2006 + *Copyright IBM Corp. 2005,2007 *Author(s): Michael Holzheu [EMAIL PROTECTED] * Heiko Carstens [EMAIL PROTECTED] * Volker Sameske [EMAIL PROTECTED] @@ -31,6 +31,43 @@ #define IPL_FCP_DUMP_STR fcp_dump #define IPL_NSS_STRnss +#define DUMP_CCW_STR ccw +#define DUMP_FCP_STR fcp +#define DUMP_NONE_STR none + +/* + * Four shutdown trigger types are supported: + * - panic + * - halt + * - power off + * - reipl + */ +#define ON_PANIC_STR on_panic +#define ON_HALT_STRon_halt +#define ON_POFF_STRon_poff +#define ON_REIPL_STR on_reboot + +struct shutdown_action; +struct shutdown_trigger { + char *name; + struct shutdown_action *action; +}; + +/* + * Five shutdown action types are supported: + */ +#define SHUTDOWN_ACTION_IPL_STRipl +#define SHUTDOWN_ACTION_REIPL_STR reipl +#define SHUTDOWN_ACTION_DUMP_STR dump +#define SHUTDOWN_ACTION_VMCMD_STR vmcmd +#define SHUTDOWN_ACTION_STOP_STR stop + +struct shutdown_action { + char *name; + void (*fn) (struct shutdown_trigger *trigger); + int (*init) (void); +}; + static char *ipl_type_str(enum ipl_type type) { switch (type) { @@ -54,10 +91,6 @@ enum dump_type { DUMP_TYPE_FCP = 4, }; -#define DUMP_NONE_STR none -#define DUMP_CCW_STRccw -#define DUMP_FCP_STRfcp - static char *dump_type_str(enum dump_type type) { switch (type) { @@ -99,30 +132,6 @@ enum dump_method { DUMP_METHOD_FCP_DIAG, }; -enum shutdown_action { - SHUTDOWN_REIPL, - SHUTDOWN_DUMP, - SHUTDOWN_STOP, -}; - -#define SHUTDOWN_REIPL_STR reipl -#define SHUTDOWN_DUMP_STR dump -#define SHUTDOWN_STOP_STR stop - -static char *shutdown_action_str(enum shutdown_action action) -{ - switch (action) { - case SHUTDOWN_REIPL: - return SHUTDOWN_REIPL_STR; - case SHUTDOWN_DUMP: - return SHUTDOWN_DUMP_STR; - case SHUTDOWN_STOP: - return SHUTDOWN_STOP_STR; - default: - return NULL; - } -} - static int diag308_set_works = 0; static int reipl_capabilities = IPL_TYPE_UNKNOWN; @@ -140,8 +149,6 @@ static enum dump_method dump_method = DU static struct ipl_parameter_block *dump_block_fcp; static struct ipl_parameter_block *dump_block_ccw; -static enum shutdown_action on_panic_action = SHUTDOWN_STOP; - static struct sclp_ipl_info sclp_ipl_info; int diag308(unsigned long subcode, void *addr) @@ -200,8 +207,8 @@ static ssize_t sys_##_prefix##_##_name## static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \ const char *buf, size_t len)\ { \ - if (sscanf(buf, _fmt_in, _value) != 1) \ - return -EINVAL; \ + strncpy(_value, buf, sizeof(_value) - 1); \ + strstrip(_value); \ return len; \ } \ static struct subsys_attribute sys_##_prefix##_##_name##_attr = \ @@ -240,33 +247,6 @@ static __init enum ipl_type get_ipl_type return IPL_TYPE_FCP; } -void __init setup_ipl_info(void) -{ - ipl_info.type = get_ipl_type();