Blob Blame History Raw
diff --git a/profiles/functions b/profiles/functions
index 957dfb6..ee525e0 100644
--- a/profiles/functions
+++ b/profiles/functions
@@ -495,19 +495,21 @@ stop() {
 #
 
 process() {
-	case "$1" in
+	ARG="$1"
+	shift
+	case "$ARG" in
 	start)
-		start
+		start "$@"
 		RETVAL=$?
 		;;
 	stop)
-		stop
+		stop "$@"
 		RETVAL=$?
 		;;
 	verify)
 		if declare -f verify &> /dev/null;
 		then
-			verify
+			verify "$@"
 		else
 			:
 		fi
diff --git a/profiles/realtime-virtual-host/script.sh b/profiles/realtime-virtual-host/script.sh
index 161052c..9c09ee3 100755
--- a/profiles/realtime-virtual-host/script.sh
+++ b/profiles/realtime-virtual-host/script.sh
@@ -2,8 +2,22 @@
 
 . /usr/lib/tuned/functions
 
+modfile=/etc/modprobe.d/kvm.rt.tuned.conf
 ltanfile=/sys/module/kvm/parameters/lapic_timer_advance_ns
 
+create_modfile()
+{
+    modinfo -p kvm | grep -q kvmclock_periodic_sync
+    if [ "$?" -eq 0 ]; then
+        echo "options kvm kvmclock_periodic_sync=0" > $modfile
+    fi
+
+    modinfo -p kvm_intel | grep -q ple_gap
+    if [ "$?" -eq 0 ]; then
+        echo "options kvm_intel ple_gap=0" >> $modfile
+    fi
+}
+
 start() {
     python /usr/libexec/tuned/defirqaffinity.py "remove" "$TUNED_isolated_cores_expanded" &&
     tuna -c "$TUNED_isolated_cores_expanded" -i
@@ -13,14 +27,8 @@ start() {
         return $retval
     fi
 
-    modinfo -p kvm | grep -q kvmclock_periodic_sync
-    if [ "$?" -eq 0 ]; then
-        echo "options kvm kvmclock_periodic_sync=0" > /etc/modprobe.d/kvm.rt.tuned.conf
-    fi
-
-    modinfo -p kvm_intel | grep -q ple_gap
-    if [ "$?" -eq 0 ]; then
-        echo "options kvm_intel ple_gap=0" >> /etc/modprobe.d/kvm.rt.tuned.conf
+    if [ ! -f $modfile ]; then
+        create_modfile
     fi
 
     if [ -f lapic_timer_adv_ns.cpumodel ]; then
@@ -55,7 +63,7 @@ start() {
 }
 
 stop() {
-    rm -f /etc/modprobe.d/kvm.rt.tuned.conf
+    [ "$1" = "profile_switch" ] && rm -f $modfile
     tuna -c "$TUNED_isolated_cores_expanded" -I &&
     python /usr/libexec/tuned/defirqaffinity.py "add" "$TUNED_isolated_cores_expanded"
     return "$?"
diff --git a/tuned.spec b/tuned.spec
index e152dac..2e2d9e9 100644
--- a/tuned.spec
+++ b/tuned.spec
@@ -139,6 +139,10 @@ mkdir -p %{buildroot}%{_datadir}/tuned/grub2
 mv %{buildroot}%{_sysconfdir}/grub.d/00_tuned %{buildroot}%{_datadir}/tuned/grub2/00_tuned
 rmdir %{buildroot}%{_sysconfdir}/grub.d
 
+# ghost for NFV
+mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
+touch %{buildroot}%{_sysconfdir}/modprobe.d/kvm.rt.tuned.conf
+
 %post
 %systemd_post tuned.service
 
@@ -283,6 +287,7 @@ fi
 %defattr(-,root,root,-)
 %config(noreplace) %{_sysconfdir}/tuned/realtime-virtual-guest-variables.conf
 %config(noreplace) %{_sysconfdir}/tuned/realtime-virtual-host-variables.conf
+%ghost %{_sysconfdir}/modprobe.d/kvm.rt.tuned.conf
 %{_prefix}/lib/tuned/realtime-virtual-guest
 %{_prefix}/lib/tuned/realtime-virtual-host
 %{_libexecdir}/tuned/defirqaffinity*
diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py
index 7b3d487..57a6335 100644
--- a/tuned/plugins/plugin_script.py
+++ b/tuned/plugins/plugin_script.py
@@ -30,14 +30,14 @@ class ScriptPlugin(base.Plugin):
 	def _instance_cleanup(self, instance):
 		pass
 
-	def _call_scripts(self, scripts, argument):
+	def _call_scripts(self, scripts, arguments):
 		for script in scripts:
 			environ = os.environ
 			environ.update(self._variables.get_env())
-			log.info("calling script '%s' with argument '%s'" % (script, argument))
+			log.info("calling script '%s' with arguments '%s'" % (script, str(arguments)))
 			log.debug("using environment '%s'" % str(environ.items()))
 			try:
-				proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \
+				proc = Popen([script] +  arguments, stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \
 					cwd = os.path.dirname(script))
 				out, err = proc.communicate()
 				if proc.returncode:
@@ -50,13 +50,13 @@ class ScriptPlugin(base.Plugin):
 
 	def _instance_apply_static(self, instance):
 		super(self.__class__, self)._instance_apply_static(instance)
-		self._call_scripts(instance._scripts, "start")
+		self._call_scripts(instance._scripts, ["start"])
 
 	def _instance_verify_static(self, instance):
 		ret = True
 		if super(self.__class__, self)._instance_verify_static(instance) == False:
 			ret = False
-		if self._call_scripts(instance._scripts, "verify") == True:
+		if self._call_scripts(instance._scripts, ["verify"]) == True:
 			log.info(consts.STR_VERIFY_PROFILE_OK % instance._scripts)
 		else:
 			log.error(consts.STR_VERIFY_PROFILE_FAIL % instance._scripts)
@@ -64,5 +64,8 @@ class ScriptPlugin(base.Plugin):
 		return ret
 
 	def _instance_unapply_static(self, instance, profile_switch = False):
-		self._call_scripts(reversed(instance._scripts), "stop")
+		args = ["stop"]
+		if profile_switch:
+			args = args + ["profile_switch"]
+		self._call_scripts(reversed(instance._scripts), args)
 		super(self.__class__, self)._instance_unapply_static(instance, profile_switch)