All of lore.kernel.org
 help / color / mirror / Atom feed
* simple check for domU?
@ 2005-11-11  0:23 Chris Bainbridge
  2005-11-11  1:52 ` Karsten M. Self
  2005-11-11 18:14 ` NAHieu
  0 siblings, 2 replies; 7+ messages in thread
From: Chris Bainbridge @ 2005-11-11  0:23 UTC (permalink / raw)
  To: Xen development list

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

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

* Re: simple check for domU?
  2005-11-11  0:23 simple check for domU? Chris Bainbridge
@ 2005-11-11  1:52 ` Karsten M. Self
  2005-11-11 16:21   ` Chris Bainbridge
  2005-11-11 18:14 ` NAHieu
  1 sibling, 1 reply; 7+ messages in thread
From: Karsten M. Self @ 2005-11-11  1:52 UTC (permalink / raw)
  To: 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

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

* Re: simple check for domU?
  2005-11-11  1:52 ` Karsten M. Self
@ 2005-11-11 16:21   ` Chris Bainbridge
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Bainbridge @ 2005-11-11 16:21 UTC (permalink / raw)
  To: 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.

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

* Re: simple check for domU?
  2005-11-11  0:23 simple check for domU? Chris Bainbridge
  2005-11-11  1:52 ` Karsten M. Self
@ 2005-11-11 18:14 ` NAHieu
  2005-11-11 20:33   ` Chris Bainbridge
  1 sibling, 1 reply; 7+ messages in thread
From: NAHieu @ 2005-11-11 18:14 UTC (permalink / raw)
  To: Chris Bainbridge; +Cc: Xen development list

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.

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

* Re: simple check for domU?
  2005-11-11 18:14 ` NAHieu
@ 2005-11-11 20:33   ` Chris Bainbridge
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Bainbridge @ 2005-11-11 20:33 UTC (permalink / raw)
  To: NAHieu; +Cc: Xen development list

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?

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

* RE: simple check for domU?
@ 2005-11-12  1:33 James Harper
  2005-11-12  2:26 ` Chris Bainbridge
  0 siblings, 1 reply; 7+ messages in thread
From: James Harper @ 2005-11-12  1:33 UTC (permalink / raw)
  To: Chris Bainbridge, NAHieu; +Cc: Xen development list

> 
> 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. 

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

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

* Re: simple check for domU?
  2005-11-12  1:33 James Harper
@ 2005-11-12  2:26 ` Chris Bainbridge
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Bainbridge @ 2005-11-12  2:26 UTC (permalink / raw)
  To: James Harper; +Cc: NAHieu, Xen development list

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.

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

end of thread, other threads:[~2005-11-12  2:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-11  0:23 simple check for domU? Chris Bainbridge
2005-11-11  1:52 ` Karsten M. Self
2005-11-11 16:21   ` Chris Bainbridge
2005-11-11 18:14 ` NAHieu
2005-11-11 20:33   ` Chris Bainbridge
  -- strict thread matches above, loose matches on Subject: below --
2005-11-12  1:33 James Harper
2005-11-12  2:26 ` Chris Bainbridge

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.