Bug 836647 - OpenVZ driver returns fatal error with virConnectListDomains() when no domains available
Summary: OpenVZ driver returns fatal error with virConnectListDomains() when no domain...
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-29 19:10 UTC by David Shrewsbury
Modified: 2016-04-26 16:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-03-23 21:39:43 UTC
Embargoed:


Attachments (Terms of Use)

Description David Shrewsbury 2012-06-29 19:10:48 UTC
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.

Comment 1 David Shrewsbury 2012-06-29 19:23:45 UTC
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 19:49:38 UTC
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 20:46:03 UTC
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.

Comment 4 Daniel Berrangé 2012-07-02 09:19:30 UTC
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 21:39:43 UTC
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.