diff mbox

[RESEND,v1,19/37] vhost-pci-slave/msg: VHOST_USER_SET_VRING_ADDR

Message ID 1482127152-84732-20-git-send-email-wei.w.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Wei W Dec. 19, 2016, 5:58 a.m. UTC
Update the virtqueue addresses to the head node of the list.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
 hw/virtio/vhost-pci-slave.c         | 10 ++++++++++
 include/hw/virtio/vhost-pci-slave.h |  3 +++
 2 files changed, 13 insertions(+)
diff mbox

Patch

diff --git a/hw/virtio/vhost-pci-slave.c b/hw/virtio/vhost-pci-slave.c
index a74b16c..5ddcb8f 100644
--- a/hw/virtio/vhost-pci-slave.c
+++ b/hw/virtio/vhost-pci-slave.c
@@ -223,6 +223,13 @@  static void vp_slave_set_vring_base(VhostUserMsg *msg)
     pvq_node->last_avail_idx = msg->payload.u64;
 }
 
+static void vp_slave_set_vring_addr(VhostUserMsg *msg)
+{
+    PeerVqNode *pvq_node = QLIST_FIRST(&vp_slave->pvq_list);
+    memcpy(&pvq_node->addr, &msg->payload.addr,
+           sizeof(struct vhost_vring_addr));
+}
+
 static int vp_slave_can_read(void *opaque)
 {
     return VHOST_USER_HDR_SIZE;
@@ -296,6 +303,9 @@  static void vp_slave_read(void *opaque, const uint8_t *buf, int size)
     case VHOST_USER_SET_VRING_BASE:
         vp_slave_set_vring_base(&msg);
         break;
+    case VHOST_USER_SET_VRING_ADDR:
+        vp_slave_set_vring_addr(&msg);
+        break;
     default:
         error_report("vhost-pci-slave does not support msg request = %d",
                      msg.request);
diff --git a/include/hw/virtio/vhost-pci-slave.h b/include/hw/virtio/vhost-pci-slave.h
index cfe4107..439198d 100644
--- a/include/hw/virtio/vhost-pci-slave.h
+++ b/include/hw/virtio/vhost-pci-slave.h
@@ -1,6 +1,8 @@ 
 #ifndef QEMU_VHOST_PCI_SLAVE_H
 #define QEMU_VHOST_PCI_SLAVE_H
 
+#include <linux/vhost.h>
+
 #include "sysemu/char.h"
 #include "exec/memory.h"
 #include "standard-headers/linux/vhost_pci_net.h"
@@ -8,6 +10,7 @@ 
 typedef struct PeerVqNode {
     uint16_t last_avail_idx;
     uint32_t vring_num;
+    struct vhost_vring_addr addr;
     QLIST_ENTRY(PeerVqNode) node;
 } PeerVqNode;