Bug 836647 - OpenVZ driver returns fatal error with virConnectListDomains() when no domains available
OpenVZ driver returns fatal error with virConnectListDomains() when no domain...
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
Depends On:
  Show dependency treegraph
Reported: 2012-06-29 15:10 EDT by David Shrewsbury
Modified: 2016-04-26 12:06 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-03-23 17:39:43 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description David Shrewsbury 2012-06-29 15:10:48 EDT
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):


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.
Comment 1 David Shrewsbury 2012-06-29 15:23:45 EDT
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.
Comment 2 Dave Allan 2012-06-29 15:49:38 EDT
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
Comment 3 David Shrewsbury 2012-06-29 16:46:03 EDT
Actually, this should be fixed with a newer version of vzctl:


My test system (Ubuntu Precise) has vzctl

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.
Comment 4 Daniel Berrange 2012-07-02 05:19:30 EDT
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.
Comment 5 Cole Robinson 2016-03-23 17:39:43 EDT
Never addressed in libvirt per comment #4, and this bug is old, so just closing. Patches welcome of course

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