}
/* Set sane init value. Override when guest acks. */
-#ifdef CONFIG_VHOST_NET_USER
- if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
- features = vhost_user_get_acked_features(net->nc);
+ if (options->get_acked_features) {
+ features = options->get_acked_features(net->nc);
if (~net->dev.features & features) {
fprintf(stderr, "vhost lacks feature mask 0x%" PRIx64
" for backend\n",
goto fail;
}
}
-#endif
vhost_net_ack_features(net, features);
#ifndef VHOST_USER_H
#define VHOST_USER_H
-struct vhost_net;
-uint64_t vhost_user_get_acked_features(NetClientState *nc);
void vhost_user_save_acked_features(NetClientState *nc);
#endif /* VHOST_USER_H */
struct vhost_net;
typedef struct vhost_net VHostNetState;
+typedef uint64_t (GetAckedFeatures)(NetClientState *nc);
+
typedef struct VhostNetOptions {
VhostBackendType backend_type;
NetClientState *net_backend;
uint32_t busyloop_timeout;
unsigned int nvqs;
const int *feature_bits;
+ GetAckedFeatures *get_acked_features;
void *opaque;
} VhostNetOptions;
options.opaque = (void *)(uintptr_t)vhostfd;
options.nvqs = 2;
options.feature_bits = kernel_feature_bits;
+ options.get_acked_features = NULL;
s->vhost_net = vhost_net_init(&options);
if (!s->vhost_net) {
return s->vhost_net;
}
-uint64_t vhost_user_get_acked_features(NetClientState *nc)
+static uint64_t vhost_user_get_acked_features(NetClientState *nc)
{
NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
options.busyloop_timeout = 0;
options.nvqs = 2;
options.feature_bits = user_feature_bits;
+ options.get_acked_features = vhost_user_get_acked_features;
+
net = vhost_net_init(&options);
if (!net) {
error_report("failed to init vhost_net for queue %d", i);
options.busyloop_timeout = 0;
options.nvqs = nvqs;
options.feature_bits = vdpa_feature_bits;
+ options.get_acked_features = NULL;
net = vhost_net_init(&options);
if (!net) {