[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 33/34] vhost: fix memslot limit check
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 33/34] vhost: fix memslot limit check |
Date: |
Tue, 16 Jan 2018 19:53:08 +0200 |
From: Jay Zhou <address@hidden>
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.
Reviewed-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>
---
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 ff949d9..e9e56c0 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1332,13 +1332,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");
@@ -1420,6 +1413,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:
--
MST
- [Qemu-devel] [PULL v2 21/34] vhost: Build temporary section list and deref after commit, (continued)
- [Qemu-devel] [PULL v2 21/34] vhost: Build temporary section list and deref after commit, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 23/34] vhost: Merge sections added to temporary list, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 24/34] x86_iommu: Move machine check to x86_iommu_realize(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 25/34] x86_iommu: check if machine has PCI bus, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 26/34] tests: acpi: move tested tables array allocation outside of test_acpi_dsdt_table(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 28/34] tests: acpi: rename test_acpi_tables()/test_dst_table() to reflect its usage, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 27/34] tests: acpi: init table descriptor in test_dst_table(), Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 29/34] tests: acpi: add comments to fetch_rsdt_referenced_tables/data->tables usage, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 30/34] vhost-user: factor out msg head and payload, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 32/34] vhost: remove assertion to prevent crash, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 33/34] vhost: fix memslot limit check,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 31/34] vhost-user: fix misaligned access to payload, Michael S. Tsirkin, 2018/01/16
- [Qemu-devel] [PULL v2 34/34] vhost: used_memslots refactoring, Michael S. Tsirkin, 2018/01/16
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Peter Maydell, 2018/01/18
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2018/01/18
- Re: [Qemu-devel] [PULL v2 00/34] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2018/01/18