From 64aeaf97d794432d4b5231056b1b7f502d9eb1725622ff82c7340680e5f0c797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 19 Mar 2014 14:11:16 +0000 Subject: [PATCH] Accepting request 225407 from home:saschpe:branches:Virtualization - Add qemu-ksm subpackage providing a systemd service file for enabling / disabling Kernel Samepage Merging. It is independent of qemu (but recommended by it). OBS-URL: https://build.opensuse.org/request/show/225407 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=191 --- ksm.service | 13 +++++++++++++ qemu.changes | 7 +++++++ qemu.spec | 37 +++++++++++++++++++++++++++++++++++++ qemu.spec.in | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 ksm.service diff --git a/ksm.service b/ksm.service new file mode 100644 index 00000000..34da85c5 --- /dev/null +++ b/ksm.service @@ -0,0 +1,13 @@ +[Unit] +Description=Kernel Samepage Merging +ConditionPathExists=/sys/kernel/mm/ksm +ConditionVirtualization=no + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/bash -c "echo 1 > /sys/kernel/mm/ksm/run" +ExecStop=/bin/bash -c "echo 0 > /sys/kernel/mm/ksm/run" + +[Install] +WantedBy=multi-user.target diff --git a/qemu.changes b/qemu.changes index 0d260cd9..3de84f49 100644 --- a/qemu.changes +++ b/qemu.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Mar 7 14:44:34 UTC 2014 - speilicke@suse.com + +- Add qemu-ksm subpackage providing a systemd service file for + enabling / disabling Kernel Samepage Merging. It is independent of + qemu (but recommended by it). + ------------------------------------------------------------------- Fri Feb 28 18:21:37 UTC 2014 - afaerber@suse.de diff --git a/qemu.spec b/qemu.spec index df40e45c..75aad4c8 100644 --- a/qemu.spec +++ b/qemu.spec @@ -36,6 +36,7 @@ Source2: qemu-ifup Source3: kvm_stat Source4: qemu-kvm.1.gz Source5: 60-kvm.rules +Source6: ksm.service # This patch queue is auto-generated from https://github.com/openSUSE/qemu Patch0001: 0001-XXX-dont-dump-core-on-sigabort.patc.patch Patch0002: 0002-XXX-work-around-SA_RESTART-race-wit.patch @@ -145,6 +146,10 @@ BuildRequires: python BuildRequires: usbredir-devel %endif %if 0%{?suse_version} >= 1210 +BuildRequires: systemd +%{?systemd_requires} +%define with_systemd 1 +Recommends: qemu-ksm = %{version} %if 0%{?suse_version} >= 1220 BuildRequires: vte-devel %else @@ -395,6 +400,18 @@ as PC and PowerMac systems. This sub-package contains the guest agent. +%if 0%{?with_systemd} +%package ksm +Summary: Kernel Samepage Merging services +Group: System/Emulators/PC + +%description ksm +Kernel Samepage Merging (KSM) is a memory-saving de-duplication feature, +that merges anonymous (private) pages (not pagecache ones). + +This package provides a service file for starting and stopping KSM. +%endif + %prep %setup -q #-n %name-1.7.0-rc2 %patch0001 -p1 @@ -544,6 +561,7 @@ install -D -m 755 %{SOURCE2} %{buildroot}/usr/share/qemu/qemu-ifup install -D -m 755 %{SOURCE3} %{buildroot}%{_bindir}/kvm_stat install -D -m 644 %{SOURCE4} %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz %endif +install -D -p -m 0744 %{SOURCE6} %{buildroot}%{_unitdir}/ksm.service %fdupes -s $RPM_BUILD_ROOT %clean @@ -572,6 +590,20 @@ fi %verify_permissions %_libexecdir/qemu-bridge-helper %endif +%if 0%{?with_systemd} +%pre ksm +%service_add_pre ksm.service + +%post ksm +%service_add_post ksm.service + +%preun ksm +%service_del_preun ksm.service + +%postun ksm +%service_del_postun ksm.service +%endif + %files %defattr(-, root, root) %doc COPYING COPYING.LIB Changelog README VERSION qemu-doc.html qemu-tech.html @@ -719,4 +751,9 @@ fi %defattr(-, root, root) %attr(755,root,kvm) %_bindir/qemu-ga +%if 0%{?with_systemd} +%files ksm +%{_unitdir}/ksm.service +%endif + %changelog diff --git a/qemu.spec.in b/qemu.spec.in index 8dac06db..af01cd04 100644 --- a/qemu.spec.in +++ b/qemu.spec.in @@ -36,6 +36,7 @@ Source2: qemu-ifup Source3: kvm_stat Source4: qemu-kvm.1.gz Source5: 60-kvm.rules +Source6: ksm.service # This patch queue is auto-generated from https://github.com/openSUSE/qemu PATCH_FILES # Please do not add patches manually here, run update_git.sh. @@ -104,6 +105,10 @@ BuildRequires: python BuildRequires: usbredir-devel %endif %if 0%{?suse_version} >= 1210 +BuildRequires: systemd +%{?systemd_requires} +%define with_systemd 1 +Recommends: qemu-ksm = %{version} %if 0%{?suse_version} >= 1220 BuildRequires: vte-devel %else @@ -354,6 +359,18 @@ as PC and PowerMac systems. This sub-package contains the guest agent. +%if 0%{?with_systemd} +%package ksm +Summary: Kernel Samepage Merging services +Group: System/Emulators/PC + +%description ksm +Kernel Samepage Merging (KSM) is a memory-saving de-duplication feature, +that merges anonymous (private) pages (not pagecache ones). + +This package provides a service file for starting and stopping KSM. +%endif + %prep %setup -q #-n %name-1.7.0-rc2 PATCH_EXEC @@ -462,6 +479,7 @@ install -D -m 755 %{SOURCE2} %{buildroot}/usr/share/qemu/qemu-ifup install -D -m 755 %{SOURCE3} %{buildroot}%{_bindir}/kvm_stat install -D -m 644 %{SOURCE4} %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz %endif +install -D -p -m 0744 %{SOURCE6} %{buildroot}%{_unitdir}/ksm.service %fdupes -s $RPM_BUILD_ROOT %clean @@ -490,6 +508,20 @@ fi %verify_permissions %_libexecdir/qemu-bridge-helper %endif +%if 0%{?with_systemd} +%pre ksm +%service_add_pre ksm.service + +%post ksm +%service_add_post ksm.service + +%preun ksm +%service_del_preun ksm.service + +%postun ksm +%service_del_postun ksm.service +%endif + %files %defattr(-, root, root) %doc COPYING COPYING.LIB Changelog README VERSION qemu-doc.html qemu-tech.html @@ -637,4 +669,9 @@ fi %defattr(-, root, root) %attr(755,root,kvm) %_bindir/qemu-ga +%if 0%{?with_systemd} +%files ksm +%{_unitdir}/ksm.service +%endif + %changelog