|
|
25aafc |
From 3e06f98a83d5f23c345a71e48115659a83f673b5 Mon Sep 17 00:00:00 2001
|
|
|
25aafc |
Message-Id: <3e06f98a83d5f23c345a71e48115659a83f673b5@dist-git>
|
|
|
25aafc |
From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
|
|
|
25aafc |
Date: Wed, 4 Dec 2019 16:18:13 +0100
|
|
|
25aafc |
Subject: [PATCH] process: wait longer on kill per assigned Hostdev
|
|
|
25aafc |
MIME-Version: 1.0
|
|
|
25aafc |
Content-Type: text/plain; charset=UTF-8
|
|
|
25aafc |
Content-Transfer-Encoding: 8bit
|
|
|
25aafc |
|
|
|
25aafc |
It was found that in cases with host devices virProcessKillPainfully
|
|
|
25aafc |
might be able to send signal zero to the target PID for quite a while
|
|
|
25aafc |
with the process already being gone from /proc/<PID>.
|
|
|
25aafc |
|
|
|
25aafc |
That is due to cleanup and reset of devices which might include a
|
|
|
25aafc |
secondary bus reset that on top of the actions taken has a 1s delay
|
|
|
25aafc |
to let the bus settle. Due to that guests with plenty of Host devices
|
|
|
25aafc |
could easily exceed the default timeouts.
|
|
|
25aafc |
|
|
|
25aafc |
To solve that, this adds an extra delay of 2s per hostdev that is associated
|
|
|
25aafc |
to a VM.
|
|
|
25aafc |
|
|
|
25aafc |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
25aafc |
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
|
|
|
25aafc |
(cherry picked from commit be2ca0444728edd12a000653d3693d68a5c9102f)
|
|
|
25aafc |
|
|
|
25aafc |
https://bugzilla.redhat.com/show_bug.cgi?id=1771204
|
|
|
25aafc |
|
|
|
25aafc |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
25aafc |
Message-Id: <6d18f7131fe022cb2ee4613ad4c58faefa9d574c.1575472548.git.jtomko@redhat.com>
|
|
|
25aafc |
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
25aafc |
---
|
|
|
25aafc |
src/libvirt_private.syms | 1 +
|
|
|
25aafc |
src/qemu/qemu_process.c | 7 +++++--
|
|
|
25aafc |
src/util/virprocess.c | 20 +++++++++++++++++---
|
|
|
25aafc |
src/util/virprocess.h | 3 +++
|
|
|
25aafc |
4 files changed, 26 insertions(+), 5 deletions(-)
|
|
|
25aafc |
|
|
|
25aafc |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
25aafc |
index 53dbce7cfe..2a3950fd35 100644
|
|
|
25aafc |
--- a/src/libvirt_private.syms
|
|
|
25aafc |
+++ b/src/libvirt_private.syms
|
|
|
25aafc |
@@ -2623,6 +2623,7 @@ virProcessGetPids;
|
|
|
25aafc |
virProcessGetStartTime;
|
|
|
25aafc |
virProcessKill;
|
|
|
25aafc |
virProcessKillPainfully;
|
|
|
25aafc |
+virProcessKillPainfullyDelay;
|
|
|
25aafc |
virProcessNamespaceAvailable;
|
|
|
25aafc |
virProcessRunInMountNamespace;
|
|
|
25aafc |
virProcessSchedPolicyTypeFromString;
|
|
|
25aafc |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
25aafc |
index 0add197af5..d813c59c0d 100644
|
|
|
25aafc |
--- a/src/qemu/qemu_process.c
|
|
|
25aafc |
+++ b/src/qemu/qemu_process.c
|
|
|
25aafc |
@@ -6937,8 +6937,11 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
|
|
|
25aafc |
return 0;
|
|
|
25aafc |
}
|
|
|
25aafc |
|
|
|
25aafc |
- ret = virProcessKillPainfully(vm->pid,
|
|
|
25aafc |
- !!(flags & VIR_QEMU_PROCESS_KILL_FORCE));
|
|
|
25aafc |
+ /* Request an extra delay of two seconds per current nhostdevs
|
|
|
25aafc |
+ * to be safe against stalls by the kernel freeing up the resources */
|
|
|
25aafc |
+ ret = virProcessKillPainfullyDelay(vm->pid,
|
|
|
25aafc |
+ !!(flags & VIR_QEMU_PROCESS_KILL_FORCE),
|
|
|
25aafc |
+ vm->def->nhostdevs * 2);
|
|
|
25aafc |
|
|
|
25aafc |
return ret;
|
|
|
25aafc |
}
|
|
|
25aafc |
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
|
|
|
25aafc |
index f92b0dce37..297c96a8e5 100644
|
|
|
25aafc |
--- a/src/util/virprocess.c
|
|
|
25aafc |
+++ b/src/util/virprocess.c
|
|
|
25aafc |
@@ -344,15 +344,21 @@ int virProcessKill(pid_t pid, int sig)
|
|
|
25aafc |
* Returns 0 if it was killed gracefully, 1 if it
|
|
|
25aafc |
* was killed forcibly, -1 if it is still alive,
|
|
|
25aafc |
* or another error occurred.
|
|
|
25aafc |
+ *
|
|
|
25aafc |
+ * Callers can proide an extra delay in seconds to
|
|
|
25aafc |
+ * wait longer than the default.
|
|
|
25aafc |
*/
|
|
|
25aafc |
int
|
|
|
25aafc |
-virProcessKillPainfully(pid_t pid, bool force)
|
|
|
25aafc |
+virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
|
|
|
25aafc |
{
|
|
|
25aafc |
size_t i;
|
|
|
25aafc |
int ret = -1;
|
|
|
25aafc |
+ /* This is in 1/5th seconds since polling is on a 0.2s interval */
|
|
|
25aafc |
+ unsigned int polldelay = 75 + (extradelay*5);
|
|
|
25aafc |
const char *signame = "TERM";
|
|
|
25aafc |
|
|
|
25aafc |
- VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
|
|
|
25aafc |
+ VIR_DEBUG("vpid=%lld force=%d extradelay=%u",
|
|
|
25aafc |
+ (long long)pid, force, extradelay);
|
|
|
25aafc |
|
|
|
25aafc |
/* This loop sends SIGTERM, then waits a few iterations (10 seconds)
|
|
|
25aafc |
* to see if it dies. If the process still hasn't exited, and
|
|
|
25aafc |
@@ -360,9 +366,12 @@ virProcessKillPainfully(pid_t pid, bool force)
|
|
|
25aafc |
* wait up to 5 seconds more for the process to exit before
|
|
|
25aafc |
* returning.
|
|
|
25aafc |
*
|
|
|
25aafc |
+ * An extra delay can be passed by the caller for cases that are
|
|
|
25aafc |
+ * expected to clean up slower than usual.
|
|
|
25aafc |
+ *
|
|
|
25aafc |
* Note that setting @force could result in dataloss for the process.
|
|
|
25aafc |
*/
|
|
|
25aafc |
- for (i = 0; i < 75; i++) {
|
|
|
25aafc |
+ for (i = 0; i < polldelay; i++) {
|
|
|
25aafc |
int signum;
|
|
|
25aafc |
if (i == 0) {
|
|
|
25aafc |
signum = SIGTERM; /* kindly suggest it should exit */
|
|
|
25aafc |
@@ -405,6 +414,11 @@ virProcessKillPainfully(pid_t pid, bool force)
|
|
|
25aafc |
}
|
|
|
25aafc |
|
|
|
25aafc |
|
|
|
25aafc |
+int virProcessKillPainfully(pid_t pid, bool force)
|
|
|
25aafc |
+{
|
|
|
25aafc |
+ return virProcessKillPainfullyDelay(pid, force, 0);
|
|
|
25aafc |
+}
|
|
|
25aafc |
+
|
|
|
25aafc |
#if HAVE_SCHED_GETAFFINITY
|
|
|
25aafc |
|
|
|
25aafc |
int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
|
|
25aafc |
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
|
|
|
25aafc |
index 3c5a882772..5faa0892fe 100644
|
|
|
25aafc |
--- a/src/util/virprocess.h
|
|
|
25aafc |
+++ b/src/util/virprocess.h
|
|
|
25aafc |
@@ -55,6 +55,9 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw)
|
|
|
25aafc |
int virProcessKill(pid_t pid, int sig);
|
|
|
25aafc |
|
|
|
25aafc |
int virProcessKillPainfully(pid_t pid, bool force);
|
|
|
25aafc |
+int virProcessKillPainfullyDelay(pid_t pid,
|
|
|
25aafc |
+ bool force,
|
|
|
25aafc |
+ unsigned int extradelay);
|
|
|
25aafc |
|
|
|
25aafc |
int virProcessSetAffinity(pid_t pid, virBitmapPtr map);
|
|
|
25aafc |
|
|
|
25aafc |
--
|
|
|
25aafc |
2.24.0
|
|
|
25aafc |
|