From 1e84e3165f8d37f8eebf862c6811f346cd8dbcca Mon Sep 17 00:00:00 2001
Message-Id: <1e84e3165f8d37f8eebf862c6811f346cd8dbcca.1375465853.git.jdenemar@redhat.com>
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Wed, 31 Jul 2013 19:48:19 +0100
Subject: [PATCH] Cope with races while killing processes
https://bugzilla.redhat.com/show_bug.cgi?id=980929
When systemd is involved in managing processes, it may start
killing off & tearing down croups associated with the process
while we're still doing virCgroupKillPainfully. We must
explicitly check for ENOENT and treat it as if we had finished
killing processes
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 75304eaa1a08b23e5206b352403de7d296fc069e)
---
src/util/vircgroup.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 0e8bb79..a70bb98 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2550,6 +2550,12 @@ static int virCgroupKillInternal(virCgroupPtr group, int signum, virHashTablePtr
while (!done) {
done = true;
if (!(fp = fopen(keypath, "r"))) {
+ if (errno == ENOENT) {
+ VIR_DEBUG("No file %s, assuming done", keypath);
+ killedAny = false;
+ goto done;
+ }
+
virReportSystemError(errno,
_("Failed to read %s"),
keypath);
@@ -2589,6 +2595,7 @@ static int virCgroupKillInternal(virCgroupPtr group, int signum, virHashTablePtr
}
}
+ done:
ret = killedAny ? 1 : 0;
cleanup:
@@ -2658,8 +2665,13 @@ static int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, virHas
if (rc == 1)
killedAny = true;
- VIR_DEBUG("Iterate over children of %s", keypath);
+ VIR_DEBUG("Iterate over children of %s (killedAny=%d)", keypath, killedAny);
if (!(dp = opendir(keypath))) {
+ if (errno == ENOENT) {
+ VIR_DEBUG("Path %s does not exist, assuming done", keypath);
+ killedAny = false;
+ goto done;
+ }
virReportSystemError(errno,
_("Cannot open %s"), keypath);
return -1;
@@ -2689,6 +2701,7 @@ static int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, virHas
virCgroupFree(&subgroup);
}
+ done:
ret = killedAny ? 1 : 0;
cleanup:
--
1.8.3.2