All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hotplug: update xencommons script to run only when needed
@ 2011-08-12  7:11 Olaf Hering
  2011-08-25 15:15 ` Ian Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2011-08-12  7:11 UTC (permalink / raw)
  To: xen-devel

# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1313133097 -7200
# Node ID 0e95f2c754bf526a89bb8a097959e6c970e9b5b7
# Parent  1f08b380d4386cdd6714786a9163e5f51aecab5d
hotplug: update xencommons script to run only when needed

Currently xencommons prints an error if /proc/xen/capabilities does not
exist when started on a non-xen kernel.

Update the xencommons script to run only when needed:
- do not run if /proc/xen does not exist
- check if /proc/xen/capabilities exists before doing the grep for dom0
- use variable for /proc/xen/capabilities
- use grep -q instead of stdout redirection when looking for xenfs,
  its already used later

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

diff -r 1f08b380d438 -r 0e95f2c754bf tools/hotplug/Linux/init.d/xencommons
--- a/tools/hotplug/Linux/init.d/xencommons
+++ b/tools/hotplug/Linux/init.d/xencommons
@@ -27,17 +27,29 @@ fi
 test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
 
 XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+XEN_CAPABILITIES=/proc/xen/capabilities
 shopt -s extglob
 
+# not running in Xen dom0 or domU
+if ! test -d /proc/xen ; then
+	exit 0
+fi
+
+# mount xenfs in dom0 or domU with a pv_ops kernel
 if test "x$1" = xstart && \
-     test -d /proc/xen && \
-   ! test -f /proc/xen/capabilities && \
-   ! grep '^xenfs ' /proc/mounts >/dev/null;
+   ! test -f $XEN_CAPABILITIES && \
+   ! grep -q '^xenfs ' /proc/mounts ;
 then
 	mount -t xenfs xenfs /proc/xen
 fi
 
-if ! grep -q "control_d" /proc/xen/capabilities ; then
+# run this script only in dom0:
+# no capabilities file in xenlinux kernel
+if ! test -f $XEN_CAPABILITIES ; then
+	exit 0
+fi
+# empty capabilities file in pv_ops kernel
+if ! grep -q "control_d" $XEN_CAPABILITIES ; then
 	exit 0
 fi

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

* [PATCH 2/2] Load gntdev and evtchn if they're modular.
@ 2011-08-20  0:49         ` Jeremy Fitzhardinge
  2011-08-30 16:46           ` [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages] Ian Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Jeremy Fitzhardinge @ 2011-08-20  0:49 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>


diff -r cfb49fe940fd -r 81f75ed45ec2 tools/hotplug/Linux/init.d/xencommons
--- a/tools/hotplug/Linux/init.d/xencommons	Tue Aug 16 16:56:16 2011 -0700
+++ b/tools/hotplug/Linux/init.d/xencommons	Tue Aug 16 17:05:18 2011 -0700
@@ -29,12 +29,18 @@
 XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
 shopt -s extglob
 
-if [ "x$1" = xstart -a -d /proc/xen -a \
-    ! -f /proc/xen/capabilities ] && \
-    ! grep -qw '^xenfs' /proc/mounts; then
-	mount -t xenfs xenfs /proc/xen
+[ -d /proc/xen ] || exit 0	# Xen not present; exit quietly
+
+if [ "x$1" = xstart ]; then
+	# Mount /proc/xen if needed
+	[ -f /proc/xen/capabilities ] || mount -t xenfs xenfs /proc/xen
+
+	# Make sure evtchn and gntdev are loaded if present
+	grep -q "xen/evtchn" /proc/misc || modprobe xen-evtchn
+	grep -q "xen/gntdev" /proc/misc || modprobe xen-gntdev
 fi
 
+# Done here if this isn't a control domain
 if ! grep -q "control_d" /proc/xen/capabilities ; then
 	exit 0
 fi

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

* Re: [PATCH] hotplug: update xencommons script to run only when needed
  2011-08-12  7:11 [PATCH] hotplug: update xencommons script to run only when needed Olaf Hering
@ 2011-08-25 15:15 ` Ian Jackson
  2011-08-25 15:24   ` Olaf Hering
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Jackson @ 2011-08-25 15:15 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel

Olaf Hering writes ("[Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
> Update the xencommons script to run only when needed:

Thanks.  I like most of this.  But:

> - use variable for /proc/xen/capabilities

Why ?  Is this going to move ?  I think if it moves we have other
problems, since it's part of the published /proc interface from
Xen-enabled kernels.

Ian.

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

* Re: [PATCH] hotplug: update xencommons script to run only when needed
  2011-08-25 15:15 ` Ian Jackson
