qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH v6 2/4] tests/vm: add console_consume helper
Date: Thu, 31 Oct 2019 15:05:16 +0100	[thread overview]
Message-ID: <467684e8-9e69-e0e3-2e1e-a8db55e8f653@redhat.com> (raw)
In-Reply-To: <20191031085306.28888-3-kraxel@redhat.com>

On 10/31/19 9:53 AM, Gerd Hoffmann wrote:
> Helper function to read all console output.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   tests/vm/basevm.py | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 2929de23aa..086bfb2c66 100755
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -242,6 +242,25 @@ class BaseVM(object):
>               return False
>           return True
>   
> +    def console_consume(self):
> +        vm = self._guest
> +        output = ""
> +        vm.console_socket.setblocking(0)
> +        while True:
> +            try:
> +                chars = vm.console_socket.recv(1)
> +            except:
> +                break
> +            output += chars.decode("latin1")

I don't know enough decode(), but I'm very happy with the rest of
the patch, thanks a lot for fixing this long standing issue Gerd!

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +            if "\r" in output or "\n" in output:
> +                lines = re.split("[\r\n]", output)
> +                output = lines.pop()
> +                if self.debug:
> +                    self.console_log("\n".join(lines))
> +        if self.debug:
> +            self.console_log(output)
> +        vm.console_socket.setblocking(1)
> +
>       def console_send(self, command):
>           vm = self._guest
>           if self.debug:
> 


  reply	other threads:[~2019-10-31 14:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31  8:53 [PATCH v6 0/4] tests/vm: netbsd autoinstall Gerd Hoffmann
2019-10-31  8:53 ` [PATCH v6 1/4] tests/vm: netbsd autoinstall, using serial console Gerd Hoffmann
2019-11-11 14:23   ` Thomas Huth
2019-10-31  8:53 ` [PATCH v6 2/4] tests/vm: add console_consume helper Gerd Hoffmann
2019-10-31 14:05   ` Philippe Mathieu-Daudé [this message]
2019-10-31  8:53 ` [PATCH v6 3/4] tests/vm: use console_consume for netbsd Gerd Hoffmann
2019-10-31 10:22   ` Kamil Rytarowski
2019-10-31 14:06   ` Philippe Mathieu-Daudé
2019-10-31  8:53 ` [PATCH v6 4/4] tests/vm: update netbsd to version 8.1 Gerd Hoffmann
2019-10-31 14:07   ` Philippe Mathieu-Daudé

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=467684e8-9e69-e0e3-2e1e-a8db55e8f653@redhat.com \
    --to=philmd@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).