This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 839259 - libvirt-python API domain query conn.listDefinedDomains() does not list all defined domains as virsh list does.
libvirt-python API domain query conn.listDefinedDomains() does not list all d...
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: libvirt (Show other bugs)
5.8
Unspecified Unspecified
unspecified Severity medium
: rc
: ---
Assigned To: Libvirt Maintainers
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-11 07:50 EDT by Frantisek Reznicek
Modified: 2015-11-15 20:14 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-11 07:53:35 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Frantisek Reznicek 2012-07-11 07:50:24 EDT
Description of problem:

'virsh list' command list all running libvirt domains / machines.

The is an equivalent in libvirt python binding:
  conn = libvirt.openReadOnly(None)
  conn.listDefinedDomains()
Python binding does not provide the information as virsh does.
See Additional info for more details...

Version-Release number of selected component (if applicable):
  libvirt-0.8.2-25.el5
  libvirt-python-0.8.2-25.el5

How reproducible:
  100%

Steps to Reproduce:
  See Additional info...
  
Actual results:
  conn.listDefinedDomains() call does not return all defined domains (as virsh list [--all])

Expected results:
conn.listDefinedDomains() call should return all defined domains (as virsh list [--all])

Additional info:

  [root@mrg-qe-16 ~]# rpm -qa | grep libvirt | sort
  libvirt-0.8.2-25.el5
  libvirt-0.8.2-25.el5
  libvirt-python-0.8.2-25.el5
  [root@mrg-qe-16 ~]# uname -a
  Linux mrg-qe-16.lab.eng.brq.redhat.com 2.6.18-308.8.2.el5 #1 SMP Tue May 29 11:54:17 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
  
  
  [root@mrg-qe-16 ~]# virsh help | grep list | grep -v "\-"
      list            list domains
  [root@mrg-qe-16 ~]# virsh list
  Id Name                 State
  ----------------------------------
    5 cluster-rhel5i-0     running
    6 cluster-rhel5x-4     running
    7 cluster-rhel5x-3     running
    8 cluster-rhel5x-2     running
    9 cluster-rhel5x-1     running
  
  [root@mrg-qe-16 ~]# virsh list --all
  Id Name                 State
  ----------------------------------
    5 cluster-rhel5i-0     running
    6 cluster-rhel5x-4     running
    7 cluster-rhel5x-3     running
    8 cluster-rhel5x-2     running
    9 cluster-rhel5x-1     running
    - cluster-rhel5x-0     shut off
  
  [root@mrg-qe-16 ~]# python
  Python 2.4.3 (#1, May  1 2012, 13:55:48) 
  [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import libvirt
  >>> conn = libvirt.openReadOnly(None)
  >>> conn.listDomainsID()
  [9, 6, 7, 8, 5]
  >>> conn.listDefinedDomains()
  ['cluster-rhel5x-0']
  >>> conn.lookupByName("cluster-rhel5x-1")
  <libvirt.virDomain instance at 0x2aad2ec99200>
  >>> conn2=libvirt.open("qemu:///system")
  >>> conn2.listDomainsID()
  [9, 6, 7, 8, 5]
  >>> conn2.listDefinedDomains()
  ['cluster-rhel5x-0']
  >>>
Comment 1 Daniel Berrange 2012-07-11 07:53:35 EDT
You are not comparing like-for-like here.  The 'virsh list --all' command will *combine* the results from  listDomainsID() and listDefineDomains().  The listDefinedDomains() API will only list defined domains which are not running.

Note You need to log in before you can comment on or make changes to this bug.