[libvirt-users] listing active and defined vs inactive and defined domains

i am trying to list active + defined and inactive + defined domains using libvirt 0.9.4 i can get active domains using: def s_activedomains(conn): #get active domain ids numofdomains=libvirt.virConnect.numOfDomains(conn) activedomains=libvirt.virConnect.listDomainsID(conn) return activedomains i am stuck on how to get inactive domains the example listed here http://libvirt.org/guide/html/Application_Development_Guide-Guest_Domains-Li... under example 4.4 and example 4.5 seems to be outdated looking at /usr/lib64/python2.6/site-packages/libvirt.py, line 2337 says that "Note that this won't work for inactive domains which have an ID of -1" i think example 4.5 is wrong because if inactive domains have an id of -1, then i can't call virDomainLookupBy{Name,ID}

On 05/04/2012 11:10 PM, John Wayne wrote:
i am trying to list active + defined and inactive + defined domains using libvirt 0.9.4 i can get active domains using:
def s_activedomains(conn): #get active domain ids numofdomains=libvirt.virConnect.numOfDomains(conn) activedomains=libvirt.virConnect.listDomainsID(conn) return activedomains
i am stuck on how to get inactive domains
virConnect.numOfDefinedDomains(conn) virConnect.listDefinedDomains(conn) then convert with virDomainLookupByName I still want to add a new API that returns a filterable list of ALL domains in one API, where the return is virDomainPtr rather than id or name (basically, a virDomainPtr is name, id, and uuid all rolled into one struct), and where you can use flags to filter the list (active only, inactive only, transient only, persistent only, and possibly other useful filters). Too late for 0.9.12, but should hit in 0.9.13... -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
John Wayne