Nitpick at the error message's output
PATCH v2 2/2 i386/sev: Nitpick at the error message's output
In reply to Hyman HuangThe 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.
Message-Id: <c5033954155dfe256f650fc9ca2084c688356317.1704469721.git.yong.huang@smartx.com>
--- target/i386/sev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/sev.c +1 -1
@@ -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
Signature · 1 line
2.39.1
v2 cover Nitpick at the error message's output
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(-)
Signature · 1 line
2.39.1
PATCH v2 1/2 i386/sev: Sort the error message
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
--- target/i386/sev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
target/i386/sev.c +6 -2
@@ -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 ;
Signature · 1 line
2.39.1
Ping
Quoted 16 lines · Hyman 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 pathsHyman Huang (2):
i386/sev: Sort the error message
i386/sev: Nitpick at the error message's outputtarget/i386/sev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)--
2.39.1
Signature · 1 line
Best regards