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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
on Fri, Nov 11, 2005 at 12:23:18AM +0000, Chris Bainbridge (chris.bainbridge@gmail.com) wrote:> 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.> [[ -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 > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel-- Karsten M. Self <karsten@xensource.com> XenSource, Inc. 2300 Geng Road #250 +1 650.798.5900 x259 Palo Alto, CA 94303 +1 650.493.1579 fax _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 11/11/05, Karsten M. Self <kself@xensource.com> wrote:> on Fri, Nov 11, 2005 at 12:23:18AM +0000, Chris Bainbridge (chris.bainbridge@gmail.com) wrote: > > 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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 11/11/05, Chris Bainbridge <chris.bainbridge@gmail.com> wrote:> 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.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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 11/11/05, NAHieu <nahieu@gmail.com> wrote:> On 11/11/05, Chris Bainbridge <chris.bainbridge@gmail.com> wrote: > > 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. > > 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? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> > If there''s no easy and reliable way to do this maybe one should beadded?>You probably need to clarify exactly what you are asking. If you are running a -xen kernel instead of -xen[0U], then it''s the same kernel but differing in what privileges you have. In theory (I hope I''m right when I say this), it is possible to give a domU kernel some access to hardware, so even the line between a privileged or not kernel is a little blurred. If you had CONFIG_ICONFIG set in your .config, you could grep for various config options in proc, which would tell you if the kernel was compiled with backend or frontend support, but that still doesn''t really help much. James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 12/11/05, James Harper <james.harper@bendigoit.com.au> wrote:> > > > If there''s no easy and reliable way to do this maybe one should be > added? > > > > You probably need to clarify exactly what you are asking. If you are > running a -xen kernel instead of -xen[0U], then it''s the same kernel but > differing in what privileges you have. In theory (I hope I''m right when > I say this), it is possible to give a domU kernel some access to > hardware, so even the line between a privileged or not kernel is a > little blurred.The Gentoo init scripts do some stuff that fails under a domU (hwclock, ntp..). There''s a function that tries to detect a if the kernel is a xenU so as to not to do the things that fail, but it''s currently broken (http://bugs.gentoo.org/show_bug.cgi?id=107976). It would be nice to have a simple way to fix it. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel