mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
process: wait longer on kill per assigned Hostdev
It was found that in cases with host devices virProcessKillPainfully might be able to send signal zero to the target PID for quite a while with the process already being gone from /proc/<PID>. That is due to cleanup and reset of devices which might include a secondary bus reset that on top of the actions taken has a 1s delay to let the bus settle. Due to that guests with plenty of Host devices could easily exceed the default timeouts. To solve that, this adds an extra delay of 2s per hostdev that is associated to a VM. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
This commit is contained in:
parent
c9247c8e26
commit
be2ca04447
@ -2605,6 +2605,7 @@ virProcessGetPids;
|
|||||||
virProcessGetStartTime;
|
virProcessGetStartTime;
|
||||||
virProcessKill;
|
virProcessKill;
|
||||||
virProcessKillPainfully;
|
virProcessKillPainfully;
|
||||||
|
virProcessKillPainfullyDelay;
|
||||||
virProcessNamespaceAvailable;
|
virProcessNamespaceAvailable;
|
||||||
virProcessRunInMountNamespace;
|
virProcessRunInMountNamespace;
|
||||||
virProcessSchedPolicyTypeFromString;
|
virProcessSchedPolicyTypeFromString;
|
||||||
|
@ -6908,8 +6908,11 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virProcessKillPainfully(vm->pid,
|
/* Request an extra delay of two seconds per current nhostdevs
|
||||||
!!(flags & VIR_QEMU_PROCESS_KILL_FORCE));
|
* to be safe against stalls by the kernel freeing up the resources */
|
||||||
|
ret = virProcessKillPainfullyDelay(vm->pid,
|
||||||
|
!!(flags & VIR_QEMU_PROCESS_KILL_FORCE),
|
||||||
|
vm->def->nhostdevs * 2);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -341,15 +341,21 @@ int virProcessKill(pid_t pid, int sig)
|
|||||||
* Returns 0 if it was killed gracefully, 1 if it
|
* Returns 0 if it was killed gracefully, 1 if it
|
||||||
* was killed forcibly, -1 if it is still alive,
|
* was killed forcibly, -1 if it is still alive,
|
||||||
* or another error occurred.
|
* or another error occurred.
|
||||||
|
*
|
||||||
|
* Callers can proide an extra delay in seconds to
|
||||||
|
* wait longer than the default.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virProcessKillPainfully(pid_t pid, bool force)
|
virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
/* This is in 1/5th seconds since polling is on a 0.2s interval */
|
||||||
|
unsigned int polldelay = 75 + (extradelay*5);
|
||||||
const char *signame = "TERM";
|
const char *signame = "TERM";
|
||||||
|
|
||||||
VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
|
VIR_DEBUG("vpid=%lld force=%d extradelay=%u",
|
||||||
|
(long long)pid, force, extradelay);
|
||||||
|
|
||||||
/* This loop sends SIGTERM, then waits a few iterations (10 seconds)
|
/* This loop sends SIGTERM, then waits a few iterations (10 seconds)
|
||||||
* to see if it dies. If the process still hasn't exited, and
|
* to see if it dies. If the process still hasn't exited, and
|
||||||
@ -357,9 +363,12 @@ virProcessKillPainfully(pid_t pid, bool force)
|
|||||||
* wait up to 5 seconds more for the process to exit before
|
* wait up to 5 seconds more for the process to exit before
|
||||||
* returning.
|
* returning.
|
||||||
*
|
*
|
||||||
|
* An extra delay can be passed by the caller for cases that are
|
||||||
|
* expected to clean up slower than usual.
|
||||||
|
*
|
||||||
* Note that setting @force could result in dataloss for the process.
|
* Note that setting @force could result in dataloss for the process.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < 75; i++) {
|
for (i = 0; i < polldelay; i++) {
|
||||||
int signum;
|
int signum;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
signum = SIGTERM; /* kindly suggest it should exit */
|
signum = SIGTERM; /* kindly suggest it should exit */
|
||||||
@ -402,6 +411,11 @@ virProcessKillPainfully(pid_t pid, bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int virProcessKillPainfully(pid_t pid, bool force)
|
||||||
|
{
|
||||||
|
return virProcessKillPainfullyDelay(pid, force, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#if HAVE_SCHED_GETAFFINITY
|
#if HAVE_SCHED_GETAFFINITY
|
||||||
|
|
||||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
|
||||||
|
@ -55,6 +55,9 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw)
|
|||||||
int virProcessKill(pid_t pid, int sig);
|
int virProcessKill(pid_t pid, int sig);
|
||||||
|
|
||||||
int virProcessKillPainfully(pid_t pid, bool force);
|
int virProcessKillPainfully(pid_t pid, bool force);
|
||||||
|
int virProcessKillPainfullyDelay(pid_t pid,
|
||||||
|
bool force,
|
||||||
|
unsigned int extradelay);
|
||||||
|
|
||||||
int virProcessSetAffinity(pid_t pid, virBitmapPtr map);
|
int virProcessSetAffinity(pid_t pid, virBitmapPtr map);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user