From b1122097d007be722b1b4477a9fa626c2ad32411 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Sep 16 2009 09:38:29 +0000 Subject: - Add ksm control script from Dan Kenigsberg --- diff --git a/ksm.init b/ksm.init new file mode 100644 index 0000000..703286b --- /dev/null +++ b/ksm.init @@ -0,0 +1,87 @@ +#!/bin/bash +# +# ksm Kernel Samepage Merging +# +# Author: Dan Kenigsberg +# +# Copyright 2009 Red Hat, Inc. and/or its affiliates. +# Released under the GPL +# +# chkconfig: - 84 16 +# description: The KSM init script starts and stops the ksm kernel thread. +# config: /etc/sysconfig/ksm +# +### BEGIN INIT INFO +# Provides: ksm +# Required-Start: +# Required-Stop: +# Should-Start: +# Short-Description: start and stop ksm +# Description: The KSM init script starts and stops the ksm kernel thread. +### END INIT INFO + +. /etc/rc.d/init.d/functions + +if [ -f /etc/sysconfig/ksm ]; then + . /etc/sysconfig/ksm +fi + +prog=ksm +RETVAL=0 + +# unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory. +default_max_kernel_pages () { + local total pagesize + total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo` + pagesize=`getconf PAGESIZE` + echo $[total * 1024 / pagesize / 2] +} + +start() { + echo -n $"Starting $prog: " + KSM_MAX_KERNEL_PAGES=${KSM_MAX_KERNEL_PAGES:-`default_max_kernel_pages`} + echo $KSM_MAX_KERNEL_PAGES > /sys/kernel/mm/ksm/max_kernel_pages + echo 1 > /sys/kernel/mm/ksm/run + RETVAL=$? + [ $RETVAL = 0 ] && success $"$prog startup" || failure $"$prog startup" + echo + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + echo 0 > /sys/kernel/mm/ksm/run + RETVAL=$? + [ $RETVAL = 0 ] && success $"$prog shutdown" || failure $"$prog shutdown" + echo +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + is_run=`cat /sys/kernel/mm/ksm/run` + RETVAL=$? + if [ $is_run -eq 1 ]; then + echo $"$prog is running" + else + echo $"$prog is not running" + fi + ;; + restart) + stop + start + ;; + signal) + signal + ;; + *) + echo $"Usage: $prog {start|stop|restart|status|help}" + RETVAL=3 +esac + +exit $RETVAL diff --git a/ksm.sysconfig b/ksm.sysconfig new file mode 100644 index 0000000..d99656d --- /dev/null +++ b/ksm.sysconfig @@ -0,0 +1,4 @@ +# The maximum number of unswappable kernel pages +# which may be allocated by ksm (0 for unlimited) +# If unset, defaults to half of total memory +# KSM_MAX_KERNEL_PAGES= diff --git a/qemu.spec b/qemu.spec index 7c7597e..9c3ffc2 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Summary: QEMU is a FAST! processor emulator Name: qemu Version: 0.10.92 -Release: 1%{?dist} +Release: 2%{?dist} # Epoch because we pushed a qemu-1.0 package Epoch: 2 License: GPLv2+ and LGPLv2+ and BSD @@ -12,9 +12,17 @@ URL: http://www.qemu.org/ Source0: http://downloads.sourceforge.net/sourceforge/kvm/qemu-%{kvmverfull}.tar.gz Source1: qemu.init + +# Loads kvm kernel modules at boot Source2: kvm.modules + +# Creates /dev/kvm Source3: 80-kvm.rules +# KSM control script +Source4: ksm.init +Source5: ksm.sysconfig + # Not upstream, why? Patch01: qemu-bios-bigger-roms.patch @@ -292,6 +300,9 @@ make V=1 %{?_smp_mflags} $buildldflags %install rm -rf $RPM_BUILD_ROOT +install -D -p -m 0755 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/ksm +install -D -p -m 0644 %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ksm + %ifarch %{ix86} x86_64 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/modules mkdir -p $RPM_BUILD_ROOT%{_bindir}/ @@ -398,6 +409,8 @@ getent passwd qemu >/dev/null || \ %{_mandir}/man8/qemu-nbd.8* %{_bindir}/qemu-nbd %config(noreplace) %{_sysconfdir}/sasl2/qemu.conf +%{_sysconfdir}/rc.d/init.d/ksm +%config(noreplace) %{_sysconfdir}/sysconfig/ksm %files user %defattr(-,root,root) %{_sysconfdir}/rc.d/init.d/qemu @@ -483,6 +496,9 @@ getent passwd qemu >/dev/null || \ %{_mandir}/man1/qemu-img.1* %changelog +* Wed Sep 16 2009 Mark McLoughlin - 2:0.10.92-2 +- Add ksm control script from Dan Kenigsberg + * Mon Sep 7 2009 Mark McLoughlin - 2:0.10.92-1 - Update to qemu-kvm-0.11.0-rc2 - Drop upstreamed patches