+ struct vhost_vring_addr addr = { 0 };
+ struct vhost_vring_state state = { 0 };
+ struct vhost_vring_file file = { 0 };
+ virtio_vring_t *vring;
+ u16 qp = i >> 1;
+ int fd = vif->vhost_fds[qp];
+
+ if (i & 1)
+ {
+ if (qp >= vif->num_txqs)
+ continue;
+ vring = vec_elt_at_index (vif->txq_vrings, qp);
+ }
+ else
+ {
+ if (qp >= vif->num_rxqs)
+ continue;
+ vring = vec_elt_at_index (vif->rxq_vrings, qp);
+ }
+
+ addr.index = state.index = file.index = vring->queue_id & 1;
+ state.num = vring->size;
+ virtio_log_debug (vif, "VHOST_SET_VRING_NUM fd %d index %u num %u", fd,
+ state.index, state.num);
+ _IOCTL (fd, VHOST_SET_VRING_NUM, &state);
+
+ addr.flags = 0;
+ addr.desc_user_addr = pointer_to_uword (vring->desc);
+ addr.avail_user_addr = pointer_to_uword (vring->avail);
+ addr.used_user_addr = pointer_to_uword (vring->used);
+
+ virtio_log_debug (vif, "VHOST_SET_VRING_ADDR fd %d index %u flags 0x%x "
+ "desc_user_addr 0x%lx avail_user_addr 0x%lx "
+ "used_user_addr 0x%lx", fd, addr.index,
+ addr.flags, addr.desc_user_addr, addr.avail_user_addr,
+ addr.used_user_addr);
+ _IOCTL (fd, VHOST_SET_VRING_ADDR, &addr);
+
+ file.fd = vring->call_fd;
+ virtio_log_debug (vif, "VHOST_SET_VRING_CALL fd %d index %u call_fd %d",
+ fd, file.index, file.fd);
+ _IOCTL (fd, VHOST_SET_VRING_CALL, &file);
+
+ file.fd = vring->kick_fd;
+ virtio_log_debug (vif, "VHOST_SET_VRING_KICK fd %d index %u kick_fd %d",
+ fd, file.index, file.fd);
+ _IOCTL (fd, VHOST_SET_VRING_KICK, &file);
+
+ file.fd = tfd;
+ virtio_log_debug (vif, "VHOST_NET_SET_BACKEND fd %d index %u tap_fd %d",
+ fd, file.index, file.fd);
+ _IOCTL (fd, VHOST_NET_SET_BACKEND, &file);