ia64/xen-unstable

changeset 12711:d7f71de58c4b

[LINUX] Fix backward compatibility with hypervisors which do not support kexec.

Also do not rely on side effects in BUG_ON(x) -- use if(x) BUG() instead.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Thu Nov 30 18:21:50 2006 +0000 (2006-11-30)
parents cefb1f761f0b
children f6993ff5cf49
files linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Thu Nov 30 18:08:34 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Thu Nov 30 18:21:50 2006 +0000
     1.3 @@ -20,7 +20,7 @@ void xen_machine_kexec_setup_resources(v
     1.4  {
     1.5  	xen_kexec_range_t range;
     1.6  	struct resource *res;
     1.7 -	int k = 0;
     1.8 +	int err, k = 0;
     1.9  
    1.10  	if (!is_initial_xendomain())
    1.11  		return;
    1.12 @@ -32,8 +32,16 @@ void xen_machine_kexec_setup_resources(v
    1.13  		range.range = KEXEC_RANGE_MA_CPU;
    1.14  		range.nr = k;
    1.15  
    1.16 -		if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.17 +		/*
    1.18 +		 * Anything other than EINVAL or success indictates
    1.19 +		 * that we are not running on a hypervisor which
    1.20 +		 * supports kexec.
    1.21 +		 */
    1.22 +		err = HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range);
    1.23 +		if (err == -EINVAL)
    1.24  			break;
    1.25 +		else if (err)
    1.26 +			return;
    1.27  
    1.28  		k++;
    1.29  	}
    1.30 @@ -52,7 +60,8 @@ void xen_machine_kexec_setup_resources(v
    1.31  		range.range = KEXEC_RANGE_MA_CPU;
    1.32  		range.nr = k;
    1.33  
    1.34 -		BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
    1.35 +		if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.36 +			BUG();
    1.37  
    1.38  		res = xen_phys_cpus + k;
    1.39  
    1.40 @@ -68,7 +77,8 @@ void xen_machine_kexec_setup_resources(v
    1.41  	memset(&range, 0, sizeof(range));
    1.42  	range.range = KEXEC_RANGE_MA_XEN;
    1.43  
    1.44 -	BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
    1.45 +	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.46 +		BUG();
    1.47  
    1.48  	xen_hypervisor_res.name = "Hypervisor code and data";
    1.49  	xen_hypervisor_res.start = range.start;
    1.50 @@ -80,7 +90,8 @@ void xen_machine_kexec_setup_resources(v
    1.51  	memset(&range, 0, sizeof(range));
    1.52  	range.range = KEXEC_RANGE_MA_CRASH;
    1.53  
    1.54 -	BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
    1.55 +	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.56 +		BUG();
    1.57  
    1.58  	if (range.size) {
    1.59  		crashk_res.start = range.start;