All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: Michael Goldish <mgoldish@redhat.com>
Cc: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: Re: [Autotest] [KVM-AUTOTEST PATCH 11/14] KVM test: add kvm_monitor.py, an interface to QEMU monitors
Date: Mon, 14 Jun 2010 09:32:18 +0800	[thread overview]
Message-ID: <20100614013218.GA5266@z> (raw)
In-Reply-To: <1276439625-32472-11-git-send-email-mgoldish@redhat.com>

On Sun, Jun 13, 2010 at 05:33:42PM +0300, Michael Goldish wrote:
> This module should replace vm.send_monitor_cmd().  Instead of connecting to the
> monitor each time a command is issued, this module maintains a continuous
> connection to the monitor.  It disconnects when a test terminates and
> reconnects as soon as the next test begins (upon unpickling).
> 
> It currently contains only an interface to the human monitor.  A QMP interface
> will be introduced in a future patch.
> 
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm/kvm_monitor.py |  356 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 356 insertions(+), 0 deletions(-)
>  create mode 100644 client/tests/kvm/kvm_monitor.py
> 
> diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py
> new file mode 100644
> index 0000000..c5cf9c3
> --- /dev/null
> +++ b/client/tests/kvm/kvm_monitor.py
> @@ -0,0 +1,356 @@
> +"""
> +Interfaces to the QEMU monitor.
> +
> +@copyright: 2008-2010 Red Hat Inc.
> +"""
> +

...

> +class HumanMonitor(Monitor):
> +    """
> +    Wraps "human monitor" commands.
> +    """
> +
> +    def __init__(self, filename, suppress_exceptions=False):
> +        """
> +        Connect to the monitor socket and find the (qemu) prompt.
> +
> +        @param filename: Monitor socket filename
> +        @raise MonitorConnectError: Raised if the connection fails and
> +                suppress_exceptions is False
> +        @raise MonitorProtocolError: Raised if the initial (qemu) prompt isn't
> +                found and suppress_exceptions is False
> +        """
> +        try:
> +            Monitor.__init__(self, filename)
> +
> +            self.protocol = "human"
> +
> +            # Find the initial (qemu) prompt
> +            s, o = self._read_up_to_qemu_prompt(20)
> +            if not s:
> +                raise MonitorProtocolError("Could not find (qemu) prompt "
> +                                           "after connecting to monitor. "
> +                                           "Output so far: %r" % o)
> +
> +            # Save the output of 'help' for future use
> +            self.help = self._get_command_output("help")

Hi Michael,

Here, self.help is a string type.
But you repeatedly define a sub function self.help() below.

If I call vm.monitor.help() in testcase, will touch this err:
 TypeError: 'str' object is not callable

How about using self.help_str = self._get_command_output("help")?
and remove help sub function, Not only repeated name, but repeated function.


Amos

> +
> +        except MonitorError, e:
> +            if suppress_exceptions:
> +                logging.warn(e)
> +            else:
> +                raise
> +

...

> +
> +    def help(self):
> +        """
> +        Send "help" and return the output.
> +        """
> +        return self._get_command_output("help")

...

  parent reply	other threads:[~2010-06-14  1:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-13 14:33 [KVM-AUTOTEST PATCH 01/14] KVM test: tests_base.cfg.sample: remove inline comments Michael Goldish
2010-06-13 14:33 ` [KVM-AUTOTEST PATCH 02/14] KVM test: tests_base.cfg.sample: style modifications Michael Goldish
2010-06-13 14:33   ` [KVM-AUTOTEST PATCH 03/14] KVM test: kvm_utils.py: warn about exceptions raised during unpickling of env Michael Goldish
2010-06-13 14:33     ` [KVM-AUTOTEST PATCH 04/14] KVM test: kvm_utils.py: remove unnecessary imports Michael Goldish
2010-06-13 14:33       ` [KVM-AUTOTEST PATCH 05/14] KVM test: kvm_vm.py: make get_pid() return the pid of the VM itself Michael Goldish
2010-06-13 14:33         ` [KVM-AUTOTEST PATCH 06/14] KVM test: kvm_vm.py: correct get_shared_meminfo() Michael Goldish
2010-06-13 14:33           ` [KVM-AUTOTEST PATCH 07/14] KVM test: kvm_vm.py: correct add_smp() mistake in make_qemu_command() Michael Goldish
2010-06-13 14:33             ` [KVM-AUTOTEST PATCH 08/14] KVM test: kvm_vm.py: use shell quoting in make_qemu_command() where appropriate Michael Goldish
2010-06-13 14:33               ` [KVM-AUTOTEST PATCH 09/14] KVM test: remove reference to _screendump_thread at postprocessing Michael Goldish
2010-06-13 14:33                 ` [KVM-AUTOTEST PATCH 10/14] KVM test: kvm_subprocess.py: use sys.executable instead of hardcoded 'python' Michael Goldish
2010-06-13 14:33                   ` [KVM-AUTOTEST PATCH 11/14] KVM test: add kvm_monitor.py, an interface to QEMU monitors Michael Goldish
2010-06-13 14:33                     ` [KVM-AUTOTEST PATCH 12/14] KVM test: use new monitor interface Michael Goldish
2010-06-13 14:33                       ` [KVM-AUTOTEST PATCH 13/14] KVM test: kvm_monitor.py: add QMP interface Michael Goldish
2010-06-13 14:33                         ` [KVM-AUTOTEST PATCH 14/14] KVM test: migration: support QMP Michael Goldish
2010-06-14  2:39                         ` [Autotest] [KVM-AUTOTEST PATCH 13/14] KVM test: kvm_monitor.py: add QMP interface Amos Kong
2010-06-14  6:34                           ` Michael Goldish
2010-06-14  1:32                     ` Amos Kong [this message]
2010-06-14  5:59                       ` [Autotest] [KVM-AUTOTEST PATCH 11/14] KVM test: add kvm_monitor.py, an interface to QEMU monitors 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=20100614013218.GA5266@z \
    --to=akong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.