[Libvir] Guest Identification

Hi, I'm trying to find a good way to correlate a domain to the machine it's running on. Can I use libvir or some other method on a domU to get some information that uniquely identifies it? Perhaps something that I can get from the XML running on dom0? I'm thinking of using the MAC address because I imagine that those things should be unique at least per hypervisor, but I'm not sure if that would work across physical boxes. The solution would be to use libvir to get the list of domains and then get the xml which includes the mac address. Then every domain on my network would hit a server and report its mac address, and then I could make a tree that links the dom0's to the domU's. I'm wondering if there's a better way to do this. Any suggestions would be greatly appreciated. Thanks for your help.

On Thu, Aug 10, 2006 at 04:11:36PM -0400, Juan Walker wrote:
Hi,
I'm trying to find a good way to correlate a domain to the machine it's running on. Can I use libvir or some other method on a domU to get some information that uniquely identifies it? Perhaps something that I can get from the XML running on dom0?
Domains have an unique identifier which you can extract: http://libvirt.org/html/libvirt-libvirt.html#virDomainGetUUID
The solution would be to use libvir to get the list of domains and then get the xml which includes the mac address. Then every domain on my network
The MAC address can be specified in the config file, it's less likely to be unique, use the UUID. The only caveat is that domain0 has a 0 filled UUID, and that will be the case on all nodes :-\ Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On 8/10/06, Daniel Veillard <veillard@redhat.com> wrote:
On Thu, Aug 10, 2006 at 04:11:36PM -0400, Juan Walker wrote:
Hi,
I'm trying to find a good way to correlate a domain to the machine it's running on. Can I use libvir or some other method on a domU to get some information that uniquely identifies it? Perhaps something that I can get from the XML running on dom0?
Domains have an unique identifier which you can extract: http://libvirt.org/html/libvirt-libvirt.html#virDomainGetUUID
Ah, great! Thanks. Is it possible for me to find out the UUID from something running on domU? I need to have the application connect to the server and identify the information it's sending as being from its specific domain. Any ideas? Juan

On Thu, Aug 10, 2006 at 04:28:20PM -0400, Juan Walker wrote:
On 8/10/06, Daniel Veillard <veillard@redhat.com> wrote:
Domains have an unique identifier which you can extract: http://libvirt.org/html/libvirt-libvirt.html#virDomainGetUUID
Ah, great! Thanks. Is it possible for me to find out the UUID from something running on domU? I need to have the application connect to the server and identify the information it's sending as being from its specific domain. Any ideas?
Oh, I don't think domU has access to that information, libvirt is meant to be used on dom0, won't work in domU. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Fri, Aug 11, 2006 at 09:05:12AM -0400, Daniel Veillard wrote:
On Thu, Aug 10, 2006 at 04:28:20PM -0400, Juan Walker wrote:
On 8/10/06, Daniel Veillard <veillard@redhat.com> wrote:
Domains have an unique identifier which you can extract: http://libvirt.org/html/libvirt-libvirt.html#virDomainGetUUID
Ah, great! Thanks. Is it possible for me to find out the UUID from something running on domU? I need to have the application connect to the server and identify the information it's sending as being from its specific domain. Any ideas?
Oh, I don't think domU has access to that information, libvirt is meant to be used on dom0, won't work in domU.
Yeah it is not a job for libvirt, but you can get this info within DomU if you are using recent enough Xen tools (xen-unstable / forthcoming Xen 3.0.3) In fully-virt (HVM) guests you can query the SMBIOS for it using DMIDecode. # dmidecode | grep --after 7 'Handle 0x0001' Handle 0x0001 DMI type 1, 25 bytes. System Information Manufacturer: IBM Product Name: 2672JHG Version: ThinkPad X31 Serial Number: KBPKNB2 UUID: EF861801-45B9-11CB-88E3-AFBFE5370493 Incidentally if you want a sensible UUID for Domain0 rather than the one Xen gives (0000000-00000-0000-0000-000000) then you can again use DMIDecode to get the UUID associated with the physical machine - this example above is from my laptop in Domain-0. On para-virt guests you can get the UUID from a file in sysfs: /sys/hypervisor/uuid As I say above though both of these tricks require a fairly recent set of Xen tools from xen-unstable. Failing that you could do some tricks such as passing the UUID on the kernel boot command line when starting the DomU instance and then access that from /proc/cmdline. Regards, Dan. -- |=- 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 -=|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Juan Walker