aboutsummaryrefslogtreecommitdiff
path: root/hw/net
diff options
context:
space:
mode:
authorNikolay Nikolaev <n.nikolaev@virtualopensystems.com>2014-05-27 15:05:22 +0300
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 16:41:56 +0300
commit81647a655fa4ff99fd5748363a174edd87a40950 (patch)
treee13e0fafe22ef7bcd48f9fdf2fbcc04b75ca9966 /hw/net
parented8b4afe5ff290ae119237e4fa2142e9f1832230 (diff)
vhost_net_init will use VhostNetOptions to get all its arguments
vhost_dev_init will replace devfd and devpath with a single opaque argument. This is initialised with a file descriptor. When TAP is used (through vhost_net), open /dev/vhost-net and pass the fd as an opaque parameter in VhostNetOptions. The same applies to vhost-scsi - open /dev/vhost-scsi and pass the fd. Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r--hw/net/vhost_net.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 0b45043a72..7a5523f36a 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -94,32 +94,34 @@ static int vhost_net_get_fd(NetClientState *backend)
}
}
-struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
- bool force)
+struct vhost_net *vhost_net_init(VhostNetOptions *options)
{
int r;
struct vhost_net *net = g_malloc(sizeof *net);
- if (!backend) {
- fprintf(stderr, "vhost-net requires backend to be setup\n");
+
+ if (!options->net_backend) {
+ fprintf(stderr, "vhost-net requires net backend to be setup\n");
goto fail;
}
- r = vhost_net_get_fd(backend);
+
+ r = vhost_net_get_fd(options->net_backend);
if (r < 0) {
goto fail;
}
- net->nc = backend;
- net->dev.backend_features = qemu_has_vnet_hdr(backend) ? 0 :
+ net->nc = options->net_backend;
+ net->dev.backend_features = qemu_has_vnet_hdr(options->net_backend) ? 0 :
(1 << VHOST_NET_F_VIRTIO_NET_HDR);
net->backend = r;
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
- r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force);
+ r = vhost_dev_init(&net->dev, options->opaque,
+ options->force);
if (r < 0) {
goto fail;
}
- if (!qemu_has_vnet_hdr_len(backend,
+ if (!qemu_has_vnet_hdr_len(options->net_backend,
sizeof(struct virtio_net_hdr_mrg_rxbuf))) {
net->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF);
}
@@ -311,8 +313,7 @@ VHostNetState *get_vhost_net(NetClientState *nc)
return vhost_net;
}
#else
-struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
- bool force)
+struct vhost_net *vhost_net_init(VhostNetOptions *options)
{
error_report("vhost-net support is not compiled in");
return NULL;