ia64/xen-unstable

changeset 12061:6ad98bc30cb4

Clean up recent changes to reboot code. This fixes PV save/restore.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Oct 31 15:54:03 2006 +0000 (2006-10-31)
parents ada9ee6ce078
children b6de59741161
files linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c linux-2.6-xen-sparse/drivers/xen/core/reboot.c linux-2.6-xen-sparse/include/xen/reboot.h tools/python/xen/xend/image.py
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Tue Oct 31 15:04:05 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Tue Oct 31 15:54:03 2006 +0000
     1.3 @@ -18,7 +18,6 @@
     1.4  #include <xen/gnttab.h>
     1.5  #include <xen/xencons.h>
     1.6  #include <xen/cpu_hotplug.h>
     1.7 -#include <xen/reboot.h>
     1.8  
     1.9  #if defined(__i386__) || defined(__x86_64__)
    1.10  
    1.11 @@ -125,7 +124,7 @@ static void post_suspend(void)
    1.12  
    1.13  #endif
    1.14  
    1.15 -int __do_suspend(void *ignore)
    1.16 +int __xen_suspend(void)
    1.17  {
    1.18  	int err;
    1.19  
    1.20 @@ -164,8 +163,6 @@ int __do_suspend(void *ignore)
    1.21  	 */
    1.22  	HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
    1.23  
    1.24 -	shutting_down = SHUTDOWN_INVALID;
    1.25 -
    1.26  	post_suspend();
    1.27  
    1.28  	gnttab_resume();
    1.29 @@ -186,17 +183,3 @@ int __do_suspend(void *ignore)
    1.30  
    1.31  	return err;
    1.32  }
    1.33 -
    1.34 -int kthread_create_on_cpu(int (*f)(void *arg),
    1.35 -				 void *arg,
    1.36 -				 const char *name,
    1.37 -				 int cpu)
    1.38 -{
    1.39 -	struct task_struct *p;
    1.40 -	p = kthread_create(f, arg, name);
    1.41 -	if (IS_ERR(p))
    1.42 -		return PTR_ERR(p);
    1.43 -	kthread_bind(p, cpu);
    1.44 -	wake_up_process(p);
    1.45 -	return 0;
    1.46 -}
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Oct 31 15:04:05 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Oct 31 15:54:03 2006 +0000
     2.3 @@ -8,13 +8,31 @@
     2.4  #include <asm/hypervisor.h>
     2.5  #include <xen/xenbus.h>
     2.6  #include <linux/kthread.h>
     2.7 -#include <xen/reboot.h>
     2.8  
     2.9  MODULE_LICENSE("Dual BSD/GPL");
    2.10  
    2.11 +#define SHUTDOWN_INVALID  -1
    2.12 +#define SHUTDOWN_POWEROFF  0
    2.13 +#define SHUTDOWN_SUSPEND   2
    2.14 +/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only
    2.15 + * report a crash, not be instructed to crash!
    2.16 + * HALT is the same as POWEROFF, as far as we're concerned.  The tools use
    2.17 + * the distinction when we return the reason code to them.
    2.18 + */
    2.19 +#define SHUTDOWN_HALT      4
    2.20 +
    2.21 +/* Ignore multiple shutdown requests. */
    2.22 +static int shutting_down = SHUTDOWN_INVALID;
    2.23 +
    2.24  static void __shutdown_handler(void *unused);
    2.25  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
    2.26  
    2.27 +#ifdef CONFIG_XEN
    2.28 +int __xen_suspend(void);
    2.29 +#else
    2.30 +#define __xen_suspend() 0
    2.31 +#endif
    2.32 +
    2.33  static int shutdown_process(void *__unused)
    2.34  {
    2.35  	static char *envp[] = { "HOME=/", "TERM=linux",
    2.36 @@ -41,21 +59,36 @@ static int shutdown_process(void *__unus
    2.37  	return 0;
    2.38  }
    2.39  
    2.40 +static int xen_suspend(void *__unused)
    2.41 +{
    2.42 +	__xen_suspend();
    2.43 +	shutting_down = SHUTDOWN_INVALID;
    2.44 +	return 0;
    2.45 +}
    2.46 +
    2.47 +static int kthread_create_on_cpu(int (*f)(void *arg),
    2.48 +				 void *arg,
    2.49 +				 const char *name,
    2.50 +				 int cpu)
    2.51 +{
    2.52 +	struct task_struct *p;
    2.53 +	p = kthread_create(f, arg, name);
    2.54 +	if (IS_ERR(p))
    2.55 +		return PTR_ERR(p);
    2.56 +	kthread_bind(p, cpu);
    2.57 +	wake_up_process(p);
    2.58 +	return 0;
    2.59 +}
    2.60  
    2.61  static void __shutdown_handler(void *unused)
    2.62  {
    2.63  	int err;
    2.64  
    2.65 -#ifdef CONFIG_XEN
    2.66  	if (shutting_down != SHUTDOWN_SUSPEND)
    2.67  		err = kernel_thread(shutdown_process, NULL,
    2.68  				    CLONE_FS | CLONE_FILES);
    2.69  	else
    2.70 -		err = kthread_create_on_cpu(__do_suspend, NULL, "suspend", 0);
    2.71 -#else /* !CONFIG_XEN */
    2.72 -		err = kernel_thread(shutdown_process, NULL,
    2.73 -				    CLONE_FS | CLONE_FILES);
    2.74 -#endif /* !CONFIG_XEN */
    2.75 +		err = kthread_create_on_cpu(xen_suspend, NULL, "suspend", 0);
    2.76  
    2.77  	if (err < 0) {
    2.78  		printk(KERN_WARNING "Error creating shutdown process (%d): "
    2.79 @@ -71,8 +104,6 @@ static void shutdown_handler(struct xenb
    2.80  	struct xenbus_transaction xbt;
    2.81  	int err;
    2.82  
    2.83 -	int cad_pid = 1; 
    2.84 -
    2.85  	if (shutting_down != SHUTDOWN_INVALID)
    2.86  		return;
    2.87  
    2.88 @@ -98,7 +129,7 @@ static void shutdown_handler(struct xenb
    2.89  	if (strcmp(str, "poweroff") == 0)
    2.90  		shutting_down = SHUTDOWN_POWEROFF;
    2.91  	else if (strcmp(str, "reboot") == 0)
    2.92 -		kill_proc(cad_pid, SIGINT, 1);
    2.93 +		kill_proc(1, SIGINT, 1); /* interrupt init */
    2.94  	else if (strcmp(str, "suspend") == 0)
    2.95  		shutting_down = SHUTDOWN_SUSPEND;
    2.96  	else if (strcmp(str, "halt") == 0)
     3.1 --- a/linux-2.6-xen-sparse/include/xen/reboot.h	Tue Oct 31 15:04:05 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,19 +0,0 @@
     3.4 -#define SHUTDOWN_INVALID  -1
     3.5 -#define SHUTDOWN_POWEROFF  0
     3.6 -#define SHUTDOWN_SUSPEND   2
     3.7 -/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only
     3.8 - * report a crash, not be instructed to crash!
     3.9 - * HALT is the same as POWEROFF, as far as we're concerned.  The tools use
    3.10 - * the distinction when we return the reason code to them.
    3.11 - */
    3.12 -#define SHUTDOWN_HALT      4
    3.13 -
    3.14 -/******************************************************************************
    3.15 - * Stop/pickle callback handling.
    3.16 - */
    3.17 -
    3.18 -/* Ignore multiple shutdown requests. */
    3.19 -static int shutting_down = SHUTDOWN_INVALID;
    3.20 -
    3.21 -int kthread_create_on_cpu(int (*f)(void *), void *, const char *, int);
    3.22 -int __do_suspend(void *);
     4.1 --- a/tools/python/xen/xend/image.py	Tue Oct 31 15:04:05 2006 +0000
     4.2 +++ b/tools/python/xen/xend/image.py	Tue Oct 31 15:54:03 2006 +0000
     4.3 @@ -462,7 +462,7 @@ class HVMImageHandler(ImageHandler):
     4.4  
     4.5      def register_reboot_feature_watch(self):
     4.6          """ add xen store watch on control/feature-reboot """
     4.7 -        self.rebootModuleWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
     4.8 +        self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
     4.9                                           self.hvm_reboot_feature)
    4.10          log.debug("hvm reboot feature watch registered")
    4.11