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

[Xen-changelog] [xen-unstable] [LINUX] Fix backward compatibility with hypervisors which do not support kexec.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxxxxx>
# Node ID d7f71de58c4b484820c49f45ed40fd577c3368d6
# Parent  cefb1f761f0b9894459d571618846141ec6f36e2
[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@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c |   21 +++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff -r cefb1f761f0b -r d7f71de58c4b 
linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c     Thu Nov 30 
18:08:34 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c     Thu Nov 30 
18:21:50 2006 +0000
@@ -20,7 +20,7 @@ void xen_machine_kexec_setup_resources(v
 {
        xen_kexec_range_t range;
        struct resource *res;
-       int k = 0;
+       int err, k = 0;
 
        if (!is_initial_xendomain())
                return;
@@ -32,8 +32,16 @@ void xen_machine_kexec_setup_resources(v
                range.range = KEXEC_RANGE_MA_CPU;
                range.nr = k;
 
-               if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
+               /*
+                * Anything other than EINVAL or success indictates
+                * that we are not running on a hypervisor which
+                * supports kexec.
+                */
+               err = HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range);
+               if (err == -EINVAL)
                        break;
+               else if (err)
+                       return;
 
                k++;
        }
@@ -52,7 +60,8 @@ void xen_machine_kexec_setup_resources(v
                range.range = KEXEC_RANGE_MA_CPU;
                range.nr = k;
 
-               BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
+               if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
+                       BUG();
 
                res = xen_phys_cpus + k;
 
@@ -68,7 +77,8 @@ void xen_machine_kexec_setup_resources(v
        memset(&range, 0, sizeof(range));
        range.range = KEXEC_RANGE_MA_XEN;
 
-       BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
+       if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
+               BUG();
 
        xen_hypervisor_res.name = "Hypervisor code and data";
        xen_hypervisor_res.start = range.start;
@@ -80,7 +90,8 @@ void xen_machine_kexec_setup_resources(v
        memset(&range, 0, sizeof(range));
        range.range = KEXEC_RANGE_MA_CRASH;
 
-       BUG_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range));
+       if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
+               BUG();
 
        if (range.size) {
                crashk_res.start = range.start;

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.