Blame SOURCES/libvirt-python-Release-the-GIL-during-virDomainGetMemoryStats-virDomainGetDiskErrors.patch

e87b17
From f4d5082f6946e4afb4326d1d37f413fed16bf7e2 Mon Sep 17 00:00:00 2001
e87b17
Message-Id: <f4d5082f6946e4afb4326d1d37f413fed16bf7e2@dist-git>
e87b17
From: Nir Soffer <nirsof@gmail.com>
e87b17
Date: Mon, 2 Oct 2017 09:59:00 +0200
e87b17
Subject: [PATCH] Release the GIL during virDomainGetMemoryStats &
e87b17
 virDomainGetDiskErrors
e87b17
e87b17
We discovered that the entire python process get stuck for about 30
e87b17
seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
e87b17
virConnect.getAllDomainStats() on inaccessible storage. This blocking
e87b17
cause a horrible mess in oVirt.
e87b17
e87b17
This patches adds the standard *_ALLOW_THREADS around the call to avoid
e87b17
this unwanted blocking.
e87b17
e87b17
Signed-off-by: Nir Soffer <nirsof@gmail.com>
e87b17
(cherry picked from commit 7af7450b0ac6bd69181f3c8d2360f4f97478191c)
e87b17
e87b17
Conflicts:
e87b17
        libvirt-override.c
e87b17
e87b17
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1497197
e87b17
e87b17
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
e87b17
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
e87b17
---
e87b17
 libvirt-override.c | 9 ++++++++-
e87b17
 1 file changed, 8 insertions(+), 1 deletion(-)
e87b17
e87b17
diff --git a/libvirt-override.c b/libvirt-override.c
e87b17
index 93c7ef0..dc81274 100644
e87b17
--- a/libvirt-override.c
e87b17
+++ b/libvirt-override.c
e87b17
@@ -363,8 +363,11 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
e87b17
         return NULL;
e87b17
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
e87b17
 
e87b17
+    LIBVIRT_BEGIN_ALLOW_THREADS;
e87b17
     nr_stats = virDomainMemoryStats(domain, stats,
e87b17
                                     VIR_DOMAIN_MEMORY_STAT_NR, 0);
e87b17
+    LIBVIRT_END_ALLOW_THREADS;
e87b17
+
e87b17
     if (nr_stats == -1)
e87b17
         return VIR_PY_NONE;
e87b17
 
e87b17
@@ -4864,7 +4867,11 @@ libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
e87b17
 
e87b17
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
e87b17
 
e87b17
-    if ((count = virDomainGetDiskErrors(domain, NULL, 0, 0)) < 0)
e87b17
+    LIBVIRT_BEGIN_ALLOW_THREADS;
e87b17
+    count = virDomainGetDiskErrors(domain, NULL, 0, 0);
e87b17
+    LIBVIRT_END_ALLOW_THREADS;
e87b17
+
e87b17
+    if (count < 0)
e87b17
         return VIR_PY_NONE;
e87b17
     ndisks = count;
e87b17
 
e87b17
-- 
e87b17
2.14.2
e87b17