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
Subject: [Qemu-devel] [PATCH v5 3/4] vhost: fix memslot limit check
Date: Wed, 10 Jan 2018 00:40:12 +0800 [thread overview]
Message-ID: <1515516013-16604-2-git-send-email-jianjay.zhou@huawei.com> (raw)
In-Reply-To: <1515516013-16604-1-git-send-email-jianjay.zhou@huawei.com>
Since used_memslots will be updated to the actual value after
registering memory listener for the first time, move the
memslots limit checking to the right place.
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
---
hw/virtio/vhost.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e4290ce..69b3599 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1251,13 +1251,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
goto fail;
}
- if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) {
- error_report("vhost backend memory slots limit is less"
- " than current number of present memory slots");
- r = -1;
- goto fail;
- }
-
r = hdev->vhost_ops->vhost_set_owner(hdev);
if (r < 0) {
VHOST_OPS_DEBUG("vhost_set_owner failed");
@@ -1339,6 +1332,18 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
hdev->memory_changed = false;
memory_listener_register(&hdev->memory_listener, &address_space_memory);
QLIST_INSERT_HEAD(&vhost_devices, hdev, entry);
+
+ if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) {
+ error_report("vhost backend memory slots limit is less"
+ " than current number of present memory slots");
+ r = -1;
+ if (busyloop_timeout) {
+ goto fail_busyloop;
+ } else {
+ goto fail;
+ }
+ }
+
return 0;
fail_busyloop:
--
1.8.3.1
next prev parent reply other threads:[~2018-01-09 16:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 16:40 [Qemu-devel] [PATCH v5 2/4][RFC] tap: do not close fd if only vhost failed to initialize Jay Zhou
2018-01-09 16:40 ` Jay Zhou [this message]
2018-01-10 13:16 ` [Qemu-devel] [PATCH v5 3/4] vhost: fix memslot limit check Igor Mammedov
2018-01-09 16:40 ` [Qemu-devel] [PATCH v5 4/4] vhost: used_memslots refactoring Jay Zhou
2018-01-10 4:18 ` [Qemu-devel] [PATCH v5 2/4][RFC] tap: do not close fd if only vhost failed to initialize Zhoujian (jay)
2018-01-10 6:01 ` Jason Wang
2018-01-10 7:39 ` Zhoujian (jay)
2018-01-11 3:34 ` Jason Wang
2018-01-11 3:54 ` Zhoujian (jay)
2018-01-11 10:30 ` Jason Wang
2018-01-11 12:31 ` 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=1515516013-16604-2-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=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).