WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [RFC PATCH 26/35] Add Xen subarch reboot support

To: virtualization@xxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [RFC PATCH 26/35] Add Xen subarch reboot support
From: Andi Kleen <ak@xxxxxxx>
Date: Tue, 9 May 2006 19:02:30 +0200
Cc: Chris Wright <chrisw@xxxxxxxxxxxx>, Ian Pratt <ian.pratt@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
Delivery-date: Tue, 09 May 2006 10:03:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060509085158.282993000@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060509084945.373541000@xxxxxxxxxxxx> <20060509085158.282993000@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.9.1
> +++ 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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>