aboutsummaryrefslogtreecommitdiff
path: root/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 /net
parented8b4afe5ff290ae119237e4fa2142e9f1832230 (diff)
downloadqemu-81647a655fa4ff99fd5748363a174edd87a40950.zip
qemu-81647a655fa4ff99fd5748363a174edd87a40950.tar.gz
qemu-81647a655fa4ff99fd5748363a174edd87a40950.tar.bz2
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 'net')
-rw-r--r--net/tap.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/net/tap.c b/net/tap.c
index fc1b865..5789ff8 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -594,6 +594,7 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
int vnet_hdr, int fd)
{
TAPState *s;
+ int vhostfd;
s = net_tap_fd_init(peer, model, name, fd, vnet_hdr);
if (!s) {
@@ -624,7 +625,10 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
if (tap->has_vhost ? tap->vhost :
vhostfdname || (tap->has_vhostforce && tap->vhostforce)) {
- int vhostfd;
+ VhostNetOptions options;
+
+ options.net_backend = &s->nc;
+ options.force = tap->has_vhostforce && tap->vhostforce;
if (tap->has_vhostfd || tap->has_vhostfds) {
vhostfd = monitor_handle_fd_param(cur_mon, vhostfdname);
@@ -632,11 +636,16 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
return -1;
}
} else {
- vhostfd = -1;
+ vhostfd = open("/dev/vhost-net", O_RDWR);
+ if (vhostfd < 0) {
+ error_report("tap: open vhost char device failed: %s",
+ strerror(errno));
+ return -1;
+ }
}
+ options.opaque = (void *)(uintptr_t)vhostfd;
- s->vhost_net = vhost_net_init(&s->nc, vhostfd,
- tap->has_vhostforce && tap->vhostforce);
+ s->vhost_net = vhost_net_init(&options);
if (!s->vhost_net) {
error_report("vhost-net requested but could not be initialized");
return -1;