All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU
@ 2011-05-04 16:32 Olaf Hering
  2011-05-05 12:20 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2011-05-04 16:32 UTC (permalink / raw)
  To: kexec

A Xen HVM guest with PV drivers loaded has also a /proc/xen directory.
But such a guest is an ordinary PC and the special handling for dom0
breaks kdump in this environment.
Test for /proc/xen/capabilities instead and cache the result.

Also make two variables static, they are only used in this file.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

---
 kexec/crashdump-xen.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Index: kexec-tools-0.8.15/kexec/crashdump-xen.c
===================================================================
--- kexec-tools-0.8.15.orig/kexec/crashdump-xen.c
+++ kexec-tools-0.8.15/kexec/crashdump-xen.c
@@ -25,14 +25,19 @@ struct crash_note_info {
 	unsigned long length;
 };
 
-int xen_phys_cpus = 0;
-struct crash_note_info *xen_phys_notes;
+static int xen_phys_cpus;
+static struct crash_note_info *xen_phys_notes;
+static int is_dom0;
 
 int xen_present(void)
 {
-	struct stat buf;
-
-	return stat("/proc/xen", &buf) == 0;
+	if (!is_dom0) {
+		if (access("/proc/xen/capabilities", F_OK) == 0)
+			is_dom0 = 1;
+		else
+			is_dom0 = -1;
+	}
+	return is_dom0 > 0;
 }
 
 unsigned long xen_architecture(struct crash_elf_info *elf_info)

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU
  2011-05-04 16:32 [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU Olaf Hering
@ 2011-05-05 12:20 ` Simon Horman
  2011-05-05 12:34   ` Olaf Hering
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2011-05-05 12:20 UTC (permalink / raw)
  To: Olaf Hering; +Cc: kexec

On Wed, May 04, 2011 at 06:32:32PM +0200, Olaf Hering wrote:
> A Xen HVM guest with PV drivers loaded has also a /proc/xen directory.
> But such a guest is an ordinary PC and the special handling for dom0
> breaks kdump in this environment.
> Test for /proc/xen/capabilities instead and cache the result.
> 
> Also make two variables static, they are only used in this file.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> 
> ---
>  kexec/crashdump-xen.c |   15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> Index: kexec-tools-0.8.15/kexec/crashdump-xen.c
> ===================================================================
> --- kexec-tools-0.8.15.orig/kexec/crashdump-xen.c
> +++ kexec-tools-0.8.15/kexec/crashdump-xen.c
> @@ -25,14 +25,19 @@ struct crash_note_info {
>  	unsigned long length;
>  };
>  
> -int xen_phys_cpus = 0;
> -struct crash_note_info *xen_phys_notes;
> +static int xen_phys_cpus;
> +static struct crash_note_info *xen_phys_notes;
> +static int is_dom0;

I think you need to explicitly initialise is_dom0 to 0.

Alternatively, is it really such a burden to call access()
each time xen_present() is called?  (I'm ambivalent with regards to this).

>  
>  int xen_present(void)
>  {
> -	struct stat buf;
> -
> -	return stat("/proc/xen", &buf) == 0;
> +	if (!is_dom0) {
> +		if (access("/proc/xen/capabilities", F_OK) == 0)
> +			is_dom0 = 1;
> +		else
> +			is_dom0 = -1;
> +	}
> +	return is_dom0 > 0;
>  }
>  
>  unsigned long xen_architecture(struct crash_elf_info *elf_info)
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU
  2011-05-05 12:20 ` Simon Horman
@ 2011-05-05 12:34   ` Olaf Hering
  2011-05-06  3:29     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2011-05-05 12:34 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec

On Thu, May 05, Simon Horman wrote:

> On Wed, May 04, 2011 at 06:32:32PM +0200, Olaf Hering wrote:

> > +static int is_dom0;
> 
> I think you need to explicitly initialise is_dom0 to 0.

Globals are always initialized to zero, its a C language thing.

> Alternatively, is it really such a burden to call access()
> each time xen_present() is called?  (I'm ambivalent with regards to this).

Probably not, its called a dozen times in my testing.

Olaf

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU
  2011-05-05 12:34   ` Olaf Hering
@ 2011-05-06  3:29     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2011-05-06  3:29 UTC (permalink / raw)
  To: Olaf Hering; +Cc: kexec

On Thu, May 05, 2011 at 02:34:46PM +0200, Olaf Hering wrote:
> On Thu, May 05, Simon Horman wrote:
> 
> > On Wed, May 04, 2011 at 06:32:32PM +0200, Olaf Hering wrote:
> 
> > > +static int is_dom0;
> > 
> > I think you need to explicitly initialise is_dom0 to 0.
> 
> Globals are always initialized to zero, its a C language thing.

Point taken :^)

> > Alternatively, is it really such a burden to call access()
> > each time xen_present() is called?  (I'm ambivalent with regards to this).
> 
> Probably not, its called a dozen times in my testing.

As we already have the code it seems that we may as well use it.

I've merged your patch as-is.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-06  3:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 16:32 [PATCH] detect Xen dom0 properly to avoid conflict with pv_on_hvm domU Olaf Hering
2011-05-05 12:20 ` Simon Horman
2011-05-05 12:34   ` Olaf Hering
2011-05-06  3:29     ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.