aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-03-09 23:49:32 -0800
committerJohn Lo <loj@cisco.com>2017-03-16 14:00:12 +0000
commitf6dae05b8b5f4e17d1cf7e108bf8a6af3a2f9785 (patch)
tree97382313bdf0c6a2e33d15228d17f6dba8eadedc
parente9f929b52ddb741ec1e4cb2d92c6be1e798933a0 (diff)
vhost: wrong value return for VHOST_USER_VRING_GET_BASE
When the VM is migrated, the driver sends VHOST_USER_VRING_GET_BASE message to the device to get the vring offset. The device is supposed to shut down the vring, and return the current vring offset. What the code did was to shutdown the vring, initialize the vring, and return 0 to the driver. The fix is to first store last_avail_idx in the message and then close the vring. Change-Id: I432e9f50f36d89fe53a45e050edcf5e1218caf7a Signed-off-by: Steven <sluong@cisco.com>
-rw-r--r--src/vnet/devices/virtio/vhost-user.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 100ec613bc2..3cbeca9b3fc 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -583,7 +583,10 @@ vhost_user_vring_close (vhost_user_intf_t * vui, u32 qid)
vring->callfd_idx = ~0;
}
if (vring->errfd != -1)
- close (vring->errfd);
+ {
+ close (vring->errfd);
+ vring->errfd = -1;
+ }
vhost_user_vring_init (vui, qid);
}
@@ -1026,12 +1029,16 @@ vhost_user_socket_read (unix_file_t * uf)
goto close_socket;
}
- /* Spec says: Client must [...] stop ring upon receiving VHOST_USER_GET_VRING_BASE. */
- vhost_user_vring_close (vui, msg.state.index);
-
+ /*
+ * Copy last_avail_idx from the vring before closing it because
+ * closing the vring also initializes the vring last_avail_idx
+ */
msg.state.num = vui->vrings[msg.state.index].last_avail_idx;
msg.flags |= 4;
msg.size = sizeof (msg.state);
+
+ /* Spec says: Client must [...] stop ring upon receiving VHOST_USER_GET_VRING_BASE. */
+ vhost_user_vring_close (vui, msg.state.index);
break;
case VHOST_USER_NONE: