* [PATCH v2 0/2] Nitpick at the error message's output
@ 2024-01-07 11:53 Hyman Huang
2024-01-07 11:53 ` [PATCH v2 1/2] i386/sev: Sort the error message Hyman Huang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hyman Huang @ 2024-01-07 11:53 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P . Berrangé, Alex Bennée, Paolo Bonzini,
Marcelo Tosatti, yong.huang
v2:
- rebase on master
- add a commit to sort the error message so that an explanation
error number can be returned on all failure paths
Hyman Huang (2):
i386/sev: Sort the error message
i386/sev: Nitpick at the error message's output
target/i386/sev.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--
2.39.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] i386/sev: Sort the error message
2024-01-07 11:53 [PATCH v2 0/2] Nitpick at the error message's output Hyman Huang
@ 2024-01-07 11:53 ` Hyman Huang
2024-01-07 11:53 ` [PATCH v2 2/2] i386/sev: Nitpick at the error message's output Hyman Huang
2024-01-15 6:26 ` [PATCH v2 0/2] " Yong Huang
2 siblings, 0 replies; 4+ messages in thread
From: Hyman Huang @ 2024-01-07 11:53 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P . Berrangé, Alex Bennée, Paolo Bonzini,
Marcelo Tosatti, yong.huang
Prior to giving the caller the return number(in the next commit),
sorting the error message:
1. report the error number on the ram_block_discard_disable
failure path
2. report the error number on the syscall "open" failure path
3. report EINVAL when a prerequisite check fails or the command
line is invalid
Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
target/i386/sev.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 9a71246682..96eff73001 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -923,7 +923,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__);
- return -1;
+ return ret;
}
sev_guest = sev;
@@ -940,6 +940,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
if (host_cbitpos != sev->cbitpos) {
error_setg(errp, "%s: cbitpos check failed, host '%d' requested '%d'",
__func__, host_cbitpos, sev->cbitpos);
+ ret = -EINVAL;
goto err;
}
@@ -952,11 +953,12 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
error_setg(errp, "%s: reduced_phys_bits check failed,"
" it should be in the range of 1 to 63, requested '%d'",
__func__, sev->reduced_phys_bits);
+ ret = -EINVAL;
goto err;
}
devname = object_property_get_str(OBJECT(sev), "sev-device", NULL);
- sev->sev_fd = open(devname, O_RDWR);
+ ret = sev->sev_fd = open(devname, O_RDWR);
if (sev->sev_fd < 0) {
error_setg(errp, "%s: Failed to open %s '%s'", __func__,
devname, strerror(errno));
@@ -981,6 +983,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
if (!kvm_kernel_irqchip_allowed()) {
error_report("%s: SEV-ES guests require in-kernel irqchip support",
__func__);
+ ret = -EINVAL;
goto err;
}
@@ -988,6 +991,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
error_report("%s: guest policy requires SEV-ES, but "
"host SEV-ES support unavailable",
__func__);
+ ret = -EINVAL;
goto err;
}
cmd = KVM_SEV_ES_INIT;
--
2.39.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] i386/sev: Nitpick at the error message's output
2024-01-07 11:53 [PATCH v2 0/2] Nitpick at the error message's output Hyman Huang
2024-01-07 11:53 ` [PATCH v2 1/2] i386/sev: Sort the error message Hyman Huang
@ 2024-01-07 11:53 ` Hyman Huang
2024-01-15 6:26 ` [PATCH v2 0/2] " Yong Huang
2 siblings, 0 replies; 4+ messages in thread
From: Hyman Huang @ 2024-01-07 11:53 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P . Berrangé, Alex Bennée, Paolo Bonzini,
Marcelo Tosatti, yong.huang
The incorrect error message was produced as a result of
the return number being disregarded on the sev_kvm_init
failure path.
For instance, when a user's failure to launch a SEV guest
is caused by an incorrect IOCTL, the following message is
reported:
kvm: sev_kvm_init: failed to initialize ret=-25 fw_error=0
kvm: failed to initialize kvm: Operation not permitted
While the error message's accurate output should be:
kvm: sev_kvm_init: failed to initialize ret=-25 fw_error=0
kvm: failed to initialize kvm: Inappropriate ioctl for device
Fix this by returning the return number directly on the
failure path.
Signed-off-by: Hyman Huang <yong.huang@smartx.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <c5033954155dfe256f650fc9ca2084c688356317.1704469721.git.yong.huang@smartx.com>
---
target/i386/sev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 96eff73001..3fef8cf163 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -1023,7 +1023,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
err:
sev_guest = NULL;
ram_block_discard_disable(false);
- return -1;
+ return ret;
}
int
--
2.39.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] Nitpick at the error message's output
2024-01-07 11:53 [PATCH v2 0/2] Nitpick at the error message's output Hyman Huang
2024-01-07 11:53 ` [PATCH v2 1/2] i386/sev: Sort the error message Hyman Huang
2024-01-07 11:53 ` [PATCH v2 2/2] i386/sev: Nitpick at the error message's output Hyman Huang
@ 2024-01-15 6:26 ` Yong Huang
2 siblings, 0 replies; 4+ messages in thread
From: Yong Huang @ 2024-01-15 6:26 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P . Berrangé, Alex Bennée, Paolo Bonzini,
Marcelo Tosatti
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
Ping
On Sun, Jan 7, 2024 at 7:53 PM Hyman Huang <yong.huang@smartx.com> wrote:
> v2:
> - rebase on master
> - add a commit to sort the error message so that an explanation
> error number can be returned on all failure paths
>
> Hyman Huang (2):
> i386/sev: Sort the error message
> i386/sev: Nitpick at the error message's output
>
> target/i386/sev.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> --
> 2.39.1
>
>
--
Best regards
[-- Attachment #2: Type: text/html, Size: 1114 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-15 6:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-07 11:53 [PATCH v2 0/2] Nitpick at the error message's output Hyman Huang
2024-01-07 11:53 ` [PATCH v2 1/2] i386/sev: Sort the error message Hyman Huang
2024-01-07 11:53 ` [PATCH v2 2/2] i386/sev: Nitpick at the error message's output Hyman Huang
2024-01-15 6:26 ` [PATCH v2 0/2] " Yong Huang
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).