return -1;
}
- if (tap->fd) {
- if (tap->ifname || tap->script || tap->downscript ||
- tap->has_vnet_hdr || tap->helper || tap->has_queues ||
- tap->fds || tap->vhostfds) {
- error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, "
- "helper=, queues=, fds=, and vhostfds= "
- "are invalid with fd=");
- return -1;
- }
+ if (tap->has_queues + !!tap->helper + !!tap->fds + !!tap->fd > 1) {
+ error_setg(errp, "queues=, helper=, fds= and fd= are mutual exclusive");
+ return -1;
+ }
+ if ((tap->fd || tap->fds || tap->helper) &&
+ (tap->ifname || tap->script || tap->downscript ||
+ tap->has_vnet_hdr)) {
+ error_setg(errp, "ifname=, script=, downscript=, vnet_hdr= "
+ "are invalid with fd=/fds=/helper=");
+ return -1;
+ }
+
+ if (tap->vhostfds && !tap->fds) {
+ error_setg(errp, "vhostfds= is invalid if fds= wasn't specified");
+ return -1;
+ }
+
+ if (tap->vhostfd && tap->fds) {
+ error_setg(errp, "vhostfd= is invalid with fds=");
+ return -1;
+ }
+
+ if (tap->fd) {
fd = monitor_fd_param(monitor_cur(), tap->fd, errp);
if (fd == -1) {
return -1;
char **vhost_fds;
int nfds = 0, nvhosts = 0;
- if (tap->ifname || tap->script || tap->downscript ||
- tap->has_vnet_hdr || tap->helper || tap->has_queues ||
- tap->vhostfd) {
- error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, "
- "helper=, queues=, and vhostfd= "
- "are invalid with fds=");
- return -1;
- }
-
fds = g_new0(char *, MAX_TAP_QUEUES);
vhost_fds = g_new0(char *, MAX_TAP_QUEUES);
g_free(vhost_fds);
return ret;
} else if (tap->helper) {
- if (tap->ifname || tap->script || tap->downscript ||
- tap->has_vnet_hdr || tap->has_queues || tap->vhostfds) {
- error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, "
- "queues=, and vhostfds= are invalid with helper=");
- return -1;
- }
-
fd = net_bridge_run_helper(tap->helper,
tap->br ?: DEFAULT_BRIDGE_INTERFACE,
errp);
g_autofree char *downscript =
tap_parse_script(tap->downscript, DEFAULT_NETWORK_DOWN_SCRIPT);
- if (tap->vhostfds) {
- error_setg(errp, "vhostfds= is invalid if fds= wasn't specified");
- return -1;
- }
-
if (tap->ifname) {
pstrcpy(ifname, sizeof ifname, tap->ifname);
} else {