1 |
tamiko 15/07/28 16:54:00 |
2 |
|
3 |
Added: libvirt-1.2.17-fix_paths_for_apparmor.patch |
4 |
libvirtd.init-r16 libvirtd.confd-r6 |
5 |
Removed: libvirtd.init-r15 libvirtd.confd-r5 |
6 |
Log: |
7 |
Change default behavior for kvm guest in openrc runscript, bug #555736; fix apparmor configuration, bug #554628; ebuild maintenance |
8 |
|
9 |
(Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key BD3A97A3) |
10 |
|
11 |
Revision Changes Path |
12 |
1.1 app-emulation/libvirt/files/libvirt-1.2.17-fix_paths_for_apparmor.patch |
13 |
|
14 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.2.17-fix_paths_for_apparmor.patch?rev=1.1&view=markup |
15 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.2.17-fix_paths_for_apparmor.patch?rev=1.1&content-type=text/plain |
16 |
|
17 |
Index: libvirt-1.2.17-fix_paths_for_apparmor.patch |
18 |
=================================================================== |
19 |
From bde898de482645f6963b673e8ff0b486a0a6db25 Mon Sep 17 00:00:00 2001 |
20 |
From: Matthias Maier <tamiko@××××××××××.org> |
21 |
Date: Tue, 28 Jul 2015 11:10:59 -0500 |
22 |
Subject: [PATCH] adapt paths for gentoo's fs layout |
23 |
|
24 |
https://bugs.gentoo.org/show_bug.cgi?id=554628 |
25 |
--- |
26 |
examples/apparmor/Makefile.am | 4 +- |
27 |
examples/apparmor/usr.lib.libvirt.virt-aa-helper | 48 ------------------------ |
28 |
examples/apparmor/usr.libexec.virt-aa-helper | 48 ++++++++++++++++++++++++ |
29 |
examples/apparmor/usr.sbin.libvirtd | 4 +- |
30 |
4 files changed, 52 insertions(+), 52 deletions(-) |
31 |
delete mode 100644 examples/apparmor/usr.lib.libvirt.virt-aa-helper |
32 |
create mode 100644 examples/apparmor/usr.libexec.virt-aa-helper |
33 |
|
34 |
diff --git a/examples/apparmor/Makefile.am b/examples/apparmor/Makefile.am |
35 |
index 7a20e16..c3c67b6 100644 |
36 |
--- a/examples/apparmor/Makefile.am |
37 |
+++ b/examples/apparmor/Makefile.am |
38 |
@@ -19,13 +19,13 @@ EXTRA_DIST= \ |
39 |
TEMPLATE.lxc \ |
40 |
libvirt-qemu \ |
41 |
libvirt-lxc \ |
42 |
- usr.lib.libvirt.virt-aa-helper \ |
43 |
+ usr.libexec.virt-aa-helper \ |
44 |
usr.sbin.libvirtd |
45 |
|
46 |
if WITH_APPARMOR_PROFILES |
47 |
apparmordir = $(sysconfdir)/apparmor.d/ |
48 |
apparmor_DATA = \ |
49 |
- usr.lib.libvirt.virt-aa-helper \ |
50 |
+ usr.libexec.virt-aa-helper \ |
51 |
usr.sbin.libvirtd \ |
52 |
$(NULL) |
53 |
|
54 |
diff --git a/examples/apparmor/usr.lib.libvirt.virt-aa-helper b/examples/apparmor/usr.lib.libvirt.virt-aa-helper |
55 |
deleted file mode 100644 |
56 |
index b34fb35..0000000 |
57 |
--- a/examples/apparmor/usr.lib.libvirt.virt-aa-helper |
58 |
+++ /dev/null |
59 |
@@ -1,48 +0,0 @@ |
60 |
-# Last Modified: Mon Apr 5 15:10:27 2010 |
61 |
-#include <tunables/global> |
62 |
- |
63 |
-profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { |
64 |
- #include <abstractions/base> |
65 |
- |
66 |
- # needed for searching directories |
67 |
- capability dac_override, |
68 |
- capability dac_read_search, |
69 |
- |
70 |
- # needed for when disk is on a network filesystem |
71 |
- network inet, |
72 |
- |
73 |
- deny @{PROC}/[0-9]*/mounts r, |
74 |
- @{PROC}/[0-9]*/net/psched r, |
75 |
- owner @{PROC}/[0-9]*/status r, |
76 |
- @{PROC}/filesystems r, |
77 |
- |
78 |
- # for hostdev |
79 |
- /sys/devices/ r, |
80 |
- /sys/devices/** r, |
81 |
- |
82 |
- /usr/{lib,lib64}/libvirt/virt-aa-helper mr, |
83 |
- /sbin/apparmor_parser Ux, |
84 |
- |
85 |
- /etc/apparmor.d/libvirt/* r, |
86 |
- /etc/apparmor.d/libvirt/libvirt-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]* rw, |
87 |
- |
88 |
- # for backingstore -- allow access to non-hidden files in @{HOME} as well |
89 |
- # as storage pools |
90 |
- audit deny @{HOME}/.* mrwkl, |
91 |
- audit deny @{HOME}/.*/ rw, |
92 |
- audit deny @{HOME}/.*/** mrwkl, |
93 |
- audit deny @{HOME}/bin/ rw, |
94 |
- audit deny @{HOME}/bin/** mrwkl, |
95 |
- @{HOME}/ r, |
96 |
- @{HOME}/** r, |
97 |
- /var/lib/libvirt/images/ r, |
98 |
- /var/lib/libvirt/images/** r, |
99 |
- /{media,mnt,opt,srv}/** r, |
100 |
- |
101 |
- /**.img r, |
102 |
- /**.qcow{,2} r, |
103 |
- /**.qed r, |
104 |
- /**.vmdk r, |
105 |
- /**.[iI][sS][oO] r, |
106 |
- /**/disk{,.*} r, |
107 |
-} |
108 |
diff --git a/examples/apparmor/usr.libexec.virt-aa-helper b/examples/apparmor/usr.libexec.virt-aa-helper |
109 |
new file mode 100644 |
110 |
index 0000000..b34fb35 |
111 |
--- /dev/null |
112 |
+++ b/examples/apparmor/usr.libexec.virt-aa-helper |
113 |
@@ -0,0 +1,48 @@ |
114 |
+# Last Modified: Mon Apr 5 15:10:27 2010 |
115 |
+#include <tunables/global> |
116 |
+ |
117 |
+profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { |
118 |
+ #include <abstractions/base> |
119 |
+ |
120 |
+ # needed for searching directories |
121 |
+ capability dac_override, |
122 |
+ capability dac_read_search, |
123 |
+ |
124 |
+ # needed for when disk is on a network filesystem |
125 |
+ network inet, |
126 |
+ |
127 |
+ deny @{PROC}/[0-9]*/mounts r, |
128 |
+ @{PROC}/[0-9]*/net/psched r, |
129 |
+ owner @{PROC}/[0-9]*/status r, |
130 |
+ @{PROC}/filesystems r, |
131 |
+ |
132 |
+ # for hostdev |
133 |
+ /sys/devices/ r, |
134 |
+ /sys/devices/** r, |
135 |
+ |
136 |
+ /usr/{lib,lib64}/libvirt/virt-aa-helper mr, |
137 |
+ /sbin/apparmor_parser Ux, |
138 |
+ |
139 |
+ /etc/apparmor.d/libvirt/* r, |
140 |
+ /etc/apparmor.d/libvirt/libvirt-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]* rw, |
141 |
+ |
142 |
+ # for backingstore -- allow access to non-hidden files in @{HOME} as well |
143 |
+ # as storage pools |
144 |
+ audit deny @{HOME}/.* mrwkl, |
145 |
+ audit deny @{HOME}/.*/ rw, |
146 |
+ audit deny @{HOME}/.*/** mrwkl, |
147 |
+ audit deny @{HOME}/bin/ rw, |
148 |
+ audit deny @{HOME}/bin/** mrwkl, |
149 |
+ @{HOME}/ r, |
150 |
+ @{HOME}/** r, |
151 |
+ /var/lib/libvirt/images/ r, |
152 |
+ /var/lib/libvirt/images/** r, |
153 |
+ /{media,mnt,opt,srv}/** r, |
154 |
+ |
155 |
+ /**.img r, |
156 |
+ /**.qcow{,2} r, |
157 |
+ /**.qed r, |
158 |
+ /**.vmdk r, |
159 |
+ /**.[iI][sS][oO] r, |
160 |
+ /**/disk{,.*} r, |
161 |
+} |
162 |
diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sbin.libvirtd |
163 |
index 5d606e6..ab2f1a9 100644 |
164 |
--- a/examples/apparmor/usr.sbin.libvirtd |
165 |
+++ b/examples/apparmor/usr.sbin.libvirtd |
166 |
@@ -58,8 +58,8 @@ |
167 |
audit deny /sys/kernel/security/apparmor/.* rwxl, |
168 |
/sys/kernel/security/apparmor/profiles r, |
169 |
/usr/{lib,lib64}/libvirt/* PUxr, |
170 |
- /usr/{lib,lib64}/libvirt/libvirt_parthelper ix, |
171 |
- /usr/{lib,lib64}/libvirt/libvirt_iohelper ix, |
172 |
+ /usr/libexec/libvirt_parthelper ix, |
173 |
+ /usr/libexec/libvirt_iohelper ix, |
174 |
/etc/libvirt/hooks/** rmix, |
175 |
/etc/xen/scripts/** rmix, |
176 |
|
177 |
-- |
178 |
2.3.6 |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
1.1 app-emulation/libvirt/files/libvirtd.init-r16 |
184 |
|
185 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.init-r16?rev=1.1&view=markup |
186 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.init-r16?rev=1.1&content-type=text/plain |
187 |
|
188 |
Index: libvirtd.init-r16 |
189 |
=================================================================== |
190 |
#!/sbin/runscript |
191 |
|
192 |
description="Virtual Machine Management daemon (libvirt)" |
193 |
extra_started_commands="reload halt" |
194 |
description_halt="Stops the libvirt daemon without stopping your VMs" |
195 |
description_reload="Restarts the libvirt daemon without stopping your VMs" |
196 |
|
197 |
depend() { |
198 |
USE_FLAG_FIREWALLD |
199 |
use USE_FLAG_AVAHI USE_FLAG_ISCSI USE_FLAG_RBD dbus virtlockd |
200 |
after ntp-client ntpd nfs nfsmount portmap rpc.statd iptables ip6tables ebtables corosync sanlock cgconfig xenconsoled |
201 |
} |
202 |
|
203 |
libvirtd_virsh() { |
204 |
local mode=$1 |
205 |
shift |
206 |
|
207 |
# Silence errors because virsh always throws an error about |
208 |
# not finding the hypervisor version when connecting to libvirtd |
209 |
LC_ALL=C virsh -c ${mode}:///system "$@" 2>/dev/null |
210 |
} |
211 |
|
212 |
libvirtd_dom_list() { |
213 |
# Make sure that it wouldn't be confused if the domain name |
214 |
# contains the word running. |
215 |
libvirtd_virsh $1 list | awk '$3 == "running" { print $1 }' |
216 |
} |
217 |
|
218 |
libvirtd_dom_count() { |
219 |
# Make sure that it wouldn't be confused if the domain name |
220 |
# contains the word running. |
221 |
libvirtd_virsh $1 list | awk 'BEGIN { count = 0 } \ |
222 |
$3 == "running" { count++ } \ |
223 |
END { print count }' |
224 |
} |
225 |
|
226 |
libvirtd_net_list() { |
227 |
# The purpose of the awk is to avoid networks with 'active' in the name |
228 |
libvirtd_virsh $1 net-list | awk '$2 == "active" { print $1 }' |
229 |
} |
230 |
|
231 |
libvirtd_net_count() { |
232 |
# The purpose of the awk is to avoid networks with 'active' in the name |
233 |
libvirtd_virsh $1 net-list | awk 'BEGIN { count = 0 } \ |
234 |
$2 == "active" { count++ } \ |
235 |
END { print count }' |
236 |
} |
237 |
|
238 |
|
239 |
start() { |
240 |
# Test configuration directories in /etc/libvirt/ to be either not |
241 |
# present or a directory, i.e. not a regular file, bug #532892 |
242 |
for dir in lxc nwfilter qemu storage; do |
243 |
if [ -f /etc/libvirt/$dir ]; then |
244 |
eerror "/etc/libvirt/$dir was created as a regular file. It must be either" |
245 |
eerror "a directory or not present for libvirtd to start up successfully." |
246 |
return 1 |
247 |
fi |
248 |
done |
249 |
|
250 |
ebegin "Starting libvirtd" |
251 |
start-stop-daemon --start \ |
252 |
--env KRB5_KTNAME=/etc/libvirt/krb5.tab \ |
253 |
--exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS} |
254 |
eend $? |
255 |
} |
256 |
|
257 |
stop() { |
258 |
local policy= |
259 |
local counter= |
260 |
local net_policy= |
261 |
local vm_name= |
262 |
local net_name= |
263 |
local dom_id= |
264 |
|
265 |
ebegin "Stopping libvirtd" |
266 |
|
267 |
if [ "${RC_CMD}" = "restart" -a -n "${LIBVIRTD_KVM_RESTART}" ] ; then |
268 |
policy="${LIBVIRTD_KVM_RESTART}" |
269 |
else |
270 |
policy="${LIBVIRTD_KVM_SHUTDOWN}" |
271 |
fi |
272 |
|
273 |
# sanitize policy: |
274 |
if [ "${policy}" != "none" -a "${policy}" != "managedsave" -a "${policy}" != "shutdown" ] ; then |
275 |
if [ -n "${policy}" ] ; then |
276 |
eerror " !!! Invalid policy \"${policy}\" specified in LIBVIRTD_KVM_SHUTDOWN/RESTART" |
277 |
fi |
278 |
if [ "${RC_CMD}" = "restart" ] ; then |
279 |
einfo " Using default (restart) policy \"none\" for domains" |
280 |
policy="none" |
281 |
else |
282 |
einfo " Using default policy \"shutdown\" for domains" |
283 |
policy="shutdown" |
284 |
fi |
285 |
fi |
286 |
|
287 |
if [ -n "${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" ] ; then |
288 |
counter="${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" |
289 |
else |
290 |
counter=500 |
291 |
fi |
292 |
|
293 |
if [ "${RC_CMD}" = "restart" -a -n "${LIBVIRTD_KVM_NET_RESTART}" ] ; then |
294 |
net_policy="${LIBVIRTD_KVM_NET_RESTART}" |
295 |
else |
296 |
net_policy="${LIBVIRTD_KVM_NET_SHUTDOWN}" |
297 |
fi |
298 |
|
299 |
# try to shutdown all (KVM/Qemu) domains |
300 |
if [ "${policy}" != "none" ] \ |
301 |
&& [ "$(libvirtd_dom_count qemu)" != "0" ] ; then |
302 |
|
303 |
einfo " Shutting down domain(s):" |
304 |
for dom_id in $(libvirtd_dom_list qemu) ; do |
305 |
vm_name="$(libvirtd_virsh qemu domname ${dom_id} | head -n 1)" |
306 |
einfo " ${vm_name}" |
307 |
libvirtd_virsh qemu ${policy} ${dom_id} > /dev/null |
308 |
done |
309 |
|
310 |
if [ "${policy}" = "shutdown" ]; then |
311 |
einfo " Waiting ${counter} seconds while domains shutdown ..." |
312 |
DOM_COUNT="$(libvirtd_dom_count qemu)" |
313 |
while [ ${DOM_COUNT} -gt 0 ] && [ ${counter} -gt 0 ] ; do |
314 |
DOM_COUNT="$(libvirtd_dom_count qemu)" |
315 |
sleep 1 |
316 |
counter=$((${counter} - 1)) |
317 |
echo -n "." |
318 |
done |
319 |
fi |
320 |
|
321 |
if [ "$(libvirtd_dom_count qemu)" != "0" ] ; then |
322 |
eerror " !!! Some guests are still running, stopping anyway" |
323 |
fi |
324 |
fi |
325 |
|
326 |
# try to shutdown all networks |
327 |
if [ "${net_policy}" != "no" ] \ |
328 |
&& [ "$(libvirtd_net_count qemu)" != "0" ]; then |
329 |
|
330 |
einfo " Shutting down network(s):" |
331 |
for net_name in $(libvirtd_net_list qemu); do |
332 |
einfo " ${net_name}" |
333 |
libvirtd_virsh qemu net-destroy ${net_name} > /dev/null |
334 |
done |
335 |
|
336 |
if [ "$(libvirtd_net_count qemu)" != "0" ]; then |
337 |
eerror " !!! Some networks are still active, stopping anyway" |
338 |
fi |
339 |
fi |
340 |
|
341 |
# Now actually stop the daemon |
342 |
start-stop-daemon --stop --quiet --exec \ |
343 |
/usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid |
344 |
eend $? |
345 |
} |
346 |
|
347 |
halt() { |
348 |
ebegin "Stopping libvirtd without shutting down your VMs" |
349 |
start-stop-daemon --stop --quiet --exec \ |
350 |
/usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid |
351 |
eend $? |
352 |
} |
353 |
|
354 |
reload() { |
355 |
halt |
356 |
start |
357 |
} |
358 |
|
359 |
|
360 |
|
361 |
1.1 app-emulation/libvirt/files/libvirtd.confd-r6 |
362 |
|
363 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.confd-r6?rev=1.1&view=markup |
364 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirtd.confd-r6?rev=1.1&content-type=text/plain |
365 |
|
366 |
Index: libvirtd.confd-r6 |
367 |
=================================================================== |
368 |
# /etc/conf.d/libvirtd |
369 |
|
370 |
# Startup dependency |
371 |
# libvirtd typically requires all networks to be up and settled which |
372 |
# is what rc_need="net" provides. However if you only use specific networks |
373 |
# for libvirtd, you may override this. Or if you only use libvirtd locally. |
374 |
rc_need="net" |
375 |
|
376 |
# LIBVIRTD_OPTS |
377 |
# You may want to add '--listen' to have libvirtd listen for tcp/ip |
378 |
# connections if you want to use libvirt for remote control. Please |
379 |
# consult 'libvirtd --help' for more options. |
380 |
#LIBVIRTD_OPTS="--listen" |
381 |
|
382 |
# LIBVIRTD_KVM_SHUTDOWN |
383 |
# controls the behavior for kvm guests on daemon shutdown. Defaults to |
384 |
# "shutdown" |
385 |
# |
386 |
# Valid options: |
387 |
# * shutdown |
388 |
# - Sends an ACPI shutdown (think when you tap the power button on your |
389 |
# machine and it begins a graceful shutdown). If your VM ignores this, |
390 |
# it will have the power yanked out from under it in |
391 |
# LIBVIRTD_KVM_SHUTDOWN_MAXWAIT seconds. |
392 |
# * managedsave |
393 |
# - Performs a state save external to the VM. qemu-kvm will stop stop the |
394 |
# CPU and save off all state to a separate file. When the machine is |
395 |
# started again, it will resume like nothing ever happened. This is |
396 |
# guarenteed to always successfully stop your machine and restart it. |
397 |
# However it may take some time to finish. |
398 |
# * none |
399 |
# - No attempts will be made to stop any VMs. If you are restarting your |
400 |
# machine the qemu-kvm process will be simply killed, which may result |
401 |
# in your VMs having disk corruption. |
402 |
LIBVIRTD_KVM_SHUTDOWN="shutdown" |
403 |
|
404 |
# LIBVIRTD_KVM_SHUTDOWN_MAXWAIT |
405 |
# timeout in seconds until stopping libvirtd and "pulling the plug" on |
406 |
# the remaining VM's still in a running state |
407 |
LIBVIRTD_KVM_SHUTDOWN_MAXWAIT="500" |
408 |
|
409 |
# LIBVIRTD_KVM_RESTART |
410 |
# controls the behavior for kvm guests on daemon restart. Defaults to |
411 |
# "none" |
412 |
# |
413 |
# Valid options: |
414 |
# * <empty> |
415 |
# - apply the same policy on daemon restart as defined by |
416 |
# LIBVIRTD_KVM_SHUTDOWN for the shutdown |
417 |
# * shutdown |
418 |
# * managedsave |
419 |
# * none |
420 |
# - as defined for LIBVIRTD_KVM_SHUTDOWN |
421 |
LIBVIRTD_KVM_RESTART="none" |
422 |
|
423 |
# LIBVIRTD_KVM_NET_SHUTDOWN |
424 |
# If libvirtd created networks for you (e.g. NATed networks) then this |
425 |
# init script will shut them down for you if this is set to 'yes'. |
426 |
# Otherwise, the networks will be left running once libvirt is shutdown. |
427 |
# For this option to be useful you must have enabled the 'virt-network' |
428 |
# USE flag and have had libvirt create a NATed network for you. Valid |
429 |
# values: 'yes' or 'no' |
430 |
LIBVIRTD_KVM_NET_SHUTDOWN="yes" |
431 |
|
432 |
# LIBVIRTD_KVM_NET_RESTART |
433 |
# Valid options: |
434 |
# * <empty> |
435 |
# - apply the same policy on daemon restart as defined by |
436 |
# LIBVIRTD_KVM_NET_SHUTDOWN for the shutdown |
437 |
# * yes |
438 |
# * no |
439 |
# - as defined for LIBVIRTD_KVM_NET_SHUTDOWN |
440 |
LIBVIRTD_KVM_NET_RESTART="" |