[PATCH 07/19] KVM test: kvm_subprocess: get rid of get_pid() (replace it with get_shell_pid())

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Don't differentiate between the PID of the subprocess and the PID of the shell
running it.

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/kvm_subprocess.py |   38 +++++------------------------------
 client/tests/kvm/kvm_tests.py      |    2 +-
 2 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index ba61a8c..d142ed9 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -290,10 +290,12 @@ class kvm_spawn:
         return self.id
 
 
-    def get_shell_pid(self):
+    def get_pid(self):
         """
-        Return the PID of the subshell process, or None if not available.
-        The subshell is the shell that runs the command.
+        Return the PID of the process.
+
+        Note: this may be the PID of the shell process running the user given
+        command.
         """
         try:
             file = open(self.shell_pid_filename, "r")
@@ -304,34 +306,6 @@ class kvm_spawn:
             return None
 
 
-    def get_pid(self, index=0):
-        """
-        Try to get and return the PID of a child process of the subshell.
-        This is usually the PID of the process executed in the subshell.
-        There are 3 exceptions:
-            - If the subshell couldn't start the process for some reason, no
-              PID can be returned.
-            - If the subshell is running several processes in parallel,
-              multiple PIDs can be returned.  Use the index parameter in this
-              case.
-            - Before starting the process, after the process has terminated,
-              or while running shell code that doesn't start any processes --
-              no PID can be returned.
-
-        @param index: The index of the child process whose PID is requested.
-                Normally this should remain 0.
-        @return: The PID of the child process, or None if none could be found.
-        """
-        parent_pid = self.get_shell_pid()
-        if not parent_pid:
-            return None
-        pids = commands.getoutput("ps --ppid %d -o pid=" % parent_pid).split()
-        try:
-            return int(pids[index])
-        except:
-            return None
-
-
     def get_status(self):
         """
         Wait for the process to exit and return its exit status, or None
@@ -375,7 +349,7 @@ class kvm_spawn:
         """
         # Kill it if it's alive
         if self.is_alive():
-            kvm_utils.kill_process_tree(self.get_shell_pid(), sig)
+            kvm_utils.kill_process_tree(self.get_pid(), sig)
         # Wait for the server to exit
         _wait(self.lock_server_running_filename)
         # Call all cleanup routines
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index deab59e..c2bfb8a 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -688,7 +688,7 @@ def run_timedrift(test, params, env):
                                       output_prefix="(host load %d) " % i,
                                       timeout=0.5))
             # Set the CPU affinity of the load process
-            pid = host_load_sessions[-1].get_shell_pid()
+            pid = host_load_sessions[-1].get_pid()
             set_cpu_affinity(pid, cpu_mask)
 
         # Sleep for a while (during load)
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux