qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] kvm: consistently return 0/-errno from kvm_convert_memory


From: Paolo Bonzini
Subject: [PATCH] kvm: consistently return 0/-errno from kvm_convert_memory
Date: Thu, 12 Dec 2024 16:57:19 +0100

In case of incorrect parameters, kvm_convert_memory() was returning
-1 instead of -EINVAL.  The guest won't notice because it will move
anyway to RUN_STATE_INTERNAL_ERROR, but fix this for consistency and
clarity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4c5cef766ad..81821af7d7a 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2998,17 +2998,17 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool 
to_private)
     ram_addr_t offset;
     MemoryRegion *mr;
     RAMBlock *rb;
-    int ret = -1;
+    int ret = -EINVAL;
 
     trace_kvm_convert_memory(start, size, to_private ? "shared_to_private" : 
"private_to_shared");
 
     if (!QEMU_PTR_IS_ALIGNED(start, qemu_real_host_page_size()) ||
         !QEMU_PTR_IS_ALIGNED(size, qemu_real_host_page_size())) {
-        return -1;
+        return ret;
     }
 
     if (!size) {
-        return -1;
+        return ret;
     }
 
     section = memory_region_find(get_system_memory(), start, size);
@@ -3026,7 +3026,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool 
to_private)
         if (!to_private) {
             return 0;
         }
-        return -1;
+        return ret;
     }
 
     if (!memory_region_has_guest_memfd(mr)) {
-- 
2.47.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]