From nobody Wed May 14 19:22:04 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522237248462581.8819469574161; Wed, 28 Mar 2018 04:40:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 056DE7F3EC; Wed, 28 Mar 2018 11:40:47 +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 C7BCE63146; Wed, 28 Mar 2018 11:40:46 +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 821AA180BAD3; Wed, 28 Mar 2018 11:40:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2SBeSuM021932 for ; Wed, 28 Mar 2018 07:40:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92BF8D7E0C; Wed, 28 Mar 2018 11:40:28 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.245.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 390A9946A2 for ; Wed, 28 Mar 2018 11:40:28 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 13:40:19 +0200 Message-Id: <20180328114021.15169-3-ptoscano@redhat.com> In-Reply-To: <20180328114021.15169-1-ptoscano@redhat.com> References: <20180328114021.15169-1-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] vmx: allocate space for network interfaces if needed 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Mar 2018 11:40:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Dynamically grow the array of network interfaces for each interface read, instead of using a single array of size 4. This way, in the future it will be easier to not limit the number of network interfaces (which this patch still does not change). Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index ba47a87b7..fd9b55950 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1751,19 +1751,16 @@ virVMXParseConfig(virVMXContext *ctx, } =20 /* def:nets */ - if (VIR_ALLOC_N(def->nets, 4) < 0) - goto cleanup; - - def->nnets =3D 0; - for (controller =3D 0; controller < 4; ++controller) { - if (virVMXParseEthernet(conf, controller, - &def->nets[def->nnets]) < 0) { + virDomainNetDefPtr net =3D NULL; + if (virVMXParseEthernet(conf, controller, &net) < 0) goto cleanup; - } =20 - if (def->nets[def->nnets] !=3D NULL) - ++def->nnets; + if (!net) + continue; + + if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) + goto cleanup; } =20 /* def:inputs */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list