From nobody Mon Feb 9 23:15:40 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 1551750987014251.06380288844252; Mon, 4 Mar 2019 17:56:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D75B59445; Tue, 5 Mar 2019 01:56:25 +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 579255D9D4; Tue, 5 Mar 2019 01:56:25 +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 135DB181A010; Tue, 5 Mar 2019 01:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x251sm5Q021364 for ; Mon, 4 Mar 2019 20:54:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 00046600D7; Tue, 5 Mar 2019 01:54:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE0E3600C2 for ; Tue, 5 Mar 2019 01:54:45 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 4022D81F10 for ; Tue, 5 Mar 2019 01:54:44 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id o6so7415238qtk.6 for ; Mon, 04 Mar 2019 17:54:44 -0800 (PST) Received: from localhost.localdomain ([177.188.104.249]) by smtp.gmail.com with ESMTPSA id s76sm4810049qki.42.2019.03.04.17.54.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 17:54:42 -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=lXqNn4VPmIpyupH8YTiJl1BpJMmWszcZharc68rqDjg=; b=uSk5A1ADIVu4xzqapjkd3ky0WlR3aFg2p003HUs4ZOhmdx+g2T/tv6BXZEwQSK3ROD qeVGHASmwbYTgrEZA6GlxrLQ0PyJT813TxBMjvvwTy92P+uB9lrVDbjfpgNBJfmtezEf YT3HpcNzosrV9IHHJznWfEe5glUPXyEBrQHJOiCCIK15DiUDmYYjD2j70F1D3/QMFp/2 fMklHjidzIdoAcry9oq51TEdK4wnQc2uAwX0j+8wVOeLhqCpFQnubtI6en/5NNdfKssU Nib3+OxZWSPx/0F9m1+S2eKm4TKFLZKw5RvVR3EB7b3t1r17c3EPr9vgtGU/TrpP0ugi xOJg== 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=lXqNn4VPmIpyupH8YTiJl1BpJMmWszcZharc68rqDjg=; b=PhsbeoBwiTRqnyz7BfjtEtnE7pd6geXk+zsOvS2OV9MvdSK3pQfZ8IhfrZeiPu8YJp 7WX+U+faBRplT2ALuAHvCXApzttyefSk47G1+IMs+8ZZldyxd5UFCXgWx3lHVqxXtgYe wQbT5jZLLGcahoHpYjsMmPp6/CZ2I+VpTc3CmZ/4a3tnlEWUn7ttsVSKujFI+2y83ZmX jZAd8OqferfUErUmXvlNssLeng7IIodmAKe+mEKxpD4sz+11Arl/4jUREIsWUDEj8LZk oXpKX6LJpN3rm5Br/ZUk8IG9ur7XmCWqsvzveP43jmIuB7eWPSBMhngvRq2XGDKC3SMb xZJA== X-Gm-Message-State: APjAAAXLYtdoZ1BSXb74LRIrsR3rjaIcnJYYS9O9gWMa5pjUahbR9mHi KQ1GkanMCiFtUt53WoMGsjCDHxYe X-Google-Smtp-Source: APXvYqxBwECaiHbnQdkUlwX+rUlhgwKmHpV4wPGtZ+yp4r0gdWQ8kO3Ycbf5djrmatFaBtzaRyiVSQ== X-Received: by 2002:a0c:d4ab:: with SMTP id u40mr318305qvh.30.1551750883165; Mon, 04 Mar 2019 17:54:43 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 4 Mar 2019 22:54:29 -0300 Message-Id: <20190305015432.8537-4-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.25]); Tue, 05 Mar 2019 01:54:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Mar 2019 01:54:44 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.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.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/6] lxc: Introduce lxcNetworkGetParseDataLegacy() method. 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Mar 2019 01:56:25 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This function was introduced to fetch/alloc new data for legacy entries inside config file: 'lxc.network.foo'. Libvirt still need to support both versions. So, this function can be easy to remove in the future. Signed-off-by: Julio Faracco --- src/lxc/lxc_native.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index a6afbbe865..1ecbae0e31 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -572,6 +572,37 @@ lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetwor= kParseDataPtr data) return -1; } =20 +static lxcNetworkParseDataPtr +lxcNetworkGetParseDataLegacy(lxcNetworkParseArray *networks, + const char *name) +{ + const char *suffix =3D STRSKIP(name, "lxc.network."); + int elem =3D virLXCNetworkConfigEntryTypeFromString(suffix); + size_t index =3D networks->nnetworks; + + if (elem =3D=3D VIR_LXC_NETWORK_CONFIG_TYPE) { + if (!networks->data) { + if (VIR_ALLOC_N(networks->data, index + 1) < 0) + return NULL; + } else { + if (VIR_REALLOC_N(networks->data, index + 1) < 0) + return NULL; + } + + if (VIR_ALLOC(networks->data[index]) < 0) + return NULL; + + networks->data[index]->index =3D index; + networks->nnetworks++; + + /* Return a new network. */ + return networks->data[index]; + } + + /* Return the last network. */ + return networks->data[index-1]; +} + static int lxcNetworkParseDataIPs(const char *name, virConfValuePtr value, @@ -679,8 +710,12 @@ lxcNetworkWalkCallback(const char *name, virConfValueP= tr value, void *data) lxcNetworkParseArray *networks =3D data; lxcNetworkParseDataPtr parseData =3D NULL; =20 - if (STRPREFIX(name, "lxc.network.")) + if (STRPREFIX(name, "lxc.network.")) { + if (!(parseData =3D lxcNetworkGetParseDataLegacy(networks, name))) + return -1; + return lxcNetworkParseDataEntry(name, value, parseData); + } =20 return 0; } --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list