On Wed, Jun 01, 2016 at 02:49:26PM +0200, Marc Richter wrote: > Hi everyone, > > please, don't roast me if I'm asking stupid things or fail to provide info, > since I'm a freshman, using libvirt. No problem, we're a friendly lot here :-) > Then a domain named "winxp_ausgeschaltet" is within that list: > > > Id Name State > ---------------------------------------------------- > ... > - winxp_ausgeschaltet shut off > > > When I do the same for the second host, it is also in that list: > > > Id Name State > ---------------------------------------------------- > ... > 7 winxp_ausgeschaltet running > > > When I do the following in Python, this domain is listed for the first host > (where it's state is "shut off"), but not for the second one: > > > import libvirt > import sys > > class kvmhost: > def __init__(self, host, keyfile): > self.conn = self.connect_kvm(host, keyfile) > self.doms = sorted(self.get_doms()) > def connect_kvm(self, host, keyfile): > try: > conn = libvirt.openReadOnly('qemu+ssh://root@' + host + > '/system?keyfile=' + keyfile) > except libvirt.libvirtError as lve: > print('Error: ' + str(lve)) > sys.exit(1) > return conn > def get_doms(self): > try: > alldoms = self.conn.listDefinedDomains() > except libvirt.libvirtError as lve: > print('Error: ' + str(lve)) > self.conn.close() > sys.exit(1) > return alldoms > > host1 = kvmhost('host1', '/path/to/ssh_keyfile') > host2 = kvmhost('host2', '/path/to/ssh_keyfile') > > print(host1.doms) > print(host2.doms) > > > What am I doing wrong here or: is there a missbehavior in libvirt or the > python module? This is expected behaviour of the listDefinedDomains() API call - though admittedly somewhat stupid behaviour. Originally libvirt has a listDomainsIDs API call that only listed guests that were running. We then added listDefinedDomains() call that only listed guests that were *not* running. So to get a complete list of guests on the host you had to use *both* listDomainsIDs and listDefinedDomains(). This had a built-in race condition if a guest started or stopped in betweeen the 2 API calls. So we introduced 'listAllDomains' as a better API that can give you a list of *all* domains whether running or stopped. > Using listAllDomains instead of listDefinedDomains gives: > > libvirt: Remote Driver error : unknown procedure: 273 I'm really surprised to see that error - this API call has existed since libvirt 0.9.13 and you say you have 1.3.1 which is more than new enough > What is the difference between listAllDomains and listDefinedDomains at all? Essentially listAllDomains() is what any app using modern libvirt should be using. We recommend ignoring listDefinedDomains & listDomainIDs unless you need to work with older (ancient) libvirt Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list