Description of problem: With the Python API, calling listDomainsID() when connected to OpenVZ that has no containers throws an exception. Version-Release number of selected component (if applicable): 0.9.8 How reproducible: Reliably reproducible. Steps to Reproduce: 1. Run this script: #!/usr/bin/env python import libvirt conn = libvirt.open('openvz+unix:///system') print "Found %d domains" % conn.numOfDomains() for id in conn.listDomainsID(): print "ok" Actual results: Found 0 domains libvir: error : internal error Child process (/usr/sbin/vzlist -ovpsid -H) status unexpected: exit status 1 Traceback (most recent call last): File "./test.py", line 7, in <module> for id in conn.listDomainsID(): File "/usr/lib/python2.7/dist-packages/libvirt.py", line 2920, in listDomainsID if ret is None: raise libvirtError ('virConnectListDomainsID() failed', conn=self) libvirt.libvirtError: internal error Child process (/usr/sbin/vzlist -ovpsid -H) status unexpected: exit status 1 Expected results: Empty list should be returned, like other hypervisors. Additional info: Workaround is to not call listDomainsID() if numOfDomains() returns 0.
Note: Although commit f0293edc3f2f147e04a837d47288253a9991677a will likely prevent this error for the Python API in v0.9.9, the OpenVZ driver should not be fatal for this call.
David, I have a few suggestions. First, you should mention this BZ on the libvirt mailing list as I'm not sure how closely the openvz libvirt folks monitor bugzilla. Also, can you comment with whether this behavior reproduces with the upstream git HEAD? Finally, I don't run openvz myself, but it looks fairly straightforward to fix; would you consider submitting patches? -Dave
Actually, this should be fixed with a newer version of vzctl: http://bugzilla.openvz.org/show_bug.cgi?id=2149 My test system (Ubuntu Precise) has vzctl 3.0.29.3. The problem is that vzctl (used directly by openvz/openvz_driver.c) will return non-zero on either error OR when no VMs are active. I'm not sure how we could (or even should) fix this for older versions of vzctl.
Even though this is fixed, I'm inclined to think we should address this in libvirt, since the majority of historically deployed OpenVZ versions will have the flaw, and it is fairly painful for libvirt users.
Never addressed in libvirt per comment #4, and this bug is old, so just closing. Patches welcome of course