From nobody Mon Feb 9 13:59:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532619794149902.8956100581588; Thu, 26 Jul 2018 08:43:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67779935A7 for ; Thu, 26 Jul 2018 15:43:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EBEE1108427C; Thu, 26 Jul 2018 15:36:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6B5AD18037FA; Thu, 26 Jul 2018 15:36:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QFaaC0008825 for ; Thu, 26 Jul 2018 11:36:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DCC62027EA0; Thu, 26 Jul 2018 15:36:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84ED92026D68; Thu, 26 Jul 2018 15:36:35 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 26 Jul 2018 17:36:28 +0200 Message-Id: <63c304e1211b7daf6836e0ed732213a3b8206b22.1532619290.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com Subject: [libvirt] [PATCH 2/3] lxc: Turn @veths into a string list in virLXCProcessStart X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 15:43:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This way it will be easier to use autofree. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/lxc/lxc_process.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index d021a890f7..3ac39d598c 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -514,8 +514,7 @@ static int virLXCProcessSetupNamespaces(virConnectPtr c= onn, * 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 @@ -525,7 +524,6 @@ static int virLXCProcessSetupNamespaces(virConnectPtr c= onn, */ static int virLXCProcessSetupInterfaces(virConnectPtr conn, virDomainDefPtr def, - size_t *nveths, char ***veths) { int ret =3D -1; @@ -534,6 +532,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, virDomainNetDefPtr net; virDomainNetType type; =20 + *veths =3D NULL; + for (i =3D 0; i < def->nnets; i++) { char *veth =3D NULL; virNetDevBandwidthPtr actualBandwidth; @@ -549,9 +549,6 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, if (virDomainNetAllocateActualDevice(def, net) < 0) goto cleanup; =20 - if (VIR_EXPAND_N(*veths, *nveths, 1) < 0) - goto cleanup; - type =3D virDomainNetGetActualType(net); switch (type) { case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -604,7 +601,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, } } =20 - (*veths)[(*nveths)-1] =3D veth; + if (virStringListAdd(veths, veth) < 0) + goto cleanup; =20 if (VIR_STRDUP(def->nets[i]->ifname_guest_actual, veth) < 0) goto cleanup; @@ -902,7 +900,6 @@ int virLXCProcessStop(virLXCDriverPtr driver, static virCommandPtr virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, virDomainObjPtr vm, - int nveths, char **veths, int *ttyFDs, size_t nttyFDs, @@ -987,7 +984,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, virCommandAddArg(cmd, "--handshake"); virCommandAddArgFormat(cmd, "%d", handshakefd); =20 - for (i =3D 0; i < nveths; i++) + for (i =3D 0; veths && veths[i]; i++) virCommandAddArgList(cmd, "--veth", veths[i], NULL); =20 virCommandPassFD(cmd, handshakefd, 0); @@ -1184,7 +1181,6 @@ int virLXCProcessStart(virConnectPtr conn, size_t i; char *logfile =3D NULL; int logfd =3D -1; - size_t nveths =3D 0; char **veths =3D NULL; int handshakefds[2] =3D { -1, -1 }; off_t pos =3D -1; @@ -1355,7 +1351,7 @@ int virLXCProcessStart(virConnectPtr conn, } =20 VIR_DEBUG("Setting up Interfaces"); - if (virLXCProcessSetupInterfaces(conn, vm->def, &nveths, &veths) < 0) + if (virLXCProcessSetupInterfaces(conn, vm->def, &veths) < 0) goto cleanup; =20 VIR_DEBUG("Setting up namespaces if any"); @@ -1379,7 +1375,7 @@ int virLXCProcessStart(virConnectPtr conn, =20 if (!(cmd =3D virLXCProcessBuildControllerCmd(driver, vm, - nveths, veths, + veths, ttyFDs, nttyFDs, nsInheritFDs, files, nfiles, @@ -1559,9 +1555,7 @@ int virLXCProcessStart(virConnectPtr conn, virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); } virCommandFree(cmd); - for (i =3D 0; i < nveths; i++) - VIR_FREE(veths[i]); - VIR_FREE(veths); + virStringListFree(veths); for (i =3D 0; i < nttyFDs; i++) VIR_FORCE_CLOSE(ttyFDs[i]); VIR_FREE(ttyFDs); --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list