hotplug: update xencommons script to run only when needed
PATCH 1/1 hotplug: update xencommons script to run only when needed
# HG changeset patch
# User Olaf Hering <[email protected]>
# 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
tools/hotplug/Linux/init.d/xencommons +16 -4
@@ -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
Olaf Hering writes ("[Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
Quoted 1 line
Update the xencommons script to run only when needed:
Thanks. I like most of this. But:
Quoted 1 line
- 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.
Quoted 10 lines · Ian Jackson
Olaf Hering writes ("[Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
Quoted 1 line
Update the xencommons script to run only when needed:
Thanks. I like most of this. But:
Quoted 1 line
- use variable for
/proc/xen/capabilitiesWhy ? 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
Olaf Hering writes ("Re: [Xen-devel] [PATCH] hotplug: update xencommons script to run only when needed"):
Quoted 1 line
There is no special reason for the variable.
Right.
Quoted 1 line
Do you want me to send a patch without the new variable?
If you like, or I can just take it out myself.
Ian.
PATCH v2 1/1 hotplug: update xencommons script to run only when needed
# 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
tools/hotplug/Linux/init.d/xencommons +13 -2
@@ -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
PATCH 2/2 Load gntdev and evtchn if they're modular.
tools/hotplug/Linux/init.d/xencommons +10 -4
@@ -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
Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
Jeremy Fitzhardinge writes ("[Xen-devel] [PATCH 2/2] Load gntdev and evtchn if they're modular."):
Quoted 4 lines
tools/hotplug/Linux/init.d/xencommons +0
-4-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
tools/hotplug/Linux/init.d/xencommons line 41
Quoted 10 lines
tools/hotplug/Linux/init.d/xencommons +9
-0+[ -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"):
Review
Quoted 4 lines
(quoted diff) +4
-0+# not running in Xen dom0 or domU +if ! test -d /proc/xen ; then + exit 0 +fi
This part is fine.
Review
Quoted 3 lines
(quoted diff) +1
-1+# mount xenfs in dom0 or domU with a pv_ops kernel if test "x$1" = xstart && \ - test -d /proc/xen && \
Fine.
Review
Quoted 6 lines
! test -f /proc/xen/capabilities && \(quoted diff) +1
-1- ! 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.
Review
Quoted 9 lines
(quoted diff) +6
-0+# 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.
Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
Quoted 11 lines · Ian Jackson
Review
Quoted 9 lines
(quoted diff) +6
-0+# 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 fiIf
/proc/xen/capabilitiesis missing, what does it mean ?
It means a domU with xenlinux PV drivers loaded, in that case the script has to do nothing.
Quoted 2 lines
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
Re: [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]
Olaf Hering writes ("Re: [Xen-devel] [PATCH 2/2] Load gntdev and evtchn if they're modular. [and 1 more messages]"):
Quoted 2 lines
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.