Personal tools
You are here: Home Members marc blog Blog on Virtualisation Connect to a libvirt machine and get information on domains
Document Actions

Connect to a libvirt machine and get information on domains

How can you connect to a libvirt host machine and get information on domains

First configure libvirtd:

/etc/libvirtd/libvirtd.conf:

    listen_tls=1
    listen_tcp=0
    tls_no_verify_certificate=0
    tls_no_verify_certificate=0

Create certificates for libvirtd and put the client ones in /etc/pki/libvirt as described on the http://libvirt.org/remote.html:"libvirtd website".

Restart libvirtd and there you go.

The following skript helps:

  import sys
  import libvirt
  uri=sys.argv[1]
  conn=libvirt.openReadOnly(uri)
   for i in conn.listDomainsID():
    dom=conn.lookupByID(i)
    info=dom.info()
    print "Dom %s, state: %u, maxMemory: %u, memory: %u, nbVirtCPU: %u, cpuTime: %u" %(dom.name(), info[0], info[1], info[2], info[3], info[4])

Descripton of info:

  • unsigned char state : the running state, one of virDomainFlags
  • unsigned long maxMem : the maximum memory in KBytes allowed
  • unsigned long memory : the memory in KBytes used by the domain
  • unsigned short nrVirtCpu : the number of virtual CPUs for the domain
  • unsigned long long cpuTime : the CPU time used in nanoseconds

On URIs:

You might want to use the no_verify=1 parameter if certs cannot be verified. Given vmhost1 as xen virtualized hostname the url would be: xen://xenhost1/?no_verify=1

Further external information:

Blog on Virtualisation
« May 2012 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Blog on Virtualisation:
More...
Categories:
Virtualisation (3)
Xen (2)
libvirt (1)
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: