Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 107976

Summary: is_xenU_sys in /etc/init.d/functions.sh is broken
Product: Gentoo Linux Reporter: Chris Bainbridge (RETIRED) <chrb>
Component: [OLD] baselayoutAssignee: Roy Marples (RETIRED) <uberlord>
Status: RESOLVED FIXED    
Severity: normal CC: cgs, erik, nao.nakashima, sascha_lucas, uberlord, via-gentoo
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 96240    
Bug Blocks:    

Description Chris Bainbridge (RETIRED) gentoo-dev 2005-10-03 04:51:19 UTC
[[ -d /proc/xen && ! -f /proc/xen/privcmd ]]

is a bad check because /proc/xen/privcmd is present under domU.

Do something like:

        [[ -d /proc/xen && ! -z `ls /sys/bus/xen/devices/` ]]

instead.
Comment 1 SpanKY gentoo-dev 2005-10-03 06:27:29 UTC
code was submitted by Chris in Bug 96240
Comment 2 Chris Bainbridge (RETIRED) gentoo-dev 2005-10-04 03:00:30 UTC
Maybe behaviour under xen3 is different? Anyway, checking /sys/bus/xen/devices
will work - there should be no backend devices in a domain0.
Comment 3 SpanKY gentoo-dev 2005-10-04 06:16:11 UTC
i dont want to run `ls` so is there a file i can check for with [[ -e ]] ?
Comment 4 Chris Bainbridge (RETIRED) gentoo-dev 2005-10-04 06:47:50 UTC
try "-e /sys/bus/xen/drivers/vbd || -e /sys/bus/xen/drivers/vif". That will
catch any domains with xen frontend vif or vbd devices.. it would be very
difficult, if not impossible, to run a domain without either of them.
Comment 5 SpanKY gentoo-dev 2005-10-04 17:20:30 UTC
hmm, well does /sys/bus/xen/devices/ always exist even if it's empty ?
Comment 6 Chris Bainbridge (RETIRED) gentoo-dev 2005-10-05 01:52:04 UTC
yes.
Comment 7 SpanKY gentoo-dev 2006-02-06 18:35:28 UTC
fixed in svn then, thanks
Comment 8 SpanKY gentoo-dev 2006-02-18 11:29:29 UTC
*** Bug 123258 has been marked as a duplicate of this bug. ***
Comment 9 SpanKY gentoo-dev 2006-04-27 05:55:40 UTC
*** Bug 131434 has been marked as a duplicate of this bug. ***
Comment 10 SpanKY gentoo-dev 2006-04-27 05:56:08 UTC
time to review again :P
Comment 11 Roy Marples (RETIRED) gentoo-dev 2006-05-16 03:13:24 UTC
I was looking at another xen bug and thought I'd look at this now I have a working xen setup and this is a very bad solution as sysfs export is optional. One solution which works is that dom0 always reports control_d in /proc/xen/capabilities and domU won't - regardless of kernel options set. This works for a dom0/U combined kernel which I used for testing as well.

I've comitted this fix to our svn and will be in baselayout-1.12.0_pre20
Comment 12 Roy Marples (RETIRED) gentoo-dev 2006-05-23 06:30:04 UTC
Fixed in baselayout-1.12.0
Comment 13 Pavel Goran 2010-11-20 06:53:15 UTC
As of baselayout-1.12.14-r1, it still doesn't work right in my configuration.

is_xenU_sys() {
        [[ ! -d /proc/xen ]] && return 1
        [[ ! -r /proc/xen/capabilities ]] && return 1
        grep -q "control_d" /proc/xen/capabilities && return 1
        return 0
}

/proc/xen/capabilities doesn't exist in my domU system (/proc/xen exists and is completely empty), so the function incorrectly returns 1.

Kernel version is 2.6.34-gentoo-r12, if that matters. Configuration:
% zgrep XEN /proc/config.gz   
CONFIG_XEN=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=32
CONFIG_XEN_SAVE_RESTORE=y
# CONFIG_XEN_DEBUG_FS is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y

P.S. Is it right to post a comment to the closed old bug, or should I have created a new one?
Comment 14 Nao Nakashima 2011-01-18 06:29:06 UTC
(In reply to comment #13)
> As of baselayout-1.12.14-r1, it still doesn't work right in my configuration.
> /proc/xen/capabilities doesn't exist in my domU system (/proc/xen exists and is
> completely empty), so the function incorrectly returns 1.

you'll need to add xenfs to /etc/fstab:

----
xenfs           /proc/xen       xenfs   defaults                   0 0
----