WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [RFC] Is this process running on which machine?

To: Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [RFC] Is this process running on which machine?
From: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Date: Sat, 18 Nov 2006 13:53:35 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sat, 18 Nov 2006 06:55:15 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <CBC70AF1753233takebe_akio@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <CBC70AF1753233takebe_akio@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Sat, Nov 18, 2006 at 06:10:57PM +0900, Akio Takebe wrote:

> Hi, all
> 
> I'd like to know "Is this process running on which machine?"
> For example, a native machien, or dom0, or domU, or HVM..
> 
> So I research codes of xen,
> then I make the following shell.
> (I haven't confirmed HVM yet because I don't use VTx machine.)
> What do you think about it?
> 
> =========================================================================
> #!/bin/bash
> 
> if [ -d /sys/hypervisor ] ; then
>         UUID=$(cat /sys/hypervisor/uuid)
>         if [ x"$UUID" == x"00000000-0000-0000-0000-000000000000" ]; then
>                 echo "this is dom0."
>         else
>                 echo "this is domU."
>         fi
> else
>         IS_HVM=$(strings /proc/acpi/dsdt | grep -i xen)
>         if [ x"IS_HVM" != x ]; then
>                 echo "this is hvm machine"
>         else
>                 echo "this is native machine"
>         fi
> fi

I wouldn't rely upon the UUID of domain 0 being all-zeros -- there have
been arguments about that in the past.

The proper mechanism for doing this is

grep -q "control_d" /proc/xen/capabilities

This will be true if you are in the "initial control domain"
(SIF_INITDOMAIN has been set).

Ewan.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel