1 |
commit: ca152da5d31120472ffce4b687550a5454b2a11f |
2 |
Author: Michal Privoznik <mprivozn <AT> redhat <DOT> com> |
3 |
AuthorDate: Tue Apr 20 07:36:45 2021 +0000 |
4 |
Commit: Matthias Maier <tamiko <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Apr 20 14:09:58 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca152da5 |
7 |
|
8 |
app-emulation/libvirt: Allow destroy of LXC containers again |
9 |
|
10 |
The original problem was fixed upstream as: |
11 |
|
12 |
ea7d0ca37c vircgroup: Fix virCgroupKillRecursive() wrt nested controllers |
13 |
|
14 |
and the commit will be part of the upcoming 7.3.0 release. |
15 |
However, the bug is so critical that the fix deserves to be |
16 |
backported to all supported releases. |
17 |
|
18 |
Please note, that for libvirt-7.2.0 I'm also dropping the code |
19 |
under src_install() that's supposed to fix docdir for ebuilds |
20 |
with revision number. This fixup is not needed because as of |
21 |
cc20e6298b7217f4b0eab3c50078257fd77ebb1b the docdir is put |
22 |
correctly onto meson's cmd line. I'm doing these two changes to |
23 |
avoid necessary revision number bump. |
24 |
|
25 |
Closes: https://bugs.gentoo.org/761721 |
26 |
Closes: https://github.com/gentoo/gentoo/pull/20468 |
27 |
Signed-off-by: Michal Privoznik <mprivozn <AT> redhat.com> |
28 |
Signed-off-by: Matthias Maier <tamiko <AT> gentoo.org> |
29 |
|
30 |
...ix-virCgroupKillRecursive-wrt-nested-cont.patch | 189 +++++++++++++++++++++ |
31 |
...irt-7.0.0-r1.ebuild => libvirt-7.0.0-r2.ebuild} | 1 + |
32 |
...ibvirt-7.1.0.ebuild => libvirt-7.1.0-r1.ebuild} | 1 + |
33 |
...ibvirt-7.2.0.ebuild => libvirt-7.2.0-r1.ebuild} | 7 +- |
34 |
4 files changed, 192 insertions(+), 6 deletions(-) |
35 |
|
36 |
diff --git a/app-emulation/libvirt/files/libvirt-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch b/app-emulation/libvirt/files/libvirt-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch |
37 |
new file mode 100644 |
38 |
index 00000000000..69572b321cf |
39 |
--- /dev/null |
40 |
+++ b/app-emulation/libvirt/files/libvirt-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch |
41 |
@@ -0,0 +1,189 @@ |
42 |
+From ea7d0ca37cce76e1327945c4864b996d7fd6d2e6 Mon Sep 17 00:00:00 2001 |
43 |
+Message-Id: <ea7d0ca37cce76e1327945c4864b996d7fd6d2e6.1618903455.git.mprivozn@××××××.com> |
44 |
+From: Michal Privoznik <mprivozn@××××××.com> |
45 |
+Date: Fri, 16 Apr 2021 16:39:14 +0200 |
46 |
+Subject: [PATCH] vircgroup: Fix virCgroupKillRecursive() wrt nested |
47 |
+ controllers |
48 |
+MIME-Version: 1.0 |
49 |
+Content-Type: text/plain; charset=UTF-8 |
50 |
+Content-Transfer-Encoding: 8bit |
51 |
+ |
52 |
+I've encountered the following bug, but only on Gentoo with |
53 |
+systemd and CGroupsV2. I've started an LXC container successfully |
54 |
+but destroying it reported the following error: |
55 |
+ |
56 |
+ error: Failed to destroy domain 'amd64' |
57 |
+ error: internal error: failed to get cgroup backend for 'pathOfController' |
58 |
+ |
59 |
+Debugging showed, that CGroup hierarchy is full of surprises: |
60 |
+ |
61 |
+/sys/fs/cgroup/machine.slice/machine-lxc\x2d861\x2damd64.scope/ |
62 |
+└── libvirt |
63 |
+ ├── dev-hugepages.mount |
64 |
+ ├── dev-mqueue.mount |
65 |
+ ├── init.scope |
66 |
+ ├── sys-fs-fuse-connections.mount |
67 |
+ ├── sys-kernel-config.mount |
68 |
+ ├── sys-kernel-debug.mount |
69 |
+ ├── sys-kernel-tracing.mount |
70 |
+ ├── system.slice |
71 |
+ │ ├── console-getty.service |
72 |
+ │ ├── dbus.service |
73 |
+ │ ├── system-getty.slice |
74 |
+ │ ├── system-modprobe.slice |
75 |
+ │ ├── systemd-journald.service |
76 |
+ │ ├── systemd-logind.service |
77 |
+ │ └── tmp.mount |
78 |
+ └── user.slice |
79 |
+ |
80 |
+For comparison, here's the same container on recent Rawhide: |
81 |
+ |
82 |
+/sys/fs/cgroup/machine.slice/machine-lxc\x2d13550\x2damd64.scope/ |
83 |
+└── libvirt |
84 |
+ |
85 |
+Anyway, those nested directories should not be a problem, because |
86 |
+virCgroupKillRecursiveInternal() removes them recursively, right? |
87 |
+Sort of. The function really does remove nested directories, but |
88 |
+it assumes that every directory has the same controller as the |
89 |
+rest. Just take a look at virCgroupV2KillRecursive() - it gets |
90 |
+'Any' controller (the first one it found in ".scope") and then |
91 |
+passes it to virCgroupKillRecursiveInternal(). |
92 |
+ |
93 |
+This assumption is not true though. The controllers found in |
94 |
+".scope" are the following: |
95 |
+ |
96 |
+ cpuset cpu io memory pids |
97 |
+ |
98 |
+while "libvirt" has fewer: |
99 |
+ |
100 |
+ cpuset cpu io memory |
101 |
+ |
102 |
+Up until now it's not problem, because of how we order |
103 |
+controllers internally - "cpu" is the first and thus picking |
104 |
+"Any" controller returns just that. But the rest of directories |
105 |
+has no controllers, their "cgroup.controllers" is just empty. |
106 |
+ |
107 |
+What fixes the bug is dropping @controller argument from |
108 |
+virCgroupKillRecursiveInternal() and letting each iteration work |
109 |
+pick its own controller. |
110 |
+ |
111 |
+Signed-off-by: Michal Privoznik <mprivozn@××××××.com> |
112 |
+Reviewed-by: Pavel Hrdina <phrdina@××××××.com> |
113 |
+--- |
114 |
+ src/util/vircgroup.c | 25 +++++++++++++++++++++++-- |
115 |
+ src/util/vircgrouppriv.h | 1 - |
116 |
+ src/util/vircgroupv1.c | 7 +------ |
117 |
+ src/util/vircgroupv2.c | 7 +------ |
118 |
+ 4 files changed, 25 insertions(+), 15 deletions(-) |
119 |
+ |
120 |
+diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c |
121 |
+index 96280a0a4e..37dde2a5ed 100644 |
122 |
+--- a/src/util/vircgroup.c |
123 |
++++ b/src/util/vircgroup.c |
124 |
+@@ -1477,6 +1477,24 @@ virCgroupHasController(virCgroup *cgroup, int controller) |
125 |
+ } |
126 |
+ |
127 |
+ |
128 |
++static int |
129 |
++virCgroupGetAnyController(virCgroup *cgroup) |
130 |
++{ |
131 |
++ size_t i; |
132 |
++ |
133 |
++ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { |
134 |
++ if (!cgroup->backends[i]) |
135 |
++ continue; |
136 |
++ |
137 |
++ return cgroup->backends[i]->getAnyController(cgroup); |
138 |
++ } |
139 |
++ |
140 |
++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", |
141 |
++ _("Unable to get any controller")); |
142 |
++ return -1; |
143 |
++} |
144 |
++ |
145 |
++ |
146 |
+ int |
147 |
+ virCgroupPathOfController(virCgroup *group, |
148 |
+ unsigned int controller, |
149 |
+@@ -2715,11 +2733,11 @@ int |
150 |
+ virCgroupKillRecursiveInternal(virCgroup *group, |
151 |
+ int signum, |
152 |
+ GHashTable *pids, |
153 |
+- int controller, |
154 |
+ const char *taskFile, |
155 |
+ bool dormdir) |
156 |
+ { |
157 |
+ int rc; |
158 |
++ int controller; |
159 |
+ bool killedAny = false; |
160 |
+ g_autofree char *keypath = NULL; |
161 |
+ g_autoptr(DIR) dp = NULL; |
162 |
+@@ -2728,6 +2746,9 @@ virCgroupKillRecursiveInternal(virCgroup *group, |
163 |
+ VIR_DEBUG("group=%p signum=%d pids=%p taskFile=%s dormdir=%d", |
164 |
+ group, signum, pids, taskFile, dormdir); |
165 |
+ |
166 |
++ if ((controller = virCgroupGetAnyController(group)) < 0) |
167 |
++ return -1; |
168 |
++ |
169 |
+ if (virCgroupPathOfController(group, controller, "", &keypath) < 0) |
170 |
+ return -1; |
171 |
+ |
172 |
+@@ -2760,7 +2781,7 @@ virCgroupKillRecursiveInternal(virCgroup *group, |
173 |
+ return -1; |
174 |
+ |
175 |
+ if ((rc = virCgroupKillRecursiveInternal(subgroup, signum, pids, |
176 |
+- controller, taskFile, true)) < 0) |
177 |
++ taskFile, true)) < 0) |
178 |
+ return -1; |
179 |
+ if (rc == 1) |
180 |
+ killedAny = true; |
181 |
+diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h |
182 |
+index 00193fb101..caf7ed84db 100644 |
183 |
+--- a/src/util/vircgrouppriv.h |
184 |
++++ b/src/util/vircgrouppriv.h |
185 |
+@@ -135,6 +135,5 @@ int virCgroupRemoveRecursively(char *grppath); |
186 |
+ int virCgroupKillRecursiveInternal(virCgroup *group, |
187 |
+ int signum, |
188 |
+ GHashTable *pids, |
189 |
+- int controller, |
190 |
+ const char *taskFile, |
191 |
+ bool dormdir); |
192 |
+diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c |
193 |
+index 2cc7dd386a..8a04bb2e4a 100644 |
194 |
+--- a/src/util/vircgroupv1.c |
195 |
++++ b/src/util/vircgroupv1.c |
196 |
+@@ -812,12 +812,7 @@ virCgroupV1KillRecursive(virCgroup *group, |
197 |
+ int signum, |
198 |
+ GHashTable *pids) |
199 |
+ { |
200 |
+- int controller = virCgroupV1GetAnyController(group); |
201 |
+- |
202 |
+- if (controller < 0) |
203 |
+- return -1; |
204 |
+- |
205 |
+- return virCgroupKillRecursiveInternal(group, signum, pids, controller, |
206 |
++ return virCgroupKillRecursiveInternal(group, signum, pids, |
207 |
+ "tasks", false); |
208 |
+ } |
209 |
+ |
210 |
+diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c |
211 |
+index e555217355..8881d3a88a 100644 |
212 |
+--- a/src/util/vircgroupv2.c |
213 |
++++ b/src/util/vircgroupv2.c |
214 |
+@@ -577,12 +577,7 @@ virCgroupV2KillRecursive(virCgroup *group, |
215 |
+ int signum, |
216 |
+ GHashTable *pids) |
217 |
+ { |
218 |
+- int controller = virCgroupV2GetAnyController(group); |
219 |
+- |
220 |
+- if (controller < 0) |
221 |
+- return -1; |
222 |
+- |
223 |
+- return virCgroupKillRecursiveInternal(group, signum, pids, controller, |
224 |
++ return virCgroupKillRecursiveInternal(group, signum, pids, |
225 |
+ "cgroup.threads", false); |
226 |
+ } |
227 |
+ |
228 |
+-- |
229 |
+2.26.3 |
230 |
+ |
231 |
|
232 |
diff --git a/app-emulation/libvirt/libvirt-7.0.0-r1.ebuild b/app-emulation/libvirt/libvirt-7.0.0-r2.ebuild |
233 |
similarity index 99% |
234 |
rename from app-emulation/libvirt/libvirt-7.0.0-r1.ebuild |
235 |
rename to app-emulation/libvirt/libvirt-7.0.0-r2.ebuild |
236 |
index a8265d3b418..745429541ce 100644 |
237 |
--- a/app-emulation/libvirt/libvirt-7.0.0-r1.ebuild |
238 |
+++ b/app-emulation/libvirt/libvirt-7.0.0-r2.ebuild |
239 |
@@ -133,6 +133,7 @@ PATCHES=( |
240 |
"${FILESDIR}"/${PN}-6.7.0-do-not-use-sysconfig.patch |
241 |
"${FILESDIR}"/${PN}-6.7.0-doc-path.patch |
242 |
"${FILESDIR}"/${PN}-6.7.0-fix-paths-for-apparmor.patch |
243 |
+ "${FILESDIR}"/${PN}-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch |
244 |
) |
245 |
|
246 |
pkg_setup() { |
247 |
|
248 |
diff --git a/app-emulation/libvirt/libvirt-7.1.0.ebuild b/app-emulation/libvirt/libvirt-7.1.0-r1.ebuild |
249 |
similarity index 98% |
250 |
rename from app-emulation/libvirt/libvirt-7.1.0.ebuild |
251 |
rename to app-emulation/libvirt/libvirt-7.1.0-r1.ebuild |
252 |
index f82c0867dc3..985e610ef46 100644 |
253 |
--- a/app-emulation/libvirt/libvirt-7.1.0.ebuild |
254 |
+++ b/app-emulation/libvirt/libvirt-7.1.0-r1.ebuild |
255 |
@@ -133,6 +133,7 @@ PATCHES=( |
256 |
"${FILESDIR}"/${PN}-6.7.0-do-not-use-sysconfig.patch |
257 |
"${FILESDIR}"/${PN}-6.7.0-doc-path.patch |
258 |
"${FILESDIR}"/${PN}-6.7.0-fix-paths-for-apparmor.patch |
259 |
+ "${FILESDIR}"/${PN}-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch |
260 |
) |
261 |
|
262 |
pkg_setup() { |
263 |
|
264 |
diff --git a/app-emulation/libvirt/libvirt-7.2.0.ebuild b/app-emulation/libvirt/libvirt-7.2.0-r1.ebuild |
265 |
similarity index 97% |
266 |
rename from app-emulation/libvirt/libvirt-7.2.0.ebuild |
267 |
rename to app-emulation/libvirt/libvirt-7.2.0-r1.ebuild |
268 |
index 56d210fe894..408b30efa06 100644 |
269 |
--- a/app-emulation/libvirt/libvirt-7.2.0.ebuild |
270 |
+++ b/app-emulation/libvirt/libvirt-7.2.0-r1.ebuild |
271 |
@@ -132,6 +132,7 @@ PATCHES=( |
272 |
"${FILESDIR}"/${PN}-6.0.0-fix_paths_in_libvirt-guests_sh.patch |
273 |
"${FILESDIR}"/${PN}-6.7.0-do-not-use-sysconfig.patch |
274 |
"${FILESDIR}"/${PN}-6.7.0-fix-paths-for-apparmor.patch |
275 |
+ "${FILESDIR}"/${PN}-7.3.0-vircgroup-Fix-virCgroupKillRecursive-wrt-nested-cont.patch |
276 |
) |
277 |
|
278 |
pkg_setup() { |
279 |
@@ -295,12 +296,6 @@ src_install() { |
280 |
rm -rf "${D}"/var |
281 |
rm -rf "${D}"/run |
282 |
|
283 |
- # Fix up doc paths for revisions |
284 |
- if [[ $PV != $PVR ]]; then |
285 |
- mv "${D}"/usr/share/doc/${PN}-${PV}/* "${D}"/usr/share/doc/${PF} || die |
286 |
- rmdir "${D}"/usr/share/doc/${PN}-${PV} || die |
287 |
- fi |
288 |
- |
289 |
newbashcomp "${S}/tools/bash-completion/vsh" virsh |
290 |
bashcomp_alias virsh virt-admin |