* [PATCH qemu] sev/i386: Fix error reporting
@ 2023-04-03 3:12 Alexey Kardashevskiy
2023-04-03 14:57 ` Markus Armbruster
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kardashevskiy @ 2023-04-03 3:12 UTC (permalink / raw)
To: kvm; +Cc: qemu-devel, Alexey Kardashevskiy
c9f5aaa6bce8 ("sev: Add Error ** to sev_kvm_init()") converted
error_report() to error_setg(), however it missed one error_report()
and other 2 changes added error_report() after conversion. The result
is the caller - kvm_init() - crashes in error_report_err as local_err
is NULL.
Follow the pattern and use error_setg instead of error_report.
Fixes: 9681f8677f26 ("sev/i386: Require in-kernel irqchip support for SEV-ES guests")
Fixes: 6b98e96f1842 ("sev/i386: Add initial support for SEV-ES")
Fixes: c9f5aaa6bce8 ("sev: Add Error ** to sev_kvm_init()")
Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
target/i386/sev.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 859e06f6ad..6b640b5c1f 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -922,7 +922,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
ret = ram_block_discard_disable(true);
if (ret) {
- error_report("%s: cannot disable RAM discard", __func__);
+ error_setg(errp, "%s: cannot disable RAM discard", __func__);
return -1;
}
@@ -968,15 +968,14 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
if (sev_es_enabled()) {
if (!kvm_kernel_irqchip_allowed()) {
- error_report("%s: SEV-ES guests require in-kernel irqchip support",
- __func__);
+ error_setg(errp, "%s: SEV-ES guests require in-kernel irqchip support",
+ __func__);
goto err;
}
if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) {
- error_report("%s: guest policy requires SEV-ES, but "
- "host SEV-ES support unavailable",
- __func__);
+ error_setg(errp, "%s: guest policy requires SEV-ES, but host SEV-ES support unavailable",
+ __func__);
goto err;
}
cmd = KVM_SEV_ES_INIT;
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH qemu] sev/i386: Fix error reporting
2023-04-03 3:12 [PATCH qemu] sev/i386: Fix error reporting Alexey Kardashevskiy
@ 2023-04-03 14:57 ` Markus Armbruster
0 siblings, 0 replies; 2+ messages in thread
From: Markus Armbruster @ 2023-04-03 14:57 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: kvm, qemu-devel
Alexey Kardashevskiy <aik@amd.com> writes:
> c9f5aaa6bce8 ("sev: Add Error ** to sev_kvm_init()") converted
> error_report() to error_setg(), however it missed one error_report()
> and other 2 changes added error_report() after conversion. The result
> is the caller - kvm_init() - crashes in error_report_err as local_err
> is NULL.
>
> Follow the pattern and use error_setg instead of error_report.
>
> Fixes: 9681f8677f26 ("sev/i386: Require in-kernel irqchip support for SEV-ES guests")
> Fixes: 6b98e96f1842 ("sev/i386: Add initial support for SEV-ES")
> Fixes: c9f5aaa6bce8 ("sev: Add Error ** to sev_kvm_init()")
> Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
> ---
> target/i386/sev.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 859e06f6ad..6b640b5c1f 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -922,7 +922,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
>
> ret = ram_block_discard_disable(true);
> if (ret) {
> - error_report("%s: cannot disable RAM discard", __func__);
> + error_setg(errp, "%s: cannot disable RAM discard", __func__);
> return -1;
> }
>
> @@ -968,15 +968,14 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
>
> if (sev_es_enabled()) {
> if (!kvm_kernel_irqchip_allowed()) {
> - error_report("%s: SEV-ES guests require in-kernel irqchip support",
> - __func__);
> + error_setg(errp, "%s: SEV-ES guests require in-kernel irqchip support",
> + __func__);
> goto err;
> }
>
> if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) {
> - error_report("%s: guest policy requires SEV-ES, but "
> - "host SEV-ES support unavailable",
> - __func__);
> + error_setg(errp, "%s: guest policy requires SEV-ES, but host SEV-ES support unavailable",
> + __func__);
> goto err;
> }
> cmd = KVM_SEV_ES_INIT;
Preexisting, but here goes anyway: __func__ in error messages is an
anti-pattern. Error messages are for the user, not the developer. The
developer can find the function just fine; grep exists.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-03 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-03 3:12 [PATCH qemu] sev/i386: Fix error reporting Alexey Kardashevskiy
2023-04-03 14:57 ` Markus Armbruster
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).