All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zixuan Wang <zxwang42@gmail.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com, drjones@redhat.com
Cc: marcorr@google.com, erdemaktas@google.com, rientjes@google.com,
	seanjc@google.com, brijesh.singh@amd.com,
	Thomas.Lendacky@amd.com, varad.gautam@suse.com, jroedel@suse.de,
	bp@suse.de
Subject: [kvm-unit-tests PATCH v2 06/10] x86 UEFI: Exit QEMU with return code
Date: Tue, 16 Nov 2021 12:40:49 -0800	[thread overview]
Message-ID: <20211116204053.220523-7-zxwang42@gmail.com> (raw)
In-Reply-To: <20211116204053.220523-1-zxwang42@gmail.com>

From: Zixuan Wang <zxwang42@gmail.com>

kvm-unit-tests runner scripts parse QEMU exit code to determine if a
test case runs successfully. But the UEFI 'reset_system' function always
exits QEMU with code 0, even if the test case returns a non-zero code.

This commit fixes this issue by calling 'exit' function to exit QEMU
with the correct code.

Signed-off-by: Zixuan Wang <zxwang42@gmail.com>
---
 lib/efi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/efi.c b/lib/efi.c
index 99eb00c..64cc978 100644
--- a/lib/efi.c
+++ b/lib/efi.c
@@ -85,6 +85,17 @@ efi_status_t efi_get_system_config_table(efi_guid_t table_guid, void **table)
 	return EFI_NOT_FOUND;
 }
 
+static void efi_exit(efi_status_t code)
+{
+	exit(code);
+
+	/*
+	 * Fallback to UEFI reset_system() service, in case testdev is
+	 * missing and exit() does not properly exit.
+	 */
+	efi_rs_call(reset_system, EFI_RESET_SHUTDOWN, code, 0, NULL);
+}
+
 efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab)
 {
 	int ret;
@@ -134,14 +145,14 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab)
 	ret = main(__argc, __argv, __environ);
 
 	/* Shutdown the guest VM */
-	efi_rs_call(reset_system, EFI_RESET_SHUTDOWN, ret, 0, NULL);
+	efi_exit(ret);
 
 	/* Unreachable */
 	return EFI_UNSUPPORTED;
 
 efi_main_error:
 	/* Shutdown the guest with error EFI status */
-	efi_rs_call(reset_system, EFI_RESET_SHUTDOWN, status, 0, NULL);
+	efi_exit(status);
 
 	/* Unreachable */
 	return EFI_UNSUPPORTED;
-- 
2.33.0


  parent reply	other threads:[~2021-11-16 20:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 20:40 [kvm-unit-tests PATCH v2 00/10] x86_64 UEFI set up process refactor and scripts fixes Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 01/10] x86 UEFI: Remove mixed_mode Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 02/10] x86 UEFI: Refactor set up process Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 03/10] x86 AMD SEV: Skip SEV-ES if SEV is unsupported Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 04/10] x86 UEFI: Convert x86 test cases to PIC Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 05/10] x86 UEFI: Set UEFI OVMF as readonly Zixuan Wang
2021-11-16 20:40 ` Zixuan Wang [this message]
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 07/10] scripts: Generalize EFI check Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 08/10] x86 UEFI: Make run_tests.sh (mostly) work under UEFI Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 09/10] x86 UEFI: Improve Boot Speed Zixuan Wang
2021-11-16 20:40 ` [kvm-unit-tests PATCH v2 10/10] x86 UEFI: Make _NO_FILE_4Uhere_ work w/ BOOTX64.EFI Zixuan Wang
2022-01-18 15:47   ` Paolo Bonzini
2022-01-18 16:51 ` [kvm-unit-tests PATCH v2 00/10] x86_64 UEFI set up process refactor and scripts fixes Paolo Bonzini
2022-01-18 17:29   ` Marc Orr

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=20211116204053.220523-7-zxwang42@gmail.com \
    --to=zxwang42@gmail.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=drjones@redhat.com \
    --cc=erdemaktas@google.com \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=varad.gautam@suse.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.