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

[Xen-devel] [PATCH 01/11] kexec: add kexec_is_loaded function


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Thu, 28 Jul 2011 15:23:01 +0200
  • Delivery-date: Thu, 28 Jul 2011 06:36:55 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Add a new function kexec_is_loaded to be used by subsequent changes for
kexec in Xen HVM guests with PV drivers loaded.

A kexec reboot in a HVM guest needs to unregister all resources such as
xenstore watches and virqs, otherwise the kexec kernel can not bind to
these resources again. But the unregister only needs to happen during a
kexec boot because the guest remains the same from the Xen point of
view. A normal reboot will shutdown and destroy the entire guest with
all its resources, then the guest will start again with a different
domain_id number. So doing all the unregister work would only delay
normal reboots.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

---
 include/linux/kexec.h |    3 ++-
 kernel/kexec.c        |    8 +++++++-
 kernel/ksysfs.c       |    2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

Index: linux-3.0/include/linux/kexec.h
===================================================================
--- linux-3.0.orig/include/linux/kexec.h
+++ linux-3.0/include/linux/kexec.h
@@ -126,6 +126,7 @@ extern asmlinkage long compat_sys_kexec_
 extern struct page *kimage_alloc_control_pages(struct kimage *image,
                                                unsigned int order);
 extern void crash_kexec(struct pt_regs *);
+extern int kexec_is_loaded(void);
 int kexec_should_crash(struct task_struct *);
 void crash_save_cpu(struct pt_regs *regs, int cpu);
 void crash_save_vmcoreinfo(void);
@@ -156,7 +157,6 @@ unsigned long paddr_vmcoreinfo_note(void
 #define VMCOREINFO_CONFIG(name) \
        vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
 
-extern struct kimage *kexec_image;
 extern struct kimage *kexec_crash_image;
 
 #ifndef kexec_flush_icache_page
@@ -214,6 +214,7 @@ void crash_free_reserved_phys_range(unsi
 struct pt_regs;
 struct task_struct;
 static inline void crash_kexec(struct pt_regs *regs) { }
+static inline int kexec_is_loaded(void) { return 0; }
 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
 #endif /* CONFIG_KEXEC */
 #endif /* LINUX_KEXEC_H */
Index: linux-3.0/kernel/kexec.c
===================================================================
--- linux-3.0.orig/kernel/kexec.c
+++ linux-3.0/kernel/kexec.c
@@ -934,7 +934,7 @@ static int kimage_load_segment(struct ki
  * kexec does not sync, or unmount filesystems so if you need
  * that to happen you need to do that yourself.
  */
-struct kimage *kexec_image;
+static struct kimage *kexec_image;
 struct kimage *kexec_crash_image;
 
 static DEFINE_MUTEX(kexec_mutex);
@@ -1567,3 +1567,9 @@ int kernel_kexec(void)
        mutex_unlock(&kexec_mutex);
        return error;
 }
+
+int kexec_is_loaded(void)
+{
+       return !!kexec_image;
+}
+EXPORT_SYMBOL_GPL(kexec_is_loaded);
Index: linux-3.0/kernel/ksysfs.c
===================================================================
--- linux-3.0.orig/kernel/ksysfs.c
+++ linux-3.0/kernel/ksysfs.c
@@ -90,7 +90,7 @@ KERNEL_ATTR_RW(profiling);
 static ssize_t kexec_loaded_show(struct kobject *kobj,
                                 struct kobj_attribute *attr, char *buf)
 {
-       return sprintf(buf, "%d\n", !!kexec_image);
+       return sprintf(buf, "%d\n", kexec_is_loaded());
 }
 KERNEL_ATTR_RO(kexec_loaded);
 


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


 


Rackspace

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