Skip to contentSkip to conversation

simple check for domU?

DISCUSSION Chris Bainbridge 3 participants 5 messages Nov 11, 2005

lore
Share & tools
lore
#0 lore raw

Hi, is there a simple way to check that we're running under a domU? So far I came up with:

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

or

-e /sys/bus/xen/drivers/vbd || -e /sys/bus/xen/drivers/vif

Neither of which is pretty, and I'm not convinced they work under all circumstances. This is useful for system setup scripts to do different things depending if they are run under dom0/U.

Thanks,
Chris

#1 lore raw
Quoted 2 lines · Chris Bainbridge

Hi, is there a simple way to check that we're running under a domU? So far I came up with:

Try:

uname -r | grep -q -- -xen

... which generally works. 'test -d /proc/xen' is pretty reliable as well.

Quoted 17 lines

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

or

-e /sys/bus/xen/drivers/vbd || -e /sys/bus/xen/drivers/vif

Neither of which is pretty, and I'm not convinced they work under all circumstances. This is useful for system setup scripts to do different things depending if they are run under dom0/U.

Thanks,
Chris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 4 lines
Karsten M. Self <[email protected]>
XenSource, Inc.
2300 Geng Road #250                                +1 650.798.5900 x259
Palo Alto, CA 94303                                +1 650.493.1579 fax
#2 lore raw
Quoted 10 lines · Karsten M. Self
Quoted 2 lines · Chris Bainbridge

Hi, is there a simple way to check that we're running under a domU? So far I came up with:

Try:

uname -r | grep -q -- -xen

... which generally works. 'test -d /proc/xen' is pretty reliable as well.

I'm looking specifically for domU and not dom0 (well, it would be useful to have a reliable way of identifying both). /proc/xen will be present in dom0 and uname depends on the kernel EXTRAVERSION which isn't guaranteed.

#3 lore raw
In reply to Chris Bainbridge
Quoted 5 lines · Chris Bainbridge

Hi, is there a simple way to check that we're running under a domU? So far I came up with:

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

Quoted 7 lines

or

-e /sys/bus/xen/drivers/vbd || -e /sys/bus/xen/drivers/vif

Neither of which is pretty, and I'm not convinced they work under all circumstances. This is useful for system setup scripts to do different things depending if they are run under dom0/U.

That is easy. Something you will never see in domU, such as xenconsoled, xenstored,...

So check for the presence of these daemons is a good way, especially that requires no privileged access.

#4 lore raw
Quoted 14 lines · NAHieu
Quoted 5 lines · Chris Bainbridge

Hi, is there a simple way to check that we're running under a domU? So far I came up with:

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

Quoted 7 lines

or

-e /sys/bus/xen/drivers/vbd || -e /sys/bus/xen/drivers/vif

Neither of which is pretty, and I'm not convinced they work under all circumstances. This is useful for system setup scripts to do different things depending if they are run under dom0/U.

Quoted 5 lines

That is easy. Something you will never see in domU, such as xenconsoled, xenstored,...

So check for the presence of these daemons is a good way, especially that requires no privileged access.

It is quite possible that someone has these daemons installed in a domU fs. Maybe you mean check if the process is running? Even that is problematic; it's possible to run a xen0 kernel without those daemons. Besides, how do we differentiate between a domU kernel and a standard kernel?

If there's no easy and reliable way to do this maybe one should be added?