From: "Cao, Chen" <kcao@redhat.com>
To: Michael Goldish <mgoldish@redhat.com>
Cc: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: Re: [KVM-AUTOTEST,01/17] Add new module kvm_subprocess
Date: Mon, 12 Oct 2009 14:55:59 +0800 [thread overview]
Message-ID: <20091012065559.GK3759@localhost.localdomain> (raw)
In-Reply-To: <eac379742371cccb0422d947d6e8083002fafda1.1248102188.git.mgoldish@redhat.com>
Hi, Michael,
I found that if the sessions initialized using kvm_subprcoess are not closed,
the processes will never exit, and /tmp/kvm_spawn will be filled with the
temporary files.
And we can find in the code,
# kvm_subprocess.py
...
# Read from child and write to files/pipes
while True:
check_termination = False
# Make a list of reader pipes whose buffers are not empty
fds = [fd for (i, fd) in enumerate(reader_fds) if buffers[i]]
# Wait until there's something to do
r, w, x = select.select([shell_fd, inpipe_fd], fds, [], 0.5)
# If a reader pipe is ready for writing --
for (i, fd) in enumerate(reader_fds):
if fd in w:
bytes_written = os.write(fd, buffers[i])
buffers[i] = buffers[i][bytes_written:]
# If there's data to read from the child process --
if shell_fd in r:
try:
data = os.read(shell_fd, 16384)
except OSError:
data = ""
if not data:
check_termination = True
# Remove carriage returns from the data -- they often cause
# trouble and are normally not needed
data = data.replace("\r", "")
output_file.write(data)
output_file.flush()
for i in range(len(readers)):
buffers[i] += data
# If os.read() raised an exception or there was nothing to read --
if check_termination or shell_fd not in r:
pid, status = os.waitpid(shell_pid, os.WNOHANG)
if pid:
status = os.WEXITSTATUS(status)
break
# If there's data to read from the client --
if inpipe_fd in r:
data = os.read(inpipe_fd, 1024)
os.write(shell_fd, data)
...
that if session.close() is not called, we will loop in the 'while' forever.
So, user have to make sure that unnecessary sessions are all killed,
otherwise, running some testcase(s) for huge number of times will suck
out all the system resource, which I think is very inconvenient.
Especially when we have to take care of many exceptions that may be raised
by our program.
e.g.
...
session = kvm_test_utils.wait_for_login(vm)
...
session2 = kvm_test_utils.wait_for_login(vm_x)
...
try:
...
except ...:
...
...
(other code may raise exceptions)
...
try:
...
except ...:
...
...
try:
...
except ...:
...
...
cleaning up the sessions will be exhausting here.
Do we have a good (or better) way to handle this?
Thanks.
Regards,
Cao, Chen
2009-10-12
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish<mgoldish@redhat.com>
wrote:
> This module is intended to be used for controlling all child
> processes in KVM
> tests: both QEMU processes and SSH/SCP/Telnet processes. Processes
> started with
> this module keep running and can be interacted with even after the
> parent
> process exits.
>
> The current run_bg() utility tracks a child process as long as the
> parent
> process is running. When the parent process exits, the tracking
> thread
> terminates and cannot resume when needed.
>
> Currently SSH/SCP/Telnet communication is handled by
> kvm_utils.kvm_spawn, which
> does not allow the child process to run after the parent process
> exits. Thus,
> open SSH/SCP/Telnet sessions cannot be reused by tests following the
> one in
> which they are opened.
>
> The new module provides a solution to these two problems, and also
> saves some
> code by reusing common code required both for QEMU processes and
> SSH/SCP/Telnet
> processes.
>
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
> client/tests/kvm/kvm_subprocess.py | 1146
> ++++++++++++++++++++++++++++++++++++
> 1 files changed, 1146 insertions(+), 0 deletions(-)
> create mode 100644 client/tests/kvm/kvm_subprocess.py
>
next prev parent reply other threads:[~2009-10-12 6:56 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-20 15:07 [KVM-AUTOTEST PATCH 0/17] kvm_subprocess, guestwizard improvements, timedrift and other small things Michael Goldish
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 01/17] Add new module kvm_subprocess Michael Goldish
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 02/17] Modify kvm_vm and kvm_preprocessing to use the new kvm_subprocess module Michael Goldish
2009-07-23 1:37 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 03/17] Modify remote_login and remote_scp in kvm_utils to use kvm_subprocess Michael Goldish
2009-07-23 4:02 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-23 4:03 ` Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 04/17] Modify run_autotest() in kvm_tests.py to use the new kvm_subprocess module Michael Goldish
2009-07-23 4:03 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 05/17] Remove kvm_spawn and run_bg() from kvm_utils.py Michael Goldish
2009-07-23 4:04 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 06/17] kvm_guest_wizard: rename output_dir to debug_dir in barrier_2() Michael Goldish
2009-07-24 18:07 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 07/17] kvm_guest_wizard: pass 'params' directly to barrier_2() Michael Goldish
2009-07-24 19:36 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 08/17] kvm_guest_wizard: allow keeping screendump history for debugging purposes Michael Goldish
2009-07-24 19:36 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 09/17] kvm_tests.cfg.sample: add 'keep_screendump_history = yes' to step file tests Michael Goldish
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 10/17] KVM test: optionally convert PPM files to PNG format after test Michael Goldish
2009-07-24 19:38 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 11/17] KVM test: kvm_tests.cfg.sample: convert PPM files to PNG by default Michael Goldish
2009-07-24 19:38 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 12/17] KVM test: add simple timedrift test (mainly for Windows) Michael Goldish
2009-07-21 9:23 ` [Autotest] " Dor Laor
2009-07-21 9:37 ` Michael Goldish
2009-07-21 9:42 ` Dor Laor
2009-07-21 17:25 ` Marcelo Tosatti
2009-07-21 14:57 ` Yolkfull Chow
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 13/17] KVM test: fix a parsing problem in kvm_config.py Michael Goldish
2009-07-27 13:31 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 14/17] KVM test: fix string and docstring indentation " Michael Goldish
2009-07-27 13:31 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 15/17] KVM test: add timedrift test to kvm_tests.cfg.sample Michael Goldish
2009-07-21 9:47 ` [Autotest] " Dor Laor
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 16/17] KVM test: initialize some VM attributes in __init__() to prevent trouble Michael Goldish
2009-07-27 13:34 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-20 15:07 ` [KVM-AUTOTEST PATCH 17/17] KVM test: make some style changes in kvm_preprocessing.py Michael Goldish
2009-07-27 13:35 ` [Autotest] " Lucas Meneghel Rodrigues
2009-07-22 20:32 ` [Autotest] [KVM-AUTOTEST PATCH 01/17] Add new module kvm_subprocess Lucas Meneghel Rodrigues
2009-10-12 6:55 ` Cao, Chen [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-08-11 12:31 [KVM-AUTOTEST PATCH] KVM test: kvm_subprocess: add function kill_tail_thread() Michael Goldish
2009-08-11 12:31 ` [KVM-AUTOTEST PATCH] KVM test: kvm_tests.cfg.sample: improve shell_prompt regular expressions Michael Goldish
[not found] <916351769.31401255352843062.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-10-12 13:07 ` [KVM-AUTOTEST,01/17] Add new module kvm_subprocess Michael Goldish
2009-10-13 1:59 ` Cao, Chen
2009-10-13 11:58 ` Michael Goldish
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091012065559.GK3759@localhost.localdomain \
--to=kcao@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mgoldish@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox