]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vhost: Add vhost_get_max_memslots()
authorDavid Hildenbrand <david@redhat.com>
Tue, 26 Sep 2023 18:57:31 +0000 (20:57 +0200)
committerDavid Hildenbrand <david@redhat.com>
Thu, 12 Oct 2023 12:15:22 +0000 (14:15 +0200)
Let's add vhost_get_max_memslots().

Message-ID: <20230926185738.277351-12-david@redhat.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
hw/virtio/vhost-stub.c
hw/virtio/vhost.c
include/hw/virtio/vhost.h

index d53dd9d288a45f119998c50cb7b57ac819027354..52d42adab2650e2d7a027496e4ec3fb990b42c32 100644 (file)
@@ -2,6 +2,11 @@
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-user.h"
 
+unsigned int vhost_get_max_memslots(void)
+{
+    return UINT_MAX;
+}
+
 unsigned int vhost_get_free_memslots(void)
 {
     return UINT_MAX;
index 041a05d5f14a20702667762ae603811a18920d4c..2bdb4fb23166b2d2c48f57ac56b93b6a48e8c954 100644 (file)
@@ -55,6 +55,17 @@ static unsigned int used_shared_memslots;
 static QLIST_HEAD(, vhost_dev) vhost_devices =
     QLIST_HEAD_INITIALIZER(vhost_devices);
 
+unsigned int vhost_get_max_memslots(void)
+{
+    unsigned int max = UINT_MAX;
+    struct vhost_dev *hdev;
+
+    QLIST_FOREACH(hdev, &vhost_devices, entry) {
+        max = MIN(max, hdev->vhost_ops->vhost_backend_memslots_limit(hdev));
+    }
+    return max;
+}
+
 unsigned int vhost_get_free_memslots(void)
 {
     unsigned int free = UINT_MAX;
index 603bf834be0cdfd15aad4cadedbea0b8599a4bf1..c7e5467693df2ac2d9ff5f7076a7618abdeaf83c 100644 (file)
@@ -315,6 +315,7 @@ uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits,
  */
 void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits,
                         uint64_t features);
+unsigned int vhost_get_max_memslots(void);
 unsigned int vhost_get_free_memslots(void);
 
 int vhost_net_set_backend(struct vhost_dev *hdev,