Is there an "officially sanctioned" method for a shell script to test whether it is running on a native OS vs pv OS vs hvm OS (and possibly also dom0 OS)? I know there are lots of different ways to determine this but am wondering if any one will work across all (recent and future) implementations of Xen and across multiple (at least Linux-based) distros. If not, perhaps there could/should be a C/python tool in the Xen tree that does this? ==================================If Xen could save time in a bottle / then clocks wouldn't virtually skew / It would save every tick / for VMs that aren't quick / and Xen then would send them anew (with apologies to the late great Jim Croce) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
It''s not a shell script, but tools/misc/xen-detect.c will do what you want on x86 platforms. To detect a Linux dom0 you can check for ''control_d'' in /proc/xen/capabilities. -- Keir On 22/2/08 20:58, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote:> Is there an "officially sanctioned" method for a shell script to > test whether it is running on a native OS vs pv OS vs hvm OS > (and possibly also dom0 OS)? > > I know there are lots of different ways to determine this but > am wondering if any one will work across all (recent and future) > implementations of Xen and across multiple (at least Linux-based) > distros. > > If not, perhaps there could/should be a C/python tool in the Xen tree > that does this? > > ==================================> If Xen could save time in a bottle / then clocks wouldn''t virtually skew / > It would save every tick / for VMs that aren''t quick / > and Xen then would send them anew > (with apologies to the late great Jim Croce) > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Thanks for pointing this tool out! Looks useful. Unfortunately, for it to be broadly useful, it would have to ship with all distros as compiling it "on demand" on the guest is often not an option. Porting xen-detect to shell script doesn''t look possible since it uses inline assembly. Any other ideas?> -----Original Message----- > From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > Sent: Friday, February 22, 2008 2:18 PM > To: dan.magenheimer@oracle.com; xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] Shell test for pv vs hvm (vs dom0) > > > It''s not a shell script, but tools/misc/xen-detect.c will do > what you want > on x86 platforms. To detect a Linux dom0 you can check for > ''control_d'' in > /proc/xen/capabilities. > > -- Keir > > On 22/2/08 20:58, "Dan Magenheimer" > <dan.magenheimer@oracle.com> wrote: > > > Is there an "officially sanctioned" method for a shell script to > > test whether it is running on a native OS vs pv OS vs hvm OS > > (and possibly also dom0 OS)? > > > > I know there are lots of different ways to determine this but > > am wondering if any one will work across all (recent and future) > > implementations of Xen and across multiple (at least Linux-based) > > distros. > > > > If not, perhaps there could/should be a C/python tool in > the Xen tree > > that does this? > > > > ==================================> > If Xen could save time in a bottle / then clocks wouldn''t > virtually skew / > > It would save every tick / for VMs that aren''t quick / > > and Xen then would send them anew > > (with apologies to the late great Jim Croce) > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
pradeep singh rautela
2008-Feb-23 05:36 UTC
Re: [Xen-devel] Shell test for pv vs hvm (vs dom0)
I don''t know, but does libvirt API has any xen compatible methods for your requirements? Just guessing, please feel free to correct me. Thanks, --Pradeep On 23/02/2008, Dan Magenheimer <dan.magenheimer@oracle.com> wrote:> Thanks for pointing this tool out! Looks useful. > > Unfortunately, for it to be broadly useful, it would have > to ship with all distros as compiling it "on demand" on > the guest is often not an option. > > Porting xen-detect to shell script doesn''t look possible since > it uses inline assembly. > > Any other ideas? > > > > -----Original Message----- > > From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > > Sent: Friday, February 22, 2008 2:18 PM > > To: dan.magenheimer@oracle.com; xen-devel@lists.xensource.com > > Subject: Re: [Xen-devel] Shell test for pv vs hvm (vs dom0) > > > > > > It''s not a shell script, but tools/misc/xen-detect.c will do > > what you want > > on x86 platforms. To detect a Linux dom0 you can check for > > ''control_d'' in > > /proc/xen/capabilities. > > > > -- Keir > > > > On 22/2/08 20:58, "Dan Magenheimer" > > <dan.magenheimer@oracle.com> wrote: > > > > > Is there an "officially sanctioned" method for a shell script to > > > test whether it is running on a native OS vs pv OS vs hvm OS > > > (and possibly also dom0 OS)? > > > > > > I know there are lots of different ways to determine this but > > > am wondering if any one will work across all (recent and future) > > > implementations of Xen and across multiple (at least Linux-based) > > > distros. > > > > > > If not, perhaps there could/should be a C/python tool in > > the Xen tree > > > that does this? > > > > > > ==================================> > > If Xen could save time in a bottle / then clocks wouldn''t > > virtually skew / > > > It would save every tick / for VMs that aren''t quick / > > > and Xen then would send them anew > > > (with apologies to the late great Jim Croce) > > > _______________________________________________ > > > Xen-devel mailing list > > > Xen-devel@lists.xensource.com > > > http://lists.xensource.com/xen-devel > > > > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >-- Pradeep Singh Rautela http://eagain.wordpress.com http://emptydomain.googlepages.com _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
There''s no general way to discriminate between HVM and native from a shell script. You might discriminate between HVM and PV on Linux by looking for /sys/hypervisor or /proc/xen. -- Keir On 22/2/08 22:38, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote:> Thanks for pointing this tool out! Looks useful. > > Unfortunately, for it to be broadly useful, it would have > to ship with all distros as compiling it "on demand" on > the guest is often not an option. > > Porting xen-detect to shell script doesn''t look possible since > it uses inline assembly. > > Any other ideas? > >> -----Original Message----- >> From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] >> Sent: Friday, February 22, 2008 2:18 PM >> To: dan.magenheimer@oracle.com; xen-devel@lists.xensource.com >> Subject: Re: [Xen-devel] Shell test for pv vs hvm (vs dom0) >> >> >> It''s not a shell script, but tools/misc/xen-detect.c will do >> what you want >> on x86 platforms. To detect a Linux dom0 you can check for >> ''control_d'' in >> /proc/xen/capabilities. >> >> -- Keir >> >> On 22/2/08 20:58, "Dan Magenheimer" >> <dan.magenheimer@oracle.com> wrote: >> >>> Is there an "officially sanctioned" method for a shell script to >>> test whether it is running on a native OS vs pv OS vs hvm OS >>> (and possibly also dom0 OS)? >>> >>> I know there are lots of different ways to determine this but >>> am wondering if any one will work across all (recent and future) >>> implementations of Xen and across multiple (at least Linux-based) >>> distros. >>> >>> If not, perhaps there could/should be a C/python tool in >> the Xen tree >>> that does this? >>> >>> ==================================>>> If Xen could save time in a bottle / then clocks wouldn''t >> virtually skew / >>> It would save every tick / for VMs that aren''t quick / >>> and Xen then would send them anew >>> (with apologies to the late great Jim Croce) >>> _______________________________________________ >>> Xen-devel mailing list >>> Xen-devel@lists.xensource.com >>> http://lists.xensource.com/xen-devel >> >> >> >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Could it be possible to define some bios magic for "hardware vendor"? So a HVM Guest would ask "What hardware am I running on?" Just a thought... Keir Fraser schrieb:> There''s no general way to discriminate between HVM and native from a shell > script. You might discriminate between HVM and PV on Linux by looking for > /sys/hypervisor or /proc/xen. > > -- Keir > > On 22/2/08 22:38, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote: > >> Thanks for pointing this tool out! Looks useful. >> >> Unfortunately, for it to be broadly useful, it would have >> to ship with all distros as compiling it "on demand" on >> the guest is often not an option._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
There''s already HVM strings in SMBIOS and ACPI tables, but they''re not particularly accessible from shell scripts in a generic way. -- Keir On 23/2/08 14:26, "Stephan Seitz" <s.seitz@netz-haut.de> wrote:> Could it be possible to define some bios magic for "hardware vendor"? > So a HVM Guest would ask "What hardware am I running on?" > > Just a thought... > > Keir Fraser schrieb: >> There''s no general way to discriminate between HVM and native from a shell >> script. You might discriminate between HVM and PV on Linux by looking for >> /sys/hypervisor or /proc/xen. >> >> -- Keir >> >> On 22/2/08 22:38, "Dan Magenheimer" <dan.magenheimer@oracle.com> wrote: >> >>> Thanks for pointing this tool out! Looks useful. >>> >>> Unfortunately, for it to be broadly useful, it would have >>> to ship with all distros as compiling it "on demand" on >>> the guest is often not an option. > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Perhaps there''s something in sysfs or proc somewhere that could discern between HVM and native?> > So a HVM Guest would ask "What hardware am I running on?"Interestingly, I just ran across a place in 2.6.18-based guests (e.g. RHEL5) in the timer code where a test is made whether an Intel or AMD "box" is being booted to decide whether or not to trust that TSC will be syncrhonized across multiple cpus. Obviously this test is invalid for virtual machines (though in this case, it is probably correct "most" of the time).> -----Original Message----- > From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > Sent: Saturday, February 23, 2008 7:36 AM > To: Stephan Seitz > Cc: dan.magenheimer@oracle.com; xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] Shell test for pv vs hvm (vs dom0) > > > There''s already HVM strings in SMBIOS and ACPI tables, but they''re not > particularly accessible from shell scripts in a generic way. > > -- Keir > > > On 23/2/08 14:26, "Stephan Seitz" <s.seitz@netz-haut.de> wrote: > > > Could it be possible to define some bios magic for > "hardware vendor"? > > So a HVM Guest would ask "What hardware am I running on?" > > > > Just a thought... > > > > Keir Fraser schrieb: > >> There''s no general way to discriminate between HVM and > native from a shell > >> script. You might discriminate between HVM and PV on Linux > by looking for > >> /sys/hypervisor or /proc/xen. > >> > >> -- Keir > >> > >> On 22/2/08 22:38, "Dan Magenheimer" > <dan.magenheimer@oracle.com> wrote: > >> > >>> Thanks for pointing this tool out! Looks useful. > >>> > >>> Unfortunately, for it to be broadly useful, it would have > >>> to ship with all distros as compiling it "on demand" on > >>> the guest is often not an option. > > > > > > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Sat, 2008-02-23 at 08:18 +0000, Keir Fraser wrote:> There''s no general way to discriminate between HVM and native from a shell > script. You might discriminate between HVM and PV on Linux by looking for > /sys/hypervisor or /proc/xen.Isn''t something like this generally sufficient for a shell script? lspci -n | grep -q "5853:0001" if [ $? -eq 0 ]; then # HVM domain elif [ -d /proc/xen ]; then if grep -q "control_d" /proc/xen/capabilities; then # DOM0 else # DOMU fi else # Native fi It seems fairly reliable on ia64 for Xen 3.x. Thanks, Alex -- Alex Williamson HP Open Source & Linux Org. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Yes, that should work for Linux just fine I think. -- Keir On 25/2/08 12:58, "Alex Williamson" <alex.williamson@hp.com> wrote:> > On Sat, 2008-02-23 at 08:18 +0000, Keir Fraser wrote: >> There''s no general way to discriminate between HVM and native from a shell >> script. You might discriminate between HVM and PV on Linux by looking for >> /sys/hypervisor or /proc/xen. > > Isn''t something like this generally sufficient for a shell script? > > lspci -n | grep -q "5853:0001" > if [ $? -eq 0 ]; then > # HVM domain > elif [ -d /proc/xen ]; then > if grep -q "control_d" /proc/xen/capabilities; then > # DOM0 > else > # DOMU > fi > else > # Native > fi > > It seems fairly reliable on ia64 for Xen 3.x. Thanks, > > Alex_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Daniel P. Berrange
2008-Feb-25 13:45 UTC
Re: [Xen-devel] Shell test for pv vs hvm (vs dom0)
On Mon, Feb 25, 2008 at 01:40:05PM +0000, Keir Fraser wrote:> Yes, that should work for Linux just fine I think.On x86 at least you also have the option of using dmidecode to detect an HVM guest, looking for ''Xen'' in the ''System Information'' block. And the ''xen-detect'' command in tools/misc/ provides another way to detect presence of Xen PV vs HVM.> On 25/2/08 12:58, "Alex Williamson" <alex.williamson@hp.com> wrote: > > > > > On Sat, 2008-02-23 at 08:18 +0000, Keir Fraser wrote: > >> There''s no general way to discriminate between HVM and native from a shell > >> script. You might discriminate between HVM and PV on Linux by looking for > >> /sys/hypervisor or /proc/xen. > > > > Isn''t something like this generally sufficient for a shell script? > > > > lspci -n | grep -q "5853:0001" > > if [ $? -eq 0 ]; then > > # HVM domain > > elif [ -d /proc/xen ]; then > > if grep -q "control_d" /proc/xen/capabilities; then > > # DOM0 > > else > > # DOMU > > fi > > else > > # Native > > fi > > > > It seems fairly reliable on ia64 for Xen 3.x. Thanks, > > > > Alex > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel-- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Thanks much! These are great!> -----Original Message----- > From: Daniel P. Berrange [mailto:berrange@redhat.com] > Sent: Monday, February 25, 2008 6:46 AM > To: Keir Fraser > Cc: Alex Williamson; dan.magenheimer@oracle.com; > xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] Shell test for pv vs hvm (vs dom0) > > > On Mon, Feb 25, 2008 at 01:40:05PM +0000, Keir Fraser wrote: > > Yes, that should work for Linux just fine I think. > > On x86 at least you also have the option of using dmidecode > to detect an > HVM guest, looking for ''Xen'' in the ''System Information'' block. > > And the ''xen-detect'' command in tools/misc/ provides another way to > detect presence of Xen PV vs HVM. > > > On 25/2/08 12:58, "Alex Williamson" <alex.williamson@hp.com> wrote: > > > > > > > > On Sat, 2008-02-23 at 08:18 +0000, Keir Fraser wrote: > > >> There''s no general way to discriminate between HVM and > native from a shell > > >> script. You might discriminate between HVM and PV on > Linux by looking for > > >> /sys/hypervisor or /proc/xen. > > > > > > Isn''t something like this generally sufficient for a shell script? > > > > > > lspci -n | grep -q "5853:0001" > > > if [ $? -eq 0 ]; then > > > # HVM domain > > > elif [ -d /proc/xen ]; then > > > if grep -q "control_d" /proc/xen/capabilities; then > > > # DOM0 > > > else > > > # DOMU > > > fi > > > else > > > # Native > > > fi > > > > > > It seems fairly reliable on ia64 for Xen 3.x. Thanks, > > > > > > Alex > > > > > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > > -- > |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 > 978 392 2496 -=| > |=- Perl modules: http://search.cpan.org/~danberr/ > -=| > |=- Projects: http://freshmeat.net/~danielpb/ > -=| > |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF > F742 7D3B 9505 -=| >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel