ia64/xen-unstable

changeset 12056:15b5cc51db30

Merge.
author Steven Smith <ssmith@xensource.com>
date Tue Oct 31 11:44:47 2006 +0000 (2006-10-31)
parents 159af40a1b37 e0942ef72b8e
children 1bf4f15c5141
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Tue Oct 31 11:44:28 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Tue Oct 31 11:44:47 2006 +0000
     1.3 @@ -9,5 +9,5 @@ obj-$(CONFIG_SYSFS)		+= hypervisor_sysfs
     1.4  obj-$(CONFIG_HOTPLUG_CPU)	+= cpu_hotplug.o
     1.5  obj-$(CONFIG_XEN_SYSFS)		+= xen_sysfs.o
     1.6  obj-$(CONFIG_XEN_SKBUFF)	+= skbuff.o
     1.7 -obj-$(CONFIG_XEN_REBOOT)	+= reboot.o
     1.8 +obj-$(CONFIG_XEN_REBOOT)	+= reboot.o machine_reboot.o
     1.9  obj-$(CONFIG_XEN_SMPBOOT)	+= smpboot.o
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Tue Oct 31 11:44:47 2006 +0000
     2.3 @@ -0,0 +1,202 @@
     2.4 +#define __KERNEL_SYSCALLS__
     2.5 +#include <linux/version.h>
     2.6 +#include <linux/kernel.h>
     2.7 +#include <linux/mm.h>
     2.8 +#include <linux/unistd.h>
     2.9 +#include <linux/module.h>
    2.10 +#include <linux/reboot.h>
    2.11 +#include <linux/sysrq.h>
    2.12 +#include <linux/stringify.h>
    2.13 +#include <asm/irq.h>
    2.14 +#include <asm/mmu_context.h>
    2.15 +#include <xen/evtchn.h>
    2.16 +#include <asm/hypervisor.h>
    2.17 +#include <xen/interface/dom0_ops.h>
    2.18 +#include <xen/xenbus.h>
    2.19 +#include <linux/cpu.h>
    2.20 +#include <linux/kthread.h>
    2.21 +#include <xen/gnttab.h>
    2.22 +#include <xen/xencons.h>
    2.23 +#include <xen/cpu_hotplug.h>
    2.24 +#include <xen/reboot.h>
    2.25 +
    2.26 +#if defined(__i386__) || defined(__x86_64__)
    2.27 +
    2.28 +/*
    2.29 + * Power off function, if any
    2.30 + */
    2.31 +void (*pm_power_off)(void);
    2.32 +EXPORT_SYMBOL(pm_power_off);
    2.33 +
    2.34 +void machine_emergency_restart(void)
    2.35 +{
    2.36 +	/* We really want to get pending console data out before we die. */
    2.37 +	xencons_force_flush();
    2.38 +	HYPERVISOR_shutdown(SHUTDOWN_reboot);
    2.39 +}
    2.40 +
    2.41 +void machine_restart(char * __unused)
    2.42 +{
    2.43 +	machine_emergency_restart();
    2.44 +}
    2.45 +
    2.46 +void machine_halt(void)
    2.47 +{
    2.48 +	machine_power_off();
    2.49 +}
    2.50 +
    2.51 +void machine_power_off(void)
    2.52 +{
    2.53 +	/* We really want to get pending console data out before we die. */
    2.54 +	xencons_force_flush();
    2.55 +	if (pm_power_off)
    2.56 +		pm_power_off();
    2.57 +	HYPERVISOR_shutdown(SHUTDOWN_poweroff);
    2.58 +}
    2.59 +
    2.60 +int reboot_thru_bios = 0;	/* for dmi_scan.c */
    2.61 +EXPORT_SYMBOL(machine_restart);
    2.62 +EXPORT_SYMBOL(machine_halt);
    2.63 +EXPORT_SYMBOL(machine_power_off);
    2.64 +
    2.65 +/* Ensure we run on the idle task page tables so that we will
    2.66 +   switch page tables before running user space. This is needed
    2.67 +   on architectures with separate kernel and user page tables
    2.68 +   because the user page table pointer is not saved/restored. */
    2.69 +static void switch_idle_mm(void)
    2.70 +{
    2.71 +	struct mm_struct *mm = current->active_mm;
    2.72 +
    2.73 +	if (mm == &init_mm)
    2.74 +		return;
    2.75 +
    2.76 +	atomic_inc(&init_mm.mm_count);
    2.77 +	switch_mm(mm, &init_mm, current);
    2.78 +	current->active_mm = &init_mm;
    2.79 +	mmdrop(mm);
    2.80 +}
    2.81 +
    2.82 +static void pre_suspend(void)
    2.83 +{
    2.84 +	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    2.85 +	clear_fixmap(FIX_SHARED_INFO);
    2.86 +
    2.87 +	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
    2.88 +	xen_start_info->console.domU.mfn =
    2.89 +		mfn_to_pfn(xen_start_info->console.domU.mfn);
    2.90 +}
    2.91 +
    2.92 +static void post_suspend(void)
    2.93 +{
    2.94 +	int i, j, k, fpp;
    2.95 +	extern unsigned long max_pfn;
    2.96 +	extern unsigned long *pfn_to_mfn_frame_list_list;
    2.97 +	extern unsigned long *pfn_to_mfn_frame_list[];
    2.98 +
    2.99 +	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
   2.100 +
   2.101 +	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   2.102 +
   2.103 +	memset(empty_zero_page, 0, PAGE_SIZE);
   2.104 +
   2.105 +	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
   2.106 +		virt_to_mfn(pfn_to_mfn_frame_list_list);
   2.107 +
   2.108 +	fpp = PAGE_SIZE/sizeof(unsigned long);
   2.109 +	for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
   2.110 +		if ((j % fpp) == 0) {
   2.111 +			k++;
   2.112 +			pfn_to_mfn_frame_list_list[k] =
   2.113 +				virt_to_mfn(pfn_to_mfn_frame_list[k]);
   2.114 +			j = 0;
   2.115 +		}
   2.116 +		pfn_to_mfn_frame_list[k][j] =
   2.117 +			virt_to_mfn(&phys_to_machine_mapping[i]);
   2.118 +	}
   2.119 +	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
   2.120 +}
   2.121 +
   2.122 +#else /* !(defined(__i386__) || defined(__x86_64__)) */
   2.123 +
   2.124 +#define switch_idle_mm()	((void)0)
   2.125 +#define mm_pin_all()		((void)0)
   2.126 +#define pre_suspend()		((void)0)
   2.127 +#define post_suspend()		((void)0)
   2.128 +
   2.129 +#endif
   2.130 +
   2.131 +int __do_suspend(void *ignore)
   2.132 +{
   2.133 +	int err;
   2.134 +
   2.135 +	extern void time_resume(void);
   2.136 +
   2.137 +	BUG_ON(smp_processor_id() != 0);
   2.138 +	BUG_ON(in_interrupt());
   2.139 +
   2.140 +#if defined(__i386__) || defined(__x86_64__)
   2.141 +	if (xen_feature(XENFEAT_auto_translated_physmap)) {
   2.142 +		printk(KERN_WARNING "Cannot suspend in "
   2.143 +		       "auto_translated_physmap mode.\n");
   2.144 +		return -EOPNOTSUPP;
   2.145 +	}
   2.146 +#endif
   2.147 +
   2.148 +	err = smp_suspend();
   2.149 +	if (err)
   2.150 +		return err;
   2.151 +
   2.152 +	xenbus_suspend();
   2.153 +
   2.154 +	preempt_disable();
   2.155 +
   2.156 +	mm_pin_all();
   2.157 +	local_irq_disable();
   2.158 +	preempt_enable();
   2.159 +
   2.160 +	gnttab_suspend();
   2.161 +
   2.162 +	pre_suspend();
   2.163 +
   2.164 +	/*
   2.165 +	 * We'll stop somewhere inside this hypercall. When it returns,
   2.166 +	 * we'll start resuming after the restore.
   2.167 +	 */
   2.168 +	HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
   2.169 +
   2.170 +	shutting_down = SHUTDOWN_INVALID;
   2.171 +
   2.172 +	post_suspend();
   2.173 +
   2.174 +	gnttab_resume();
   2.175 +
   2.176 +	irq_resume();
   2.177 +
   2.178 +	time_resume();
   2.179 +
   2.180 +	switch_idle_mm();
   2.181 +
   2.182 +	local_irq_enable();
   2.183 +
   2.184 +	xencons_resume();
   2.185 +
   2.186 +	xenbus_resume();
   2.187 +
   2.188 +	smp_resume();
   2.189 +
   2.190 +	return err;
   2.191 +}
   2.192 +
   2.193 +int kthread_create_on_cpu(int (*f)(void *arg),
   2.194 +				 void *arg,
   2.195 +				 const char *name,
   2.196 +				 int cpu)
   2.197 +{
   2.198 +	struct task_struct *p;
   2.199 +	p = kthread_create(f, arg, name);
   2.200 +	if (IS_ERR(p))
   2.201 +		return PTR_ERR(p);
   2.202 +	kthread_bind(p, cpu);
   2.203 +	wake_up_process(p);
   2.204 +	return 0;
   2.205 +}
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Oct 31 11:44:28 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Oct 31 11:44:47 2006 +0000
     3.3 @@ -1,216 +1,20 @@
     3.4  #define __KERNEL_SYSCALLS__
     3.5  #include <linux/version.h>
     3.6  #include <linux/kernel.h>
     3.7 -#include <linux/mm.h>
     3.8  #include <linux/unistd.h>
     3.9  #include <linux/module.h>
    3.10  #include <linux/reboot.h>
    3.11  #include <linux/sysrq.h>
    3.12 -#include <linux/stringify.h>
    3.13 -#include <asm/irq.h>
    3.14 -#include <asm/mmu_context.h>
    3.15 -#include <xen/evtchn.h>
    3.16  #include <asm/hypervisor.h>
    3.17 -#include <xen/interface/dom0_ops.h>
    3.18  #include <xen/xenbus.h>
    3.19 -#include <linux/cpu.h>
    3.20  #include <linux/kthread.h>
    3.21 -#include <xen/gnttab.h>
    3.22 -#include <xen/xencons.h>
    3.23 -#include <xen/cpu_hotplug.h>
    3.24 -
    3.25 -extern void ctrl_alt_del(void);
    3.26 -
    3.27 -#define SHUTDOWN_INVALID  -1
    3.28 -#define SHUTDOWN_POWEROFF  0
    3.29 -#define SHUTDOWN_SUSPEND   2
    3.30 -/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only
    3.31 - * report a crash, not be instructed to crash!
    3.32 - * HALT is the same as POWEROFF, as far as we're concerned.  The tools use
    3.33 - * the distinction when we return the reason code to them.
    3.34 - */
    3.35 -#define SHUTDOWN_HALT      4
    3.36 -
    3.37 -#if defined(__i386__) || defined(__x86_64__)
    3.38 -
    3.39 -/*
    3.40 - * Power off function, if any
    3.41 - */
    3.42 -void (*pm_power_off)(void);
    3.43 -EXPORT_SYMBOL(pm_power_off);
    3.44 +#include <xen/reboot.h>
    3.45  
    3.46 -void machine_emergency_restart(void)
    3.47 -{
    3.48 -	/* We really want to get pending console data out before we die. */
    3.49 -	xencons_force_flush();
    3.50 -	HYPERVISOR_shutdown(SHUTDOWN_reboot);
    3.51 -}
    3.52 -
    3.53 -void machine_restart(char * __unused)
    3.54 -{
    3.55 -	machine_emergency_restart();
    3.56 -}
    3.57 -
    3.58 -void machine_halt(void)
    3.59 -{
    3.60 -	machine_power_off();
    3.61 -}
    3.62 +MODULE_LICENSE("Dual BSD/GPL");
    3.63  
    3.64 -void machine_power_off(void)
    3.65 -{
    3.66 -	/* We really want to get pending console data out before we die. */
    3.67 -	xencons_force_flush();
    3.68 -	if (pm_power_off)
    3.69 -		pm_power_off();
    3.70 -	HYPERVISOR_shutdown(SHUTDOWN_poweroff);
    3.71 -}
    3.72 -
    3.73 -int reboot_thru_bios = 0;	/* for dmi_scan.c */
    3.74 -EXPORT_SYMBOL(machine_restart);
    3.75 -EXPORT_SYMBOL(machine_halt);
    3.76 -EXPORT_SYMBOL(machine_power_off);
    3.77 -
    3.78 -#endif /* defined(__i386__) || defined(__x86_64__) */
    3.79 -
    3.80 -/******************************************************************************
    3.81 - * Stop/pickle callback handling.
    3.82 - */
    3.83 -
    3.84 -/* Ignore multiple shutdown requests. */
    3.85 -static int shutting_down = SHUTDOWN_INVALID;
    3.86  static void __shutdown_handler(void *unused);
    3.87  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
    3.88  
    3.89 -#if defined(__i386__) || defined(__x86_64__)
    3.90 -
    3.91 -/* Ensure we run on the idle task page tables so that we will
    3.92 -   switch page tables before running user space. This is needed
    3.93 -   on architectures with separate kernel and user page tables
    3.94 -   because the user page table pointer is not saved/restored. */
    3.95 -static void switch_idle_mm(void)
    3.96 -{
    3.97 -	struct mm_struct *mm = current->active_mm;
    3.98 -
    3.99 -	if (mm == &init_mm)
   3.100 -		return;
   3.101 -
   3.102 -	atomic_inc(&init_mm.mm_count);
   3.103 -	switch_mm(mm, &init_mm, current);
   3.104 -	current->active_mm = &init_mm;
   3.105 -	mmdrop(mm);
   3.106 -}
   3.107 -
   3.108 -static void pre_suspend(void)
   3.109 -{
   3.110 -	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
   3.111 -	clear_fixmap(FIX_SHARED_INFO);
   3.112 -
   3.113 -	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
   3.114 -	xen_start_info->console.domU.mfn =
   3.115 -		mfn_to_pfn(xen_start_info->console.domU.mfn);
   3.116 -}
   3.117 -
   3.118 -static void post_suspend(void)
   3.119 -{
   3.120 -	int i, j, k, fpp;
   3.121 -	extern unsigned long max_pfn;
   3.122 -	extern unsigned long *pfn_to_mfn_frame_list_list;
   3.123 -	extern unsigned long *pfn_to_mfn_frame_list[];
   3.124 -
   3.125 -	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
   3.126 -
   3.127 -	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   3.128 -
   3.129 -	memset(empty_zero_page, 0, PAGE_SIZE);
   3.130 -
   3.131 -	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
   3.132 -		virt_to_mfn(pfn_to_mfn_frame_list_list);
   3.133 -
   3.134 -	fpp = PAGE_SIZE/sizeof(unsigned long);
   3.135 -	for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
   3.136 -		if ((j % fpp) == 0) {
   3.137 -			k++;
   3.138 -			pfn_to_mfn_frame_list_list[k] =
   3.139 -				virt_to_mfn(pfn_to_mfn_frame_list[k]);
   3.140 -			j = 0;
   3.141 -		}
   3.142 -		pfn_to_mfn_frame_list[k][j] =
   3.143 -			virt_to_mfn(&phys_to_machine_mapping[i]);
   3.144 -	}
   3.145 -	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
   3.146 -}
   3.147 -
   3.148 -#else /* !(defined(__i386__) || defined(__x86_64__)) */
   3.149 -
   3.150 -#define switch_idle_mm()	((void)0)
   3.151 -#define mm_pin_all()		((void)0)
   3.152 -#define pre_suspend()		((void)0)
   3.153 -#define post_suspend()		((void)0)
   3.154 -
   3.155 -#endif
   3.156 -
   3.157 -static int __do_suspend(void *ignore)
   3.158 -{
   3.159 -	int err;
   3.160 -
   3.161 -	extern void time_resume(void);
   3.162 -
   3.163 -	BUG_ON(smp_processor_id() != 0);
   3.164 -	BUG_ON(in_interrupt());
   3.165 -
   3.166 -#if defined(__i386__) || defined(__x86_64__)
   3.167 -	if (xen_feature(XENFEAT_auto_translated_physmap)) {
   3.168 -		printk(KERN_WARNING "Cannot suspend in "
   3.169 -		       "auto_translated_physmap mode.\n");
   3.170 -		return -EOPNOTSUPP;
   3.171 -	}
   3.172 -#endif
   3.173 -
   3.174 -	err = smp_suspend();
   3.175 -	if (err)
   3.176 -		return err;
   3.177 -
   3.178 -	xenbus_suspend();
   3.179 -
   3.180 -	preempt_disable();
   3.181 -
   3.182 -	mm_pin_all();
   3.183 -	local_irq_disable();
   3.184 -	preempt_enable();
   3.185 -
   3.186 -	gnttab_suspend();
   3.187 -
   3.188 -	pre_suspend();
   3.189 -
   3.190 -	/*
   3.191 -	 * We'll stop somewhere inside this hypercall. When it returns,
   3.192 -	 * we'll start resuming after the restore.
   3.193 -	 */
   3.194 -	HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
   3.195 -
   3.196 -	shutting_down = SHUTDOWN_INVALID;
   3.197 -
   3.198 -	post_suspend();
   3.199 -
   3.200 -	gnttab_resume();
   3.201 -
   3.202 -	irq_resume();
   3.203 -
   3.204 -	time_resume();
   3.205 -
   3.206 -	switch_idle_mm();
   3.207 -
   3.208 -	local_irq_enable();
   3.209 -
   3.210 -	xencons_resume();
   3.211 -
   3.212 -	xenbus_resume();
   3.213 -
   3.214 -	smp_resume();
   3.215 -
   3.216 -	return err;
   3.217 -}
   3.218 -
   3.219  static int shutdown_process(void *__unused)
   3.220  {
   3.221  	static char *envp[] = { "HOME=/", "TERM=linux",
   3.222 @@ -222,11 +26,13 @@ static int shutdown_process(void *__unus
   3.223  
   3.224  	if ((shutting_down == SHUTDOWN_POWEROFF) ||
   3.225  	    (shutting_down == SHUTDOWN_HALT)) {
   3.226 -		if (execve("/sbin/poweroff", poweroff_argv, envp) < 0) {
   3.227 +		if (call_usermodehelper_keys("/sbin/poweroff", poweroff_argv, envp, NULL, 0) < 0) {
   3.228 +#ifdef CONFIG_XEN
   3.229  			sys_reboot(LINUX_REBOOT_MAGIC1,
   3.230  				   LINUX_REBOOT_MAGIC2,
   3.231  				   LINUX_REBOOT_CMD_POWER_OFF,
   3.232  				   NULL);
   3.233 +#endif /* CONFIG_XEN */
   3.234  		}
   3.235  	}
   3.236  
   3.237 @@ -235,29 +41,21 @@ static int shutdown_process(void *__unus
   3.238  	return 0;
   3.239  }
   3.240  
   3.241 -static int kthread_create_on_cpu(int (*f)(void *arg),
   3.242 -				 void *arg,
   3.243 -				 const char *name,
   3.244 -				 int cpu)
   3.245 -{
   3.246 -	struct task_struct *p;
   3.247 -	p = kthread_create(f, arg, name);
   3.248 -	if (IS_ERR(p))
   3.249 -		return PTR_ERR(p);
   3.250 -	kthread_bind(p, cpu);
   3.251 -	wake_up_process(p);
   3.252 -	return 0;
   3.253 -}
   3.254  
   3.255  static void __shutdown_handler(void *unused)
   3.256  {
   3.257  	int err;
   3.258  
   3.259 +#ifdef CONFIG_XEN
   3.260  	if (shutting_down != SHUTDOWN_SUSPEND)
   3.261  		err = kernel_thread(shutdown_process, NULL,
   3.262  				    CLONE_FS | CLONE_FILES);
   3.263  	else
   3.264  		err = kthread_create_on_cpu(__do_suspend, NULL, "suspend", 0);
   3.265 +#else /* !CONFIG_XEN */
   3.266 +		err = kernel_thread(shutdown_process, NULL,
   3.267 +				    CLONE_FS | CLONE_FILES);
   3.268 +#endif /* !CONFIG_XEN */
   3.269  
   3.270  	if (err < 0) {
   3.271  		printk(KERN_WARNING "Error creating shutdown process (%d): "
   3.272 @@ -273,6 +71,8 @@ static void shutdown_handler(struct xenb
   3.273  	struct xenbus_transaction xbt;
   3.274  	int err;
   3.275  
   3.276 +	int cad_pid = 1; 
   3.277 +
   3.278  	if (shutting_down != SHUTDOWN_INVALID)
   3.279  		return;
   3.280  
   3.281 @@ -298,7 +98,7 @@ static void shutdown_handler(struct xenb
   3.282  	if (strcmp(str, "poweroff") == 0)
   3.283  		shutting_down = SHUTDOWN_POWEROFF;
   3.284  	else if (strcmp(str, "reboot") == 0)
   3.285 -		ctrl_alt_del();
   3.286 +		kill_proc(cad_pid, SIGINT, 1);
   3.287  	else if (strcmp(str, "suspend") == 0)
   3.288  		shutting_down = SHUTDOWN_SUSPEND;
   3.289  	else if (strcmp(str, "halt") == 0)
   3.290 @@ -364,10 +164,14 @@ static int setup_shutdown_watcher(struct
   3.291  	err = register_xenbus_watch(&shutdown_watch);
   3.292  	if (err)
   3.293  		printk(KERN_ERR "Failed to set shutdown watcher\n");
   3.294 +	else
   3.295 +		xenbus_write(XBT_NIL, "control", "feature-reboot", "1");
   3.296  
   3.297  	err = register_xenbus_watch(&sysrq_watch);
   3.298  	if (err)
   3.299  		printk(KERN_ERR "Failed to set sysrq watcher\n");
   3.300 +	else
   3.301 +		xenbus_write(XBT_NIL, "control", "feature-sysrq", "1");
   3.302  
   3.303  	return NOTIFY_DONE;
   3.304  }
   3.305 @@ -378,6 +182,7 @@ static int __init setup_shutdown_event(v
   3.306  		.notifier_call = setup_shutdown_watcher
   3.307  	};
   3.308  	register_xenstore_notifier(&xenstore_notifier);
   3.309 +
   3.310  	return 0;
   3.311  }
   3.312  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Oct 31 11:44:28 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Oct 31 11:44:47 2006 +0000
     4.3 @@ -166,9 +166,6 @@ netif_t *netif_alloc(domid_t domid, unsi
     4.4  	SET_ETHTOOL_OPS(dev, &network_ethtool_ops);
     4.5  
     4.6  	dev->tx_queue_len = netbk_queue_length;
     4.7 -	if (dev->tx_queue_len != 0)
     4.8 -		printk(KERN_WARNING "netbk: WARNING: device '%s' has non-zero "
     4.9 -		       "queue length (%lu)!\n", dev->name, dev->tx_queue_len);
    4.10  
    4.11  	/*
    4.12  	 * Initialise a dummy MAC address. We choose the numerically
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6-xen-sparse/include/xen/reboot.h	Tue Oct 31 11:44:47 2006 +0000
     5.3 @@ -0,0 +1,19 @@
     5.4 +#define SHUTDOWN_INVALID  -1
     5.5 +#define SHUTDOWN_POWEROFF  0
     5.6 +#define SHUTDOWN_SUSPEND   2
     5.7 +/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only
     5.8 + * report a crash, not be instructed to crash!
     5.9 + * HALT is the same as POWEROFF, as far as we're concerned.  The tools use
    5.10 + * the distinction when we return the reason code to them.
    5.11 + */
    5.12 +#define SHUTDOWN_HALT      4
    5.13 +
    5.14 +/******************************************************************************
    5.15 + * Stop/pickle callback handling.
    5.16 + */
    5.17 +
    5.18 +/* Ignore multiple shutdown requests. */
    5.19 +static int shutting_down = SHUTDOWN_INVALID;
    5.20 +
    5.21 +int kthread_create_on_cpu(int (*f)(void *), void *, const char *, int);
    5.22 +int __do_suspend(void *);
     6.1 --- a/tools/python/xen/xend/image.py	Tue Oct 31 11:44:28 2006 +0000
     6.2 +++ b/tools/python/xen/xend/image.py	Tue Oct 31 11:44:47 2006 +0000
     6.3 @@ -282,6 +282,7 @@ class HVMImageHandler(ImageHandler):
     6.4          log.debug("apic           = %d", self.apic)
     6.5  
     6.6          self.register_shutdown_watch()
     6.7 +        self.register_reboot_feature_watch()
     6.8  
     6.9          return xc.hvm_build(dom            = self.vm.getDomid(),
    6.10                              image          = self.kernel,
    6.11 @@ -416,6 +417,7 @@ class HVMImageHandler(ImageHandler):
    6.12  
    6.13      def destroy(self):
    6.14          self.unregister_shutdown_watch();
    6.15 +        self.unregister_reboot_feature_watch();
    6.16          if not self.pid:
    6.17              return
    6.18          os.kill(self.pid, signal.SIGKILL)
    6.19 @@ -458,6 +460,39 @@ class HVMImageHandler(ImageHandler):
    6.20  
    6.21          return 1 # Keep watching
    6.22  
    6.23 +    def register_reboot_feature_watch(self):
    6.24 +        """ add xen store watch on control/feature-reboot """
    6.25 +        self.rebootModuleWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
    6.26 +                                         self.hvm_reboot_feature)
    6.27 +        log.debug("hvm reboot feature watch registered")
    6.28 +
    6.29 +    def unregister_reboot_feature_watch(self):
    6.30 +        """Remove the watch on the control/feature-reboot, if any. Nothrow
    6.31 +        guarantee."""
    6.32 +
    6.33 +        try:
    6.34 +            if self.rebootFeatureWatch:
    6.35 +                self.rebootFeatureWatch.unwatch()
    6.36 +        except:
    6.37 +            log.exception("Unwatching hvm reboot feature watch failed.")
    6.38 +        self.rebootFeatureWatch = None
    6.39 +        log.debug("hvm reboot feature watch unregistered")
    6.40 +
    6.41 +    def hvm_reboot_feature(self, _):
    6.42 +        """ watch call back on node control/feature-reboot,
    6.43 +            if node changed, this function will be called
    6.44 +        """
    6.45 +        xd = xen.xend.XendDomain.instance()
    6.46 +        vm = xd.domain_lookup( self.vm.getDomid() )
    6.47 +
    6.48 +        status = vm.readDom('control/feature-reboot')
    6.49 +        log.debug("hvm_reboot_feature fired, module status=%s", status)
    6.50 +        if status == '1':
    6.51 +            self.unregister_shutdown_watch()
    6.52 +
    6.53 +        return 1 # Keep watching
    6.54 +
    6.55 +
    6.56  class IA64_HVM_ImageHandler(HVMImageHandler):
    6.57  
    6.58      ostype = "hvm"
     7.1 --- a/unmodified_drivers/linux-2.6/Makefile	Tue Oct 31 11:44:28 2006 +0000
     7.2 +++ b/unmodified_drivers/linux-2.6/Makefile	Tue Oct 31 11:44:47 2006 +0000
     7.3 @@ -4,3 +4,4 @@ obj-m += platform-pci/
     7.4  obj-m += xenbus/
     7.5  obj-m += blkfront/
     7.6  obj-m += netfront/
     7.7 +obj-m += util/
     8.1 --- a/unmodified_drivers/linux-2.6/mkbuildtree	Tue Oct 31 11:44:28 2006 +0000
     8.2 +++ b/unmodified_drivers/linux-2.6/mkbuildtree	Tue Oct 31 11:44:47 2006 +0000
     8.3 @@ -22,6 +22,7 @@ done
     8.4  ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
     8.5  ln -sf ${XL}/drivers/xen/core/features.c platform-pci
     8.6  ln -sf ${XL}/drivers/xen/core/xen_proc.c xenbus
     8.7 +ln -sf ${XL}/drivers/xen/core/reboot.c util
     8.8  
     8.9  mkdir -p include
    8.10  mkdir -p include/xen
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/unmodified_drivers/linux-2.6/util/Kbuild	Tue Oct 31 11:44:47 2006 +0000
     9.3 @@ -0,0 +1,3 @@
     9.4 +include $(M)/overrides.mk
     9.5 +
     9.6 +obj-m := reboot.o
    10.1 --- a/xen/common/sched_credit.c	Tue Oct 31 11:44:28 2006 +0000
    10.2 +++ b/xen/common/sched_credit.c	Tue Oct 31 11:44:47 2006 +0000
    10.3 @@ -82,19 +82,12 @@
    10.4          printk("\t%-30s = %u\n", #_X, CSCHED_STAT(_X));  \
    10.5      } while ( 0 );
    10.6  
    10.7 +/*
    10.8 + * Try and keep often cranked stats on top so they'll fit on one
    10.9 + * cache line.
   10.10 + */
   10.11  #define CSCHED_STATS_EXPAND_SCHED(_MACRO)   \
   10.12 -    _MACRO(vcpu_init)                       \
   10.13 -    _MACRO(vcpu_sleep)                      \
   10.14 -    _MACRO(vcpu_wake_running)               \
   10.15 -    _MACRO(vcpu_wake_onrunq)                \
   10.16 -    _MACRO(vcpu_wake_runnable)              \
   10.17 -    _MACRO(vcpu_wake_not_runnable)          \
   10.18 -    _MACRO(dom_destroy)                     \
   10.19      _MACRO(schedule)                        \
   10.20 -    _MACRO(tickle_local_idler)              \
   10.21 -    _MACRO(tickle_local_over)               \
   10.22 -    _MACRO(tickle_local_under)              \
   10.23 -    _MACRO(tickle_local_other)              \
   10.24      _MACRO(acct_run)                        \
   10.25      _MACRO(acct_no_work)                    \
   10.26      _MACRO(acct_balance)                    \
   10.27 @@ -102,20 +95,28 @@
   10.28      _MACRO(acct_min_credit)                 \
   10.29      _MACRO(acct_vcpu_active)                \
   10.30      _MACRO(acct_vcpu_idle)                  \
   10.31 -    _MACRO(acct_vcpu_credit_min)
   10.32 -
   10.33 -#define CSCHED_STATS_EXPAND_SMP_LOAD_BALANCE(_MACRO)    \
   10.34 -    _MACRO(vcpu_migrate)                                \
   10.35 -    _MACRO(load_balance_idle)                           \
   10.36 -    _MACRO(load_balance_over)                           \
   10.37 -    _MACRO(load_balance_other)                          \
   10.38 -    _MACRO(steal_trylock_failed)                        \
   10.39 -    _MACRO(steal_peer_down)                             \
   10.40 -    _MACRO(steal_peer_idle)                             \
   10.41 -    _MACRO(steal_peer_running)                          \
   10.42 -    _MACRO(steal_peer_pinned)                           \
   10.43 -    _MACRO(tickle_idlers_none)                          \
   10.44 -    _MACRO(tickle_idlers_some)
   10.45 +    _MACRO(vcpu_sleep)                      \
   10.46 +    _MACRO(vcpu_wake_running)               \
   10.47 +    _MACRO(vcpu_wake_onrunq)                \
   10.48 +    _MACRO(vcpu_wake_runnable)              \
   10.49 +    _MACRO(vcpu_wake_not_runnable)          \
   10.50 +    _MACRO(tickle_local_idler)              \
   10.51 +    _MACRO(tickle_local_over)               \
   10.52 +    _MACRO(tickle_local_under)              \
   10.53 +    _MACRO(tickle_local_other)              \
   10.54 +    _MACRO(tickle_idlers_none)              \
   10.55 +    _MACRO(tickle_idlers_some)              \
   10.56 +    _MACRO(vcpu_migrate)                    \
   10.57 +    _MACRO(load_balance_idle)               \
   10.58 +    _MACRO(load_balance_over)               \
   10.59 +    _MACRO(load_balance_other)              \
   10.60 +    _MACRO(steal_trylock_failed)            \
   10.61 +    _MACRO(steal_peer_down)                 \
   10.62 +    _MACRO(steal_peer_idle)                 \
   10.63 +    _MACRO(steal_peer_running)              \
   10.64 +    _MACRO(steal_peer_pinned)               \
   10.65 +    _MACRO(vcpu_init)                       \
   10.66 +    _MACRO(dom_destroy)
   10.67  
   10.68  #ifndef NDEBUG
   10.69  #define CSCHED_STATS_EXPAND_CHECKS(_MACRO)  \
   10.70 @@ -124,10 +125,9 @@
   10.71  #define CSCHED_STATS_EXPAND_CHECKS(_MACRO)
   10.72  #endif
   10.73  
   10.74 -#define CSCHED_STATS_EXPAND(_MACRO)                 \
   10.75 -    CSCHED_STATS_EXPAND_SCHED(_MACRO)               \
   10.76 -    CSCHED_STATS_EXPAND_SMP_LOAD_BALANCE(_MACRO)    \
   10.77 -    CSCHED_STATS_EXPAND_CHECKS(_MACRO)
   10.78 +#define CSCHED_STATS_EXPAND(_MACRO)         \
   10.79 +    CSCHED_STATS_EXPAND_CHECKS(_MACRO)      \
   10.80 +    CSCHED_STATS_EXPAND_SCHED(_MACRO)
   10.81  
   10.82  #define CSCHED_STATS_RESET()                                        \
   10.83      do                                                              \
   10.84 @@ -177,11 +177,14 @@ struct csched_vcpu {
   10.85      struct csched_dom *sdom;
   10.86      struct vcpu *vcpu;
   10.87      atomic_t credit;
   10.88 -    int credit_last;
   10.89 -    uint32_t credit_incr;
   10.90 -    uint32_t state_active;
   10.91 -    uint32_t state_idle;
   10.92      int16_t pri;
   10.93 +    struct {
   10.94 +        int credit_last;
   10.95 +        uint32_t credit_incr;
   10.96 +        uint32_t state_active;
   10.97 +        uint32_t state_idle;
   10.98 +        uint32_t migrate;
   10.99 +    } stats;
  10.100  };
  10.101  
  10.102  /*
  10.103 @@ -404,7 +407,7 @@ csched_vcpu_acct(struct csched_vcpu *svc
  10.104          if ( list_empty(&svc->active_vcpu_elem) )
  10.105          {
  10.106              CSCHED_STAT_CRANK(acct_vcpu_active);
  10.107 -            svc->state_active++;
  10.108 +            svc->stats.state_active++;
  10.109  
  10.110              sdom->active_vcpu_count++;
  10.111              list_add(&svc->active_vcpu_elem, &sdom->active_vcpu);
  10.112 @@ -435,7 +438,7 @@ static inline void
  10.113      BUG_ON( list_empty(&svc->active_vcpu_elem) );
  10.114  
  10.115      CSCHED_STAT_CRANK(acct_vcpu_idle);
  10.116 -    svc->state_idle++;
  10.117 +    svc->stats.state_idle++;
  10.118  
  10.119      sdom->active_vcpu_count--;
  10.120      list_del_init(&svc->active_vcpu_elem);
  10.121 @@ -495,11 +498,8 @@ csched_vcpu_init(struct vcpu *vc)
  10.122      svc->sdom = sdom;
  10.123      svc->vcpu = vc;
  10.124      atomic_set(&svc->credit, 0);
  10.125 -    svc->credit_last = 0;
  10.126 -    svc->credit_incr = 0U;
  10.127 -    svc->state_active = 0U;
  10.128 -    svc->state_idle = 0U;
  10.129      svc->pri = pri;
  10.130 +    memset(&svc->stats, 0, sizeof(svc->stats));
  10.131      vc->sched_priv = svc;
  10.132  
  10.133      CSCHED_VCPU_CHECK(vc);
  10.134 @@ -864,8 +864,8 @@ csched_acct(void)
  10.135                  }
  10.136              }
  10.137  
  10.138 -            svc->credit_last = credit;
  10.139 -            svc->credit_incr = credit_fair;
  10.140 +            svc->stats.credit_last = credit;
  10.141 +            svc->stats.credit_incr = credit_fair;
  10.142              credit_balance += credit;
  10.143          }
  10.144      }
  10.145 @@ -1014,6 +1014,7 @@ csched_load_balance(int cpu, struct csch
  10.146          if ( speer )
  10.147          {
  10.148              CSCHED_STAT_CRANK(vcpu_migrate);
  10.149 +            speer->stats.migrate++;
  10.150              return speer;
  10.151          }
  10.152      }
  10.153 @@ -1100,12 +1101,13 @@ csched_dump_vcpu(struct csched_vcpu *svc
  10.154  
  10.155      if ( sdom )
  10.156      {
  10.157 -        printk(" credit=%i (%d+%u) {a=%u i=%u w=%u}",
  10.158 +        printk(" credit=%i (%d+%u) {a/i=%u/%u m=%u w=%u}",
  10.159              atomic_read(&svc->credit),
  10.160 -            svc->credit_last,
  10.161 -            svc->credit_incr,
  10.162 -            svc->state_active,
  10.163 -            svc->state_idle,
  10.164 +            svc->stats.credit_last,
  10.165 +            svc->stats.credit_incr,
  10.166 +            svc->stats.state_active,
  10.167 +            svc->stats.state_idle,
  10.168 +            svc->stats.migrate,
  10.169              sdom->weight);
  10.170      }
  10.171