Blame SOURCES/tuned-2.5.1-realtime-virtual-host-modprobe-race-fix.patch

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