<div dir="ltr"><div>I mean a &#39;False&#39; can&#39;t tell us whether it&#39;s because of &#39;protocol type error&#39; or not, Maybe it&#39;s another error from libvirt, for example, the ISO_STREAM_XML is deprecated and can not work with new version of ibvirt. So i don&#39;t think the backend can handle this correctly.</div>
<div><br></div><div>Frist, this exception got raised is not a &#39;protocol type error&#39; and we don&#39;t know what it is. Second, the error handler of libvirt is got replaced, and the error message will not show now, then we won&#39;t see it.</div>
As Cristian pointed out, it&#39;s good to just hide the &quot;protocol&quot; error&quot;, but not them all. <div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 2:23 AM, Aline Manera <span dir="ltr">&lt;<a href="mailto:alinefm@linux.vnet.ibm.com" target="_blank">alinefm@linux.vnet.ibm.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 01/23/2014 08:16 AM, apporc wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When running feature tests, we get bunch of error messages as below:<br>
<br>
*** Running feature tests ***<br>
libvirt: Domain Config error : internal error unknown protocol type &#39;http&#39;<br>
libvirt: Domain Config error : internal error unknown protocol type &#39;https&#39;<br>
libvirt: Domain Config error : internal error unknown protocol type &#39;ftp&#39;<br>
libvirt: Domain Config error : internal error unknown protocol type &#39;ftps&#39;<br>
libvirt: Domain Config error : internal error unknown protocol type &#39;tftp&#39;<br>
*** Feature tests completed ***<br>
<br>
By replacing default error handler of libvirt, this patch succeeded to<br>
avoid the error. After Featuretest, the default error handler will be restored.<br>
The default error handler(in libvirtmod.so) just do one thing, it prints the error message to<br>
stderr before we catch the exception in python.<br>
<br>
Signed-off-by: apporc &lt;<a href="mailto:appleorchard2000@gmail.com" target="_blank">appleorchard2000@gmail.com</a>&gt;<br>
---<br>
  src/kimchi/featuretests.py |   14 ++++++++++++--<br>
  1 file changed, 12 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py<br>
index a5755a2..d68fcb8 100644<br>
--- a/src/kimchi/featuretests.py<br>
+++ b/src/kimchi/featuretests.py<br>
@@ -57,16 +57,26 @@ class FeatureTests(object):<br>
<br>
      @staticmethod<br>
      def libvirt_supports_iso_stream(<u></u>protocol):<br>
+        def libvirt_errorhandler(userdata, error):<br>
+            # A libvirt error handler to ignore annoying messages in stderr<br>
+            pass<br>
+<br>
          xml = ISO_STREAM_XML % {&#39;protocol&#39;: protocol}<br>
          conn = None<br>
          try:<br>
+            # Register the error handler to hide libvirt error in stderr<br>
+            libvirt.registerErrorHandler(<u></u>f=libvirt_errorhandler, ctx=None)<br>
              conn = libvirt.open(&#39;qemu:///system&#39;)<br>
              dom = conn.defineXML(xml)<br>
              dom.undefine()<br>
              return True<br>
-        except libvirt.libvirtError:<br>
-            return False<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        except libvirt.libvirtError, e:<br>
+            if e.message == &quot;internal error unknown protocol type &#39;%s&#39;&quot; % protocol:<br>
+                return False<br>
+            else:<br>
+                raise e<br>
</blockquote>
<br></div></div>
Independent of the exception we should not raise it.<br>
It is a feature test, so if something failed we just return &#39;False&#39; and backend will handle it correctly.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          finally:<br>
+            libvirt.registerErrorHandler(<u></u>f=None, ctx=None)<br>
              conn is None or conn.close()<br>
<br>
      @staticmethod<br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Regards,<div>apporc</div></div>
</div>