From: Avi Kivity <avi@redhat.com>
To: Michael Goldish <mgoldish@redhat.com>
Cc: kvm@vger.kernel.org, David Huff <dhuff@redhat.com>
Subject: Re: [PATCH][KVM_AUTOTEST] Added functionality to the preprocessor to run scripts
Date: Wed, 03 Jun 2009 09:45:43 +0300 [thread overview]
Message-ID: <4A261C17.7080900@redhat.com> (raw)
In-Reply-To: <511807252.1061881244009668219.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
Michael Goldish wrote:
> ----- "Avi Kivity" <avi@redhat.com> wrote:
>
>
>> David Huff wrote:
>>
>>> This patch will run pre and post scripts
>>> defined in config file with the parameter pre_command
>>> and post_command post_command.
>>>
>>> Also exports all the prameters in preprocess for passing
>>> arguments to the script.
>>>
>>> + #execute any pre_commands
>>> + pre_command = params.get("pre_command")
>>> + if pre_command:
>>> + # export environment vars
>>> + for k in params.keys():
>>> + kvm_log.info("Adding KVM_TEST_%s to Environment" %
>>>
>> (k))
>>
>>> + os.putenv("KVM_TEST_%s" % (k), str(params[k]))
>>> + # execute command
>>> + kvm_log.info("Executing command '%s'..." % pre_command)
>>> + timeout = int(params.get("pre_commmand_timeout", "600"))
>>> + (status, pid, output) = kvm_utils.run_bg("cd %s; %s" %
>>>
>> (test.bindir, pre_command),
>>
>>> + None,
>>>
>> kvm_log.debug, "(pre_command) ", timeout=timeout)
>>
>>> + if status != 0:
>>> + kvm_utils.safe_kill(pid, signal.SIGTERM)
>>> + raise error.TestError, "Custom processing pre_command
>>>
>> failed"
>>
>>>
>>>
>> kvm_utils.run_bg should throw an exception instead of returning
>> status.
>>
>
> - What if we're interested in the status for some reason? Its value
> may indicate what went wrong with the child process.
>
Put it in the exception string.
> - If we throw an exception we should add a parameter that controls
> whether an exception should be thrown (something like "ignore_status")
> because in some cases we don't want to throw an exception.
>
I'll complain every time I see it. If you don't care if the command
succeeds or not, why run it in the first place?
> - A run_bg call has 3 possible outcomes: success (status == 0), failure
> (status != 0) and timeout (process still running). If we throw an exception
> upon failure, what do we do upon timeout? Sometimes it's good (qemu should
> keep running unless something went wrong) and sometimes bad (pre_command
> should probably not time out). So we end up needing an ignore_timeout
> parameter as well.
>
A run_bg() call should return an object with a .join() method, or throw
an exception. At some point you must call the join() method, which
throws an exception or returns None.
> - What if we want the test to fail with an informative test-specific
> exception such as "something failed after migration"?
>
Chained exceptions can provide detailed information.
>> But if status != 0, will there actually be a pid to kill?
>>
>
> If the timeout expires and the process is still running, status is None.
>
functions which can return with three possible outcomes are difficult to
use.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2009-06-03 6:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <91999434.1061671244009504146.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 6:14 ` [PATCH][KVM_AUTOTEST] Added functionality to the preprocessor to run scripts Michael Goldish
2009-06-03 6:45 ` Avi Kivity [this message]
2009-06-03 23:31 ` Lucas Meneghel Rodrigues
[not found] <837206814.1138871244056506696.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 19:15 ` Michael Goldish
[not found] <1680667705.1130361244052268822.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 18:05 ` Michael Goldish
2009-06-03 18:17 ` Avi Kivity
[not found] <1788153169.1063471244013561944.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-03 7:21 ` Michael Goldish
2009-06-03 8:13 ` Avi Kivity
[not found] <1222268607.226581242993156722.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-05-22 11:58 ` [PATCH] [KVM_Autotest] " Michael Goldish
2009-05-26 16:07 ` David Huff
2009-05-26 21:08 ` [PATCH][KVM_AUTOTEST] " David Huff
2009-05-31 11:23 ` Avi Kivity
2009-05-27 17:13 ` [PATCH] [KVM_Autotest] " sudhir kumar
2009-05-21 20:22 David Huff
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=4A261C17.7080900@redhat.com \
--to=avi@redhat.com \
--cc=dhuff@redhat.com \
--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