Commit 9f575681 authored by Anael Beutot's avatar Anael Beutot
Browse files

Libvirt error handling.

Only log error in case of error.
parent 2c97e81a
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -222,6 +222,8 @@ class Hypervisor(object):
        self.name = name
        self.type = u'kvm'

        # register libvirt error handler
        libvirt.registerErrorHandler(self.vir_error_cb, None)
        # libvirt event loop abstraction
        self.vir_event_loop = VirEventLoop(self.handler.main.evloop)
        # This tells libvirt what event loop implementation it
@@ -259,9 +261,27 @@ class Hypervisor(object):

    def stop(self):
        self.vir_event_loop.stop()
        self.vir_con.close()
        # unregister callback
        try:
            self.vir_con.domainEventDeregister(self.vir_cb)
        except libvirt.libvirtError:
            # in case the libvirt connection is broken, it will raise the error
            pass
        ret = self.vir_con.close()
        logger.debug('Libvirt still handling %s ref connections', ret)
        # TODO delet objects

    def vir_error_cb(self, ctxt, err):
        """Libvirt error callback.

        See http://libvirt.org/errors.html for more informations.

        :param ctxt: arbitrary context data (not needed because context is
            givent by self
        :param err: libvirt error code
        """
        logger.error('Libvirt error %s', err)

    def vir_cb(self, conn, dom, event, detail, opaque):
        """Callback for libvirt event loop."""
        logger.debug('Received event %s on domain %s, detail %s', event,