From: Jay Zhou <jianjay.zhou@huawei.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, imammedo@redhat.com, weidong.huang@huawei.com,
wangxinxin.wang@huawei.com, arei.gonglei@huawei.com,
liuzhe13@huawei.com, jianjay.zhou@huawei.com,
qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash
Date: Wed, 10 Jan 2018 00:39:35 +0800 [thread overview]
Message-ID: <1515515975-28968-1-git-send-email-jianjay.zhou@huawei.com> (raw)
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: qemu-stable@nongnu.org
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
---
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
next reply other threads:[~2018-01-09 16:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 16:39 Jay Zhou [this message]
2018-01-10 13:31 ` [Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash Igor Mammedov
2018-01-11 1:27 ` Zhoujian (jay)
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=1515515975-28968-1-git-send-email-jianjay.zhou@huawei.com \
--to=jianjay.zhou@huawei.com \
--cc=arei.gonglei@huawei.com \
--cc=imammedo@redhat.com \
--cc=liuzhe13@huawei.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
--cc=weidong.huang@huawei.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).