LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   XEN VM Can you tell which is your host machine (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/xen-vm-can-you-tell-which-is-your-host-machine-869034/)

LQParsons 03-16-2011 04:27 PM

XEN VM Can you tell which is your host machine
 
Hi.
We're using the VMs of XEN (SuSE Linux) to run system critical processes, and further redundancy by having XEN on another machine. We boot the VMs over NFS so they are identical. We run one or the other.

Is there anyway, within a VM, to find out your host machine ?

As our VMs have their names in our DNS, with identical IPs, one connects via IP or NAME; it'd be interesting to be able to tell which of the parent hosts you are situated.

Thanks.
-doug

LQParsons 03-26-2011 12:04 PM

If I'm logged onto a machine,

Question #1
How can I tell if it's a Xen/VM ?

Question #2
If so, how do I determine the host on which it is running ?

Thanks.
-doug

(I'm fully prepared to receive some basic information, as I have as yet never traipsed down this primrose path. <.grin>)

Slax-Dude 03-26-2011 06:18 PM

You can easily do this if you use libvirt to manage xen, by either querying each host with virsh or using the php API and build a status page you can access.
The virsh approach is the most useful for script automation, of course.

tommylovell 03-27-2011 12:41 PM

Quote:

Question #1
How can I tell if it's a Xen/VM ?
Look at 'model name' in /proc/cpuinfo. I think that often shows a virtual cpu of some sort.

LQParsons 03-27-2011 05:43 PM

Hi Thanks.
$ virsh
looks interesting, its help says it's similar to
$ xm
as a tool to manage the VM running beneath.
I've been using xm as I tend to avoid GUI -- just a personal preference.

My question, however, is from the bottom looking up.

Not too long ago, one of my VMs wouldn't boot, got caught in an FSCK repair loop. Since the disks are virtual, the answer was to reboot the mother machine, do the FSCK-repair on the real disk, then all the VMs were restarted and were fine.

That got me thinking, say I have a VM, let's call it vm-foobar
which can be running under XEN on some number of machines: Moe, Larry, Curly.

(As we have many architectures {some more decrepit than others} in our heterogeneous shop, we're thinking of using VMs to better enable moving important functions from one machine to another for any disaster or maintenance.)

So when I get onto my VM, say
$ ssh fubar@foobar.test.lab
is there a way I can determine which host: (Moe, Larry, or Curly) I'm running on?

virsh doesn't run in the VM, it's only available on the mother ship.
/proc/cpuinfo gives me good information, just not what I'm looking for.

Thanks to all for all help received thus far.

-Doug.

Slax-Dude 03-27-2011 05:47 PM

Quote:

Originally Posted by LQParsons (Post 4305573)
virsh doesn't run in the VM, it's only available on the mother ship.

It will if you install it there ;)


All times are GMT -5. The time now is 09:57 PM.