I think the reason you succeed in using LibvirtConnection may be it
retries several times when encountering error.
LibvirtConnection is useful to me for it reuse the connection instance
and avoid opening new instance.
But with differenct LibvirtConnection object, I think reuse cannot work.
So what about a global object for all feature tests?
On 2014年05月22日 22:26, shaohef(a)linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
On my F20, the kimchi can not start. It report:
$ sudo PYTHONPATH=src ./src/kimchid
*** Running feature tests ***
[21/May/2014:19:41:48] ENGINE Error in 'start' listener <bound method
CapabilitiesModel._set_capabilities of
<kimchi.model.config.CapabilitiesModel object at 0x314ac10>>
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cherrypy/process/wspbus.py",
line 197, in publish
output.append(listener(*args, **kwargs))
File "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/config.py",
line 69, in _set_capabilities
self.metadata_support = FeatureTests.has_metadata_support()
File "/home/shhfeng/work/workdir/kimchi/src/kimchi/featuretests.py",
line 197, in has_metadata_support
conn = libvirt.open('qemu:///system')
File "/usr/lib64/python2.7/site-packages/libvirt.py", line 247, in
open
if ret is None:raise libvirtError('virConnectOpen() failed')
libvirtError: Failed to connect socket to
'/var/run/libvirt/libvirt-sock': Connection refused
[21/May/2014:19:41:48] ENGINE Shutting down due to error in start
listener:
[21/May/2014:19:41:48] ENGINE Bus STOPPING
Now use LibvirtConnection to get connection, kimchi can work well.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/featuretests.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
index 5192361..df833e1 100644
--- a/src/kimchi/featuretests.py
+++ b/src/kimchi/featuretests.py
@@ -28,6 +28,7 @@
from lxml.builder import E
+from kimchi.model.libvirtconnection import LibvirtConnection
from kimchi.rollbackcontext import RollbackContext
from kimchi.utils import kimchi_log
@@ -104,7 +105,7 @@ def libvirt_supports_iso_stream(protocol):
conn = None
try:
FeatureTests.disable_screen_error_logging()
- conn = libvirt.open('qemu:///system')
+ conn = LibvirtConnection('qemu:///system').get()
dom = conn.defineXML(xml)
dom.undefine()
return True
@@ -122,7 +123,7 @@ def _get_xml():
xml = ET.tostring(obj)
return xml
try:
- conn = libvirt.open('qemu:///system')
+ conn = LibvirtConnection('qemu:///system').get()
FeatureTests.disable_screen_error_logging()
conn.findStoragePoolSources('netfs', _get_xml(), 0)
except libvirt.libvirtError as e:
@@ -174,7 +175,7 @@ def qemu_iso_stream_dns():
def libvirt_support_fc_host():
try:
FeatureTests.disable_screen_error_logging()
- conn = libvirt.open('qemu:///system')
+ conn = LibvirtConnection('qemu:///system').get()
pool = None
pool = conn.storagePoolDefineXML(SCSI_FC_XML, 0)
except libvirt.libvirtError as e:
@@ -194,7 +195,7 @@ def has_metadata_support():
with RollbackContext() as rollback:
FeatureTests.disable_screen_error_logging()
rollback.prependDefer(FeatureTests.enable_screen_error_logging)
- conn = libvirt.open('qemu:///system')
+ conn = LibvirtConnection('qemu:///system').get()
rollback.prependDefer(conn.close)
dom = conn.defineXML(SIMPLE_VM_XML)
rollback.prependDefer(dom.undefine)