[Libvir] More queries

Hi, I've more quries on libvirt apis: 1. Is there any API in libvirt that gives me the uptime of the guets. 2. Can I know how many physical CPUs are dedicated to a VM or if they are shared. 3. How do I know the logical cpu consumption of the guests( from dom0 using libvirt obviously). 4. Can get the ip address of each of the guests with any of the APIs Thanks, Vadiraj

Katti, Vadiraj (STSD-Openview) wrote:
Hi, I've more quries on libvirt apis: 1. Is there any API in libvirt that gives me the uptime of the guets.
No there isn't, unfortunately. Best you can do is to tell how much CPU time a guest has used. I suspect this information is not available from the Xen hypervisor. If it is, then we ought to expose it where possible.
2. Can I know how many physical CPUs are dedicated to a VM or if they are shared.
Yes you can tell this by using the terribly complicated 'virDomainGetVcpus' function. Read the manual page _very_ carefully for this one :-( virt-top uses this function to display the % used and mapping of VCPUs to PCPUs in real time, so you might find playing with virt-top and looking at the code useful: http://hg.et.redhat.com/virt/applications/virt-top--devel?f=e100f86fdf28;fil...
3. How do I know the logical cpu consumption of the guests( from dom0 using libvirt obviously).
This is sort of possible. See this page for discussion and limitations of the current API: http://et.redhat.com/~rjones/virt-top/faq.html#pcpu
4. Can get the ip address of each of the guests with any of the APIs
No. Guests can send out packets from their interface using any IP address they want. By convention it's normally set up so that guests get an IP address from a DHCP server, but that's only a convention, not required. Imagine rephrasing the question as "Can I get the IP address of each machine on my LAN?". Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

Richard W.M. Jones wrote:
Katti, Vadiraj (STSD-Openview) wrote:
4. Can get the ip address of each of the guests with any of the APIs
No. Guests can send out packets from their interface using any IP address they want. By convention it's normally set up so that guests get an IP address from a DHCP server, but that's only a convention, not required. Imagine rephrasing the question as "Can I get the IP address of each machine on my LAN?".
Actually, if I'd thought about that a bit more, I might have said: look in your local ARP table, and compare the MAC addresses with the ones in the libvirt domain XML. It's still true to say that there isn't necessarily a fixed 1-1 relationship between guests' network cards and IP addresses. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Thu, Dec 13, 2007 at 03:35:44PM +0000, Richard W.M. Jones wrote:
Katti, Vadiraj (STSD-Openview) wrote:
Hi, I've more quries on libvirt apis: 1. Is there any API in libvirt that gives me the uptime of the guets.
No there isn't, unfortunately. Best you can do is to tell how much CPU time a guest has used.
I suspect this information is not available from the Xen hypervisor. If it is, then we ought to expose it where possible.
It is not available from the HV - the HV has no concept of real world time.
2. Can I know how many physical CPUs are dedicated to a VM or if they are shared.
Yes you can tell this by using the terribly complicated 'virDomainGetVcpus' function. Read the manual page _very_ carefully for this one :-(
virt-top uses this function to display the % used and mapping of VCPUs to PCPUs in real time, so you might find playing with virt-top and looking at the code useful: http://hg.et.redhat.com/virt/applications/virt-top--devel?f=e100f86fdf28;fil...
3. How do I know the logical cpu consumption of the guests( from dom0 using libvirt obviously).
This is sort of possible. See this page for discussion and limitations of the current API:
http://et.redhat.com/~rjones/virt-top/faq.html#pcpu
4. Can get the ip address of each of the guests with any of the APIs
No. Guests can send out packets from their interface using any IP address they want. By convention it's normally set up so that guests get an IP address from a DHCP server, but that's only a convention, not required. Imagine rephrasing the question as "Can I get the IP address of each machine on my LAN?".
And guests can have multiple IP address. They can have IPv4 and IPv6 address. They can even have the same addresses under some scenarios (clustering) 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 -=|

"Xm uptime" gives the uptime of all the domains running. So I believe there should be a way to get it. I'm trying to find what interface xm uses. Will update the group once I get more insight. -----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Thursday, December 13, 2007 9:06 PM To: Katti, Vadiraj (STSD-Openview) Cc: libvir-list@redhat.com Subject: Re: [Libvir] More queries Katti, Vadiraj (STSD-Openview) wrote:
Hi, I've more quries on libvirt apis: 1. Is there any API in libvirt that gives me the uptime of the guets.
2. Can I know how many physical CPUs are dedicated to a VM or if
No there isn't, unfortunately. Best you can do is to tell how much CPU time a guest has used. I suspect this information is not available from the Xen hypervisor. If it is, then we ought to expose it where possible. they
are shared.
Yes you can tell this by using the terribly complicated 'virDomainGetVcpus' function. Read the manual page _very_ carefully for this one :-( virt-top uses this function to display the % used and mapping of VCPUs to PCPUs in real time, so you might find playing with virt-top and looking at the code useful: http://hg.et.redhat.com/virt/applications/virt-top--devel?f=e100f86fdf28 ;file=virt-top/virt_top.ml
3. How do I know the logical cpu consumption of the guests( from dom0 using libvirt obviously).
This is sort of possible. See this page for discussion and limitations of the current API: http://et.redhat.com/~rjones/virt-top/faq.html#pcpu
4. Can get the ip address of each of the guests with any of the APIs
No. Guests can send out packets from their interface using any IP address they want. By convention it's normally set up so that guests get an IP address from a DHCP server, but that's only a convention, not required. Imagine rephrasing the question as "Can I get the IP address of each machine on my LAN?". Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

Katti, Vadiraj (STSD-Openview) wrote:
"Xm uptime" gives the uptime of all the domains running. So I believe there should be a way to get it. I'm trying to find what interface xm uses. Will update the group once I get more insight.
Indeed it does. Apparently xend returns a 'start_time' field for a domain, which is the start time as a Unix time_t. 'xm uptime' just prints out the current time minus this start time. One problem seems to be that this is saved in the image across reboots, so presumably it's fairly meaningless if the host machine was switched off for a signficant length of time. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
participants (3)
-
Daniel P. Berrange
-
Katti, Vadiraj (STSD-Openview)
-
Richard W.M. Jones