From: Paulo F. S. <pfs...@li...> - 2015-01-08 18:58:15
|
This patch add a --with-systemd attribute to install a systemd unit to turn smt on or off (permanently or not). After it's installed you can use systemd commands like: status, start, stop, enable and disable to control it. --- .gitignore | 1 + Makefile.am | 11 +++++++++++ configure.ac | 18 +++++++++++++++++- systemd/smt_off.service.in | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 systemd/smt_off.service.in diff --git a/.gitignore b/.gitignore index c0348c7..15d072b 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ /src/Makefile.in /src/drmgr/Makefile /src/drmgr/Makefile.in +/systemd/smt_off.service # # git files that we don't want to ignore even it they are dot-files diff --git a/Makefile.am b/Makefile.am index c302a54..3735a11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,10 @@ EXTRA_DIST += COPYRIGHT Changelog powerpc-utils.spec.in doc/activate_firmware.do doc/nvram.doxycfg doc/rtas_ibm_get_vpd.doxycfg doc/serv_config.doxycfg \ doc/set_poweron_time.doxycfg doc/uesensor.doxycfg +if WITH_SYSTEMD +EXTRA_DIST += systemd/smt_off.service.in +endif + sbin_PROGRAMS += src/nvram src/lsprop src/lparstat src/ppc64_cpu pseries_platform_SOURCES = src/common/pseries_platform.c src/common/pseries_platform.h @@ -145,3 +149,10 @@ src_drmgr_lsslot_SOURCES = \ $(pseries_platform_SOURCES) src_drmgr_lsslot_LDADD = -lrtas + +if WITH_SYSTEMD +install-data-hook: systemd/smt_off.service + $(MKDIR_P) @prefix@${systemd_unit_dir} + $(INSTALL_SCRIPT) $< @prefix@${systemd_unit_dir}/ + sed -i -e 's,$${exec_prefix},@sbindir@,g' @prefix@${systemd_unit_dir}/smt_off.service +endif diff --git a/configure.ac b/configure.ac index f7fcd55..7fa5b01 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,22 @@ AS_IF([test "x$with_librtas" != "xno"], AM_CONDITIONAL([WITH_LIBRTAS], [test "x$with_librtas" = "xyes"]) +# check for systemd +systemd_unit_dir=/usr/lib/systemd/system +AC_ARG_WITH([systemd], + [AC_HELP_STRING([--with-systemd@<:@=DIR@:>@], + [install systemd unit files (not default and unit dir is /usr/lib/systemd/system)])], + [if test "$withval" = "no"; then + with_systemd=0 + else + with_systemd=1 + test $withval != "yes" && systemd_unit_dir=$withval + fi], + with_systemd=0 + ) +AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = 1]) +AC_SUBST(systemd_unit_dir) + AC_DEFUN([LOCAL_CHECK_FLAGS],[ AC_REQUIRE([AX_CHECK_LINK_FLAG]) AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) @@ -72,5 +88,5 @@ AC_DEFUN([LOCAL_CHECK_FLAGS],[ ]) LOCAL_CHECK_FLAGS -AC_CONFIG_FILES([Makefile powerpc-utils.spec]) +AC_CONFIG_FILES([Makefile powerpc-utils.spec systemd/smt_off.service]) AC_OUTPUT diff --git a/systemd/smt_off.service.in b/systemd/smt_off.service.in new file mode 100644 index 0000000..ed95945 --- /dev/null +++ b/systemd/smt_off.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=ppc64 set SMT off +Before=libvirt-bin.service + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=@sbindir@/ppc64_cpu --smt=off +ExecStop=@sbindir@/ppc64_cpu --smt=on + +[Install] +WantedBy=multi-user.target -- 2.1.0 -- Paulo Flabiano Smorigo IBM Linux Technology Center |