qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash


From: Jay Zhou
Subject: [Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash
Date: Wed, 10 Jan 2018 00:39:35 +0800

Start QEMU with more DIMM devices than limit but without any
vhost backends and then hotplug a vhost user backend, the VM
will be crashed.
Instead of asserting in vhost_user_set_mem_table(), error number
is used to gracefully prevent device to start. This fixes the
crash issue.

Cc: address@hidden
Signed-off-by: Igor Mammedov <address@hidden>
Signed-off-by: Jay Zhou <address@hidden>
---
 hw/virtio/vhost-user.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 093675e..8500562 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -317,11 +317,14 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
                                      &offset);
         fd = memory_region_get_fd(mr);
         if (fd > 0) {
+            if (fd_num == VHOST_MEMORY_MAX_NREGIONS) {
+                error_report("Failed preparing vhost-user memory table msg");
+                return -1;
+            }
             msg.payload.memory.regions[fd_num].userspace_addr = 
reg->userspace_addr;
             msg.payload.memory.regions[fd_num].memory_size  = reg->memory_size;
             msg.payload.memory.regions[fd_num].guest_phys_addr = 
reg->guest_phys_addr;
             msg.payload.memory.regions[fd_num].mmap_offset = offset;
-            assert(fd_num < VHOST_MEMORY_MAX_NREGIONS);
             fds[fd_num++] = fd;
         }
     }
-- 
1.8.3.1





reply via email to

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