Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm actually testing RHEL 5.3 with Xen between two servers in order to have a disaster recovery solution. So I'm playing with moving my domU from one dom0 server to the other server.

Unfortunatly when somebody else move the domU I don't have any clue where my domain is hosted. I'm wondering where I can't find my dom0 name with inside domU. I'm looking for something like the gzonename command on a solaris sparse zone. I check inside /proc/xen but I don't see anything special except the dom0 kernel release.

Does anybody know a wait to find this ?

share|improve this question
    
What benefit is there to having a domU know its dom0's hostname? –  SirStan Aug 20 '09 at 23:11
2  
If you want to add some memory or disk, it's better to know on which dom0 you have to connect. –  svigan Aug 20 '09 at 23:23
    
Surprised that it's 2 years since this was asked, and no real answer has been provided. I'm searching for the same thing at the moment - how to identify the dom0 that a domU I'm logged into is physically running on. –  dossy Mar 1 '12 at 18:40

5 Answers 5

We use xenstore-write /tool/hostname $(uname -n); xenstore-chmod /tool/hostname r on Dom0 and then xenstore-read /tool/hostname within the VMs. Easy and lightweight ...

share|improve this answer
    
This works well. Can you confirm if this persist over XEN server reboots or does this need to run on each startup? –  AXE-Labs Jul 21 at 19:28

I'm pretty sure there's no way to find the dom0 "name" (which is a nebulous concept at best) from within the domU. If you're not running pygrub, you could add something to the kernel boot command line (in the domU config file stored on each dom0) that you could query from /proc/cmdline, but that's a bit of a hack.

What you really should be doing is having a script that can query the dom0s to display which VMs are where. Even something that looped through the dom0s and ran xm list would probably do for your simple purposes.

share|improve this answer
    
Actually what I'm doing is starting the dom0 with a home made script which create a /etc/hvname file within the name of the dom0. –  svigan Aug 20 '09 at 23:37

I found a clever solution (which I can't take credit for): add a parameter to the Xen script to tell the domU which dom0 it's running on

share|improve this answer
    
Since the kernel will ignore anything that it does not undestand - ok. But this will propably not work in a live-migrate (i.e. the kernel-parameter will not change after the move). –  Nils May 18 '11 at 19:56

SLES11 has a "clever" solution provided by two rpms:

The first runs on the Dom0 and creates a small ram-disk (loop-device in /dev/shm). That ram-disk is attached in ro/read many-mode to the DomU. Then a daemon-process in Dom0 updates some information in the ram-disk at configurable intervals (Dom0-hostname, cpu-load of the Dom0, ...).

The second runs in the DomU and reads the values of that attached ram-disk.

See SLES11 XEN Documentation for further details...

share|improve this answer

I know this has been posted for a few years but I see this is a heavily accessed page which still does not have an way to find this retroactively, so here's the method I used:

From the VM, use tcpdump to find the switch name and port number:

[myID@vm001 ~] sudo tcpdump –nn –v –i eth0 –s 1500 –c 1 ‘ether[20:2] == 0x2000’

Give it a few min. to run; when it's done, look for these two lines in the output (they will be separated by other output lines):

Device-ID (0x01), length: 26 bytes: ‘Switch001.mydomain.com’
Port-ID (0x03), length: 19 bytes: ‘GigabitEthernet8/17’

You will then need to look at your switch port to determine what physical server is attached. Hopefully you either have physical access to the switch and can perform a cable trace or can engage someone who can, or you have good descriptions on switch port configurations and can view that information or engage someone who can. I have read access to our switches and was able to find my host server that way:

SWITCH001#sho interface description | inc 8/17
Gi8/17                         up             up       HOST0002
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.