[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 14/54] vhost: remove assertion to prevent crash
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 14/54] vhost: remove assertion to prevent crash |
Date: |
Tue, 6 Feb 2018 13:14:35 -0600 |
From: Jay Zhou <address@hidden>
QEMU will assert on vhost-user backed virtio device hotplug if QEMU is
using more RAM regions than VHOST_MEMORY_MAX_NREGIONS (for example if
it were started with a lot of DIMM devices).
Fix it by returning error instead of asserting and let callers of
vhost_set_mem_table() handle error condition gracefully.
Cc: address@hidden
Signed-off-by: Igor Mammedov <address@hidden>
Signed-off-by: Jay Zhou <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
(cherry picked from commit f4bf56fb78ed0e9f60fa1ed656c14ff4c494da5a)
Signed-off-by: Michael Roth <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 093675ed98..850056298d 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;
}
}
--
2.11.0
- [Qemu-stable] [PATCH 00/54] Patch Round-up for stable 2.11.1, freeze on 2018-02-12, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 09/54] block: Open backing image in force share mode for size probe, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 11/54] hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 12/54] hw/intc/arm_gic: reserved register addresses are RAZ/WI, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 13/54] virtio_error: don't invoke status callbacks, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 14/54] vhost: remove assertion to prevent crash,
Michael Roth <=
- [Qemu-stable] [PATCH 18/54] scsi-disk: release AioContext in unaligned WRITE SAME case, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 15/54] hw/sd/pl181: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 17/54] hw/sd/ssi-sd: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 16/54] hw/sd/milkymist-memcard: Reset SD card on controller reset, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 20/54] i386: Change X86CPUDefinition::model_id to const char*, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 01/54] target/i386: Fix handling of VEX prefixes, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 21/54] i386: Add support for SPEC_CTRL MSR, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 23/54] i386: Add FEAT_8000_0008_EBX CPUID feature word, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 19/54] hw/pci-bridge: fix QEMU crash because of pcie-root-port, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 27/54] s390x: fix storage attributes migration for non-small guests, Michael Roth, 2018/02/06