From nobody Mon Feb 9 04:03:44 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155051698652260.03343186344364; Mon, 18 Feb 2019 11:09:46 -0800 (PST) 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 85F8AB0831; Mon, 18 Feb 2019 19:09:44 +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 599A11001F5B; Mon, 18 Feb 2019 19:09:44 +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 0FA46181A010; Mon, 18 Feb 2019 19:09:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1IJ9UFG019060 for ; Mon, 18 Feb 2019 14:09:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 460CA19C66; Mon, 18 Feb 2019 19:09:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CCC419C57 for ; Mon, 18 Feb 2019 19:09:26 +0000 (UTC) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BA8178EBD for ; Mon, 18 Feb 2019 19:09:25 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id j36so20390300qta.7 for ; Mon, 18 Feb 2019 11:09:25 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OYq9yalLfQjEH27I7/bYGD6fg1q6Fy9VV68OA05+aWo=; b=aS19fsjbtYjVc7Jyu1wzNitJrY9Bnvekru14Fsvkkbq8uNzHql8e9xmcEBgA2J86Yu 9ASFlNnzvW9m7e161w0cX3LI4Y6oFOkIYb1LkdsDpFf/tfb+wfiK6iGNhtkuPeXSVstD Jm+IZ/KBKWca5F3xgOLzN+/MpgC5h4U//mg5aNYH8HUbcX7HIOUdsc5KOMppvHol83sa d1OeruJ4Yn7+lQ3TNkr11R0nyaWhe4fZlyrpmMnGi12BEN0nYKT28GP4PPQuLYxVeLCO cKwBUyEjl059s9pp7MLrBk1iZCDwQvnrQ+RZWwtPTwTm0EwmQJotmRXhWq1GK1qVykLx t2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OYq9yalLfQjEH27I7/bYGD6fg1q6Fy9VV68OA05+aWo=; b=fiAxYsgvF0jXqtZbriIy/jHLvFRkYFuByL9YP8wMFNLX2og8RgB6yod6yFL1/Znxea jtABjsOcJFPdaUSoRxoN1i3GS/sZKo0ibjz+Hz7LoA5L/SDtrRY5DPvdI/idkpkf46aZ cAOjnju0TWNlFUwr6Jr1IH+jPVtuoz+KVuW3NG0gKv/dpp+u0m/VVxFSOUawySfsblRi CDY4sWHj25isBVFbYitcoGKesXeaFbBctAKu945cEO5QQOam850td+NFKLHEoNPgbCym KWxquGymETzWryrOwpPj6Zc+UJkuxynydIAllqKQgbvot4LPp7YS1sNHqOdElUfxbQUK As+g== X-Gm-Message-State: AHQUAuY+MWHoC0Nm4ZoQxALTb7SCmU3m1JhjmERjqGPMZ//S74naQVA4 488/eT2dXy4zmaHOhDJQMvPIlkIX X-Google-Smtp-Source: AHgI3Ibrw0R8KCKQNVg7cQU2G1qS1Nyk+31IthuXqY1FJU+brhMx9lVRRjlSz66Q6Tpa3H3TZhy6Dg== X-Received: by 2002:ac8:6895:: with SMTP id m21mr19164405qtq.147.1550516964348; Mon, 18 Feb 2019 11:09:24 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:09 -0300 Message-Id: <20190218190910.22477-6-jcfaracco@gmail.com> In-Reply-To: <20190218190910.22477-1-jcfaracco@gmail.com> References: <20190218190910.22477-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Feb 2019 19:09:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Feb 2019 19:09:25 +0000 (UTC) for IP:'209.85.160.178' DOMAIN:'mail-qt1-f178.google.com' HELO:'mail-qt1-f178.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.160.178 mail-qt1-f178.google.com 209.85.160.178 mail-qt1-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] lxc: Create a method to initialize network data outisde. 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: , 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.39]); Mon, 18 Feb 2019 19:09:45 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method has the same idea of the method to parse IPv{4,6} data. The method lxcNetworkParseDataInit() is responsible to initialize network settings outside handler. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 56 +++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 95e08c18f4..25e35e93dd 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -552,6 +552,37 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data) return -1; } =20 +static int +lxcNetworkParseDataInit(virConfValuePtr value, lxcNetworkParseData *parseD= ata) +{ + virDomainDefPtr def =3D parseData->def; + size_t networks =3D parseData->networks; + bool privnet =3D parseData->privnet; + int status; + + /* Store the previous NIC */ + status =3D lxcAddNetworkDefinition(parseData); + + if (status < 0) + return -1; + else if (status > 0) + networks++; + else if (parseData->type !=3D NULL && STREQ(parseData->type, "none")) + privnet =3D false; + + /* clean NIC to store a new one */ + memset(parseData, 0, sizeof(*parseData)); + + parseData->def =3D def; + parseData->networks =3D networks; + parseData->privnet =3D privnet; + + /* Keep the new value */ + parseData->type =3D value->str; + + return 0; +} + static int lxcNetworkParseDataIPs(const char *name, virConfValuePtr value, lxcNetwork= ParseData *parseData) { @@ -591,32 +622,9 @@ lxcNetworkParseDataIPs(const char *name, virConfValueP= tr value, lxcNetworkParseD static int lxcNetworkParseDataSuffix(const char *name, virConfValuePtr value, lxcNetw= orkParseData *parseData) { - int status; - if (STREQ(name, "type")) { - virDomainDefPtr def =3D parseData->def; - size_t networks =3D parseData->networks; - bool privnet =3D parseData->privnet; - - /* Store the previous NIC */ - status =3D lxcAddNetworkDefinition(parseData); - - if (status < 0) + if (lxcNetworkParseDataInit(value, parseData) < 0) return -1; - else if (status > 0) - networks++; - else if (parseData->type !=3D NULL && STREQ(parseData->type, "none= ")) - privnet =3D false; - - /* clean NIC to store a new one */ - memset(parseData, 0, sizeof(*parseData)); - - parseData->def =3D def; - parseData->networks =3D networks; - parseData->privnet =3D privnet; - - /* Keep the new value */ - parseData->type =3D value->str; } else if (STREQ(name, "link")) parseData->link =3D value->str; --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list