[Kimchi-devel] [PATCH V4] [Kimchi] Handle Libvirt host ENOSPC event

joserz at linux.vnet.ibm.com joserz at linux.vnet.ibm.com
Fri May 27 12:37:11 UTC 2016


Reviewed-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
On Tue, May 24, 2016 at 05:16:32PM -0300, Lucio Correia wrote:
> When storage pool is out of space and guest requires more,
> guest is paused and nothing is told to the user. This patch
> uses Libvirt Event handling and Asynchronous Notifications
> mechanism to tell web users about what happened.
> 
> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
> ---
>  i18n.py                |  1 +
>  model/libvirtevents.py | 28 ++++++++++++++++++++++++++++
>  model/model.py         |  3 +++
>  3 files changed, 32 insertions(+)
> 
> V4: try/except added for libvirt event callback registration
> 
> diff --git a/i18n.py b/i18n.py
> index 3a5a9d1..2d8390f 100644
> --- a/i18n.py
> +++ b/i18n.py
> @@ -335,6 +335,7 @@ messages = {
>      "KCHEVENT0001E": _("Failed to register the default event implementation."),
>      "KCHEVENT0002E": _("Failed to register timeout event."),
>      "KCHEVENT0003E": _("Failed to Run the default event implementation."),
> +    "KCHEVENT0004W": _("I/O error on guest '%(vm)s': storage pool out of space for %(devAlias)s (%(srcPath)s)."),
> 
>      # These messages (ending with L) are for user log purposes
>      "KCHNET0001L": _("Created %(connection)s virtual network '%(name)s'"),
> diff --git a/model/libvirtevents.py b/model/libvirtevents.py
> index ab5c17d..6425f9b 100644
> --- a/model/libvirtevents.py
> +++ b/model/libvirtevents.py
> @@ -22,6 +22,9 @@ import libvirt
>  import time
> 
>  from wok.exception import OperationFailed
> +from wok.message import WokMessage
> +from wok.model.notifications import add_notification
> +from wok.utils import wok_log
> 
> 
>  class LibvirtEvents(object):
> @@ -57,3 +60,28 @@ class LibvirtEvents(object):
>      # Event loop handler used to limit length of waiting for any other event.
>      def _kimchi_EventTimeout(self, timer, opaque):
>          time.sleep(1)
> +
> +    def event_enospc_cb(self, conn, dom, path, dev, action, reason, args):
> +        if reason == "enospc":
> +            info = {
> +                "vm": dom.name(),
> +                "srcPath": path,
> +                "devAlias": dev,
> +            }
> +            add_notification("KCHEVENT0004W", info, '/plugins/kimchi')
> +            msg = WokMessage("KCHEVENT0004W", info, '/plugins/kimchi')
> +            wok_log.warning(msg.get_text())
> +
> +    def handleEnospc(self, conn):
> +        """
> +        Register Libvirt IO_ERROR_REASON event to handle host ENOSPC
> +        """
> +        try:
> +            conn.get().domainEventRegisterAny(
> +                None,
> +                libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON,
> +                self.event_enospc_cb,
> +                libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
> +            )
> +        except libvirt.libvirtError as e:
> +            wok_log.error("Register of ENOSPC event failed: %s" % e.message)
> diff --git a/model/model.py b/model/model.py
> index ed474d2..327d5a7 100644
> --- a/model/model.py
> +++ b/model/model.py
> @@ -50,6 +50,9 @@ class Model(BaseModel):
>                   'eventsloop': self.events}
>          models = []
> 
> +        # Register for Libvirt's host ENOSPC event and notify UI if it happens
> +        self.events.handleEnospc(self.conn)
> +
>          # Import task model from Wok
>          instances = get_instances('wok.model.tasks')
>          for instance in instances:
> -- 
> 1.9.1
> 
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
> 




More information about the Kimchi-devel mailing list