New patch 0010-Debianize-libvirt-guests.patch
Laurent LĂ©onard
13 years ago
0 | From: =?UTF-8?q?Laurent=20L=C3=A9onard?= <laurent@open-minds.org> | |
1 | Date: Thu, 9 Dec 2010 22:36:29 +0100 | |
2 | Subject: [PATCH] Debianize libvirt-guests | |
3 | ||
4 | Origin: vendor | |
5 | --- | |
6 | tools/libvirt-guests.init.in | 78 +++++++++++++++++------------------------ | |
7 | tools/libvirt-guests.sysconf | 6 ++-- | |
8 | 2 files changed, 35 insertions(+), 49 deletions(-) | |
9 | ||
10 | diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in | |
11 | index 5dab36b..0fe82fb 100644 | |
12 | --- a/tools/libvirt-guests.init.in | |
13 | +++ b/tools/libvirt-guests.init.in | |
14 | @@ -4,8 +4,8 @@ | |
15 | # | |
16 | ### BEGIN INIT INFO | |
17 | # Provides: libvirt-guests | |
18 | -# Required-Start: libvirtd | |
19 | -# Required-Stop: libvirtd | |
20 | +# Required-Start: $remote_fs libvirt-bin | |
21 | +# Required-Stop: $remote_fs libvirt-bin | |
22 | # Default-Start: 2 3 4 5 | |
23 | # Default-Stop: 0 1 6 | |
24 | # Short-Description: suspend/resume libvirt guests on shutdown/boot | |
25 | @@ -14,32 +14,19 @@ | |
26 | # See http://libvirt.org | |
27 | ### END INIT INFO | |
28 | ||
29 | -# the following is chkconfig init header | |
30 | -# | |
31 | -# libvirt-guests: suspend/resume libvirt guests on shutdown/boot | |
32 | -# | |
33 | -# chkconfig: 345 99 01 | |
34 | -# description: This is a script for suspending active libvirt guests \ | |
35 | -# on shutdown and resuming them on next boot \ | |
36 | -# See http://libvirt.org | |
37 | -# | |
38 | - | |
39 | -sysconfdir=@sysconfdir@ | |
40 | -localstatedir=@localstatedir@ | |
41 | -libvirtd=@sbindir@/libvirtd | |
42 | - | |
43 | -# Source function library. | |
44 | -. "$sysconfdir"/rc.d/init.d/functions | |
45 | +sysconfdir=/etc | |
46 | +localstatedir=/var | |
47 | +libvirtd=/usr/sbin/libvirtd | |
48 | ||
49 | URIS=default | |
50 | -ON_BOOT=start | |
51 | -ON_SHUTDOWN=suspend | |
52 | -SHUTDOWN_TIMEOUT=0 | |
53 | +ON_BOOT=ignore | |
54 | +ON_SHUTDOWN=shutdown | |
55 | +SHUTDOWN_TIMEOUT=30 | |
56 | ||
57 | -test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests | |
58 | +test -f "$sysconfdir"/default/libvirt-guests && . "$sysconfdir"/default/libvirt-guests | |
59 | ||
60 | LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests | |
61 | -VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests | |
62 | +VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests | |
63 | ||
64 | RETVAL=0 | |
65 | ||
66 | @@ -128,7 +115,7 @@ start() { | |
67 | [ -f "$LISTFILE" ] || { started; return 0; } | |
68 | ||
69 | if [ "x$ON_BOOT" != xstart ]; then | |
70 | - echo $"libvirt-guests is configured not to start any guests on boot" | |
71 | + echo "libvirt-guests is configured not to start any guests on boot" | |
72 | rm -f "$LISTFILE" | |
73 | started | |
74 | return 0 | |
75 | @@ -143,20 +130,20 @@ start() { | |
76 | fi | |
77 | done | |
78 | if ! $configured; then | |
79 | - echo $"Ignoring guests on $uri URI" | |
80 | + echo "Ignoring guests on $uri URI" | |
81 | continue | |
82 | fi | |
83 | ||
84 | - echo $"Resuming guests on $uri URI..." | |
85 | + echo "Resuming guests on $uri URI..." | |
86 | for guest in $list; do | |
87 | name=$(guest_name $uri $guest) | |
88 | - echo -n $"Resuming guest $name: " | |
89 | + echo -n "Resuming guest $name: " | |
90 | if guest_is_on $uri $guest; then | |
91 | if $guest_running; then | |
92 | - echo $"already active" | |
93 | + echo "already active" | |
94 | else | |
95 | retval run_virsh $uri start "$name" >/dev/null && \ | |
96 | - echo $"done" | |
97 | + echo "done" | |
98 | fi | |
99 | fi | |
100 | done | |
101 | @@ -172,7 +159,7 @@ suspend_guest() | |
102 | guest=$2 | |
103 | ||
104 | name=$(guest_name $uri $guest) | |
105 | - label=$"Suspending $name: " | |
106 | + label="Suspending $name: " | |
107 | echo -n "$label" | |
108 | run_virsh $uri managedsave $guest >/dev/null & | |
109 | virsh_pid=$! | |
110 | @@ -187,7 +174,7 @@ suspend_guest() | |
111 | printf '\r%s%-12s ' "$label" "..." | |
112 | fi | |
113 | done | |
114 | - retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" | |
115 | + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "done" | |
116 | } | |
117 | ||
118 | shutdown_guest() | |
119 | @@ -196,7 +183,7 @@ shutdown_guest() | |
120 | guest=$2 | |
121 | ||
122 | name=$(guest_name $uri $guest) | |
123 | - label=$"Shutting down $name: " | |
124 | + label="Shutting down $name: " | |
125 | echo -n "$label" | |
126 | retval run_virsh $uri shutdown $guest >/dev/null || return | |
127 | timeout=$SHUTDOWN_TIMEOUT | |
128 | @@ -210,9 +197,9 @@ shutdown_guest() | |
129 | ||
130 | if guest_is_on $uri $guest; then | |
131 | if $guest_running; then | |
132 | - printf '\r%s%-12s\n' "$label" $"failed to shutdown in time" | |
133 | + printf '\r%s%-12s\n' "$label" "failed to shutdown in time" | |
134 | else | |
135 | - printf '\r%s%-12s\n' "$label" $"done" | |
136 | + printf '\r%s%-12s\n' "$label" "done" | |
137 | fi | |
138 | fi | |
139 | } | |
140 | @@ -225,7 +212,7 @@ stop() { | |
141 | if [ "x$ON_SHUTDOWN" = xshutdown ]; then | |
142 | suspending=false | |
143 | if [ $SHUTDOWN_TIMEOUT -le 0 ]; then | |
144 | - echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
145 | + echo "Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
146 | RETVAL=6 | |
147 | return | |
148 | fi | |
149 | @@ -233,10 +220,10 @@ stop() { | |
150 | ||
151 | : >"$LISTFILE" | |
152 | for uri in $URIS; do | |
153 | - echo -n $"Running guests on $uri URI: " | |
154 | + echo -n "Running guests on $uri URI: " | |
155 | ||
156 | if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then | |
157 | - echo $"libvirtd not installed; skipping this URI." | |
158 | + echo "libvirtd not installed; skipping this URI." | |
159 | continue | |
160 | fi | |
161 | ||
162 | @@ -249,7 +236,7 @@ stop() { | |
163 | empty=false | |
164 | done | |
165 | if $empty; then | |
166 | - echo $"no running guests." | |
167 | + echo "no running guests." | |
168 | else | |
169 | echo | |
170 | echo $uri $list >>"$LISTFILE" | |
171 | @@ -259,9 +246,9 @@ stop() { | |
172 | ||
173 | while read uri list; do | |
174 | if $suspending; then | |
175 | - echo $"Suspending guests on $uri URI..." | |
176 | + echo "Suspending guests on $uri URI..." | |
177 | else | |
178 | - echo $"Shutting down guests on $uri URI..." | |
179 | + echo "Shutting down guests on $uri URI..." | |
180 | fi | |
181 | ||
182 | for guest in $list; do | |
183 | @@ -285,17 +272,16 @@ gueststatus() { | |
184 | ||
185 | # rh_status | |
186 | # Display current status: whether saved state exists, and whether start | |
187 | -# has been executed. We cannot use status() from the functions library, | |
188 | -# since there is no external daemon process matching this init script. | |
189 | +# has been executed. | |
190 | rh_status() { | |
191 | if [ -f "$LISTFILE" ]; then | |
192 | - echo $"stopped, with saved guests" | |
193 | + echo "stopped, with saved guests" | |
194 | RETVAL=3 | |
195 | else | |
196 | if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then | |
197 | - echo $"started" | |
198 | + echo "started" | |
199 | else | |
200 | - echo $"stopped, with no saved guests" | |
201 | + echo "stopped, with no saved guests" | |
202 | fi | |
203 | RETVAL=0 | |
204 | fi | |
205 | @@ -304,7 +290,7 @@ rh_status() { | |
206 | # usage [val] | |
207 | # Display usage string, then exit with VAL (defaults to 2). | |
208 | usage() { | |
209 | - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
210 | + echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
211 | exit ${1-2} | |
212 | } | |
213 | ||
214 | diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf | |
215 | index cd58728..53d89bd 100644 | |
216 | --- a/tools/libvirt-guests.sysconf | |
217 | +++ b/tools/libvirt-guests.sysconf | |
218 | @@ -8,7 +8,7 @@ | |
219 | # - ignore libvirt-guests init script won't start any guest on boot, however, | |
220 | # guests marked as autostart will still be automatically started by | |
221 | # libvirtd | |
222 | -#ON_BOOT=start | |
223 | +#ON_BOOT=ignore | |
224 | ||
225 | # action taken on host shutdown | |
226 | # - suspend all running guests are suspended using virsh managedsave | |
227 | @@ -18,7 +18,7 @@ | |
228 | # which just needs a long time to shutdown. When setting | |
229 | # ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a | |
230 | # value suitable for your guests. | |
231 | -#ON_SHUTDOWN=suspend | |
232 | +#ON_SHUTDOWN=shutdown | |
233 | ||
234 | # number of seconds we're willing to wait for a guest to shut down | |
235 | -#SHUTDOWN_TIMEOUT=0 | |
236 | +#SHUTDOWN_TIMEOUT=30 | |
237 | -- |