Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: ip-allowed-cli…
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 112 lines (93 sloc) 2.104 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#! /bin/bash
#
# squeezed Start/Stop the memory ballooning daemon
#
# chkconfig: 2345 22 77
# description: Memory ballooning daemon
# processname: squeezed
# pidfile: /var/run/squeezed.pid

# Source function library.
. /etc/init.d/functions

# Memory ballooning daemon

# location of the executable:
SQUEEZED="@LIBEXECDIR@/squeezed"

# pidfile:
PID_FILE="/var/run/squeezed.pid"

# lock file
SUBSYS_FILE="/var/lock/subsys/squeezed"

# Source function library.
. /etc/init.d/functions

if [ -e /var/xapi/xiu-xc ]; then
export XENCTRL_OSDEP="@OPTDIR@/lib/libxenctrl_xiu.so"
export XIU=/var/xapi/xiu
fi

# Enable core dumping
ulimit -c unlimited

start() {
echo -n $"Starting the memory ballooning daemon: "

# XXX: remove when domain 0 advertises ballooning via guest agent
xenstore-write /local/domain/0/control/feature-balloon 1

if [ -e ${SUBSYS_FILE} ]; then
if [ -e ${PID_FILE} ] && [ -e /proc/`cat ${PID_FILE}` ]; then
echo -n $"cannot start squeezed: already running."
failure $"cannot start squeezed: already running."
echo
return 1
fi
fi

xenstore-rm /squeezed
${SQUEEZED} -daemon -pidfile ${PID_FILE} >/dev/null 2>&1 </dev/null

MAX_RETRIES=30
RETRY=0
while [ ${RETRY} -lt ${MAX_RETRIES} ]; do
         PID=$(cat ${PID_FILE} 2>/dev/null)
kill -0 ${PID} 2> /dev/null
if [ $? -eq 0 ]; then
touch ${SUBSYS_FILE}
success
echo
return 0
fi
sleep 1
echo -n .
RETRY=$(( ${RETRY} + 1 ))
done
echo -n $"failed to start squeezed."
failure $"failed to start squeezed."
killproc squeezed
rm -f ${SUBSYS_FILE} ${PID_FILE}
echo
return 1
}

stop() {
echo -n $"Stopping the memory ballooning daemon: "

if [ ! -e ${SUBSYS_FILE} ]; then
echo -n $"cannot stop squeezed: squeezed is not running."
failure $"cannot stop squeezed: squeezed is not running."
echo
return 1;
fi

killproc squeezed
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f ${SUBSYS_FILE}
return $RETVAL
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
Something went wrong with that request. Please try again.