@ 2011-08-25 15:24   ` Olaf Hering
  2011-08-25 15:34     ` Ian Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2011-08-25 15:24 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

On Thu, Aug 25, Ian Jackson wrote:

> Olaf Hering writes ("[Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
> > Update the xencommons script to run only when needed:
> 
> Thanks.  I like most of this.  But:
> 
> > - use variable for /proc/xen/capabilities
> 
> Why ?  Is this going to move ?  I think if it moves we have other
> problems, since it's part of the published /proc interface from
> Xen-enabled kernels.

There is no special reason for the variable.
Do you want me to send a patch without the new variable?

Olaf

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

* Re: [PATCH] hotplug: update xencommons script to run only when needed
  2011-08-25 15:24   ` Olaf Hering
@ 2011-08-25 15:34     ` Ian Jackson
  2011-08-26  9:10       ` [PATCH v2] " Olaf Hering
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Jackson @ 2011-08-25 15:34 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel

Olaf Hering writes ("Re: [Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
> There is no special reason for the variable.

Right.

> Do you want me to send a patch without the new variable?

If you like, or I can just take it out myself.

Ian.

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

* [PATCH v2] hotplug: update xencommons script to run only when needed
  2011-08-25 15:34     ` Ian Jackson
@ 2011-08-26  9:10       ` Olaf Hering
  2011-08-20  0:49         ` [PATCH 2/2] Load gntdev and evtchn if they're modular Jeremy Fitzhardinge
  0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2011-08-26  9:10 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

# HG changeset patch
# Parent 227130622561e20136a1ef56201fe65ead5a76e8
hotplug: update xencommons script to run only when needed

Currently xencommons prints an error if /proc/xen/capabilities does not
exist when started on a non-xen kernel.

Update the xencommons script to run only when needed:
- do not run if /proc/xen does not exist
- check if /proc/xen/capabilities exists before doing the grep for dom0
- use grep -q instead of stdout redirection when looking for xenfs

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

diff -r 227130622561 tools/hotplug/Linux/init.d/xencommons
--- a/tools/hotplug/Linux/init.d/xencommons
+++ b/tools/hotplug/Linux/init.d/xencommons
@@ -29,14 +29,25 @@ test -f $xencommons_config/xencommons &&
 XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
 shopt -s extglob
 
+# not running in Xen dom0 or domU
+if ! test -d /proc/xen ; then
+	exit 0
+fi
+
+# mount xenfs in dom0 or domU with a pv_ops kernel
 if test "x$1" = xstart && \
-     test -d /proc/xen && \
    ! test -f /proc/xen/capabilities && \
-   ! grep '^xenfs ' /proc/mounts >/dev/null;
+   ! grep -q '^xenfs ' /proc/mounts ;
 then
 	mount -t xenfs xenfs /proc/xen
 fi
 
+# run this script only in dom0:
+# no capabilities file in xenlinux kernel
+if ! test -f /proc/xen/capabilities ; then
+	exit 0
+fi
+# empty capabilities file in pv_ops kernel
 if ! grep -q "control_d" /proc/xen/capabilities ; then
 	exit 0
 fi

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

* Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
  2011-08-20  0:49         ` [PATCH 2/2] Load gntdev and evtchn if they're modular Jeremy Fitzhardinge
@ 2011-08-30 16:46           ` Ian Jackson
  2011-08-30 18:12             ` Olaf Hering
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Jackson @ 2011-08-30 16:46 UTC (permalink / raw)
  To: Olaf Hering, Jeremy Fitzhardinge; +Cc: xen-devel

Jeremy Fitzhardinge writes ("[Xen-devel] [PATCH 2/2] Load gntdev and evtchn if they're modular."):
> -if [ "x$1" = xstart -a -d /proc/xen -a \
> -    ! -f /proc/xen/capabilities ] && \
> -    ! grep -qw '^xenfs' /proc/mounts; then
> -	mount -t xenfs xenfs /proc/xen
> +[ -d /proc/xen ] || exit 0	# Xen not present; exit quietly
> +
> +if [ "x$1" = xstart ]; then
> +	# Mount /proc/xen if needed
> +	[ -f /proc/xen/capabilities ] || mount -t xenfs xenfs /proc/xen
> +
> +	# Make sure evtchn and gntdev are loaded if present
> +	grep -q "xen/evtchn" /proc/misc || modprobe xen-evtchn
> +	grep -q "xen/gntdev" /proc/misc || modprobe xen-gntdev
>  fi

I'd be inclined to accept this although because I didn't like your
previous patch, it doesn't apply.

Olaf Hering writes ("[Xen-devel] [PATCH v2] hotplug: update xencommons script to run only when needed"):
> +# not running in Xen dom0 or domU
> +if ! test -d /proc/xen ; then
> +	exit 0
> +fi

This part is fine.

> +# mount xenfs in dom0 or domU with a pv_ops kernel
>  if test "x$1" = xstart && \
> -     test -d /proc/xen && \

Fine.

>     ! test -f /proc/xen/capabilities && \
> -   ! grep '^xenfs ' /proc/mounts >/dev/null;
> +   ! grep -q '^xenfs ' /proc/mounts ;
>  then
>  	mount -t xenfs xenfs /proc/xen
>  fi

As I said to Jeremy, I'm not sure I want style changes.  I'm not
convinced of the huge usefulness of this one either.

> +# run this script only in dom0:
> +# no capabilities file in xenlinux kernel
> +if ! test -f /proc/xen/capabilities ; then
> +	exit 0
> +fi
> +# empty capabilities file in pv_ops kernel
>  if ! grep -q "control_d" /proc/xen/capabilities ; then
>  	exit 0
>  fi

If /proc/xen/capabilities is missing, what does it mean ?  Do domU
kernels really not provide that file ?  Also these two ifs would be
better combined.

Ian.

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

* Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
  2011-08-30 16:46           ` [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages] Ian Jackson
@ 2011-08-30 18:12             ` Olaf Hering
  2011-08-31 16:02               ` Ian Jackson
  0 siblings, 1 reply; 9+ messages in thread
From: Olaf Hering @ 2011-08-30 18:12 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Jeremy Fitzhardinge, xen-devel

On Tue, Aug 30, Ian Jackson wrote:

> > +# run this script only in dom0:
> > +# no capabilities file in xenlinux kernel
> > +if ! test -f /proc/xen/capabilities ; then
> > +	exit 0
> > +fi
> > +# empty capabilities file in pv_ops kernel
> >  if ! grep -q "control_d" /proc/xen/capabilities ; then
> >  	exit 0
> >  fi
> 
> If /proc/xen/capabilities is missing, what does it mean ?

It means a domU with xenlinux PV drivers loaded, in that case the script
has to do nothing.

> kernels really not provide that file ?  Also these two ifs would be
> better combined.

How would that look like? First the file is not there, so grep will
print an error - thats what my patch tries to fix.
Second the file is there and may indicate a dom0.

Olaf

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

* Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
  2011-08-30 18:12             ` Olaf Hering
@ 2011-08-31 16:02               ` Ian Jackson
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Jackson @ 2011-08-31 16:02 UTC (permalink / raw)
  To: Olaf Hering; +Cc: Jeremy Fitzhardinge, xen-devel, Ian Jackson

Olaf Hering writes ("Re: [Xen-devel] [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]"):
> How would that look like? First the file is not there, so grep will
> print an error - thats what my patch tries to fix.

If you write
   false && true
the shell does not execute true.

Ian.

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

end of thread, other threads:[~2011-08-31 16:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12  7:11 [PATCH] hotplug: update xencommons script to run only when needed Olaf Hering
2011-08-25 15:15 ` Ian Jackson
2011-08-25 15:24   ` Olaf Hering
2011-08-25 15:34     ` Ian Jackson
2011-08-26  9:10       ` [PATCH v2] " Olaf Hering
2011-08-20  0:49         ` [PATCH 2/2] Load gntdev and evtchn if they're modular Jeremy Fitzhardinge
2011-08-30 16:46           ` [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages] Ian Jackson
2011-08-30 18:12             ` Olaf Hering
2011-08-31 16:02               ` Ian Jackson

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.