qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Zhenzhong Duan" <zhenzhong.duan@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"David Hildenbrand" <david@redhat.com>
Subject: [PULL 13/13] system/physmem: use return value of ram_block_discard_require() as errno
Date: Tue, 16 Jul 2024 20:09:40 +0200	[thread overview]
Message-ID: <20240716180941.40211-14-philmd@linaro.org> (raw)
In-Reply-To: <20240716180941.40211-1-philmd@linaro.org>

From: Zhenzhong Duan <zhenzhong.duan@intel.com>

When ram_block_discard_require() fails, errno is passed to error_setg_errno().
It's a stale value or 0 which is unrelated to ram_block_discard_require().

As ram_block_discard_require() already returns -EBUSY in failure case,
use it as errno for error_setg_errno().

Fixes: 852f0048f3ea ("make guest_memfd require uncoordinated discard")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20240716064213.290696-1-zhenzhong.duan@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/physmem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/system/physmem.c b/system/physmem.c
index 2154432cb6..9a3b3a7636 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -1845,11 +1845,14 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
     }
 
     if (new_block->flags & RAM_GUEST_MEMFD) {
+        int ret;
+
         assert(kvm_enabled());
         assert(new_block->guest_memfd < 0);
 
-        if (ram_block_discard_require(true) < 0) {
-            error_setg_errno(errp, errno,
+        ret = ram_block_discard_require(true);
+        if (ret < 0) {
+            error_setg_errno(errp, -ret,
                              "cannot set up private guest memory: discard currently blocked");
             error_append_hint(errp, "Are you using assigned devices?\n");
             goto out_free;
-- 
2.41.0



  parent reply	other threads:[~2024-07-16 18:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 18:09 [PULL 00/13] Misc HW/UI patches for 2024-07-16 Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 01/13] hw/core/loader: allow loading larger ROMs Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 02/13] hw/isa/vt82c686: Turn "intr" irq into a named gpio Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 03/13] include/hw/qdev-core.h: Correct and clarify gpio doc comments Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 04/13] loader: remove load_image_gzipped function as its not used anywhere Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 05/13] accel/tcg: Make cpu_exec_interrupt hook mandatory Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 06/13] system/cpus: Add cpu_pause() function Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 07/13] esp: remove transfer size check from DMA DATA IN and DATA OUT transfers Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 08/13] ui/cocoa: Release CGColorSpace Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 09/13] ui/console: Convert mouse visibility parameter into bool Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 10/13] ui/cocoa: Add cursor composition Philippe Mathieu-Daudé
2024-07-16 18:09 ` [PULL 11/13] ui/console: Remove dpy_cursor_define_supported() Philippe Mathieu-Daudé
2024-10-29 12:30   ` Michael Tokarev
2024-10-29 14:04     ` Phil Dennis-Jordan
2025-01-09 13:58       ` Michael Weiser
2025-01-09 14:34         ` Hank Knox
2025-03-11 10:52           ` Michael Weiser
2024-07-16 18:09 ` [PULL 12/13] vl: fix "type is NULL" in -vga help Philippe Mathieu-Daudé
2024-07-16 18:09 ` Philippe Mathieu-Daudé [this message]
2024-07-17  5:41 ` [PULL 00/13] Misc HW/UI patches for 2024-07-16 Richard Henderson

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=20240716180941.40211-14-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=david@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhenzhong.duan@intel.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 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).