qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 3/3] vhost: fail backend intialization if memslot


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH v4 3/3] vhost: fail backend intialization if memslots number is more than its supported limit
Date: Tue, 6 Oct 2015 10:37:29 +0200

Signed-off-by: Igor Mammedov <address@hidden>
---
v4:
  * check that used slots are less than limit of new backend
    (Michael S. Tsirkin)
---
 hw/virtio/vhost.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index a3b4f9e..f14a5c5 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -933,6 +933,12 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
         return -errno;
     }
 
+    if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) {
+        fprintf(stderr, "vhost backend memory slots limit is less"
+                " than current number of present memory slots\n");
+        close((uintptr_t)opaque);
+        return -1;
+    }
     QLIST_INSERT_HEAD(&vhost_devices, hdev, entry);
 
     r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_OWNER, NULL);
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]