From nobody Mon Feb 9 02:51:14 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 155175093185984.73499866407974; Mon, 4 Mar 2019 17:55:31 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48C0288304; Tue, 5 Mar 2019 01:55:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 194A16013F; Tue, 5 Mar 2019 01:55:30 +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 C51293FB11; Tue, 5 Mar 2019 01:55:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x251smET021370 for ; Mon, 4 Mar 2019 20:54:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA8061001DF8; Tue, 5 Mar 2019 01:54:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B41331001DC5 for ; Tue, 5 Mar 2019 01:54:46 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 B3663307E042 for ; Tue, 5 Mar 2019 01:54:45 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id a48so7419358qtb.4 for ; Mon, 04 Mar 2019 17:54:45 -0800 (PST) Received: from localhost.localdomain ([177.188.104.249]) by smtp.gmail.com with ESMTPSA id s76sm4810049qki.42.2019.03.04.17.54.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 17:54:44 -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=EyecPGFW8ifYsd+JpA6SUjm1eXELG3xTTmsl3Oc8+ns=; b=XVmpmBruVXiZZ2z/3zfHp5E9v747q+l/C4Dvy29MI+qpaElaRw/2NVZegHgXezDD/8 9JKoZFLdLkfxJeUMfaZDrBnhtY17a2MBMznhTBAitAL6qdVlIqw20po7G2CJ5SeN7/fV TPYJHdNklZA9d1ZQ3O/QmWxbARk6lTTOjes9JI2EuGLvZmrJ0s9zX6eGhlYmWy+U3QIZ 0hhkzjPN28SXP0TfNnOpT/jOgzLsmVoAl3dRrW9nEMOtZJm/XcsPHL7MGWApW9/b/b3c 2nu1UP/7Ix5pWmTuD/S5H/HhEhunBgvt0mJLbLHvFhU8gIPNgszOTg31B6t7TDdhEkmr 4sSQ== 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=EyecPGFW8ifYsd+JpA6SUjm1eXELG3xTTmsl3Oc8+ns=; b=mHBhi58857XauvEy3YpbrF3tuCoSYbel7NDf3JjkACdHP2uVGPZr9awZCYhJDLpRhX 1cbfwH+oibOxjE1InN3jyBOyyd1zTVmJMufDuq0tm+uabGAwNZ5vwiiSxN3y6ISBr+CX YwPYrC5/68YpAVEip9ho4hYUbTkUcWTwOj5X2ljmMkaaUMNP+r9VxvsqBoVdecHT4WdZ PufBfzCE5W8szGsD5kBiyKzCYZZSnAGCKFNJ8ARMQJwqmdsnAXY7bo28AojWQKRIP/oo ColTehuunNvCUzBDhQMmqEdTegztEGiWqecpZMFs664+npKMTsgH+JGAHVolABBoANK9 2UAA== X-Gm-Message-State: APjAAAUDnuFQ+HS21ywLDXNvrGoTVpp0A+H8pEmwvNQgs737qV7UnP5P 0FXwV7Dzy0OirC57OxIRzFRiW9DK X-Google-Smtp-Source: APXvYqzEISH7sVpxBFetXPASiVcWQ/NdQr6LPeVtGwEOCrIs3fAKnpABG0athzl9lFb2cxm33NiodQ== X-Received: by 2002:a0c:8807:: with SMTP id 7mr285639qvl.67.1551750884685; Mon, 04 Mar 2019 17:54:44 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 4 Mar 2019 22:54:30 -0300 Message-Id: <20190305015432.8537-5-jcfaracco@gmail.com> In-Reply-To: <20190305015432.8537-1-jcfaracco@gmail.com> References: <20190305015432.8537-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.42]); Tue, 05 Mar 2019 01:54:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 05 Mar 2019 01:54:45 +0000 (UTC) for IP:'209.85.160.193' DOMAIN:'mail-qt1-f193.google.com' HELO:'mail-qt1-f193.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.193 mail-qt1-f193.google.com 209.85.160.193 mail-qt1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/6] lxc: Introduce lxcNetworkGetParseData() for 'lxc.net.' entry. 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Mar 2019 01:55:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This commit moves old lxcNetworkGetParseData() to lxcNetworkGetParseDataLegacy() and create a new method for LXC version 3.X called lxcNetworkGetParseData(). This is same idea of method lxcNetworkGetParseDataLegacy(). In the future, it can be easy to remove or rebase, in case of deprecate 'lxc.network.foo' style. Signed-off-by: Julio Faracco --- src/lxc/lxc_native.c | 65 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 1ecbae0e31..22b74d10fb 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -603,6 +603,53 @@ lxcNetworkGetParseDataLegacy(lxcNetworkParseArray *net= works, return networks->data[index-1]; } =20 +static lxcNetworkParseDataPtr +lxcNetworkGetParseData(lxcNetworkParseArray *networks, + const char *name) +{ + size_t index, nnetworks =3D networks->nnetworks; + size_t i; + + sscanf(name, "lxc.net.%zu", &index); + + if (!nnetworks) { + if (VIR_ALLOC_N(networks->data, 1) < 0) + return NULL; + + if (VIR_ALLOC(networks->data[0]) < 0) + return NULL; + + networks->data[0]->index =3D index; + networks->nnetworks++; + + return networks->data[0]; + } + + for (i =3D 0; i < nnetworks; i++) { + if (networks->data[i]->index =3D=3D index) + return networks->data[i]; + } + + /* This is a new element in an existing array. */ + if (VIR_REALLOC_N(networks->data, nnetworks + 1) < 0) + return NULL; + + if (VIR_ALLOC(networks->data[nnetworks]) < 0) + return NULL; + + networks->nnetworks++; + + for (i =3D nnetworks; i > 0; i--) { + if (networks->data[i-1]->index < index) { + networks->data[i]->index =3D index; + return networks->data[i]; + } + memcpy(networks->data[i], networks->data[i-1], sizeof(lxcNetworkPa= rseData)); + } + + return NULL; +} + static int lxcNetworkParseDataIPs(const char *name, virConfValuePtr value, @@ -692,14 +739,25 @@ lxcNetworkParseDataSuffix(const char *entry, return 0; } =20 +static int +lxcNetworkParseDataEntryLegacy(const char *name, + virConfValuePtr value, + lxcNetworkParseData *parseData) +{ + const char *suffix =3D STRSKIP(name, "lxc.network."); + + return lxcNetworkParseDataSuffix(suffix, value, parseData); +} =20 static int lxcNetworkParseDataEntry(const char *name, virConfValuePtr value, lxcNetworkParseDataPtr parseData) { - const char *suffix =3D STRSKIP(name, "lxc.network."); + const char *suffix =3D STRSKIP(name, "lxc.net."); =20 + suffix =3D strchr(suffix, '.'); + suffix =3D STRSKIP(suffix, "."); return lxcNetworkParseDataSuffix(suffix, value, parseData); } =20 @@ -714,6 +772,11 @@ lxcNetworkWalkCallback(const char *name, virConfValueP= tr value, void *data) if (!(parseData =3D lxcNetworkGetParseDataLegacy(networks, name))) return -1; =20 + return lxcNetworkParseDataEntryLegacy(name, value, parseData); + } else if (STRPREFIX(name, "lxc.net.")) { + if (!(parseData =3D lxcNetworkGetParseData(networks, name))) + return -1; + return lxcNetworkParseDataEntry(name, value, parseData); } =20 --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list