aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSi-Wei Liu <si-wei.liu@oracle.com>2024-02-14 03:27:53 -0800
committerMichael S. Tsirkin <mst@redhat.com>2024-03-12 17:56:55 -0400
commitc812b0655f8ccd1def48f14b89cec07e8fb68d83 (patch)
treef85fc3f8fc23b32f9fcc2c0b3076a43f17bbb36d /hw
parent573581b18dfd458ddac22f832bfb3f6fc9b585dc (diff)
vdpa: factor out vhost_vdpa_last_dev
Generalize duplicated condition check for the last vq of vdpa device to a common function. Message-Id: <1707910082-10243-4-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Eugenio PĂ©rez <eperezma@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/virtio/vhost-vdpa.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index ddae494ca8..8bd62e8dd2 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -555,6 +555,11 @@ static bool vhost_vdpa_first_dev(struct vhost_dev *dev)
return v->index == 0;
}
+static bool vhost_vdpa_last_dev(struct vhost_dev *dev)
+{
+ return dev->vq_index + dev->nvqs == dev->vq_index_end;
+}
+
static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
uint64_t *features)
{
@@ -1315,7 +1320,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
}
- if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+ if (!vhost_vdpa_last_dev(dev)) {
return 0;
}
@@ -1337,7 +1342,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev *dev)
{
struct vhost_vdpa *v = dev->opaque;
- if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+ if (!vhost_vdpa_last_dev(dev)) {
return;
}