From: Igor Mammedov <imammedo@redhat.com>
To: Jay Zhou <jianjay.zhou@huawei.com>
Cc: qemu-devel@nongnu.org, weidong.huang@huawei.com, mst@redhat.com,
wangxinxin.wang@huawei.com, qemu-stable@nongnu.org,
arei.gonglei@huawei.com, liuzhe13@huawei.com
Subject: Re: [Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash
Date: Wed, 10 Jan 2018 14:31:18 +0100 [thread overview]
Message-ID: <20180110143118.39b47b16@redhat.com> (raw)
In-Reply-To: <1515515975-28968-1-git-send-email-jianjay.zhou@huawei.com>
On Wed, 10 Jan 2018 00:39:35 +0800
Jay Zhou <jianjay.zhou@huawei.com> wrote:
> 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.
I'd rewrite commit message as following:
--
QEMU will assert on vhsot-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: 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;
> }
> }
next prev parent reply other threads:[~2018-01-10 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 16:39 [Qemu-devel] [PATCH v5 1/4] vhost: remove assertion to prevent crash Jay Zhou
2018-01-10 13:31 ` Igor Mammedov [this message]
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=20180110143118.39b47b16@redhat.com \
--to=imammedo@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=jianjay.zhou@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.