[libvirt] Just to make sure I understand the API

To make sure I understand the API. If I have a domain defined, but not started.. it will show up in the list returned by: virConnectListDefinedDomains but not in the list virConnectListDomains Conversely, if it is started... it will only be in the list: virConnectListDomains not in the list virConnectListDefinedDomains Is that correct? -- bk

2010/1/9 Bryan Kearney <bkearney@redhat.com>:
To make sure I understand the API. If I have a domain defined, but not started.. it will show up in the list returned by:
virConnectListDefinedDomains
but not in the list
virConnectListDomains
Conversely, if it is started... it will only be in the list:
virConnectListDomains
not in the list
virConnectListDefinedDomains
Is that correct?
-- bk
Yes, that's the correct behavior of these functions. virConnectListDefinedDomains list domains that are inactive but defined and virConnectListDomains lists domains that are active. If you combine the output of both functions then you get the complete list of domains libvirt knows about for a given host. Matthias

On Sun, Jan 10, 2010 at 01:20:38PM +0100, Matthias Bolte wrote:
2010/1/9 Bryan Kearney <bkearney@redhat.com>:
To make sure I understand the API. If I have a domain defined, but not started.. it will show up in the list returned by:
virConnectListDefinedDomains
but not in the list
virConnectListDomains
Conversely, if it is started... it will only be in the list:
virConnectListDomains
not in the list
virConnectListDefinedDomains
Is that correct?
-- bk
Yes, that's the correct behavior of these functions. virConnectListDefinedDomains list domains that are inactive but defined and virConnectListDomains lists domains that are active.
If you combine the output of both functions then you get the complete list of domains libvirt knows about for a given host.
Modulo the obvious race condition where a guest starts/stops in between the time you call those two functions :-) One of these days I'll have time to add an API I've long wanted - one that lists all domains, and returns the virDomainPtr objects directly virConnectListAllDomains(virConnectPtr conn, virDomainPtr *domains, int *ndomains); where libvirt allocates 'domains' to be the right size, not requiring the caller todo so. Similarly this same API pattern for all other objects virNetworkPtr, virStoragePoolPtr, etc, etc Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Anno domini 2010 Daniel P. Berrange scripsit: Hi! [...]
Yes, that's the correct behavior of these functions. virConnectListDefinedDomains list domains that are inactive but defined and virConnectListDomains lists domains that are active.
If you combine the output of both functions then you get the complete list of domains libvirt knows about for a given host.
Modulo the obvious race condition where a guest starts/stops in between the time you call those two functions :-)
One of these days I'll have time to add an API I've long wanted - one that lists all domains, and returns the virDomainPtr objects directly
virConnectListAllDomains(virConnectPtr conn, virDomainPtr *domains, int *ndomains);
where libvirt allocates 'domains' to be the right size, not requiring the caller todo so. Similarly this same API pattern for all other objects virNetworkPtr, virStoragePoolPtr, etc, etc
This would be _really_ appreciated :) Ciao Max -- Eine Freie Meinung in einem Freien Kopf für einen Freien Staat voll Freier Bürger.
participants (4)
-
Bryan Kearney
-
Daniel P. Berrange
-
Matthias Bolte
-
Maximilian Wilhelm