@@ -261,6 +261,8 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev,
void virtio_vhost_init(struct kvm *kvm, int vhost_fd);
void virtio_vhost_set_vring(struct kvm *kvm, int vhost_fd, u32 index,
struct virt_queue *queue);
+void virtio_vhost_set_vring_kick(struct kvm *kvm, int vhost_fd,
+ u32 index, int event_fd);
int virtio_transport_parser(const struct option *opt, const char *arg, int unset);
@@ -701,18 +701,11 @@ static void notify_vq_gsi(struct kvm *kvm, void *dev, u32 vq, u32 gsi)
static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd)
{
struct net_dev *ndev = dev;
- struct vhost_vring_file file = {
- .index = vq,
- .fd = efd,
- };
- int r;
if (ndev->vhost_fd == 0 || is_ctrl_vq(ndev, vq))
return;
- r = ioctl(ndev->vhost_fd, VHOST_SET_VRING_KICK, &file);
- if (r < 0)
- die_perror("VHOST_SET_VRING_KICK failed");
+ virtio_vhost_set_vring_kick(kvm, ndev->vhost_fd, vq, efd);
}
static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
@@ -121,18 +121,11 @@ static void notify_vq_gsi(struct kvm *kvm, void *dev, u32 vq, u32 gsi)
static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd)
{
struct scsi_dev *sdev = dev;
- struct vhost_vring_file file = {
- .index = vq,
- .fd = efd,
- };
- int r;
if (sdev->vhost_fd == 0)
return;
- r = ioctl(sdev->vhost_fd, VHOST_SET_VRING_KICK, &file);
- if (r < 0)
- die_perror("VHOST_SET_VRING_KICK failed");
+ virtio_vhost_set_vring_kick(kvm, sdev->vhost_fd, vq, efd);
}
static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
@@ -65,3 +65,17 @@ void virtio_vhost_set_vring(struct kvm *kvm, int vhost_fd, u32 index,
if (r < 0)
die_perror("VHOST_SET_VRING_ADDR failed");
}
+
+void virtio_vhost_set_vring_kick(struct kvm *kvm, int vhost_fd,
+ u32 index, int event_fd)
+{
+ int r;
+ struct vhost_vring_file file = {
+ .index = index,
+ .fd = event_fd,
+ };
+
+ r = ioctl(vhost_fd, VHOST_SET_VRING_KICK, &file);
+ if (r < 0)
+ die_perror("VHOST_SET_VRING_KICK failed");
+}
@@ -80,21 +80,11 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq)
static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd)
{
struct vsock_dev *vdev = dev;
- struct vhost_vring_file file = {
- .index = vq,
- .fd = efd,
- };
- int r;
- if (is_event_vq(vq))
+ if (vdev->vhost_fd == -1 || is_event_vq(vq))
return;
- if (vdev->vhost_fd == -1)
- return;
-
- r = ioctl(vdev->vhost_fd, VHOST_SET_VRING_KICK, &file);
- if (r < 0)
- die_perror("VHOST_SET_VRING_KICK failed");
+ virtio_vhost_set_vring_kick(kvm, vdev->vhost_fd, vq, efd);
}
static void notify_status(struct kvm *kvm, void *dev, u32 status)