aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/vhost-user.c27
-rw-r--r--net/vhost-vdpa.c32
2 files changed, 35 insertions, 24 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 3a6b90d..5993e4a 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -45,10 +45,23 @@ uint64_t vhost_user_get_acked_features(NetClientState *nc)
return s->acked_features;
}
-static void vhost_user_stop(int queues, NetClientState *ncs[])
+void vhost_user_save_acked_features(NetClientState *nc)
{
NetVhostUserState *s;
+
+ s = DO_UPCAST(NetVhostUserState, nc, nc);
+ if (s->vhost_net) {
+ uint64_t features = vhost_net_get_acked_features(s->vhost_net);
+ if (features) {
+ s->acked_features = features;
+ }
+ }
+}
+
+static void vhost_user_stop(int queues, NetClientState *ncs[])
+{
int i;
+ NetVhostUserState *s;
for (i = 0; i < queues; i++) {
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
@@ -56,11 +69,7 @@ static void vhost_user_stop(int queues, NetClientState *ncs[])
s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
if (s->vhost_net) {
- /* save acked features */
- uint64_t features = vhost_net_get_acked_features(s->vhost_net);
- if (features) {
- s->acked_features = features;
- }
+ vhost_user_save_acked_features(ncs[i]);
vhost_net_cleanup(s->vhost_net);
}
}
@@ -251,11 +260,7 @@ static void chr_closed_bh(void *opaque)
s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
for (i = queues -1; i >= 0; i--) {
- s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
-
- if (s->vhost_net) {
- s->acked_features = vhost_net_get_acked_features(s->vhost_net);
- }
+ vhost_user_save_acked_features(ncs[i]);
}
qmp_set_link(name, false, &err);
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index d36664f..1a13a34 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -74,7 +74,6 @@ const int vdpa_feature_bits[] = {
VIRTIO_F_RING_RESET,
VIRTIO_NET_F_RSS,
VIRTIO_NET_F_HASH_REPORT,
- VIRTIO_NET_F_GUEST_ANNOUNCE,
VIRTIO_NET_F_STATUS,
VHOST_INVALID_FEATURE_BIT
};
@@ -616,9 +615,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
s->cvq_cmd_out_buffer,
vhost_vdpa_net_cvq_cmd_len());
- dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
- if (unlikely(dev_written < 0)) {
- goto out;
+ if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) {
+ /*
+ * Guest announce capability is emulated by qemu, so don't forward to
+ * the device.
+ */
+ dev_written = sizeof(status);
+ *s->status = VIRTIO_NET_OK;
+ } else {
+ dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
+ if (unlikely(dev_written < 0)) {
+ goto out;
+ }
}
if (unlikely(dev_written < sizeof(status))) {
@@ -702,14 +710,6 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
return nc;
}
-static int vhost_vdpa_get_iova_range(int fd,
- struct vhost_vdpa_iova_range *iova_range)
-{
- int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
-
- return ret < 0 ? -errno : 0;
-}
-
static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **errp)
{
int ret = ioctl(fd, VHOST_GET_FEATURES, features);
@@ -805,7 +805,13 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
return queue_pairs;
}
- vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
+ r = vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
+ if (unlikely(r < 0)) {
+ error_setg(errp, "vhost-vdpa: get iova range failed: %s",
+ strerror(-r));
+ goto err;
+ }
+
if (opts->x_svq) {
if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
goto err_svq;