This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 01/11] kexec: add kexec_is_loaded function
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Thu, 28 Jul 2011 15:23:01 +0200
Delivery-date: Thu, 28 Jul 2011 06:36:55 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1311859422; l=3147; s=domk; d=aepfle.de; h=References:Subject:To:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=TqLQPveKQrIVBe7NheeXne8WNLU=; b=oYee/xJ+zRfIBtfmU31azXeX3+irjQtrf1a3EJQn/zh4nglRg2ntPQSPijtP5L13ukf WgFQEqZndFWLnzKiWQ+5smjeG7Be2J6YTiIrmdnVW2ds/StjDT3bDE5MB5gITz9pEntVz E2XbM26i3duf0Cl7w6sOeLglavjmlmjdpKg=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20110728132300.248098023@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.48-16.4
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)
        return error;
+int kexec_is_loaded(void)
+       return !!kexec_image;
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());

Xen-devel mailing list

<Prev in Thread] Current Thread [Next in Thread>