kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] runtime: better handling of QEMU aborts
@ 2016-11-15 14:28 Andrew Jones
  2016-11-15 14:36 ` Andrew Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Jones @ 2016-11-15 14:28 UTC (permalink / raw)
  To: kvm; +Cc: rkrcmar, pbonzini, peter.maydell

Add two changes to run_qemu. The first saves/restores terminal settings.
This solves an annoying loss of terminal echo when QEMU aborts during
a test run. The second ensures we see a message about the abort, because
the "Aborted (core dumped)" message we should see gets eaten.

Note, the first change is necessary because QEMU modifies the terminal
settings when using '-serial stdio', but calling abort() invokes exit
without first calling qemu_chr_free(serial_hds[0]) to restore them.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 scripts/arch-run.bash | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 8e75c6ed6e17..2b288205ab55 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -26,13 +26,19 @@
 ##############################################################################
 run_qemu ()
 {
-	local stdout errors ret sig
+	local stdout errors ret sig tty
 
 	# stdout to {stdout}, stderr to $errors
+	tty=$(stty -g)
 	exec {stdout}>&1
 	errors=$("${@}" 2>&1 1>&${stdout})
 	ret=$?
 	exec {stdout}>&-
+	stty "$tty"
+
+	if [ $ret -eq 134 ]; then
+		errors=$(printf "%s\n" "$errors"; echo "QEMU Aborted")
+	fi
 
 	if [ "$errors" ]; then
 		printf "%s\n" "$errors" >&2
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [kvm-unit-tests PATCH] runtime: better handling of QEMU aborts
  2016-11-15 14:28 [kvm-unit-tests PATCH] runtime: better handling of QEMU aborts Andrew Jones
@ 2016-11-15 14:36 ` Andrew Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Jones @ 2016-11-15 14:36 UTC (permalink / raw)
  To: kvm; +Cc: rkrcmar, pbonzini, peter.maydell

On Tue, Nov 15, 2016 at 03:28:43PM +0100, Andrew Jones wrote:
> Add two changes to run_qemu. The first saves/restores terminal settings.
> This solves an annoying loss of terminal echo when QEMU aborts during
> a test run. The second ensures we see a message about the abort, because
> the "Aborted (core dumped)" message we should see gets eaten.
> 
> Note, the first change is necessary because QEMU modifies the terminal
> settings when using '-serial stdio', but calling abort() invokes exit
> without first calling qemu_chr_free(serial_hds[0]) to restore them.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  scripts/arch-run.bash | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 8e75c6ed6e17..2b288205ab55 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -26,13 +26,19 @@
>  ##############################################################################
>  run_qemu ()
>  {
> -	local stdout errors ret sig
> +	local stdout errors ret sig tty
>  
>  	# stdout to {stdout}, stderr to $errors
> +	tty=$(stty -g)
>  	exec {stdout}>&1
>  	errors=$("${@}" 2>&1 1>&${stdout})
>  	ret=$?
>  	exec {stdout}>&-
> +	stty "$tty"
> +
> +	if [ $ret -eq 134 ]; then
> +		errors=$(printf "%s\n" "$errors"; echo "QEMU Aborted")

Doh, this prints an empty line when errors is empty. Anyway, Radim
just reminded me that code here has changed with some in-flight patch.
I'll rebase on that when it lands.

> +	fi
>  
>  	if [ "$errors" ]; then
>  		printf "%s\n" "$errors" >&2
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-15 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 14:28 [kvm-unit-tests PATCH] runtime: better handling of QEMU aborts Andrew Jones
2016-11-15 14:36 ` Andrew Jones

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).