6

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 ?

3
  • What benefit is there to having a domU know its dom0's hostname?
    – SirStan
    Aug 20, 2009 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, 2009 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, 2012 at 18:40

6 Answers 6

9

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

1
  • 1
    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, 2014 at 19:28
3

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.

1
  • 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, 2009 at 23:37
2

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

Update 2017-01-31: Section 10.7

3
  • The provided link shows the whole SLES XEN documentation. What is the name of the clever solution so that curious reader can look it up?
    – L.R.
    Jan 31, 2017 at 14:46
  • @L.R. I updated my answer with the current according section
    – Nils
    Jan 31, 2017 at 22:30
  • Nice :) vhostmd and vm-dump-metrics were the keywords that I was looking for.
    – L.R.
    Feb 16, 2017 at 8:04
1

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

1
  • 1
    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, 2011 at 19:56
1

Install lldpd on the Xen Dom0 and DomUs. Then lldpctl will tell you which network bridge and the hostname of the bridge (i.e. the name of the Dom0). On the Dom0 you will also see the upstream switches if they have LLDP enabled, which can also be useful.

This works for PV, PVHVM, etc. In fact, it should work for any virtualisation platform that can run LLDP on the host, unless the host forwards LLDP packets straight through (which it should not).

1

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:

$ 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# show interface description | inc 8/17
Gi8/17                         up             up       HOST0002

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .