From nobody Wed May 1 13:48:58 2024 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 1550516974257429.76546691037436; Mon, 18 Feb 2019 11:09:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F26036EBA2; Mon, 18 Feb 2019 19:09:31 +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 B3FF65D71C; Mon, 18 Feb 2019 19:09:31 +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 64BCC181A00B; Mon, 18 Feb 2019 19:09:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1IJ9TX5019055 for ; Mon, 18 Feb 2019 14:09:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id DF267579BB; Mon, 18 Feb 2019 19:09:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D71ED60C1D for ; Mon, 18 Feb 2019 19:09:20 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 53C64C05784A for ; Mon, 18 Feb 2019 19:09:19 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id p15so10604766qkl.5 for ; Mon, 18 Feb 2019 11:09:19 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:17 -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=G7+7KTrLqvvcDrvOkm4AdXLj9JFhcYU1rmb3A5kbtqU=; b=uYD11ut3iKOXDMZan5yr/ecwQmx8YCP0pteV0Jljsm/E9amC+zHpvZto8OFASlvby9 EHmvKfgODMhKaK7XqdR6Jb8raOQ8XL97btQFxeBtqtSPvqyKbsGfX5HAcSQXKyIx2CTq M0p1/LGB+4hB87jp66QH1OU6v6KmIdg291LE3hS09eOzsmSkvE2FAGuLoiglv9Mm8gcl wnksiyfwWawY8GWkn6UflB/XD+XvkWPcvXXwJJj6SZKuXBCidEEGvg8Heb7Gb2HX8obG LMeaDbSNIuFbsipFf5ZXD8n9P1PGSkVxzXFzTkTXHxQzhSaWu1EuwfUO82gG5LGaHJ1L IF6g== 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=G7+7KTrLqvvcDrvOkm4AdXLj9JFhcYU1rmb3A5kbtqU=; b=n8OFlHXR3LMMJ7mi8j75jWfy3ao3SWXvl9xvMAuQnRyGOodVru/NqU4hUMVo9SKGZQ vScnYt7rsP2IYOFUxUYZgqCuDMKeqt2haKof9dgHeoRPliX8gUu53tAnL/jXQEO0R85U 57vu7jiaaL5hbm3ubw8QiSg3U8aZEK2GcMi0OujSEH+2AyxfXefFkcZ0124jHdOPPD7C BT3RgMiPTEwnZLHkkDCk79NZ+ChakyCJMZg7/sWNriVDhc/y2SrbPHPcR+a+uD/Ov260 gCISMzTZyoZ8N+y2Of8gJ0H8EAlU/sqERRtLSnQTySRpjTpl60xwe/Uc3NmhjiWZBz6R Oowg== X-Gm-Message-State: AHQUAub0IXTuBuLaoFOFcFS7Bz5EkjQTotYczGc8go09+OLcVhbe1dnQ OCF/pVYRLFvzHHfZmBHZJXeqyzcX X-Google-Smtp-Source: AHgI3IaUobKzE9d5XpkH/yvVMVs+h6IXarDbBOMQenebyG9nPq3SNlsu/UxUbAv3LI2BF9O+b4P75Q== X-Received: by 2002:a37:cfdd:: with SMTP id v90mr14411726qkl.193.1550516958307; Mon, 18 Feb 2019 11:09:18 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:05 -0300 Message-Id: <20190218190910.22477-2-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.31]); Mon, 18 Feb 2019 19:09:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 19:09:19 +0000 (UTC) for IP:'209.85.222.177' DOMAIN:'mail-qk1-f177.google.com' HELO:'mail-qk1-f177.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.177 mail-qk1-f177.google.com 209.85.222.177 mail-qk1-f177.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] lxc: Create a separate method to handle IPv{4, 6} outside parser. 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 19:09:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The new method called lxcNetworkParseDataIPs() is responsible to handle IPv{4,6} settings now. The idea is let lxcNetworkWalkCallback() method handle all entries related to network definition only. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 65 +++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 1eee3fc2bb..5bbbbf132c 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -552,6 +552,42 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data) return -1; } =20 +static int +lxcNetworkParseDataIPs(const char *name, virConfValuePtr value, lxcNetwork= ParseData *parseData) +{ + int family =3D AF_INET; + char **ipparts =3D NULL; + virNetDevIPAddrPtr ip =3D NULL; + + if (VIR_ALLOC(ip) < 0) + return -1; + + if (STREQ(name, "lxc.network.ipv6")) + family =3D AF_INET6; + + ipparts =3D virStringSplit(value->str, "/", 2); + if (virStringListLength((const char * const *)ipparts) !=3D 2 || + virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || + virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { + + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid CIDR address: '%s'"), value->str); + + virStringListFree(ipparts); + VIR_FREE(ip); + return -1; + } + + virStringListFree(ipparts); + + if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) { + VIR_FREE(ip); + return -1; + } + + return 0; +} + static int lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data) { @@ -597,35 +633,8 @@ lxcNetworkWalkCallback(const char *name, virConfValueP= tr value, void *data) parseData->name =3D value->str; else if (STREQ(name, "lxc.network.ipv4") || STREQ(name, "lxc.network.ipv6")) { - int family =3D AF_INET; - char **ipparts =3D NULL; - virNetDevIPAddrPtr ip =3D NULL; - - if (VIR_ALLOC(ip) < 0) + if (lxcNetworkParseDataIPs(name, value, parseData) < 0) return -1; - - if (STREQ(name, "lxc.network.ipv6")) - family =3D AF_INET6; - - ipparts =3D virStringSplit(value->str, "/", 2); - if (virStringListLength((const char * const *)ipparts) !=3D 2 || - virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || - virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { - - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid CIDR address: '%s'"), value->str); - - virStringListFree(ipparts); - VIR_FREE(ip); - return -1; - } - - virStringListFree(ipparts); - - if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) { - VIR_FREE(ip); - return -1; - } } else if (STREQ(name, "lxc.network.ipv4.gateway")) { parseData->gateway_ipv4 =3D value->str; } else if (STREQ(name, "lxc.network.ipv6.gateway")) { --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 13:48:58 2024 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 1550516990138439.4656321743573; Mon, 18 Feb 2019 11:09:50 -0800 (PST) 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 49A9581DE0; Mon, 18 Feb 2019 19:09:48 +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 1889F17265; Mon, 18 Feb 2019 19:09:48 +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 C5CB34EA67; Mon, 18 Feb 2019 19:09:47 +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 x1IJ9SO2019041 for ; Mon, 18 Feb 2019 14:09:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id DABB1102492D; Mon, 18 Feb 2019 19:09:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D10FB101962B for ; Mon, 18 Feb 2019 19:09:21 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 B0F97107BD for ; Mon, 18 Feb 2019 19:09:20 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id v139so193044qkb.12 for ; Mon, 18 Feb 2019 11:09:20 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:19 -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=VnF8l5BbW0dwH14R1ppCkRxqEPS+2yq/ZhCYfr5cp/A=; b=rpfwHuarKIrvjdfgrFHxwcVYYmGVuztm5LG6o0TqbfMtc2BvcGmIpH3zFsrFI+sjgP tcE4J8p3QZX2GvtKlQNUavu40HOzwDupy0J7q22tmzQmXHFrZFnd2zzPfPQAewGfifxF vNV1mGYALL/K30QX+w0IwWkK9Zwcn0AtKptf+xg9tTnVy05YXDqCGRpM7Ce3DywDoayk wM1lhOtGEIBfvlquDVPfKHpoRZhmdyLvnVpXzo4kctxi6e2IuDrGLMtMRRXFB9f4DUhp 5TC8HVmhW3u1ZGB0Or2nOI3jphw/O75Q17dEjvtS0FCAAA5d+CvfL4ZaGMSVjHZmBnsL +PHQ== 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=VnF8l5BbW0dwH14R1ppCkRxqEPS+2yq/ZhCYfr5cp/A=; b=sZ2sLC1A7JPv+AGMwDQ1v0hHqzAmMXVFbFY8WOOEJmLh9/HU9vT3nmee3Jsga0tmej RJnWueylLJP3yqxIC4NBAmN/97XJq6Cxl8Syh4BJFq1HAG7Nuj1NJc0sLyPxwhswegz5 ocaBeQisLPOh4G+zXWoVOdCI4AuVH+hIjj5keoyk9bJ3dl/vYwnZfX0BkcXjvlUzHo46 CNYZMBJnfKRxhEUFNHw6LGPHCxblMhmu3LICJL+PrkPHl2NbAR4+l1fPVxi71oB/nfu8 0bzr7QpDUsC2adpgfJotUEa4rHtrJQC0ZP2FhHEQLwo1uG3r1l6oDkNg+tP+BEKEbbDO kPFA== X-Gm-Message-State: AHQUAuaqC848ZNPW5mmp6t/mYJ84i88164VTW3k98JEdOd73YwOnbfdH tBrGipgqBXTC3GqHfChLLAxIKbM4 X-Google-Smtp-Source: AHgI3IY7uCJOfYGhbmvAWSMfCCLrdT9tQvOiEAsr6JfVUfU9w3E//f6GehdB8csS+Sl+5pPs3ahopg== X-Received: by 2002:a37:a42:: with SMTP id 63mr17810497qkk.269.1550516959773; Mon, 18 Feb 2019 11:09:19 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:06 -0300 Message-Id: <20190218190910.22477-3-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.28]); Mon, 18 Feb 2019 19:09:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 18 Feb 2019 19:09:20 +0000 (UTC) for IP:'209.85.222.195' DOMAIN:'mail-qk1-f195.google.com' HELO:'mail-qk1-f195.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.195 mail-qk1-f195.google.com 209.85.222.195 mail-qk1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] lxc: Create a new method called lxcNetworkParseDataEntry(). 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 19:09:48 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This new method is responsible to verify is the settings correspond to network entry. Right now, it is only verifying "lxc.network.", but in the future, it can be used to verify "lxc.net.X." too. Any other case would be rejected. On the other hand, the idea here is working only with types. If we know that entry is part of network settings, after we just need to know which type is. It keeps the hanlder simple. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 5bbbbf132c..c144f3c52e 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -648,6 +648,14 @@ lxcNetworkWalkCallback(const char *name, virConfValueP= tr value, void *data) return 0; } =20 +static int +lxcNetworkParseDataEntry(const char *name, virConfValuePtr value, lxcNetwo= rkParseData *parseData) +{ + const char *suffix =3D STRSKIP(name, "lxc.network."); + + return lxcNetworkParseDataSuffix(suffix, value, parseData); +} + static int lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties) { --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 13:48:58 2024 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 1550516986385347.4646273568535; Mon, 18 Feb 2019 11:09:46 -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 87BC4227A1; 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 56EEA5ED5A; 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 13DF3181A048; Mon, 18 Feb 2019 19:09:44 +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 x1IJ9Swk019040 for ; Mon, 18 Feb 2019 14:09:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id D99C81024909; Mon, 18 Feb 2019 19:09:28 +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 D0DF71001F5B for ; Mon, 18 Feb 2019 19:09:25 +0000 (UTC) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 34B8985360 for ; Mon, 18 Feb 2019 19:09:22 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id p48so20428570qtk.2 for ; Mon, 18 Feb 2019 11:09:22 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:20 -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=YcwHPvSsn3htfHA2qizJoA7aR6E7WTSPxip5NQ6fC+Q=; b=V4W101F91z4rYVfOxGeGcUg2LfBzwLKVaH950JfzlsrpTS5i+pTJ2rmbEHrj6sj6Wt H/PL/xxAEVQ9zqIJARCNhr35rzJ6QAeJh/eQiQj1C4cz5m6nt5cToP6OlJE4iblI74Ij oj3xEBcwUpOzlJYhVBs5Y929813yYLwJIG9miAST4jLVt5BCMGDIxkjzJXcMPZWdKRuh qZD7BlxmE4Ytx7BlaRBmEqIK/wNfjM5cYqbGS/nDTGJ7i1WyGhyLoK7YOs8LTiKvkD0/ g5iKVBymUlJfTOh/YO26iWk61S98S32DsYHqNfUq6gGOTkNWVsIuZyR1+nKe2OScgB+a Q7Ng== 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=YcwHPvSsn3htfHA2qizJoA7aR6E7WTSPxip5NQ6fC+Q=; b=Thzj8Sn3CY/pgAWraJBY5dqYAqMnPhqIMZwHMXaz9UxKlctsIYq6seVjC8/strHvGY Y997+06Zh5ZQmsSmZkx/OBAzoDc0GkBF3BDFopULcQ99rL+icbL8B8Go822fJFufX1KL lff2ILd+U8wPdT9gYFxqObbsTLB5Y1FpyqdfTIKPBK1C9PzRkkBr3dYv0rBUfHhcUunj 9Xuk0emG2dsMHnb1xRWXU8SMnKvVJLgbaY7uj2i5ZqUhWTJzm1ZRNX+IPUvF5Ybd21U3 iBO/pCLsjbJqZUtjeqnWfOKgrNwrq7+QFVhB/HmfDmQDhxKeINyqXWR/jFqVqlTbqmpi LQxQ== X-Gm-Message-State: AHQUAuZ5ja+++3ZvNeqO0EyBsN7HohQRH49DyZOvF9XS3dGx03C3BbFK vIvG3wqegjQLdPwsemdGoG9g9mOR X-Google-Smtp-Source: AHgI3IZrH332CMJT0FqBOswmbAZhuOwFhNKjJTaqGPndDNtloLH9vPu7lLv8p9J7yi6dFw0towSv2w== X-Received: by 2002:ac8:3f0f:: with SMTP id c15mr19500212qtk.142.1550516961239; Mon, 18 Feb 2019 11:09:21 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:07 -0300 Message-Id: <20190218190910.22477-4-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.25]); Mon, 18 Feb 2019 19:09:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 19:09:22 +0000 (UTC) for IP:'209.85.160.173' DOMAIN:'mail-qt1-f173.google.com' HELO:'mail-qt1-f173.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.173 mail-qt1-f173.google.com 209.85.160.173 mail-qt1-f173.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] lxc: Converting full string entries in types only. 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.26]); 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 commit removes the full network entry setting: "lxc.network.X" to type only. Like "type", "name", "flags", etc. So, here no matter if the settings is "lxc.network.X" or "lxc.net.X.Y". Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index c144f3c52e..ed50415a93 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -562,7 +562,7 @@ lxcNetworkParseDataIPs(const char *name, virConfValuePt= r value, lxcNetworkParseD if (VIR_ALLOC(ip) < 0) return -1; =20 - if (STREQ(name, "lxc.network.ipv6")) + if (STREQ(name, "ipv6")) family =3D AF_INET6; =20 ipparts =3D virStringSplit(value->str, "/", 2); @@ -589,12 +589,11 @@ lxcNetworkParseDataIPs(const char *name, virConfValue= Ptr value, lxcNetworkParseD } =20 static int -lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data) +lxcNetworkParseDataSuffix(const char *name, virConfValuePtr value, lxcNetw= orkParseData *parseData) { - lxcNetworkParseData *parseData =3D data; int status; =20 - if (STREQ(name, "lxc.network.type")) { + if (STREQ(name, "type")) { virDomainDefPtr def =3D parseData->def; size_t networks =3D parseData->networks; bool privnet =3D parseData->privnet; @@ -619,30 +618,31 @@ lxcNetworkWalkCallback(const char *name, virConfValue= Ptr value, void *data) /* Keep the new value */ parseData->type =3D value->str; } - else if (STREQ(name, "lxc.network.link")) + else if (STREQ(name, "link")) parseData->link =3D value->str; - else if (STREQ(name, "lxc.network.hwaddr")) + else if (STREQ(name, "hwaddr")) parseData->mac =3D value->str; - else if (STREQ(name, "lxc.network.flags")) + else if (STREQ(name, "flags")) parseData->flag =3D value->str; - else if (STREQ(name, "lxc.network.macvlan.mode")) + else if (STREQ(name, "macvlan.mode")) parseData->macvlanmode =3D value->str; - else if (STREQ(name, "lxc.network.vlan.id")) + else if (STREQ(name, "vlan.id")) parseData->vlanid =3D value->str; - else if (STREQ(name, "lxc.network.name")) + else if (STREQ(name, "name")) parseData->name =3D value->str; - else if (STREQ(name, "lxc.network.ipv4") || - STREQ(name, "lxc.network.ipv6")) { + else if (STREQ(name, "ipv4") || + STREQ(name, "ipv6")) { if (lxcNetworkParseDataIPs(name, value, parseData) < 0) return -1; - } else if (STREQ(name, "lxc.network.ipv4.gateway")) { + } else if (STREQ(name, "ipv4.gateway")) { parseData->gateway_ipv4 =3D value->str; - } else if (STREQ(name, "lxc.network.ipv6.gateway")) { + } else if (STREQ(name, "ipv6.gateway")) { parseData->gateway_ipv6 =3D value->str; - } else if (STRPREFIX(name, "lxc.network")) { + } else { VIR_WARN("Unhandled network property: %s =3D %s", name, value->str); + return -1; } =20 return 0; --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 13:48:58 2024 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 1550842543791304.2931250812487; Fri, 22 Feb 2019 05:35:43 -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 01E2430603BF; Fri, 22 Feb 2019 13:35:37 +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 CA7075D9D4; Fri, 22 Feb 2019 13:35:36 +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 68573181A00C; Fri, 22 Feb 2019 13:35:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1IJ9RZP019030 for ; Mon, 18 Feb 2019 14:09:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE95B5D71A; Mon, 18 Feb 2019 19:09:27 +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 A4A2D5D71C for ; Mon, 18 Feb 2019 19:09:24 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (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 C2E3381F1B for ; Mon, 18 Feb 2019 19:09:23 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id 2so20412574qtb.5 for ; Mon, 18 Feb 2019 11:09:23 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:22 -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=jHl4oxL6QEO+2VhlJk40EtTQfS/5hxWvsd57hxtsAMw=; b=maIU/rCpi86rXq4qrvYDnr2sWX1T6VZcTzNdH/Y0tR0O6iM6j1YbajHefElqY02/g4 Kmw5If+pOXjjUhqTEYPfUt6xTUbZU2X4tGPw+vNAXEJgLzC8coFK3Br4lu7TvCbpDQKY Qz0v36RMoj7nqOyQOkAh23aYOjFdOzCDynpcnP8cDnVxHDcXMGz0pXHp/DbsAQIhN1Ws 0FVLzZPdkOwX1ZeetwQnyFCklLk3YXf0/aB+g6zo/hV87qPRf9vJ3aa85On3cpM1tucy BGtWYEFqURWxGKpwHrsfCos2QYM+OkdkaHaUJimKXJbejLVFFzODHX7PlZm38nqjklE/ x9gQ== 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=jHl4oxL6QEO+2VhlJk40EtTQfS/5hxWvsd57hxtsAMw=; b=SVnHzHL7bYYP2S3YyWWAVPug/Gqw5tMYiHUU4oGeSj/5CtQ630ScaUZQfNT9bLAvxn oylBHBsPiLgWlbFB1j/vHlRXTJ87NpfG58yrsmeMGdU2uxxkV6LhHw94myXO0qigP1rb vnGNfmI2ec9LZSkSwv0ZTw9xvjwNkdemqaVrbjw1MwZ7dAmCo52r4+4kly0W+797ekD3 89PWsltgOJtjO5Wo9wEyPA1jBmW8eOvVgtT/1AYpCf8sQaSVvT+5935K0DiaN0mayZ56 CvuI37igLW2lMu9rJqPzjqFDZuw5NI3QrXYKu8UuJuThB/+IxQap6e6No5jRjypAH/ju Fcbg== X-Gm-Message-State: AHQUAuZUimD/AL5Drc6bmo63Pz2FWvAh6jXP3b6wOchwbcZHkZY2RULB aULTeakugDOHFDA1ue3NTQ64b49b X-Google-Smtp-Source: AHgI3Ia7+TunBlm+Tc6melDzfuT0N5FoEr0Pq5UuGj1BQdh06s9eeHMPf/tbSQprrR8oR2tIqF9pZw== X-Received: by 2002:a0c:b786:: with SMTP id l6mr18728633qve.244.1550516962802; Mon, 18 Feb 2019 11:09:22 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:08 -0300 Message-Id: <20190218190910.22477-5-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.25]); Mon, 18 Feb 2019 19:09:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 19:09:23 +0000 (UTC) for IP:'209.85.160.195' DOMAIN:'mail-qt1-f195.google.com' HELO:'mail-qt1-f195.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.195 mail-qt1-f195.google.com 209.85.160.195 mail-qt1-f195.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] lxc: Refactoring lxcNetworkWalkCallback() to a simple 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.47]); Fri, 22 Feb 2019 13:35:42 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The method lxcNetworkWalkCallback() needs to be simple enough to handle both possible network settings with indexes or the simple one. It is better the decouple the whole algorithm to parse data to only parse which entry type libvirt is handling. Signed-off-by: Julio Faracco --- src/lxc/lxc_native.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index ed50415a93..95e08c18f4 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -656,6 +656,19 @@ lxcNetworkParseDataEntry(const char *name, virConfValu= ePtr value, lxcNetworkPars return lxcNetworkParseDataSuffix(suffix, value, parseData); } =20 +static int +lxcNetworkWalkCallback(const char *name, + virConfValuePtr value, + void *data) +{ + lxcNetworkParseData *parseData =3D data; + + if (STRPREFIX(name, "lxc.network.")) + return lxcNetworkParseDataEntry(name, value, parseData); + + return 0; +} + static int lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties) { --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 13:48:58 2024 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 From nobody Wed May 1 13:48:58 2024 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 1550842738610595.6315125308263; Fri, 22 Feb 2019 05:38:58 -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 A2B50C0740D5; Fri, 22 Feb 2019 13:38:56 +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 543955D9D4; Fri, 22 Feb 2019 13:38:56 +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 A1C8224C21; Fri, 22 Feb 2019 13:38:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1IJ9SJl019035 for ; Mon, 18 Feb 2019 14:09:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 915C74B4; Mon, 18 Feb 2019 19:09:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AF515FC36 for ; Mon, 18 Feb 2019 19:09:27 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (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 CFDDAC0799B1 for ; Mon, 18 Feb 2019 19:09:26 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id p48so20428880qtk.2 for ; Mon, 18 Feb 2019 11:09:26 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:25 -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=p2ZTdHRbbThdkzWjNFAyytl5HbiOQPR3rR7qYJkouQE=; b=OmPP/mlnUwhi5javGwgjALeXVtpn32kvhlWsovsoBvwIjB3w59jB1fCXEt/BauKBiZ jM7ti4vvzmpQLpl+RvgFIDe8ioDqiW8IvTnLPDZCtLCYnRGuJL6mO23//PND8cy44of5 Co1ZtKXtplfGbD70t+C7mEbWs0LkFWFLkv0CLWNcJ3m2qf36EN/jFauj4HmsfAvudXl4 gJP0oXPyIckLac4SSyAnbHIBW1NqCV4FfkqJtP9rdjHOThBil7gU3mqJ2Kbwmac8VWCe Wn5eCbNcuoVahFE/FEljZ1Ulx1f4iCqv6yUyrHwutkUZG7Dm1+XqdfpG6ayDOu+uOVp3 a4tg== 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=p2ZTdHRbbThdkzWjNFAyytl5HbiOQPR3rR7qYJkouQE=; b=WDTRV2+R9VyFBVXOZfL2KQu1slMDNb6prFF1Am5RJxEGi6RUXuhNbffaJYg4qph2tf 7iWXpaz7qmyuUFanO85jqNb57D5H31UAOjOLFo5HquFaIwOsMWWiJoINb6BWfC2jPGPo pBYcS7GcU+IxfBvijQHp1moBEQUCkA/BYEm9SonrqgPWwy28iyNK8QIV4CXtpsATqoc3 MZYm/AJI5j7tqqX2vkDRmVbwDgUh9S+WFK0Wth2ogLhLIMg2mK2Ct3LosElvrgOS7mRe 13z4F8nrCLCSewiDbS1MbMijj9Bh+Bt2J931yTTVV1D1TwPzRxiD1E/mOS/IMkG8p6kp lEtQ== X-Gm-Message-State: AHQUAuZ1uW4rpk7oe8pU5tz3WZvSPJxiD6KWmkfbnlmx8mkMbu3XoPct n3f/r5tJKzMrG4d8P+8A9dphxqvG X-Google-Smtp-Source: AHgI3IY0xbjspSzDNLDN1ATkj78jhy82FcBrIiyfk5UVD4U5233Cdr2EZww3QFQV99bmfyK6dRdmRg== X-Received: by 2002:a0c:b485:: with SMTP id c5mr10720912qve.78.1550516965828; Mon, 18 Feb 2019 11:09:25 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:10 -0300 Message-Id: <20190218190910.22477-7-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.31]); Mon, 18 Feb 2019 19:09:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 19:09:27 +0000 (UTC) for IP:'209.85.160.194' DOMAIN:'mail-qt1-f194.google.com' HELO:'mail-qt1-f194.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.194 mail-qt1-f194.google.com 209.85.160.194 mail-qt1-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] lxc: Converting 'if, else' logic into a 'switch, case'. 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.31]); Fri, 22 Feb 2019 13:38:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The structure used to handle network entries was based on 'if,else' conditions. This commit converts this ugly structure into a switch to clearify each option of the handler. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 58 ++++++++++++++++++++++++++++++++------------ src/lxc/lxc_native.h | 17 +++++++++++++ 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 25e35e93dd..c746c443da 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -35,6 +35,20 @@ =20 VIR_LOG_INIT("lxc.lxc_native"); =20 +VIR_ENUM_IMPL(virLXCNetworkConfigEntry, VIR_LXC_NETWORK_CONFIG_LAST, + "name", + "type", + "link", + "hwaddr", + "flags", + "macvlan.mode", + "vlan.id", + "ipv4", + "ipv4.gateway", + "ipv6", + "ipv6.gateway" +); + static virDomainFSDefPtr lxcCreateFSDef(int type, const char *src, @@ -620,35 +634,47 @@ lxcNetworkParseDataIPs(const char *name, virConfValue= Ptr value, lxcNetworkParseD } =20 static int -lxcNetworkParseDataSuffix(const char *name, virConfValuePtr value, lxcNetw= orkParseData *parseData) +lxcNetworkParseDataSuffix(const char *entry, virConfValuePtr value, lxcNet= workParseData *parseData) { - if (STREQ(name, "type")) { + int type =3D virLXCNetworkConfigEntryTypeFromString(entry); + + switch (type) { + case VIR_LXC_NETWORK_CONFIG_TYPE: if (lxcNetworkParseDataInit(value, parseData) < 0) return -1; - } - else if (STREQ(name, "link")) + break; + case VIR_LXC_NETWORK_CONFIG_LINK: parseData->link =3D value->str; - else if (STREQ(name, "hwaddr")) + break; + case VIR_LXC_NETWORK_CONFIG_HWADDR: parseData->mac =3D value->str; - else if (STREQ(name, "flags")) + break; + case VIR_LXC_NETWORK_CONFIG_FLAGS: parseData->flag =3D value->str; - else if (STREQ(name, "macvlan.mode")) + break; + case VIR_LXC_NETWORK_CONFIG_MACVLAN_MODE: parseData->macvlanmode =3D value->str; - else if (STREQ(name, "vlan.id")) + break; + case VIR_LXC_NETWORK_CONFIG_VLAN_ID: parseData->vlanid =3D value->str; - else if (STREQ(name, "name")) + break; + case VIR_LXC_NETWORK_CONFIG_NAME: parseData->name =3D value->str; - else if (STREQ(name, "ipv4") || - STREQ(name, "ipv6")) { - if (lxcNetworkParseDataIPs(name, value, parseData) < 0) + break; + case VIR_LXC_NETWORK_CONFIG_IPV4: + case VIR_LXC_NETWORK_CONFIG_IPV6: + if (lxcNetworkParseDataIPs(entry, value, parseData) < 0) return -1; - } else if (STREQ(name, "ipv4.gateway")) { + break; + case VIR_LXC_NETWORK_CONFIG_IPV4_GATEWAY: parseData->gateway_ipv4 =3D value->str; - } else if (STREQ(name, "ipv6.gateway")) { + break; + case VIR_LXC_NETWORK_CONFIG_IPV6_GATEWAY: parseData->gateway_ipv6 =3D value->str; - } else { + break; + default: VIR_WARN("Unhandled network property: %s =3D %s", - name, + entry, value->str); return -1; } diff --git a/src/lxc/lxc_native.h b/src/lxc/lxc_native.h index 86f5163e12..0939be346d 100644 --- a/src/lxc/lxc_native.h +++ b/src/lxc/lxc_native.h @@ -25,6 +25,23 @@ =20 # define LXC_CONFIG_FORMAT "lxc-tools" =20 +typedef enum { + VIR_LXC_NETWORK_CONFIG_NAME, + VIR_LXC_NETWORK_CONFIG_TYPE, + VIR_LXC_NETWORK_CONFIG_LINK, + VIR_LXC_NETWORK_CONFIG_HWADDR, + VIR_LXC_NETWORK_CONFIG_FLAGS, + VIR_LXC_NETWORK_CONFIG_MACVLAN_MODE, + VIR_LXC_NETWORK_CONFIG_VLAN_ID, + VIR_LXC_NETWORK_CONFIG_IPV4, + VIR_LXC_NETWORK_CONFIG_IPV4_GATEWAY, + VIR_LXC_NETWORK_CONFIG_IPV6, + VIR_LXC_NETWORK_CONFIG_IPV6_GATEWAY, + VIR_LXC_NETWORK_CONFIG_LAST, +} virLXCNetworkConfigEntry; + +VIR_ENUM_DECL(virLXCNetworkConfigEntry); + virDomainDefPtr lxcParseConfigString(const char *config, virCapsPtr caps, virDomainXMLOptionPtr xmlopt); --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list