qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hyman Huang <yong.huang@smartx.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P . Berrangé" <berrange@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	yong.huang@smartx.com
Subject: [PATCH v2 1/2] i386/sev: Sort the error message
Date: Sun,  7 Jan 2024 19:53:10 +0800	[thread overview]
Message-ID: <c34aaa8055cd09b17f7abebfb2d1397331f7d5c0.1704626686.git.yong.huang@smartx.com> (raw)
In-Reply-To: <cover.1704626686.git.yong.huang@smartx.com>

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



  reply	other threads:[~2024-01-07 11:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-01-07 11:53 ` [PATCH v2 2/2] i386/sev: " Hyman Huang
2024-01-15  6:26 ` [PATCH v2 0/2] " Yong Huang

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=c34aaa8055cd09b17f7abebfb2d1397331f7d5c0.1704626686.git.yong.huang@smartx.com \
    --to=yong.huang@smartx.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 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).