[RFC PATCH 26/35] Add Xen subarch reboot support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +++ linus-2.6/drivers/xen/core/reboot.c
> @@ -0,0 +1,232 @@
> +#define __KERNEL_SYSCALLS__
> +#include <linux/version.h>
> +#include <linux/kernel.h>
> +#include <linux/mm.h>
> +#include <linux/unistd.h>
> +#include <linux/module.h>
> +#include <linux/reboot.h>
> +#include <linux/sysrq.h>
> +#include <linux/stringify.h>
> +#include <linux/syscalls.h>
> +#include <linux/cpu.h>
> +#include <linux/kthread.h>

Do you really need all these includes?

> +#if defined(__i386__) || defined(__x86_64__)

aka CONFIG_X86

> +/*
> + * Power off function, if any
> + */
> +void (*pm_power_off)(void);
> +EXPORT_SYMBOL(pm_power_off);
> +#endif
> +
> +extern void ctrl_alt_del(void);


That should be in some header

> +
> +/* Ignore multiple shutdown requests. */
> +static int shutting_down = SHUTDOWN_INVALID;
> +static void __shutdown_handler(void *unused);
> +static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
> +
> +static int shutdown_process(void *__unused)
> +{
> +	static char *envp[] = { "HOME=/", "TERM=linux",
> +				"PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
> +	static char *poweroff_argv[] = { "/sbin/poweroff", NULL };

This should be configurable, probably in a sysctl

> +
> +	if ((shutting_down == SHUTDOWN_POWEROFF) ||
> +	    (shutting_down == SHUTDOWN_HALT)) {
> +		if (execve(poweroff_argv[0], poweroff_argv, envp) < 0) {
> +			sys_reboot(LINUX_REBOOT_MAGIC1,
> +				   LINUX_REBOOT_MAGIC2,
> +				   LINUX_REBOOT_CMD_POWER_OFF,
> +				   NULL);
> +		}
> +	}
> +
> +	shutting_down = SHUTDOWN_INVALID; /* could try again */
> +
> +	return 0;
> +}
> +
> +static void __shutdown_handler(void *unused)
> +{
> +	int err = 0;
> +
> +	if (shutting_down != SHUTDOWN_SUSPEND)


The whole shutting_down handling looks racy. Probably needs some locking?

-Andi

[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux