* virLXCProcessSetupInterfaces:
* @conn: pointer to connection
* @def: pointer to virtual machine structure
- * @nveths: number of interfaces
- * @veths: interface names
+ * @veths: string list of interface names
*
* Sets up the container interfaces by creating the veth device pairs and
* attaching the parent end to the appropriate bridge. The container end
*/
static int virLXCProcessSetupInterfaces(virConnectPtr conn,
virDomainDefPtr def,
- size_t *nveths,
char ***veths)
{
int ret = -1;
virDomainNetDefPtr net;
virDomainNetType type;
+ if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0)
+ return -1;
+
for (i = 0; i < def->nnets; i++) {
char *veth = NULL;
virNetDevBandwidthPtr actualBandwidth;
if (virDomainNetAllocateActualDevice(def, net) < 0)
goto cleanup;
- if (VIR_EXPAND_N(*veths, *nveths, 1) < 0)
- goto cleanup;
-
type = virDomainNetGetActualType(net);
switch (type) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
}
}
- (*veths)[(*nveths)-1] = veth;
+ (*veths)[i] = veth;
if (VIR_STRDUP(def->nets[i]->ifname_guest_actual, veth) < 0)
goto cleanup;
static virCommandPtr
virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
virDomainObjPtr vm,
- int nveths,
char **veths,
int *ttyFDs,
size_t nttyFDs,
virCommandAddArg(cmd, "--handshake");
virCommandAddArgFormat(cmd, "%d", handshakefd);
- for (i = 0; i < nveths; i++)
+ for (i = 0; veths && veths[i]; i++)
virCommandAddArgList(cmd, "--veth", veths[i], NULL);
virCommandPassFD(cmd, handshakefd, 0);
size_t i;
char *logfile = NULL;
int logfd = -1;
- size_t nveths = 0;
char **veths = NULL;
int handshakefds[2] = { -1, -1 };
off_t pos = -1;
}
VIR_DEBUG("Setting up Interfaces");
- if (virLXCProcessSetupInterfaces(conn, vm->def, &nveths, &veths) < 0)
+ if (virLXCProcessSetupInterfaces(conn, vm->def, &veths) < 0)
goto cleanup;
VIR_DEBUG("Setting up namespaces if any");
if (!(cmd = virLXCProcessBuildControllerCmd(driver,
vm,
- nveths, veths,
+ veths,
ttyFDs, nttyFDs,
nsInheritFDs,
files, nfiles,
virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
}
virCommandFree(cmd);
- for (i = 0; i < nveths; i++)
- VIR_FREE(veths[i]);
- VIR_FREE(veths);
+ virStringListFree(veths);
for (i = 0; i < nttyFDs; i++)
VIR_FORCE_CLOSE(ttyFDs[i]);
VIR_FREE(ttyFDs);