|
@@ -690,6 +690,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
|
}
|
|
}
|
|
|
|
|
|
if (vhostfdname) {
|
|
if (vhostfdname) {
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
|
|
vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err);
|
|
if (vhostfd == -1) {
|
|
if (vhostfd == -1) {
|
|
if (tap->has_vhostforce && tap->vhostforce) {
|
|
if (tap->has_vhostforce && tap->vhostforce) {
|
|
@@ -699,7 +701,12 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- qemu_set_nonblock(vhostfd);
|
|
|
|
|
|
+ ret = qemu_try_set_nonblock(vhostfd);
|
|
|
|
+ if (ret < 0) {
|
|
|
|
+ error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
|
|
|
+ name, fd);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
vhostfd = open("/dev/vhost-net", O_RDWR);
|
|
vhostfd = open("/dev/vhost-net", O_RDWR);
|
|
if (vhostfd < 0) {
|
|
if (vhostfd < 0) {
|
|
@@ -767,6 +774,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
|
|
Error *err = NULL;
|
|
Error *err = NULL;
|
|
const char *vhostfdname;
|
|
const char *vhostfdname;
|
|
char ifname[128];
|
|
char ifname[128];
|
|
|
|
+ int ret = 0;
|
|
|
|
|
|
assert(netdev->type == NET_CLIENT_DRIVER_TAP);
|
|
assert(netdev->type == NET_CLIENT_DRIVER_TAP);
|
|
tap = &netdev->u.tap;
|
|
tap = &netdev->u.tap;
|
|
@@ -795,7 +803,12 @@ int net_init_tap(const Netdev *netdev, const char *name,
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- qemu_set_nonblock(fd);
|
|
|
|
|
|
+ ret = qemu_try_set_nonblock(fd);
|
|
|
|
+ if (ret < 0) {
|
|
|
|
+ error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
|
|
|
+ name, fd);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
|
|
vnet_hdr = tap_probe_vnet_hdr(fd);
|
|
vnet_hdr = tap_probe_vnet_hdr(fd);
|
|
|
|
|
|
@@ -810,7 +823,6 @@ int net_init_tap(const Netdev *netdev, const char *name,
|
|
char **fds;
|
|
char **fds;
|
|
char **vhost_fds;
|
|
char **vhost_fds;
|
|
int nfds = 0, nvhosts = 0;
|
|
int nfds = 0, nvhosts = 0;
|
|
- int ret = 0;
|
|
|
|
|
|
|
|
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
|
|
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
|
|
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
|
|
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
|
|
@@ -842,7 +854,12 @@ int net_init_tap(const Netdev *netdev, const char *name,
|
|
goto free_fail;
|
|
goto free_fail;
|
|
}
|
|
}
|
|
|
|
|
|
- qemu_set_nonblock(fd);
|
|
|
|
|
|
+ ret = qemu_try_set_nonblock(fd);
|
|
|
|
+ if (ret < 0) {
|
|
|
|
+ error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
|
|
|
|
+ name, fd);
|
|
|
|
+ goto free_fail;
|
|
|
|
+ }
|
|
|
|
|
|
if (i == 0) {
|
|
if (i == 0) {
|
|
vnet_hdr = tap_probe_vnet_hdr(fd);
|
|
vnet_hdr = tap_probe_vnet_hdr(fd);
|