Reviewed-by: Paulo Ricardo Paz Vital <pvital(a)linux.vnet.ibm.com>
On May 06 06:37PM, 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(a)linux.vnet.ibm.com>
---
i18n.py | 2 +-
model/libvirtevents.py | 24 ++++++++++++++++++++++++
model/model.py | 3 +++
3 files changed, 28 insertions(+), 1 deletion(-)
This patch depends on:
* [Kimchi] Add support to Libvirt Events
* [Wok] Save notifications in memory instead of object store
diff --git a/i18n.py b/i18n.py
index 569f84d..ddfa871 100644
--- a/i18n.py
+++ b/i18n.py
@@ -334,5 +334,5 @@ 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)."),
}
diff --git a/model/libvirtevents.py b/model/libvirtevents.py
index 710840a..00e9433 100644
--- a/model/libvirtevents.py
+++ b/model/libvirtevents.py
@@ -22,6 +22,8 @@ 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
@@ -58,3 +60,25 @@ 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
+ """
+ conn.get().domainEventRegisterAny(
+ None,
+ libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON,
+ self.event_enospc_cb,
+ libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
+ )
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(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel