const char *prefix,
char type_sep,
int vlan,
- int tapfd,
+ const char *tapfd,
char **str)
{
switch (net->type) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- if (virAsprintf(str, "%stap%cfd=%d,vlan=%d%s%s",
+ if (virAsprintf(str, "%stap%cfd=%s,vlan=%d%s%s",
prefix ? prefix : "",
type_sep, tapfd, vlan,
(net->hostnet_name ? ",name=" : ""),
for (i = 0 ; i < def->nnets ; i++) {
virDomainNetDefPtr net = def->nets[i];
char *nic, *host;
- int tapfd = -1;
+ char *tapfd_name = NULL;
net->vlan = i;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
- tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
+ int tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
if (tapfd < 0)
goto error;
}
(*tapfds)[(*ntapfds)++] = tapfd;
+
+ if (virAsprintf(&tapfd_name, "%d", tapfd) < 0)
+ goto no_memory;
}
if (qemuBuildHostNetStr(conn, net, NULL, ',',
- net->vlan, tapfd, &host) < 0)
+ net->vlan, tapfd_name, &host) < 0) {
+ VIR_FREE(tapfd_name);
goto error;
+ }
ADD_ARG_LIT("-net");
ADD_ARG(host);
+
+ VIR_FREE(tapfd_name);
}
}
net->vlan = vm->def->nets[i]->vlan;
if (qemuBuildHostNetStr(conn, net,
- "host_net_add ", ' ', net->vlan, -1, &cmd) < 0)
+ "host_net_add ", ' ', net->vlan, NULL, &cmd) < 0)
return -1;
remove_cmd = NULL;