From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219296; cv=none;
d=zoho.com; s=zohoarc;
b=UarsxkR8/3r7GcgQyMVtjJpoR4wyO0Y1Vt4eUxPAy+Vl31QERrTB/BOLIXMadtw805BQLPKWg0FXScY+F8kxZXmwfb3UH/luK4JpFgcgU0E0ju5SRGWCLTut+Ewj5scePN07neEGgBWojgwAG4UAbetYB0hn0YtMovHxqrR19zs=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219296;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=hIckg8CjR6dVNYHvfctweijgLqSG2m96qLQOP8FBWQs=;
b=YXRPQqo20OPLVRHkZmHIA8C91KUtkh+g6HlddB0qX4muxweF2fN4GD1teJ1B99n5Jc0TNGVjWrWcwCB8I+5fbx0lilaWTkwPZwBqNze8bXu25RDa+kmrFXmyFyWdoxJFuRjFszi7SvnHUuqD653F0/+E3Ddg+FMv0atqezt2zCw=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219296404296.1115039929025;
Wed, 11 Sep 2019 09:28:16 -0700 (PDT)
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 551C1C04D312;
Wed, 11 Sep 2019 16:28:14 +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 309515DA8D;
Wed, 11 Sep 2019 16:28:14 +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 4C670180BA96;
Wed, 11 Sep 2019 16:28:13 +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 x8BGSBfQ013040 for ;
Wed, 11 Sep 2019 12:28:11 -0400
Received: by smtp.corp.redhat.com (Postfix)
id AFBBB6017E; Wed, 11 Sep 2019 16:28:11 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 1FB7260167;
Wed, 11 Sep 2019 16:28:10 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:10 +0100
Message-Id: <20190911162333.8668-2-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 01/24] docs: document that C & Python are the
preferred languages
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-Type: text/plain; charset="utf-8"
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]);
Wed, 11 Sep 2019 16:28:14 +0000 (UTC)
Blacklist Perl and Shell code in favour of Python for
sake of readability and portability.
Signed-off-by: Daniel P. Berrang=C3=A9
---
docs/hacking.html.in | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 90376968c3..edf2f54ce3 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -343,6 +343,36 @@
Richard Jones' guide to working with open source projects.
=20
+
+
+
+ The libvirt repository makes use of a large number of programming
+ languages. It is anticipated that in the future libvirt will adopt
+ use of other new languages. To reduce the overall burden on develope=
rs,
+ there is thus a general desire to phase out usage of some of the
+ existing languages.
+
+
+
+ The preferred languages at this time are:
+
+
+
+ - C - for the main libvirt codebase. Dialect supported by
+ GCC/CLang only.
+ - Python - for supporting build scripts / tools. Code must
+ run with both version 2.7 and 3.x at this time.
+
+
+
+ Languages that should not be used for any new contributions:
+
+
+
+ - Perl - build scripts must be written in Python instead.
+ - Shell - build scripts must be written in Python instead.
+
+
=20
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219296; cv=none;
d=zoho.com; s=zohoarc;
b=nRhO0T7+qO2tdgWkDJUtO2QcWfn6u1w45JpUIJ5L9W4hSIgHW1qtLApv6oY5fru0l7pdyJc0p+vbfGExrxYVo5TbE1OFJGvjVUVA7yzgeWh+yjSnZLKRUEPwhIsRhrT+wxia3HhhUaupoDbToqMtbvdzADYJyLZa86guetDTjd0=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219296;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=eABY+NEYXXL8F8f7AiN07oZujWIYUQYM87U/hgoohZk=;
b=Bh1JYG9F0Z1n5IWtRxFboXuYlkvfMix1xqXWb3QDiRlMVRcgOdoaV62P626LqWf8mHFJEF7PM0AHvdXSw6c8HwtD2K8NvDrCPoh3g8xFIqAdJM0OM6UoEkZmL/mXEHR9WOrWqh/o0oF8SERAMqEbJvID5ze/OBTx29EVhWTYUgw=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219296813797.4492870121716;
Wed, 11 Sep 2019 09:28:16 -0700 (PDT)
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 420051DB6;
Wed, 11 Sep 2019 16:28:14 +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 14EFB6012A;
Wed, 11 Sep 2019 16:28:14 +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 6E2E62551C;
Wed, 11 Sep 2019 16:28:13 +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 x8BGSCWh013045 for ;
Wed, 11 Sep 2019 12:28:12 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 91ECC6012A; Wed, 11 Sep 2019 16:28:12 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 0239E60167;
Wed, 11 Sep 2019 16:28:11 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:11 +0100
Message-Id: <20190911162333.8668-3-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 02/24] cfg.mk: fix comment detection for python
semicolon check
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.71]);
Wed, 11 Sep 2019 16:28:14 +0000 (UTC)
The pattern
^[^#].*\;$$
Was attempting to detect any trailing ';' in python code
which was not in a comment. This does not allow for the
comment '#' character to be indented with whitespace.
Signed-off-by: Daniel P. Berrang=C3=A9
Reviewed-by: Eric Blake
---
cfg.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index 1f29729949..d09ab507e0 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -815,7 +815,7 @@ sc_require_enum_last_marker:
=20
# In Python files we don't want to end lines with a semicolon like in C
sc_prohibit_semicolon_at_eol_in_python:
- @prohibit=3D'^[^#].*\;$$' \
+ @prohibit=3D'^[ \t]*[^# \t].*\;$$' \
in_vc_files=3D'\.py$$' \
halt=3D'python does not require to end lines with a semicolon' \
$(_sc_search_regexp)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219303; cv=none;
d=zoho.com; s=zohoarc;
b=Dcp9qyCZl0mk3KTEdJxbiQ8m42Uz4AYhkStb2W5PmGkTxf3cjrzmBDRT4B0WV8G1psgny099AELpJW/K/6c4SOazWJue4gLmDT00c2IV5Mk/0ArCS+2KovGqPkp/pyvwDSKcHyZwnuRye5Fe02nfLt6b+ohGXI6k2Hzdl/Cz3Gc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219303;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=semYKeqoEzCxdKliGCnPhhIhHabR6FDDjBYKkX0vNLM=;
b=Xwp9IPZsZRR4a+u0KiuqK8EDWEH1K6YUpKmLx8TIcHisUrFBUBavLQEtegXPcEXr5PPzT5IN1HRU6OyK2Rr9Y2LbxGnP9QUAHLpP2fr4lfsxaz9dPD6AgMrHOj8VyHU0uY875sY4lGtrWUCxKLstl0XoaX2Mb7XZkZ7RD/YozvI=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219303937389.1827682968368;
Wed, 11 Sep 2019 09:28:23 -0700 (PDT)
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 1FB2A10DCC86;
Wed, 11 Sep 2019 16:28:22 +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 ED181601B3;
Wed, 11 Sep 2019 16:28:21 +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 A033924FDF;
Wed, 11 Sep 2019 16:28:21 +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 x8BGSDU2013055 for ;
Wed, 11 Sep 2019 12:28:13 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 734AF601B3; Wed, 11 Sep 2019 16:28:13 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id D793C60167;
Wed, 11 Sep 2019 16:28:12 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:12 +0100
Message-Id: <20190911162333.8668-4-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 03/24] build: force a UTF-8 locale for python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.64]);
Wed, 11 Sep 2019 16:28:22 +0000 (UTC)
Python3 versions less than 3.7 have very unhelpful handling
of the C locale where they assume data is 7-bit only. This
violates POSIX which requires the C locale to be 8-bit clean.
Python3 >=3D 3.7 now assumes that the C locale is always UTF-8.
Set env variables to force LC_CTYPE to en_US.UTF-8 so that
we get UTF-8 handling on all python versions. Note we do
not use C.UTF-8 since not all C libraries support that.
Signed-off-by: Daniel P. Berrang=C3=A9
Reviewed-by: Eric Blake
---
Makefile.am | 2 +-
configure.ac | 8 ++++++++
docs/Makefile.am | 3 ++-
src/esx/Makefile.inc.am | 2 +-
src/hyperv/Makefile.inc.am | 2 +-
src/util/Makefile.inc.am | 8 ++++----
6 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index cf9ff94f4f..711f365504 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,7 +69,7 @@ NEWS: \
$(srcdir)/docs/news.xml \
>$@-tmp \
|| { rm -f $@-tmp; exit 1; }; \
- $(PYTHON) $(srcdir)/docs/reformat-news.py $@-tmp >$@ \
+ $(RUNUTF8) $(PYTHON) $(srcdir)/docs/reformat-news.py $@-tmp >$@ \
|| { rm -f $@-tmp; exit 1; }; \
rm -f $@-tmp; \
fi
diff --git a/configure.ac b/configure.ac
index 7c76a9c9ec..31810b9010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -706,6 +706,14 @@ AC_PATH_PROGS([PYTHON], [python3 python2 python])
if test -z "$PYTHON"; then
AC_MSG_ERROR(['python3', 'python2' or 'python' binary is required to b=
uild libvirt])
fi
+
+dnl Python3 < 3.7 treats the C locale as 7-bit only.
+dnl We must force env vars so it treats it as UTF-8
+dnl regardless of the user's locale.
+RUNUTF8=3D"LC_ALL=3D LANG=3DC LC_CTYPE=3Den_US.UTF-8"
+AC_SUBST(RUNUTF8)
+
+
AC_PATH_PROG([PERL], [perl])
if test -z "$PERL"; then
AC_MSG_ERROR(['perl' binary is required to build libvirt])
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 1cdb584b0b..14f3faffd4 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -348,7 +348,8 @@ $(APIBUILD_STAMP): $(srcdir)/apibuild.py \
$(top_srcdir)/src/util/virerror.c \
$(top_srcdir)/src/util/virevent.c \
$(top_srcdir)/src/util/virtypedparam.c
- $(AM_V_GEN)srcdir=3D$(srcdir) builddir=3D$(builddir) $(PYTHON) $(APIBUILD)
+ $(AM_V_GEN)srcdir=3D$(srcdir) builddir=3D$(builddir) \
+ $(RUNUTF8) $(PYTHON) $(APIBUILD)
touch $@
=20
=20
diff --git a/src/esx/Makefile.inc.am b/src/esx/Makefile.inc.am
index 2d55c6573c..70a13ea829 100644
--- a/src/esx/Makefile.inc.am
+++ b/src/esx/Makefile.inc.am
@@ -63,7 +63,7 @@ $(ESX_DRIVER_GENERATED): $(ESX_GENERATED_STAMP)
=20
$(ESX_GENERATED_STAMP): $(srcdir)/esx/esx_vi_generator.input \
$(srcdir)/esx/esx_vi_generator.py
- $(AM_V_GEN)srcdir=3D$(srcdir) $(PYTHON) $(srcdir)/esx/esx_vi_generator.py=
\
+ $(AM_V_GEN)srcdir=3D$(srcdir) $(RUNUTF8) $(PYTHON) $(srcdir)/esx/esx_vi_g=
enerator.py \
&& touch $@
=20
MAINTAINERCLEANFILES +=3D $(ESX_DRIVER_GENERATED) $(ESX_GENERATED_STAMP)
diff --git a/src/hyperv/Makefile.inc.am b/src/hyperv/Makefile.inc.am
index 51be8bcacc..6728b39c90 100644
--- a/src/hyperv/Makefile.inc.am
+++ b/src/hyperv/Makefile.inc.am
@@ -41,7 +41,7 @@ $(HYPERV_DRIVER_GENERATED): $(HYPERV_GENERATED_STAMP)
=20
$(HYPERV_GENERATED_STAMP): $(srcdir)/hyperv/hyperv_wmi_generator.input \
$(srcdir)/hyperv/hyperv_wmi_generator.py
- $(AM_V_GEN)srcdir=3D$(srcdir) $(PYTHON) \
+ $(AM_V_GEN)srcdir=3D$(srcdir) $(RUNUTF8) $(PYTHON) \
$(srcdir)/hyperv/hyperv_wmi_generator.py \
&& touch $@
=20
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 46866cf213..adb5e6d727 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -300,7 +300,7 @@ util/virkeycodetable_%.h: $(srcdir)/keycodemapdb/data/k=
eymaps.csv \
$(AM_V_GEN)export NAME=3D`echo $@ | sed -e 's,util/virkeycodetable_,,' \
-e 's,\.h,,'` && \
$(MKDIR_P) util/ && \
- $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
+ $(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang stdc --varname virKeyCodeTable_$$NAME code-table \
$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
mv $@-tmp $@ || rm -f $@-tmp
@@ -310,7 +310,7 @@ util/virkeynametable_%.h: $(srcdir)/keycodemapdb/data/k=
eymaps.csv \
$(AM_V_GEN)export NAME=3D`echo $@ | sed -e 's,util/virkeynametable_,,' \
-e 's,\.h,,'` && \
$(MKDIR_P) util/ && \
- $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
+ $(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang stdc --varname virKeyNameTable_$$NAME name-table \
$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
mv $@-tmp $@ || rm -f $@-tmp
@@ -320,7 +320,7 @@ util/virkeycode-%.pod: $(srcdir)/keycodemapdb/data/keym=
aps.csv \
$(AM_V_GEN)export NAME=3D`echo $@ | sed -e 's,util/virkeycode-,,' \
-e 's,\.pod,,'` && \
$(MKDIR_P) util/ && \
- $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
+ $(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang pod \
--varname "virkeycode-$$NAME - Key code values for $$NAME" \
code-docs \
@@ -332,7 +332,7 @@ util/virkeyname-%.pod: $(srcdir)/keycodemapdb/data/keym=
aps.csv \
$(AM_V_GEN)export NAME=3D`echo $@ | sed -e 's,util/virkeyname-,,' \
-e 's,\.pod,,'` && \
$(MKDIR_P) util/ && \
- $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
+ $(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
--lang pod \
--varname "virkeyname-$$NAME - Key name values for $$NAME" \
name-docs \
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219304; cv=none;
d=zoho.com; s=zohoarc;
b=f6spqosyZsP7ihsxleUli+gnyyap8lmEe4QB9Lnv11x8QHKOYU6ZXi3td5JCpXYKp7xOyN71e3bEbCFAsLxSWB3PVO82k8/uL5af7Ad4JLHRtTtra98eKlbdGI+Q03kGecpRNVfVStWRsQr5GKgt/ATzH/7JrcWWfc7+UQih4YU=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219304;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=787IGNDVJ4Ql84o6prOJxQhMfhvwBOF7g/nHbaFOozc=;
b=N74yNAjAvobtVpmvaM45gHc+xy+QCnfQkFiiac3PEC5qN6vRluJHo24p4c7TAil2s3mFs5ZZduJWFqCtv7Nif53vX1TlFLHRjTceA3c7VIK/Y1YebcEW8Ed7Wf+CnkiNZfcndxtDobGsGVumxPeMORyGqpPSa7FLsDliO0Nj284=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 156821930403943.28785993598012;
Wed, 11 Sep 2019 09:28:24 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 162DE3082B3F;
Wed, 11 Sep 2019 16:28:22 +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 E1B4960606;
Wed, 11 Sep 2019 16:28:21 +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 98ED424FDE;
Wed, 11 Sep 2019 16:28:21 +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 x8BGSE10013066 for ;
Wed, 11 Sep 2019 12:28:14 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 78238601A5; Wed, 11 Sep 2019 16:28:14 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id B98FE60167;
Wed, 11 Sep 2019 16:28:13 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:13 +0100
Message-Id: <20190911162333.8668-5-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 04/24] build-aux: rewrite augest test generator
in Python
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-Type: text/plain; charset="utf-8"
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]);
Wed, 11 Sep 2019 16:28:22 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the augeas-gentest.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
The use of $(AUG_GENTEST) as a dependancy in the makefiles needed
to be fixed, because this was assumed to be the filename of the
script, but is in fact a full shell command line.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/augeas-gentest.pl | 60 ---------------------------
build-aux/augeas-gentest.py | 72 +++++++++++++++++++++++++++++++++
src/Makefile.am | 3 +-
src/bhyve/Makefile.inc.am | 4 +-
src/interface/Makefile.inc.am | 2 +-
src/libxl/Makefile.inc.am | 4 +-
src/locking/Makefile.inc.am | 6 +--
src/logging/Makefile.inc.am | 2 +-
src/lxc/Makefile.inc.am | 4 +-
src/network/Makefile.inc.am | 2 +-
src/node_device/Makefile.inc.am | 2 +-
src/nwfilter/Makefile.inc.am | 2 +-
src/qemu/Makefile.inc.am | 4 +-
src/remote/Makefile.inc.am | 4 +-
src/secret/Makefile.inc.am | 2 +-
src/storage/Makefile.inc.am | 2 +-
src/vbox/Makefile.inc.am | 2 +-
src/vz/Makefile.inc.am | 2 +-
19 files changed, 97 insertions(+), 84 deletions(-)
delete mode 100755 build-aux/augeas-gentest.pl
create mode 100755 build-aux/augeas-gentest.py
diff --git a/Makefile.am b/Makefile.am
index 711f365504..17448a914e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,7 +41,7 @@ EXTRA_DIST =3D \
run.in \
README.md \
AUTHORS.in \
- build-aux/augeas-gentest.pl \
+ build-aux/augeas-gentest.py \
build-aux/check-spacing.pl \
build-aux/gitlog-to-changelog \
build-aux/header-ifdef.pl \
diff --git a/build-aux/augeas-gentest.pl b/build-aux/augeas-gentest.pl
deleted file mode 100755
index 65834b533b..0000000000
--- a/build-aux/augeas-gentest.pl
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env perl
-#
-# augeas-gentest.pl: Generate an augeas test file, from an
-# example config file + test file template
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-
-use strict;
-use warnings;
-
-die "syntax: $0 CONFIG TEMPLATE\n" unless @ARGV =3D=3D 2;
-
-my $config =3D shift @ARGV;
-my $template =3D shift @ARGV;
-
-open CONFIG, "<", $config or die "cannot read $config: $!";
-open TEMPLATE, "<", $template or die "cannot read $template: $!";
-
-my $group =3D 0;
-while () {
- if (/\@CONFIG\@/) {
- my $group =3D 0;
- print " let conf =3D \"";
- while () {
- if (/^#\w/) {
- s/^#//;
- s/\"/\\\"/g;
- print $_;
- $group =3D /\[\s$/;
- } elsif ($group) {
- s/\"/\\\"/g;
- if (/#\s*\]/) {
- $group =3D 0;
- }
- if (/^#/) {
- s/^#//;
- print $_;
- }
- }
- }
- print "\"\n";
- } else {
- print $_;
- }
-}
-
-close TEMPLATE;
-close CONFIG;
diff --git a/build-aux/augeas-gentest.py b/build-aux/augeas-gentest.py
new file mode 100755
index 0000000000..b7f343ef42
--- /dev/null
+++ b/build-aux/augeas-gentest.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012-2019 Red Hat, Inc.
+#
+# augeas-gentest.py: Generate an augeas test file, from an
+# example config file + test file template
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import sys
+
+if len(sys.argv) !=3D 3:
+ print("syntax: %s CONFIG TEMPLATE" % sys.argv[0], file=3Dsys.stderr)
+ sys.exit(1)
+
+config =3D sys.argv[1]
+template =3D sys.argv[2]
+
+def expand_config(config):
+ with open(config) as fh:
+ optprog =3D re.compile(r'''^#\w.*''')
+ groupstartprog =3D re.compile(r'''.*\[\s$''')
+ groupendprog =3D re.compile(r'''#\s*\].*$''')
+
+ group =3D False
+ for line in fh:
+ if optprog.match(line) is not None:
+ line =3D line[1:]
+ line =3D line.replace('"', '\\"')
+ print(line, end=3D'')
+ if groupstartprog.match(line):
+ group =3D True
+ elif group:
+ line =3D line.replace('"', '\\"')
+
+ if groupendprog.match(line):
+ group =3D False
+
+ if line[0] =3D=3D '#':
+ line =3D line[1:]
+ print(line, end=3D'')
+
+
+def expand_template(template, config):
+ with open(template) as fh:
+ group =3D 0
+
+ markerprog =3D re.compile(r'''\s*@CONFIG@\s*''')
+ for line in fh:
+ if markerprog.match(line) is not None:
+ print(' let conf =3D "', end=3D'')
+ expand_config(config)
+ print('"')
+ else:
+ print(line, end=3D'')
+
+expand_template(template, config)
diff --git a/src/Makefile.am b/src/Makefile.am
index f5093b9c90..7a4de2aa53 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -422,7 +422,8 @@ check-augeas: $(augeas_DATA) $(augeastest_DATA)
fi
.PHONY: check-augeas
=20
-AUG_GENTEST =3D $(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl
+AUG_GENTEST_SCRIPT =3D $(top_srcdir)/build-aux/augeas-gentest.py
+AUG_GENTEST =3D $(RUNUTF8) $(PYTHON) $(AUG_GENTEST_SCRIPT)
=20
=20
#
diff --git a/src/bhyve/Makefile.inc.am b/src/bhyve/Makefile.inc.am
index 195069872a..7e49a8bb5c 100644
--- a/src/bhyve/Makefile.inc.am
+++ b/src/bhyve/Makefile.inc.am
@@ -77,7 +77,7 @@ bhyve/virtbhyved.aug: remote/libvirtd.aug.in
$< > $@
=20
bhyve/test_virtbhyved.aug: remote/test_libvirtd.aug.in \
- bhyve/virtbhyved.conf $(AUG_GENTEST)
+ bhyve/virtbhyved.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) bhyve/virtbhyved.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
@@ -91,7 +91,7 @@ augeas_DATA +=3D bhyve/libvirtd_bhyve.aug
augeastest_DATA +=3D bhyve/test_libvirtd_bhyve.aug
=20
bhyve/test_libvirtd_bhyve.aug: bhyve/test_libvirtd_bhyve.aug.in \
- $(srcdir)/bhyve/bhyve.conf $(AUG_GENTEST)
+ $(srcdir)/bhyve/bhyve.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/bhyve/bhyve.conf $< > $@
=20
endif WITH_BHYVE
diff --git a/src/interface/Makefile.inc.am b/src/interface/Makefile.inc.am
index a88df0bd11..b042da4c57 100644
--- a/src/interface/Makefile.inc.am
+++ b/src/interface/Makefile.inc.am
@@ -95,7 +95,7 @@ interface/virtinterfaced.aug: remote/libvirtd.aug.in
$< > $@
=20
interface/test_virtinterfaced.aug: remote/test_libvirtd.aug.in \
- interface/virtinterfaced.conf $(AUG_GENTEST)
+ interface/virtinterfaced.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) interface/virtinterfaced.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/libxl/Makefile.inc.am b/src/libxl/Makefile.inc.am
index a2151162e6..617b2a9019 100644
--- a/src/libxl/Makefile.inc.am
+++ b/src/libxl/Makefile.inc.am
@@ -108,7 +108,7 @@ libxl/virtxend.aug: remote/libvirtd.aug.in
$< > $@
=20
libxl/test_virtxend.aug: remote/test_libvirtd.aug.in \
- libxl/virtxend.conf $(AUG_GENTEST)
+ libxl/virtxend.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) libxl/virtxend.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
@@ -122,7 +122,7 @@ augeas_DATA +=3D libxl/libvirtd_libxl.aug
augeastest_DATA +=3D libxl/test_libvirtd_libxl.aug
=20
libxl/test_libvirtd_libxl.aug: libxl/test_libvirtd_libxl.aug.in \
- $(srcdir)/libxl/libxl.conf $(AUG_GENTEST)
+ $(srcdir)/libxl/libxl.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/libxl/libxl.conf $< > $@
=20
INSTALL_DATA_DIRS +=3D libxl
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index fae92a6e45..df0c51aaf6 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -219,7 +219,7 @@ endif WITH_SANLOCK
if WITH_SANLOCK
if WITH_QEMU
locking/test_libvirt_sanlock.aug: locking/test_libvirt_sanlock.aug.in \
- locking/qemu-sanlock.conf $(AUG_GENTEST)
+ locking/qemu-sanlock.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-sanlock.conf $< > $@
=20
endif WITH_QEMU
@@ -227,12 +227,12 @@ endif WITH_SANLOCK
=20
if WITH_QEMU
locking/test_libvirt_lockd.aug: locking/test_libvirt_lockd.aug.in \
- locking/qemu-lockd.conf $(AUG_GENTEST)
+ locking/qemu-lockd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-lockd.conf $< > $@
endif WITH_QEMU
=20
locking/test_virtlockd.aug: locking/test_virtlockd.aug.in \
- locking/virtlockd.conf $(AUG_GENTEST)
+ locking/virtlockd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/locking/virtlockd.conf $< > $@
=20
endif WITH_LIBVIRTD
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index 7e441dbffb..ce777e278a 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -101,7 +101,7 @@ augeas_DATA +=3D logging/virtlogd.aug
augeastest_DATA +=3D logging/test_virtlogd.aug
=20
logging/test_virtlogd.aug: logging/test_virtlogd.aug.in \
- logging/virtlogd.conf $(AUG_GENTEST)
+ logging/virtlogd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/logging/virtlogd.conf $< > $@
=20
endif WITH_LIBVIRTD
diff --git a/src/lxc/Makefile.inc.am b/src/lxc/Makefile.inc.am
index b4d560702c..0e12800886 100644
--- a/src/lxc/Makefile.inc.am
+++ b/src/lxc/Makefile.inc.am
@@ -164,7 +164,7 @@ lxc/virtlxcd.aug: remote/libvirtd.aug.in
$< > $@
=20
lxc/test_virtlxcd.aug: remote/test_libvirtd.aug.in \
- lxc/virtlxcd.conf $(AUG_GENTEST)
+ lxc/virtlxcd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) lxc/virtlxcd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
@@ -222,7 +222,7 @@ augeas_DATA +=3D lxc/libvirtd_lxc.aug
augeastest_DATA +=3D lxc/test_libvirtd_lxc.aug
=20
lxc/test_libvirtd_lxc.aug: lxc/test_libvirtd_lxc.aug.in \
- $(srcdir)/lxc/lxc.conf $(AUG_GENTEST)
+ $(srcdir)/lxc/lxc.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/lxc/lxc.conf $< > $@
=20
INSTALL_DATA_DIRS +=3D lxc
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 9f20dad7b3..31e4b1fbe4 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -102,7 +102,7 @@ network/virtnetworkd.aug: remote/libvirtd.aug.in
$< > $@
=20
network/test_virtnetworkd.aug: remote/test_libvirtd.aug.in \
- network/virtnetworkd.conf $(AUG_GENTEST)
+ network/virtnetworkd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) network/virtnetworkd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/node_device/Makefile.inc.am b/src/node_device/Makefile.inc=
.am
index 5a6525d843..dfe16d62d6 100644
--- a/src/node_device/Makefile.inc.am
+++ b/src/node_device/Makefile.inc.am
@@ -118,7 +118,7 @@ node_device/virtnodedevd.aug: remote/libvirtd.aug.in
$< > $@
=20
node_device/test_virtnodedevd.aug: remote/test_libvirtd.aug.in \
- node_device/virtnodedevd.conf $(AUG_GENTEST)
+ node_device/virtnodedevd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) node_device/virtnodedevd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/nwfilter/Makefile.inc.am b/src/nwfilter/Makefile.inc.am
index 7693634e29..476768ef11 100644
--- a/src/nwfilter/Makefile.inc.am
+++ b/src/nwfilter/Makefile.inc.am
@@ -103,7 +103,7 @@ nwfilter/virtnwfilterd.aug: remote/libvirtd.aug.in
$< > $@
=20
nwfilter/test_virtnwfilterd.aug: remote/test_libvirtd.aug.in \
- nwfilter/virtnwfilterd.conf $(AUG_GENTEST)
+ nwfilter/virtnwfilterd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) nwfilter/virtnwfilterd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index d16b315ebc..caa79cae6a 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -165,7 +165,7 @@ qemu/virtqemud.aug: remote/libvirtd.aug.in
$< > $@
=20
qemu/test_virtqemud.aug: remote/test_libvirtd.aug.in \
- qemu/virtqemud.conf $(AUG_GENTEST)
+ qemu/virtqemud.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) qemu/virtqemud.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
@@ -180,7 +180,7 @@ augeas_DATA +=3D qemu/libvirtd_qemu.aug
augeastest_DATA +=3D qemu/test_libvirtd_qemu.aug
=20
qemu/test_libvirtd_qemu.aug: qemu/test_libvirtd_qemu.aug.in \
- $(srcdir)/qemu/qemu.conf $(AUG_GENTEST)
+ $(srcdir)/qemu/qemu.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/qemu/qemu.conf $< > $@
=20
INSTALL_DATA_DIRS +=3D qemu
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index abf04d998a..0c5e2fd376 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -285,7 +285,7 @@ remote/virtproxyd.aug: remote/libvirtd.aug.in
$< > $@
=20
remote/test_libvirtd.aug: remote/test_libvirtd.aug.in \
- remote/libvirtd.conf $(AUG_GENTEST)
+ remote/libvirtd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) remote/libvirtd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
@@ -298,7 +298,7 @@ remote/test_libvirtd.aug: remote/test_libvirtd.aug.in \
> $@ || rm -f $@
=20
remote/test_virtproxyd.aug: remote/test_libvirtd.aug.in \
- remote/virtproxyd.conf $(AUG_GENTEST)
+ remote/virtproxyd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) remote/virtproxyd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/secret/Makefile.inc.am b/src/secret/Makefile.inc.am
index 37f816406e..1e25993225 100644
--- a/src/secret/Makefile.inc.am
+++ b/src/secret/Makefile.inc.am
@@ -91,7 +91,7 @@ secret/virtsecretd.aug: remote/libvirtd.aug.in
$< > $@
=20
secret/test_virtsecretd.aug: remote/test_libvirtd.aug.in \
- secret/virtsecretd.conf $(AUG_GENTEST)
+ secret/virtsecretd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) secret/virtsecretd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am
index fd0d57d2b6..3542ee52e8 100644
--- a/src/storage/Makefile.inc.am
+++ b/src/storage/Makefile.inc.am
@@ -195,7 +195,7 @@ storage/virtstoraged.aug: remote/libvirtd.aug.in
$< > $@
=20
storage/test_virtstoraged.aug: remote/test_libvirtd.aug.in \
- storage/virtstoraged.conf $(AUG_GENTEST)
+ storage/virtstoraged.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) storage/virtstoraged.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/vbox/Makefile.inc.am b/src/vbox/Makefile.inc.am
index 178c360b99..1f2bcb5488 100644
--- a/src/vbox/Makefile.inc.am
+++ b/src/vbox/Makefile.inc.am
@@ -117,7 +117,7 @@ vbox/virtvboxd.aug: remote/libvirtd.aug.in
$< > $@
=20
vbox/test_virtvboxd.aug: remote/test_libvirtd.aug.in \
- vbox/virtvboxd.conf $(AUG_GENTEST)
+ vbox/virtvboxd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) vbox/virtvboxd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
diff --git a/src/vz/Makefile.inc.am b/src/vz/Makefile.inc.am
index f56fceb8f7..fa7b8b79dd 100644
--- a/src/vz/Makefile.inc.am
+++ b/src/vz/Makefile.inc.am
@@ -91,7 +91,7 @@ vz/virtvzd.aug: remote/libvirtd.aug.in
$< > $@
=20
vz/test_virtvzd.aug: remote/test_libvirtd.aug.in \
- vz/virtvzd.conf $(AUG_GENTEST)
+ vz/virtvzd.conf $(AUG_GENTEST_SCRIPT)
$(AM_V_GEN)$(AUG_GENTEST) vz/virtvzd.conf \
$(srcdir)/remote/test_libvirtd.aug.in | \
$(SED) \
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219307; cv=none;
d=zoho.com; s=zohoarc;
b=LbEW9/q+lKEkLPcdyAeESBGvJI9y7BVx6arSxYRWK2Bg8JRUphPZKf2oysA4JfkBr69omL7O8Fyk6q+ES1MStgFGefmfzxn0nk7NNE7spfFQvfYQt+5aAdc8OAJV0K8F9DoE5bB5sqWJR5Gwm0wwTDZp5VcH7bZ1jTIJo6HsYEo=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219307;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=ouf3bcfkE0m/YGWVLf3mpJkp01s3d8tv7SVdaoyYPKE=;
b=MdmHymKm5dXpwUIo6zhy0tOp6KbOgLaAoWLeQCjTorBdNQ//IBBP/t8yMLvbWv5ThewNUS+Vdk1G6QeC4vMkfWM5zTUWWOo+7EKPjMen1pOiciRNceSSnwOq2GtC53o1Rvv4+vH1hYmhl7LHUojkvKko7lx0xoBOpT2I8+pN3nk=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219307977246.86695845573297;
Wed, 11 Sep 2019 09:28:27 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id D84BD18CB8E3;
Wed, 11 Sep 2019 16:28: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 AD84A60625;
Wed, 11 Sep 2019 16:28: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 5DB66180BA9E;
Wed, 11 Sep 2019 16:28: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 x8BGSFQx013075 for ;
Wed, 11 Sep 2019 12:28:15 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 59B2A6012A; Wed, 11 Sep 2019 16:28:15 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id BDDFC601A5;
Wed, 11 Sep 2019 16:28:14 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:14 +0100
Message-Id: <20190911162333.8668-6-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 05/24] build-aux: rewrite po file minimizer in
Python
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-Type: text/plain; charset="utf-8"
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]);
Wed, 11 Sep 2019 16:28:26 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the minimize-po.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/minimize-po.pl | 37 -------------------------
build-aux/minimize-po.py | 60 ++++++++++++++++++++++++++++++++++++++++
po/Makefile.am | 2 +-
4 files changed, 62 insertions(+), 39 deletions(-)
delete mode 100755 build-aux/minimize-po.pl
create mode 100755 build-aux/minimize-po.py
diff --git a/Makefile.am b/Makefile.am
index 17448a914e..8f688d40d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -45,7 +45,7 @@ EXTRA_DIST =3D \
build-aux/check-spacing.pl \
build-aux/gitlog-to-changelog \
build-aux/header-ifdef.pl \
- build-aux/minimize-po.pl \
+ build-aux/minimize-po.py \
build-aux/mock-noinline.pl \
build-aux/prohibit-duplicate-header.pl \
build-aux/useless-if-before-free \
diff --git a/build-aux/minimize-po.pl b/build-aux/minimize-po.pl
deleted file mode 100755
index 497533a836..0000000000
--- a/build-aux/minimize-po.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-
-my @block;
-my $msgstr =3D 0;
-my $empty =3D 0;
-my $unused =3D 0;
-my $fuzzy =3D 0;
-while (<>) {
- if (/^$/) {
- if (!$empty && !$unused && !$fuzzy) {
- print @block;
- }
- @block =3D ();
- $msgstr =3D 0;
- $fuzzy =3D 0;
- push @block, $_;
- } else {
- if (/^msgstr/) {
- $msgstr =3D 1;
- $empty =3D 1;
- }
- if (/^#.*fuzzy/) {
- $fuzzy =3D 1;
- }
- if (/^#~ msgstr/) {
- $unused =3D 1;
- }
- if ($msgstr && /".+"/) {
- $empty =3D 0;
- }
- push @block, $_;
- }
-}
-
-if (@block && !$empty && !$unused) {
- print @block;
-}
diff --git a/build-aux/minimize-po.py b/build-aux/minimize-po.py
new file mode 100755
index 0000000000..5046bacede
--- /dev/null
+++ b/build-aux/minimize-po.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import sys
+
+block =3D []
+msgstr =3D False
+empty =3D False
+unused =3D False
+fuzzy =3D False
+
+strprog =3D re.compile(r'''.*".+".*''')
+
+for line in sys.stdin:
+ line =3D line.rstrip("\n")
+
+ if line =3D=3D "":
+ if not empty and not unused and not fuzzy:
+ for b in block:
+ print(b)
+
+ block =3D []
+ msgstr =3D False
+ fuzzy =3D False
+ block.append(line)
+ else:
+ if line.startswith("msgstr"):
+ msgstr =3D True
+ empty =3D True
+
+ if line[0] =3D=3D '#' and line.find("fuzzy") !=3D -1:
+ fuzzy =3D True
+ if line.startswith("#~ msgstr"):
+ unused =3D True
+ if msgstr and strprog.match(line):
+ empty =3D False
+
+ block.append(line)
+
+if not empty and not unused and not fuzzy:
+ for b in block:
+ print(b)
diff --git a/po/Makefile.am b/po/Makefile.am
index da117edbd5..90025b15dd 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ -58,7 +58,7 @@ update-mini-po: $(POTFILE)
$(MSGMERGE) --no-location --no-fuzzy-matching --sort-output \
$$lang.po $(POTFILE) | \
$(SED) $(SED_PO_FIXUP_ARGS) | \
- $(PERL) $(top_srcdir)/build-aux/minimize-po.pl > \
+ $(RUNUTF8) $(PYTHON) $(top_srcdir)/build-aux/minimize-po.py > \
$(srcdir)/$$lang.mini.po ; \
done
=20
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219307; cv=none;
d=zoho.com; s=zohoarc;
b=SFrzBU6qsKw+dpoWJUIDRkHzne/sTO8+eOzmQcwh262hktz1sMF+viBL1NgJygZftdszu14FV6lrTbGn03GYFR6vNzkRd+jvfOplmDmSyvU+3tWK4LyCcwwlXIwA9lBLeayhJvCZq7l+JmG4to806qasrjYXg8S9lxLnBUnPHIE=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219307;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=clmj4PSkokxhvTeVZ+VV4tLYsoLsqAYujAjk3olPWkQ=;
b=f5nNXYgNZ1uiwT1wLehptzLYcsxzGosDgMurJAxOu+5foFL08nws3fMb/d8OLO6rzN7hkONMXwm/T5qT5uqTfKTqAXj+nCB4eTaUo+QfQ7vlPqAD+MRr4gokBtJrluKWATWaW5PRahX2f4Dny+qDn4dfm9g9YreauZzU8h4VAAA=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219307643814.6725693757111;
Wed, 11 Sep 2019 09:28:27 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com
[10.5.11.23])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id C692F30821DF;
Wed, 11 Sep 2019 16:28: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 A0C4B19C77;
Wed, 11 Sep 2019 16:28: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 53308180BA9D;
Wed, 11 Sep 2019 16:28: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 x8BGSGTa013084 for ;
Wed, 11 Sep 2019 12:28:16 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 3B0F16017E; Wed, 11 Sep 2019 16:28:16 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 9F59860167;
Wed, 11 Sep 2019 16:28:15 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:15 +0100
Message-Id: <20190911162333.8668-7-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 06/24] build-aux: rewrite duplicate header
checker in Python
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-Type: text/plain; charset="utf-8"
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.23
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]);
Wed, 11 Sep 2019 16:28:26 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the prohibit-duplicate-header.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/prohibit-duplicate-header.pl | 26 -------------
build-aux/prohibit-duplicate-header.py | 54 ++++++++++++++++++++++++++
cfg.mk | 4 +-
4 files changed, 57 insertions(+), 29 deletions(-)
delete mode 100644 build-aux/prohibit-duplicate-header.pl
create mode 100644 build-aux/prohibit-duplicate-header.py
diff --git a/Makefile.am b/Makefile.am
index 8f688d40d0..a7d8da7146 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ EXTRA_DIST =3D \
build-aux/header-ifdef.pl \
build-aux/minimize-po.py \
build-aux/mock-noinline.pl \
- build-aux/prohibit-duplicate-header.pl \
+ build-aux/prohibit-duplicate-header.py \
build-aux/useless-if-before-free \
build-aux/vc-list-files \
ci/Makefile \
diff --git a/build-aux/prohibit-duplicate-header.pl b/build-aux/prohibit-du=
plicate-header.pl
deleted file mode 100644
index 4a2ea65665..0000000000
--- a/build-aux/prohibit-duplicate-header.pl
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-
-my $file =3D " ";
-my $ret =3D 0;
-my %includes =3D ( );
-my $lineno =3D 0;
-
-while (<>) {
- if (not $file eq $ARGV) {
- %includes =3D ( );
- $file =3D $ARGV;
- $lineno =3D 0;
- }
- $lineno++;
- if (/^# *include *[<"]([^>"]*\.h)[">]/) {
- $includes{$1}++;
- if ($includes{$1} =3D=3D 2) {
- $ret =3D 1;
- print STDERR "$ARGV:$lineno: $_";
- print STDERR "Do not include a header more than once per file\=
n";
- }
- }
-}
-exit $ret;
diff --git a/build-aux/prohibit-duplicate-header.py b/build-aux/prohibit-du=
plicate-header.py
new file mode 100644
index 0000000000..0ef86e8453
--- /dev/null
+++ b/build-aux/prohibit-duplicate-header.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import sys
+
+def check_file(filename):
+ includes =3D {}
+ lineno =3D 0
+ errs =3D False
+ with open(filename, "r") as fh:
+ headerprog =3D re.compile(r'''^# *include *[<"]([^>"]*\.h)[">]\s*$=
''')
+ for line in fh:
+ lineno =3D lineno + 1
+
+ headermatch =3D headerprog.match(line)
+ if headermatch is not None:
+ inc =3D headermatch.group(1)
+
+ if inc in includes:
+ print("%s:%d: %s" % (filename, lineno, inc), file=3Dsy=
s.stderr)
+ errs =3D True
+ else:
+ includes[inc] =3D True
+
+ return errs
+
+ret =3D 0
+
+for filename in sys.argv[1:]:
+ if check_file(filename):
+ ret =3D 1
+
+if ret =3D=3D 1:
+ print("Do not include a header more than once per file", file=3Dsys.st=
derr)
+
+sys.exit(ret)
diff --git a/cfg.mk b/cfg.mk
index d09ab507e0..933857bc2f 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1147,8 +1147,8 @@ endif
=20
# Don't include duplicate header in the source (either *.c or *.h)
prohibit-duplicate-header:
- $(AM_V_GEN)$(VC_LIST_EXCEPT) | $(GREP) '\.[chx]$$' | xargs \
- $(PERL) -W $(top_srcdir)/build-aux/prohibit-duplicate-header.pl
+ $(AM_V_GEN)$(VC_LIST_EXCEPT) | $(GREP) '\.[chx]$$' | $(RUNUTF8) xargs \
+ $(PYTHON) $(top_srcdir)/build-aux/prohibit-duplicate-header.py
=20
spacing-check:
$(AM_V_GEN)$(VC_LIST) | $(GREP) '\.c$$' | xargs \
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219311; cv=none;
d=zoho.com; s=zohoarc;
b=VeTYszQ8zFLHM+V+2xySk7Z3qOKkBL0zqEuUG7ffXHnWlutly1BfO34PC4QRy+4JO0/Hi9xE6U97Q6l9X+Rq9rJHipPSACRGwKslcpy6ViTwGYkUoSumDRnIa77WbPAjf8iceuoZVhglgYVLEOzp7kSi0I2+C3xGRXObkoztHKc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219311;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=AYjI7qznyw2/Hn5/ZmLod4bWAB4qkjRFVAR5sMJ57KI=;
b=lGO2h3a6LX6s8Yhcphzs4R/Y68O9qxruSna6F8MB0Vke746YH6A54imqigc5ZCual6CvOkSTq+CDtt6ILwwtAiimS3viVgDx7I7kZKQJTRMznpX5snRVd4qqUpBojH2S+xnKQZxLtaS4KSzSMzyJ0P5fIy5+pureIyOJHpAjdFw=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219311532360.52568209495416;
Wed, 11 Sep 2019 09:28:31 -0700 (PDT)
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 B969A7F75E;
Wed, 11 Sep 2019 16:28:29 +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 8D3A11001938;
Wed, 11 Sep 2019 16:28:29 +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 3D02124F36;
Wed, 11 Sep 2019 16:28:29 +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 x8BGSHvQ013096 for ;
Wed, 11 Sep 2019 12:28:17 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 3EC886012A; Wed, 11 Sep 2019 16:28:17 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 80A9B60167;
Wed, 11 Sep 2019 16:28:16 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:16 +0100
Message-Id: <20190911162333.8668-8-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 07/24] build-aux: rewrite whitespace checker in
Python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.71]);
Wed, 11 Sep 2019 16:28:30 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-spacing.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/check-spacing.pl | 198 -----------------------------------
build-aux/check-spacing.py | 204 +++++++++++++++++++++++++++++++++++++
cfg.mk | 4 +-
4 files changed, 207 insertions(+), 201 deletions(-)
delete mode 100755 build-aux/check-spacing.pl
create mode 100755 build-aux/check-spacing.py
diff --git a/Makefile.am b/Makefile.am
index a7d8da7146..03bf1beb78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,7 +42,7 @@ EXTRA_DIST =3D \
README.md \
AUTHORS.in \
build-aux/augeas-gentest.py \
- build-aux/check-spacing.pl \
+ build-aux/check-spacing.py \
build-aux/gitlog-to-changelog \
build-aux/header-ifdef.pl \
build-aux/minimize-po.py \
diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl
deleted file mode 100755
index 33377f3dd3..0000000000
--- a/build-aux/check-spacing.pl
+++ /dev/null
@@ -1,198 +0,0 @@
-#!/usr/bin/env perl
-#
-# check-spacing.pl: Report any usage of 'function (..args..)'
-# Also check for other syntax issues, such as correct use of ';'
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-
-use strict;
-use warnings;
-
-my $ret =3D 0;
-my $incomment =3D 0;
-
-foreach my $file (@ARGV) {
- # Per-file variables for multiline Curly Bracket (cb_) check
- my $cb_linenum =3D 0;
- my $cb_code =3D "";
- my $cb_scolon =3D 0;
-
- open FILE, $file;
-
- while (defined (my $line =3D )) {
- my $data =3D $line;
- # For temporary modifications
- my $tmpdata;
-
- # Kill any quoted , ; =3D or "
- $data =3D~ s/'[";,=3D]'/'X'/g;
-
- # Kill any quoted strings
- $data =3D~ s,"(?:[^\\\"]|\\.)*","XXX",g;
-
- next if $data =3D~ /^#/;
-
- # Kill contents of multi-line comments
- # and detect end of multi-line comments
- if ($incomment) {
- if ($data =3D~ m,\*/,) {
- $incomment =3D 0;
- $data =3D~ s,^.*\*/,*/,;
- } else {
- $data =3D "";
- }
- }
-
- # Kill single line comments, and detect
- # start of multi-line comments
- if ($data =3D~ m,/\*.*\*/,) {
- $data =3D~ s,/\*.*\*/,/* */,;
- } elsif ($data =3D~ m,/\*,) {
- $incomment =3D 1;
- $data =3D~ s,/\*.*,/*,;
- }
-
- # We need to match things like
- #
- # int foo (int bar, bool wizz);
- # foo (bar, wizz);
- #
- # but not match things like:
- #
- # typedef int (*foo)(bar wizz)
- #
- # we can't do this (efficiently) without
- # missing things like
- #
- # foo (*bar, wizz);
- #
- # We also don't want to spoil the $data so it can be used
- # later on.
- $tmpdata =3D $data;
- while ($tmpdata =3D~ /(\w+)\s\((?!\*)/) {
- my $kw =3D $1;
-
- # Allow space after keywords only
- if ($kw =3D~ /^(?:if|for|while|switch|return)$/) {
- $tmpdata =3D~ s/(?:$kw\s\()/XXX(/;
- } else {
- print "Whitespace after non-keyword:\n";
- print "$file:$.: $line";
- $ret =3D 1;
- last;
- }
- }
-
- # Require whitespace immediately after keywords
- if ($data =3D~ /\b(?:if|for|while|switch|return)\(/) {
- print "No whitespace after keyword:\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # Forbid whitespace between )( of a function typedef
- if ($data =3D~ /\(\*\w+\)\s+\(/) {
- print "Whitespace between ')' and '(':\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # Forbid whitespace following ( or prior to )
- # but allow whitespace before ) on a single line
- # (optionally followed by a semicolon)
- if (($data =3D~ /\s\)/ && not $data =3D~ /^\s+\);?$/) ||
- $data =3D~ /\((?!$)\s/) {
- print "Whitespace after '(' or before ')':\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # Forbid whitespace before ";" or ",". Things like below are allow=
ed:
- #
- # 1) The expression is empty for "for" loop. E.g.
- # for (i =3D 0; ; i++)
- #
- # 2) An empty statement. E.g.
- # while (write(statuswrite, &status, 1) =3D=3D -1 &&
- # errno =3D=3D EINTR)
- # ;
- #
- if ($data =3D~ /\s[;,]/) {
- unless ($data =3D~ /\S; ; / ||
- $data =3D~ /^\s+;/) {
- print "Whitespace before semicolon or comma:\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
- }
-
- # Require EOL, macro line continuation, or whitespace after ";".
- # Allow "for (;;)" as an exception.
- if ($data =3D~ /;[^ \\\n;)]/) {
- print "Invalid character after semicolon:\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # Require EOL, space, or enum/struct end after comma.
- if ($data =3D~ /,[^ \\\n)}]/) {
- print "Invalid character after comma:\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # Require spaces around assignment '=3D', compounds and '=3D=3D'
- if ($data =3D~ /[^ ]\b[!<>&|\-+*\/%\^=3D]?=3D/ ||
- $data =3D~ /=3D[^=3D \\\n]/) {
- print "Spacing around '=3D' or '=3D=3D':\n";
- print "$file:$.: $line";
- $ret =3D 1;
- }
-
- # One line conditional statements with one line bodies should
- # not use curly brackets.
- if ($data =3D~ /^\s*(if|while|for)\b.*\{$/) {
- $cb_linenum =3D $.;
- $cb_code =3D $line;
- $cb_scolon =3D 0;
- }
-
- # We need to check for exactly one semicolon inside the body,
- # because empty statements (e.g. with comment only) are
- # allowed
- if ($cb_linenum =3D=3D $. - 1 && $data =3D~ /^[^;]*;[^;]*$/) {
- $cb_code .=3D $line;
- $cb_scolon =3D 1;
- }
-
- if ($data =3D~ /^\s*}\s*$/ &&
- $cb_linenum =3D=3D $. - 2 &&
- $cb_scolon) {
-
- print "Curly brackets around single-line body:\n";
- print "$file:$cb_linenum-$.:\n$cb_code$line";
- $ret =3D 1;
-
- # There _should_ be no need to reset the values; but to
- # keep my inner peace...
- $cb_linenum =3D 0;
- $cb_scolon =3D 0;
- $cb_code =3D "";
- }
- }
- close FILE;
-}
-
-exit $ret;
diff --git a/build-aux/check-spacing.py b/build-aux/check-spacing.py
new file mode 100755
index 0000000000..ec565585ad
--- /dev/null
+++ b/build-aux/check-spacing.py
@@ -0,0 +1,204 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012-2019 Red Hat, Inc.
+#
+# check-spacing.pl: Report any usage of 'function (..args..)'
+# Also check for other syntax issues, such as correct use of ';'
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import sys
+
+def check_whitespace(filename):
+ errs =3D False
+ with open(filename, 'r') as fh:
+ quotedmetaprog =3D re.compile(r"""'[";,=3D]'""")
+ quotedstringprog =3D re.compile(r'''"(?:[^\\\"]|\\.)*"''')
+ commentstartprog =3D re.compile(r'''^(.*)/\*.*$''')
+ commentendprog =3D re.compile(r'''^.*\*/(.*)$''')
+ commentprog =3D re.compile(r'''^(.*)/\*.*\*/(.*)''')
+ funcprog =3D re.compile(r'''(\w+)\s\((?!\*)''')
+ keywordprog =3D re.compile(r'''^.*\b(?:if|for|while|switch|return)=
\(.*$''')
+ functypedefprog =3D re.compile(r'''^.*\(\*\w+\)\s+\(.*$''')
+ whitespaceprog1 =3D re.compile(r'''^.*\s\).*$''')
+ whitespaceprog2 =3D re.compile(r'''^\s+\);?$''')
+ whitespaceprog3 =3D re.compile(r'''^.*\((?!$)\s.*''')
+ commasemiprog1 =3D re.compile(r'''.*\s[;,].*''')
+ commasemiprog2 =3D re.compile(r'''.*\S; ; .*''')
+ commasemiprog3 =3D re.compile(r'''^\s+;''')
+ semicolonprog =3D re.compile(r'''.*;[^ \\\n;)].*''')
+ commaprog =3D re.compile(r'''.*,[^ \\\n)}].*''')
+ assignprog1 =3D re.compile(r'''[^ ]\b[!<>&|\-+*\/%\^=3D]?=3D''')
+ assignprog2 =3D re.compile(r'''=3D[^=3D \\\n]''')
+ condstartprog =3D re.compile(r'''^\s*(if|while|for)\b.*\{$''')
+ statementprog =3D re.compile(r'''^[^;]*;[^;]*$''')
+ condendprog =3D re.compile(r'''^\s*}\s*$''')
+
+ incomment =3D False
+ # Per-file variables for multiline Curly Bracket (cb_) check
+ cb_lineno =3D 0
+ cb_code =3D ""
+ cb_scolon =3D False
+
+ lineno =3D 0
+ for line in fh:
+ lineno =3D lineno + 1
+ data =3D line
+ # For temporary modifications
+
+ # Kill any quoted , ; =3D or "
+ data =3D quotedmetaprog.sub("'X'", data)
+
+ # Kill any quoted strings
+ data =3D quotedstringprog.sub('"XXX"', data)
+
+ if data[0] =3D=3D '#':
+ continue
+
+ # Kill contents of multi-line comments
+ # and detect end of multi-line comments
+ if incomment:
+ if commentendprog.match(data):
+ data =3D commentendprog.sub('*/\2', data)
+ incomment =3D False
+ else:
+ data =3D ""
+
+ # Kill single line comments, and detect
+ # start of multi-line comments
+ if commentprog.match(data):
+ data =3D commentprog.sub(r'''\1/* */\2''', data)
+ elif commentstartprog.match(data):
+ data =3D commentstartprog.sub(r'''\1/*''', data)
+ incomment =3D True
+
+ # We need to match things like
+ #
+ # int foo (int bar, bool wizz);
+ # foo (bar, wizz);
+ #
+ # but not match things like:
+ #
+ # typedef int (*foo)(bar wizz)
+ #
+ # we can't do this (efficiently) without
+ # missing things like
+ #
+ # foo (*bar, wizz);
+ #
+ for match in funcprog.finditer(data):
+ kw =3D match.group(1)
+
+ # Allow space after keywords only
+ if kw not in ["if", "for", "while", "switch", "return"]:
+ print("Whitespace after non-keyword:", file=3Dsys.stde=
rr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Ds=
ys.stderr)
+ errs =3D True
+ break
+
+ # Require whitespace immediately after keywords
+ if keywordprog.match(data):
+ print("No whitespace after keyword:", file=3Dsys.stderr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Forbid whitespace between )( of a function typedef
+ if functypedefprog.match(data):
+ print("Whitespace between ')' and '(':", file=3Dsys.stderr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Forbid whitespace following ( or prior to )
+ # but allow whitespace before ) on a single line
+ # (optionally followed by a semicolon)
+ if ((whitespaceprog1.match(data) and
+ not whitespaceprog2.match(data))
+ or whitespaceprog3.match(data)):
+ print("Whitespace after '(' or before ')':", file=3Dsys.st=
derr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Forbid whitespace before ";" or ",". Things like below are a=
llowed:
+ #
+ # 1) The expression is empty for "for" loop. E.g.
+ # for (i =3D 0; ; i++)
+ #
+ # 2) An empty statement. E.g.
+ # while (write(statuswrite, &status, 1) =3D=3D -1 &&
+ # errno =3D=3D EINTR)
+ # ;
+ #
+ if commasemiprog1.match(data) and not (
+ commasemiprog2.match(data) or
+ commasemiprog3.match(data)):
+ print("Whitespace before semicolon or comma:", file=3Dsys.=
stderr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Require EOL, macro line continuation, or whitespace after ";=
".
+ # Allow "for (;;)" as an exception.
+ if semicolonprog.match(data):
+ print("Invalid character after semicolon:", file=3Dsys.std=
err)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Require EOL, space, or enum/struct end after comma.
+ if commaprog.match(data):
+ print("Invalid character after comma:", file=3Dsys.stderr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # Require spaces around assignment '=3D', compounds and '=3D=
=3D'
+ if assignprog1.match(data) or assignprog2.match(data):
+ print("Spacing around '=3D' or '=3D=3D':", file=3Dsys.stde=
rr)
+ print("%s:%d: %s" % (filename, lineno, line), file=3Dsys.s=
tderr)
+ errs =3D True
+
+ # One line conditional statements with one line bodies should
+ # not use curly brackets.
+ if condstartprog.match(data):
+ cb_lineno =3D lineno
+ cb_code =3D line
+ cb_scolon =3D False
+
+ # We need to check for exactly one semicolon inside the body,
+ # because empty statements (e.g. with comment only) are
+ # allowed
+ if (cb_lineno =3D=3D lineno - 1) and statementprog.match(data):
+ cb_code =3D cb_code + line
+ cb_scolon =3D True
+
+ if condendprog.match(data) and (cb_lineno =3D=3D lineno - 2) a=
nd cb_scolon:
+ print("Curly brackets around single-line body:", file=3Dsy=
s.stderr)
+ print("%s:%d:\n%s%s"% (filename, cb_linenum - lineno, cb_c=
ode, line), file=3Dsys.stderr)
+ errs =3D True
+
+ # There _should_ be no need to reset the values; but to
+ # keep my inner peace...
+ cb_linenum =3D 0
+ cb_scolon =3D False
+ cb_code =3D ""
+
+ return errs
+
+ret =3D 0
+for filename in sys.argv[1:]:
+ if check_whitespace(filename):
+ ret =3D 1
+
+sys.exit(ret)
diff --git a/cfg.mk b/cfg.mk
index 933857bc2f..4da3554b30 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1151,8 +1151,8 @@ prohibit-duplicate-header:
$(PYTHON) $(top_srcdir)/build-aux/prohibit-duplicate-header.py
=20
spacing-check:
- $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.c$$' | xargs \
- $(PERL) $(top_srcdir)/build-aux/check-spacing.pl || \
+ $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.c$$' | $(RUNUTF8) xargs \
+ $(PYTHON) $(top_srcdir)/build-aux/check-spacing.py || \
{ echo '$(ME): incorrect formatting' 1>&2; exit 1; }
=20
mock-noinline:
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219306; cv=none;
d=zoho.com; s=zohoarc;
b=NHisDHa3H4ZqFtfmBYzY3H/Z/XWqbKruN3PZ41ZB6SFFslN9ajE7X2vhO3UyK369NwViJgOu4istHsGUhzU7/GrBhyulKBF8bU/rozRvRo2Anx5jK2idmFgbEgsnK0v8OT14Up6ZhOVBGipjd00NyQ3X6+4EL74k1Le+g3lcUE8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219306;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=xp5G16DiGWMbmo7lRmoqQxOaTVjzo5dDwLvg3w7PEvc=;
b=ZjdIV4xbX4laejBDhHrYsQA6Djt7aLRnunzEbVvFGGeM3izxt2WG/eA63yl6omwi2Ef5gaPGUbEhssjqE+3vAyYDff7JknSXqPWTwAGZreoYLs6slRpHeiG+TuECcd6QuM20HNn2aj/Nesy92o9bYMK4aZyLfeOXEtejfNf1F2c=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219306552101.94432587532333;
Wed, 11 Sep 2019 09:28:26 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id C3CCC8AC6FF;
Wed, 11 Sep 2019 16:28:24 +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 9939F60606;
Wed, 11 Sep 2019 16:28:24 +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 5ADCB180BA96;
Wed, 11 Sep 2019 16:28:24 +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 x8BGSICo013104 for ;
Wed, 11 Sep 2019 12:28:18 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 1F5936017E; Wed, 11 Sep 2019 16:28:18 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 847BA60167;
Wed, 11 Sep 2019 16:28:17 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:17 +0100
Message-Id: <20190911162333.8668-9-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 08/24] build-aux: rewrite mock inline checker
in Python
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-Type: text/plain; charset="utf-8"
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]);
Wed, 11 Sep 2019 16:28:25 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the mock-noinline.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/mock-noinline.pl | 75 --------------------------------
build-aux/mock-noinline.py | 88 ++++++++++++++++++++++++++++++++++++++
cfg.mk | 4 +-
4 files changed, 91 insertions(+), 78 deletions(-)
delete mode 100644 build-aux/mock-noinline.pl
create mode 100644 build-aux/mock-noinline.py
diff --git a/Makefile.am b/Makefile.am
index 03bf1beb78..db77da890c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,7 @@ EXTRA_DIST =3D \
build-aux/gitlog-to-changelog \
build-aux/header-ifdef.pl \
build-aux/minimize-po.py \
- build-aux/mock-noinline.pl \
+ build-aux/mock-noinline.py \
build-aux/prohibit-duplicate-header.py \
build-aux/useless-if-before-free \
build-aux/vc-list-files \
diff --git a/build-aux/mock-noinline.pl b/build-aux/mock-noinline.pl
deleted file mode 100644
index 958e133885..0000000000
--- a/build-aux/mock-noinline.pl
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env perl
-
-my %noninlined;
-my %mocked;
-
-# Functions in public header don't get the noinline annotation
-# so whitelist them here
-$noninlined{"virEventAddTimeout"} =3D 1;
-# This one confuses the script as its defined in the mock file
-# but is actually just a local helper
-$noninlined{"virMockStatRedirect"} =3D 1;
-
-foreach my $arg (@ARGV) {
- if ($arg =3D~ /\.h$/) {
- #print "Scan header $arg\n";
- &scan_annotations($arg);
- } elsif ($arg =3D~ /mock\.c$/) {
- #print "Scan mock $arg\n";
- &scan_overrides($arg);
- }
-}
-
-my $warned =3D 0;
-foreach my $func (keys %mocked) {
- next if exists $noninlined{$func};
-
- $warned++;
- print STDERR "$func is mocked at $mocked{$func} but missing noinline a=
nnotation\n";
-}
-
-exit $warned ? 1 : 0;
-
-
-sub scan_annotations {
- my $file =3D shift;
-
- open FH, $file or die "cannot read $file: $!";
-
- my $func;
- while () {
- if (/^\s*(\w+)\(/ || /^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(/) {
- my $name =3D $1;
- if ($name !~ /ATTRIBUTE/) {
- $func =3D $name;
- }
- } elsif (/^\s*$/) {
- $func =3D undef;
- }
- if (/ATTRIBUTE_NOINLINE/) {
- if (defined $func) {
- $noninlined{$func} =3D 1;
- }
- }
- }
-
- close FH
-}
-
-sub scan_overrides {
- my $file =3D shift;
-
- open FH, $file or die "cannot read $file: $!";
-
- my $func;
- while () {
- if (/^(\w+)\(/ || /^\w+\s*(?:\*\s*)?(\w+)\(/) {
- my $name =3D $1;
- if ($name =3D~ /^vir/) {
- $mocked{$name} =3D "$file:$.";
- }
- }
- }
-
- close FH
-}
diff --git a/build-aux/mock-noinline.py b/build-aux/mock-noinline.py
new file mode 100644
index 0000000000..fdc60c5de9
--- /dev/null
+++ b/build-aux/mock-noinline.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import sys
+
+noninlined =3D {}
+mocked =3D {}
+
+# Functions in public header don't get the noinline annotation
+# so whitelist them here
+noninlined["virEventAddTimeout"] =3D True
+# This one confuses the script as its defined in the mock file
+# but is actually just a local helper
+noninlined["virMockStatRedirect"] =3D True
+
+def scan_annotations(filename):
+ funcprog1 =3D re.compile(r'''^\s*(\w+)\(.*''')
+ funcprog2 =3D re.compile(r'''^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(.*''')
+ with open(filename, "r") as fh:
+ func =3D None
+ for line in fh:
+ line =3D line.strip()
+ m =3D funcprog1.match(line)
+ if m is None:
+ m =3D funcprog2.match(line)
+ if m is not None:
+ name =3D m.group(1)
+ if name.find("ATTRIBUTE") =3D=3D -1:
+ func =3D name
+ elif line =3D=3D "":
+ func =3D None
+
+ if line.find("ATTRIBUTE_NOINLINE") !=3D -1:
+ if func is not None:
+ noninlined[func] =3D True
+
+def scan_overrides(filename):
+ funcprog1 =3D re.compile(r'''^(\w+)\(.*''')
+ funcprog2 =3D re.compile(r'''^\w+\s*(?:\*\s*)?(\w+)\(.*''')
+ with open(filename, "r") as fh:
+ func =3D None
+ lineno =3D 0
+ for line in fh:
+ lineno =3D lineno + 1
+ #line =3D line.strip()
+
+ m =3D funcprog1.match(line)
+ if m is None:
+ m =3D funcprog2.match(line)
+ if m is not None:
+ name =3D m.group(1)
+ if name.startswith("vir"):
+ mocked[name] =3D "%s:%d" % (filename, lineno)
+
+
+for filename in sys.argv[1:]:
+ if filename.endswith(".h"):
+ scan_annotations(filename)
+ elif filename.endswith("mock.c"):
+ scan_overrides(filename)
+
+warned =3D False
+for func in mocked.keys():
+ if func not in noninlined:
+ warned =3D True
+ print("%s is mocked at %s but missing noinline annotation" % (func=
, mocked[func]), file=3Dsys.stderr)
+
+if warned:
+ sys.exit(1)
+sys.exit(0)
diff --git a/cfg.mk b/cfg.mk
index 4da3554b30..490e6b7f14 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1156,8 +1156,8 @@ spacing-check:
{ echo '$(ME): incorrect formatting' 1>&2; exit 1; }
=20
mock-noinline:
- $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[ch]$$' | xargs \
- $(PERL) $(top_srcdir)/build-aux/mock-noinline.pl
+ $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[ch]$$' | $(RUNUTF8) xargs \
+ $(PYTHON) $(top_srcdir)/build-aux/mock-noinline.py
=20
header-ifdef:
$(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[h]$$' | xargs \
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219315; cv=none;
d=zoho.com; s=zohoarc;
b=AVVrffl9Vrm8AfZLJxayf4D4+bez6iLmf0fjIV4Jhl9YWKEEso0LdzUxkbhy3fy5hg171dxk4xYt9tvxNq7Oko4OoCEFxHHv+/cSPfCdKre53g1BKGnGrM2zyunFl6yE99R+ZDjftjYF91pJtmznMe7IjiHJ8coacs62NADB2qM=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219315;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=XyoTZiVstd3byNk70l6v0ERNJsBISMB/g3cPDisWmB0=;
b=MroEHt9AzvIKpGUwwn69IkIYLhXEw3JtNgtkWGuiuK0LRTIZnt34d8tuu6FXOGQd8qKlhia0LnSLsOg7GZ3qWq6Q+Q66gjNg7F1g/+EDdAoXE0XN262IPWG96P8RRxY8Zs1OPU/Xb2DCPuL9TP3ODnxYi4n8HaGE3SEz8Bj0wnY=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219315713293.9721199686645;
Wed, 11 Sep 2019 09:28:35 -0700 (PDT)
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 0521F10C0932;
Wed, 11 Sep 2019 16:28:34 +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 8A7A15DD61;
Wed, 11 Sep 2019 16:28:33 +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 3D8DA180BAA3;
Wed, 11 Sep 2019 16:28:33 +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 x8BGSJw7013116 for ;
Wed, 11 Sep 2019 12:28:19 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 021DA601B3; Wed, 11 Sep 2019 16:28:19 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 654476012A;
Wed, 11 Sep 2019 16:28:18 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:18 +0100
Message-Id: <20190911162333.8668-10-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 09/24] build-aux: rewrite header ifdef checker
in Python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.66]);
Wed, 11 Sep 2019 16:28:34 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the header-ifdef.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
Makefile.am | 2 +-
build-aux/header-ifdef.pl | 182 ---------------------------------
build-aux/header-ifdef.py | 206 ++++++++++++++++++++++++++++++++++++++
cfg.mk | 4 +-
4 files changed, 209 insertions(+), 185 deletions(-)
delete mode 100644 build-aux/header-ifdef.pl
create mode 100644 build-aux/header-ifdef.py
diff --git a/Makefile.am b/Makefile.am
index db77da890c..4ba729d3f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@ EXTRA_DIST =3D \
build-aux/augeas-gentest.py \
build-aux/check-spacing.py \
build-aux/gitlog-to-changelog \
- build-aux/header-ifdef.pl \
+ build-aux/header-ifdef.py \
build-aux/minimize-po.py \
build-aux/mock-noinline.py \
build-aux/prohibit-duplicate-header.py \
diff --git a/build-aux/header-ifdef.pl b/build-aux/header-ifdef.pl
deleted file mode 100644
index dba3dbcbdc..0000000000
--- a/build-aux/header-ifdef.pl
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/perl
-#
-# Validate that header files follow a standard layout:
-#
-# /*
-# ...copyright header...
-# */
-#
-# #pragma once
-# ....content....
-#
-#---
-#
-# For any file ending priv.h, before the #pragma once
-# We will have a further section
-#
-# #ifndef SYMBOL_ALLOW
-# # error ....
-# #endif /* SYMBOL_ALLOW */
-#
-#
-#---
-#
-# For public headers (files in include/), use the standard header guard in=
stead of #pragma once:
-# #ifndef SYMBOL
-# # define SYMBOL
-# ....content....
-# #endif /* SYMBOL */
-
-use strict;
-use warnings;
-
-my $STATE_COPYRIGHT_COMMENT =3D 0;
-my $STATE_COPYRIGHT_BLANK =3D 1;
-my $STATE_PRIV_START =3D 2;
-my $STATE_PRIV_ERROR =3D 3;
-my $STATE_PRIV_END =3D 4;
-my $STATE_PRIV_BLANK =3D 5;
-my $STATE_GUARD_START =3D 6;
-my $STATE_GUARD_DEFINE =3D 7;
-my $STATE_GUARD_END =3D 8;
-my $STATE_EOF =3D 9;
-my $STATE_PRAGMA =3D 10;
-
-my $file =3D " ";
-my $ret =3D 0;
-my $ifdef =3D "";
-my $ifdefpriv =3D "";
-my $publicheader =3D 0;
-
-my $state =3D $STATE_EOF;
-my $mistake =3D 0;
-
-sub mistake {
- my $msg =3D shift;
- warn $msg;
- $mistake =3D 1;
- $ret =3D 1;
-}
-
-while (<>) {
- if (not $file eq $ARGV) {
- if ($state =3D=3D $STATE_COPYRIGHT_COMMENT) {
- &mistake("$file: missing copyright comment");
- } elsif ($state =3D=3D $STATE_COPYRIGHT_BLANK) {
- &mistake("$file: missing blank line after copyright header");
- } elsif ($state =3D=3D $STATE_PRIV_START) {
- &mistake("$file: missing '#ifndef $ifdefpriv'");
- } elsif ($state =3D=3D $STATE_PRIV_ERROR) {
- &mistake("$file: missing '# error ...priv allow...'");
- } elsif ($state =3D=3D $STATE_PRIV_END) {
- &mistake("$file: missing '#endif /* $ifdefpriv */'");
- } elsif ($state =3D=3D $STATE_PRIV_BLANK) {
- &mistake("$file: missing blank line after priv header check");
- } elsif ($state =3D=3D $STATE_GUARD_START) {
- if ($publicheader) {
- &mistake("$file: missing '#ifndef $ifdef'");
- } else {
- &mistake("$file: missing '#pragma once' header guard");
- }
- } elsif ($state =3D=3D $STATE_GUARD_DEFINE) {
- &mistake("$file: missing '# define $ifdef'");
- } elsif ($state =3D=3D $STATE_GUARD_END) {
- &mistake("$file: missing '#endif /* $ifdef */'");
- }
-
- $ifdef =3D uc $ARGV;
- $ifdef =3D~ s,.*/,,;
- $ifdef =3D~ s,[^A-Z0-9],_,g;
- $ifdef =3D~ s,__+,_,g;
- unless ($ifdef =3D~ /^LIBVIRT_/ && $ARGV !~ /libvirt_internal.h/) {
- $ifdef =3D "LIBVIRT_" . $ifdef;
- }
- $ifdefpriv =3D $ifdef . "_ALLOW";
-
- $file =3D $ARGV;
- $state =3D $STATE_COPYRIGHT_COMMENT;
- $mistake =3D 0;
- $publicheader =3D ($ARGV =3D~ /include\//);
- }
-
- if ($mistake ||
- $ARGV =3D~ /config-post\.h$/ ||
- $ARGV =3D~ /vbox_(CAPI|XPCOM)/) {
- $state =3D $STATE_EOF;
- next;
- }
-
- if ($state =3D=3D $STATE_COPYRIGHT_COMMENT) {
- if (m,\*/,) {
- $state =3D $STATE_COPYRIGHT_BLANK;
- }
- } elsif ($state =3D=3D $STATE_COPYRIGHT_BLANK) {
- if (! /^$/) {
- &mistake("$file: missing blank line after copyright header");
- }
- if ($ARGV =3D~ /priv\.h$/) {
- $state =3D $STATE_PRIV_START;
- } else {
- $state =3D $STATE_GUARD_START;
- }
- } elsif ($state =3D=3D $STATE_PRIV_START) {
- if (/^$/) {
- &mistake("$file: too many blank lines after copyright header");
- } elsif (/#ifndef $ifdefpriv$/) {
- $state =3D $STATE_PRIV_ERROR;
- } else {
- &mistake("$file: missing '#ifndef $ifdefpriv'");
- }
- } elsif ($state =3D=3D $STATE_PRIV_ERROR) {
- if (/# error ".*"$/) {
- $state =3D $STATE_PRIV_END;
- } else {
- &mistake("$file: missing '# error ...priv allow...'");
- }
- } elsif ($state =3D=3D $STATE_PRIV_END) {
- if (m,#endif /\* $ifdefpriv \*/,) {
- $state =3D $STATE_PRIV_BLANK;
- } else {
- &mistake("$file: missing '#endif /* $ifdefpriv */'");
- }
- } elsif ($state =3D=3D $STATE_PRIV_BLANK) {
- if (! /^$/) {
- &mistake("$file: missing blank line after priv guard");
- }
- $state =3D $STATE_GUARD_START;
- } elsif ($state =3D=3D $STATE_GUARD_START) {
- if (/^$/) {
- &mistake("$file: too many blank lines after copyright header");
- }
- if ($publicheader) {
- if (/#ifndef $ifdef$/) {
- $state =3D $STATE_GUARD_DEFINE;
- } else {
- &mistake("$file: missing '#ifndef $ifdef'");
- }
- } else {
- if (/#pragma once/) {
- $state =3D $STATE_PRAGMA;
- } else {
- &mistake("$file: missing '#pragma once' header guard");
- }
- }
- } elsif ($state =3D=3D $STATE_GUARD_DEFINE) {
- if (/# define $ifdef$/) {
- $state =3D $STATE_GUARD_END;
- } else {
- &mistake("$file: missing '# define $ifdef'");
- }
- } elsif ($state =3D=3D $STATE_GUARD_END) {
- if (m,#endif /\* $ifdef \*/$,) {
- $state =3D $STATE_EOF;
- }
- } elsif ($state =3D=3D $STATE_PRAGMA) {
- next;
- } elsif ($state =3D=3D $STATE_EOF) {
- die "$file: unexpected content after '#endif /* $ifdef */'";
- } else {
- die "$file: unexpected state $state";
- }
-}
-exit $ret;
diff --git a/build-aux/header-ifdef.py b/build-aux/header-ifdef.py
new file mode 100644
index 0000000000..86c4781a7e
--- /dev/null
+++ b/build-aux/header-ifdef.py
@@ -0,0 +1,206 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+# Validate that header files follow a standard layout:
+#
+# /*
+# ...copyright header...
+# */
+#
+# #pragma once
+# ....content....
+#
+#---
+#
+# For any file ending priv.h, before the #pragma once
+# We will have a further section
+#
+# #ifndef SYMBOL_ALLOW
+# # error ....
+# #endif /* SYMBOL_ALLOW */
+#
+#
+#---
+#
+# For public headers (files in include/), use the standard header guard in=
stead of #pragma once:
+# #ifndef SYMBOL
+# # define SYMBOL
+# ....content....
+# #endif /* SYMBOL */
+
+from __future__ import print_function
+
+import os.path
+import re
+import sys
+
+STATE_COPYRIGHT_COMMENT =3D 0
+STATE_COPYRIGHT_BLANK =3D 1
+STATE_PRIV_START =3D 2
+STATE_PRIV_ERROR =3D 3
+STATE_PRIV_END =3D 4
+STATE_PRIV_BLANK =3D 5
+STATE_GUARD_START =3D 6
+STATE_GUARD_DEFINE =3D 7
+STATE_GUARD_END =3D 8
+STATE_EOF =3D 9
+STATE_PRAGMA =3D 10
+
+def check_header(filename):
+ ifdef =3D ""
+ ifdefpriv =3D ""
+
+ state =3D STATE_EOF
+
+ ifdef =3D os.path.basename(filename).upper()
+ ifdef =3D re.sub(r"""[^A-Z0-9]""", "_", ifdef)
+ ifdef =3D re.sub(r"""__+""", "_", ifdef)
+
+ if not ifdef.startswith("LIBVIRT_") or filename.find("libvirt_internal=
.h") !=3D -1:
+ ifdef =3D "LIBVIRT_" + ifdef
+
+ ifdefpriv =3D ifdef + "_ALLOW"
+
+ state =3D STATE_COPYRIGHT_COMMENT
+ publicheader =3D False
+ if filename.find("include/") !=3D -1:
+ publicheader =3D True
+
+ with open(filename, "r") as fh:
+ for line in fh:
+ line =3D line.rstrip("\n")
+ if state =3D=3D STATE_COPYRIGHT_COMMENT:
+ if line.find("*/") !=3D -1:
+ state =3D STATE_COPYRIGHT_BLANK
+ elif state =3D=3D STATE_COPYRIGHT_BLANK:
+ if line !=3D "":
+ print("%s: missing blank line after copyright header" =
% filename, file=3Dsys.stderr)
+ return True
+
+ if filename.endswith("priv.h"):
+ state =3D STATE_PRIV_START
+ else:
+ state =3D STATE_GUARD_START
+ elif state =3D=3D STATE_PRIV_START:
+ if line =3D=3D "":
+ print("%s: too many blank lines after copyright header=
" % filename, file=3Dsys.stderr)
+ return True
+ elif re.match(r"""#ifndef %s$""" % ifdefpriv, line):
+ state =3D STATE_PRIV_ERROR
+ else:
+ print("%s: missing '#ifndef %s'" % (filename, ifdefpri=
v), file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_ERROR:
+ if re.match(r"""# error ".*"$""", line):
+ state =3D STATE_PRIV_END
+ else:
+ print("%s: missing '# error ...priv allow...'" % filen=
ame, file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_END:
+ if re.match(r"""#endif /\* %s \*/""" % ifdefpriv, line):
+ state =3D STATE_PRIV_BLANK
+ else:
+ print("%s: missing '#endif /* %s */'" % (filename, ifd=
efpriv), file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_BLANK:
+ if line !=3D "":
+ print("%s: missing blank line after priv guard" % file=
name, file=3Dsys.stderr)
+ return True
+ state =3D STATE_GUARD_START
+ elif state =3D=3D STATE_GUARD_START:
+ if line =3D=3D "":
+ print("%s: too many blank lines after copyright header=
" % filename, file=3Dsys.stderr)
+ return True
+ if publicheader:
+ if re.match(r"""#ifndef %s$""" % ifdef, line):
+ state =3D STATE_GUARD_DEFINE
+ else:
+ print("%s: missing '#ifndef %s'" % (filename, ifde=
f), file=3Dsys.stderr)
+ return True
+ else:
+ if re.match(r"""#pragma once""", line):
+ state =3D STATE_PRAGMA
+ else:
+ print("%s: missing '#pragma once' header guard" % =
filename, file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_GUARD_DEFINE:
+ if re.match(r"""# define %s$""" % ifdef, line):
+ state =3D STATE_GUARD_END
+ else:
+ print("%s: missing '# define %s'" % (filename, ifdef),=
file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_GUARD_END:
+ if re.match(r"""#endif /\* %s \*/$""" % ifdef, line):
+ state =3D STATE_EOF
+ elif state =3D=3D STATE_PRAGMA:
+ next
+ elif state =3D=3D STATE_EOF:
+ print("%s: unexpected content after '#endif /* %s */'" % (=
filename, ifdef), file=3Dsys.stderr)
+ return True
+ else:
+ print("%s: unexpected state $state" % filename, file=3Dsys=
.stderr)
+ return True
+
+
+ if state =3D=3D STATE_COPYRIGHT_COMMENT:
+ print("%s: missing copyright comment" % filename, file=3Dsys.stder=
r)
+ return True
+ elif state =3D=3D STATE_COPYRIGHT_BLANK:
+ print("%s: missing blank line after copyright header" % filename, =
file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_START:
+ print("%s: missing '#ifndef %s'" % (filename, ifdefpriv), file=3Ds=
ys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_ERROR:
+ print("%s: missing '# error ...priv allow...'" % filename, file=3D=
sys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_END:
+ print("%s: missing '#endif /* %s */'" % (filename, ifdefpriv), fil=
e=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_PRIV_BLANK:
+ print("%s: missing blank line after priv header check" % filename,=
file=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_GUARD_START:
+ if publicheader:
+ print("%s: missing '#ifndef %s'" % (filename, ifdef), file=3Ds=
ys.stderr)
+ return True
+ else:
+ print("%s: missing '#pragma once' header guard" % filename, fi=
le=3Dsys.stderr)
+ return True
+ elif state =3D=3D STATE_GUARD_DEFINE:
+ print("%s: missing '# define %s'" % (filename, ifdef), file=3Dsys.=
stderr)
+ return True
+ elif state =3D=3D STATE_GUARD_END:
+ print("%s: missing '#endif /* %s */'" % (filename, ifdef), file=3D=
sys.stderr)
+ return True
+
+ return False
+
+ret =3D 0
+
+for filename in sys.argv[1:]:
+ if filename.find("config-post.h") !=3D -1:
+ continue
+ if filename.find("vbox_CAPI") !=3D -1:
+ continue
+ if filename.find("vbox_XPCOM") !=3D -1:
+ continue
+ if check_header(filename):
+ ret =3D 1
+
+sys.exit(ret)
diff --git a/cfg.mk b/cfg.mk
index 490e6b7f14..3e63fee9ff 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1160,8 +1160,8 @@ mock-noinline:
$(PYTHON) $(top_srcdir)/build-aux/mock-noinline.py
=20
header-ifdef:
- $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[h]$$' | xargs \
- $(PERL) $(top_srcdir)/build-aux/header-ifdef.pl
+ $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[h]$$' | $(RUNUTF8) xargs \
+ $(PYTHON) $(top_srcdir)/build-aux/header-ifdef.py
=20
test-wrap-argv:
$(AM_V_GEN)$(VC_LIST) | $(GREP) -E '\.(ldargs|args)' | xargs \
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219320; cv=none;
d=zoho.com; s=zohoarc;
b=Zbl/vVTUaIxK6ZmDOWTvxnhqJH5aZ9VpEY+EhgDH6s2Xh4Mg6t1Qilt00ww0ljBkMAqPej8bljoV2MZeoXcQH2wnlbudbiu2CKX3+480+3fveMxB10X65HnjvN2rGN+igidWbw+vK+600tamCN+bxLWFYpyYMFff2HNL9E//JzI=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219320;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=Ewtqrwk8kN7C708wZbdDStPqgE58A5/yMfblbcUo2dc=;
b=CFJnUeFyHioLGhGFCjB2QrfjuN0AZ6dL+AjNGfNCi2+xwFJX5nx2Hq3z/u+zBOYylyisJvzeAthMAX8X10CjGpjv8DgnmWazrh8htnoGE+GD8awzI6Rc9Ynf959hbZVndSpX7QkFjUg1rrp2ssRJwXlR9+Xy3C+c10B44MYI2EI=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219320277874.650471334086;
Wed, 11 Sep 2019 09:28:40 -0700 (PDT)
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 6BE4C10CC209;
Wed, 11 Sep 2019 16:28: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 43D956017E;
Wed, 11 Sep 2019 16:28:37 +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 00535180BAA5;
Wed, 11 Sep 2019 16:28:36 +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 x8BGSJpM013121 for ;
Wed, 11 Sep 2019 12:28:19 -0400
Received: by smtp.corp.redhat.com (Postfix)
id D6E1C601A5; Wed, 11 Sep 2019 16:28:19 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 4748C6012A;
Wed, 11 Sep 2019 16:28:19 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:19 +0100
Message-Id: <20190911162333.8668-11-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 10/24] src: rewrite ACL permissions checker in
Python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.65]);
Wed, 11 Sep 2019 16:28:37 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-aclperms.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 4 +--
src/check-aclperms.pl | 73 ----------------------------------------
src/check-aclperms.py | 77 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 75 deletions(-)
delete mode 100755 src/check-aclperms.pl
create mode 100755 src/check-aclperms.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a4de2aa53..c441525b7d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -359,11 +359,11 @@ check-aclrules:
$(addprefix $(srcdir)/,$(filter-out /%,$(STATEFUL_DRIVER_SOURCE_FILES)))
=20
check-aclperms:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-aclperms.pl \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-aclperms.py \
$(srcdir)/access/viraccessperm.h \
$(srcdir)/access/viraccessperm.c
=20
-EXTRA_DIST +=3D check-driverimpls.pl check-aclrules.pl check-aclperms.pl
+EXTRA_DIST +=3D check-driverimpls.pl check-aclrules.pl check-aclperms.py
=20
check-local: check-protocol check-symfile check-symsorting \
check-drivername check-driverimpls check-aclrules \
diff --git a/src/check-aclperms.pl b/src/check-aclperms.pl
deleted file mode 100755
index 55b6598313..0000000000
--- a/src/check-aclperms.pl
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-# This script just validates that the stringified version of
-# a virAccessPerm enum matches the enum constant name. We do
-# a lot of auto-generation of code, so when these don't match
-# problems occur, preventing auth from succeeding at all.
-
-my $hdr =3D shift;
-my $impl =3D shift;
-
-my %perms;
-
-my @perms;
-
-open HDR, $hdr or die "cannot read $hdr: $!";
-
-while () {
- if (/^\s+VIR_ACCESS_PERM_([_A-Z]+)(,?|\s|$)/) {
- my $perm =3D $1;
-
- $perms{$perm} =3D 1 unless ($perm =3D~ /_LAST$/);
- }
-}
-
-close HDR;
-
-
-open IMPL, $impl or die "cannot read $impl: $!";
-
-my $group;
-my $warned =3D 0;
-
-while (defined (my $line =3D )) {
- if ($line =3D~ /VIR_ACCESS_PERM_([_A-Z]+)_LAST/) {
- $group =3D $1;
- } elsif ($line =3D~ /"[_a-z]+"/) {
- my @bits =3D split /,/, $line;
- foreach my $bit (@bits) {
- if ($bit =3D~ /"([_a-z]+)"/) {
- my $perm =3D uc($group . "_" . $1);
- if (!exists $perms{$perm}) {
- print STDERR "Unknown perm string $1 for group $group\=
n";
- $warned =3D 1;
- }
- delete $perms{$perm};
- }
- }
- }
-}
-close IMPL;
-
-foreach my $perm (keys %perms) {
- print STDERR "Perm $perm had not string form\n";
- $warned =3D 1;
-}
-
-exit $warned;
diff --git a/src/check-aclperms.py b/src/check-aclperms.py
new file mode 100755
index 0000000000..ace6ab6757
--- /dev/null
+++ b/src/check-aclperms.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2013-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+# This script just validates that the stringified version of
+# a virAccessPerm enum matches the enum constant name. We do
+# a lot of auto-generation of code, so when these don't match
+# problems occur, preventing auth from succeeding at all.
+
+from __future__ import print_function
+
+import re
+import sys
+
+if len(sys.argv) !=3D 3:
+ print("syntax: %s HEADER IMPL" % (sys.argv[0]), file=3Dsys.stderr)
+ sys.exit(1)
+
+hdr =3D sys.argv[1]
+impl =3D sys.argv[2]
+
+perms =3D {}
+
+with open(hdr) as fh:
+ symprog =3D re.compile(r"^\s+VIR_ACCESS_PERM_([_A-Z]+)(,?|\s|$).*")
+ for line in fh:
+ symmatch =3D symprog.match(line)
+ if symmatch is not None:
+ perm =3D symmatch.group(1)
+
+ if not perm.endswith("_LAST"):
+ perms[perm] =3D 1
+
+warned =3D False
+
+with open(impl) as fh:
+ group =3D None
+ symlastprog =3D re.compile(r".*VIR_ACCESS_PERM_([_A-Z]+)_LAST.*")
+ alnumprog =3D re.compile(r'''.*"([_a-z]+)".*''')
+
+ for line in fh:
+ symlastmatch =3D symlastprog.match(line)
+ if symlastmatch is not None:
+ group =3D symlastmatch.group(1)
+ elif alnumprog.match(line) is not None:
+ bits =3D line.split(",")
+ for bit in bits:
+ m =3D alnumprog.match(bit)
+ if m is not None:
+ perm =3D (group + "_" + m.group(1)).upper()
+ if perm not in perms:
+ print("Unknown perm string %s for group %s" % (m.g=
roup(1), group), file=3Dsys.stderr)
+ warned =3D True
+
+ del perms[perm]
+
+for perm in perms.keys():
+ print("Perm %s had not string form" % perm, file=3Dsys.stderr)
+ warned =3D True
+
+if warned:
+ sys.exit(1)
+sys.exit(0)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219311; cv=none;
d=zoho.com; s=zohoarc;
b=hUY3qvHkTWpxonQlKxtcCVEqjhxLGiAxjnDp1myGJfLcWYlV/YXQUkHfuZtW41ZEHY0KzzVxKvu0VejyDCmISMmkd2poQMkSLIISEN+8VJTs3YF2tORHbVuAZz04DSMaXggxknXmzq1ALa2ji/SmHlrS1kzGKAcpt8A+xLwjFsA=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219311;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=HkomV1rOKZwLOwmudSx9AAa1a4Nnz9xdIVzZ8KpP1ts=;
b=LnygIzWOKIQouE+qa6CWvwpJHyyL1hCuxzFmP9zxpRz6LGzPRJLcJRab10A+KOMUcvvJxHVklWQGjyf84v5SDGZRqIZBTu1Vdt/9mmDXDqIMdadi8kXFzKevapw8mtERCZFWIHDOFRWwDbzoDrcoU2x7T48ASZ6IW02wTLGK5ds=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219311573732.4364274821613;
Wed, 11 Sep 2019 09:28:31 -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 A70CE10C0931;
Wed, 11 Sep 2019 16:28:29 +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 76DE95C258;
Wed, 11 Sep 2019 16:28:29 +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 2993F24F39;
Wed, 11 Sep 2019 16:28:29 +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 x8BGSKPF013130 for ;
Wed, 11 Sep 2019 12:28:20 -0400
Received: by smtp.corp.redhat.com (Postfix)
id B73006012A; Wed, 11 Sep 2019 16:28:20 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 2886E601A5;
Wed, 11 Sep 2019 16:28:20 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:20 +0100
Message-Id: <20190911162333.8668-12-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 11/24] src: rewrite symfile sorting checker in
Python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.66]);
Wed, 11 Sep 2019 16:28:30 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-symsorting.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 6 +--
src/check-symsorting.pl | 106 -------------------------------------
src/check-symsorting.py | 112 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+), 109 deletions(-)
delete mode 100755 src/check-symsorting.pl
create mode 100755 src/check-symsorting.py
diff --git a/src/Makefile.am b/src/Makefile.am
index c441525b7d..4bdd16af22 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -285,12 +285,12 @@ check-symfile:
check-admin-symfile:
endif ! WITH_LINUX
check-symsorting:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-symsorting.py \
$(srcdir) $(SYM_FILES)
check-admin-symsorting:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-symsorting.py \
$(srcdir) $(ADMIN_SYM_FILES)
-EXTRA_DIST +=3D check-symfile.pl check-symsorting.pl
+EXTRA_DIST +=3D check-symfile.pl check-symsorting.py
=20
# Keep this list synced with RPC_PROBE_FILES
PROTOCOL_STRUCTS =3D \
diff --git a/src/check-symsorting.pl b/src/check-symsorting.pl
deleted file mode 100755
index 51e38bdedb..0000000000
--- a/src/check-symsorting.pl
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env perl
-
-# Copyright (C) 2012-2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-
-use strict;
-use warnings;
-
-die "syntax: $0 SRCDIR SYMFILE..." unless int(@ARGV) >=3D 2;
-
-my $ret =3D 0;
-my $srcdir =3D shift;
-my $lastgroup =3D undef;
-foreach my $symfile (@ARGV) {
- open SYMFILE, $symfile or die "cannot read $symfile: $!";
-
- my $line =3D 0;
- my $groupfile =3D "";
- my @group;
-
- while () {
- chomp;
-
- if (/^#\s*((\w+\/)*(\w+\.h))\s*$/) {
- $groupfile =3D $1;
- } elsif (/^#/) {
- # Ignore comments
- } elsif (/^\s*$/) {
- if (@group) {
- &check_sorting(\@group, $symfile, $line, $groupfile);
- }
- @group =3D ();
- $line =3D $.;
- } else {
- $_ =3D~ s/;//;
- push @group, $_;
- }
- }
-
- close SYMFILE;
- if (@group) {
- &check_sorting(\@group, $symfile, $line, $groupfile);
- }
- $lastgroup =3D undef;
-}
-
-sub check_sorting {
- my $group =3D shift;
- my $symfile =3D shift;
- my $line =3D shift;
- my $groupfile =3D shift;
-
- my @group =3D @{$group};
- my @sorted =3D sort { lc $a cmp lc $b } @group;
- my $sorted =3D 1;
- my $first;
- my $last;
-
- # Check that groups are in order and groupfile exists
- if (defined $lastgroup && lc $lastgroup ge lc $groupfile) {
- print "Symbol block at $symfile:$line: block not sorted\n";
- print "Move $groupfile block before $lastgroup block\n";
- print "\n";
- $ret =3D 1;
- }
- if (! -e "$srcdir/$groupfile") {
- print "Symbol block at $symfile:$line: $groupfile not found\n";
- print "\n";
- $ret =3D 1;
- }
- $lastgroup =3D $groupfile;
-
- # Check that symbols within a group are in order
- for (my $i =3D 0 ; $i <=3D $#sorted ; $i++) {
- if ($sorted[$i] ne $group[$i]) {
- $first =3D $i unless defined $first;
- $last =3D $i;
- $sorted =3D 0;
- }
- }
- if (!$sorted) {
- @group =3D splice @group, $first, ($last-$first+1);
- @sorted =3D splice @sorted, $first, ($last-$first+1);
- print "Symbol block at $symfile:$line: symbols not sorted\n";
- print map { " " . $_ . "\n" } @group;
- print "Correct ordering\n";
- print map { " " . $_ . "\n" } @sorted;
- print "\n";
- $ret =3D 1;
- }
-}
-
-exit $ret;
diff --git a/src/check-symsorting.py b/src/check-symsorting.py
new file mode 100755
index 0000000000..a1d16a4c43
--- /dev/null
+++ b/src/check-symsorting.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2012-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import os.path
+import re
+import sys
+
+if len(sys.argv) < 3:
+ print("syntax: %s SRCDIR SYMFILE..." % sys.argv[0], file=3Dsys.stderr)
+ sys.exit(1)
+
+def check_sorting(group, symfile, line, groupfile, lastgroup):
+ sortedgroup =3D sorted(group, key=3Dstr.lower)
+ issorted =3D True
+ first =3D None
+ last =3D None
+
+ err =3D False
+ # Check that groups are in order and groupfile exists
+ if lastgroup is not None and lastgroup.lower() > groupfile.lower():
+ print("Symbol block at %s:%s: block not sorted" % (symfile, line),=
file=3Dsys.stderr)
+ print("Move %s block before %s block" % (groupfile, lastgroup), fi=
le=3Dsys.stderr)
+ print("", file=3Dsys.stderr)
+ err =3D True
+
+ if not os.path.exists(os.path.join(srcdir, groupfile)):
+ print("Symbol block at %s:%s: %s not found" % (symfile, line, grou=
pfile), file=3Dsys.stderr)
+ print("", file=3Dsys.stderr)
+ err =3D True
+
+ # Check that symbols within a group are in order
+ for i in range(len(group)):
+ if sortedgroup[i] !=3D group[i]:
+ if first is None:
+ first =3D i
+
+ last =3D i
+ issorted =3D False
+
+ if not issorted:
+ actual =3D group[first:(last-first+1)]
+ expect =3D sortedgroup[first:(last-first+1)]
+ print("Symbol block at %s:%s: symbols not sorted" % (symfile, line=
), file=3Dsys.stderr)
+ for g in actual:
+ print(" %s" % g, file=3Dsys.stderr)
+ print("Correct ordering", file=3Dsys.stderr)
+ for g in expect:
+ print(" %s" % g, file=3Dsys.stderr)
+ print("", file=3Dsys.stderr)
+ err =3D True
+
+ return err
+
+
+ret =3D 0
+srcdir =3D sys.argv[1]
+lastgroup =3D None
+for symfile in sys.argv[2:]:
+ with open(symfile, "r") as fh:
+ lineno =3D 0
+ groupfile =3D ""
+ group =3D []
+ thisline =3D 0
+
+ filenameprog =3D re.compile(r'''^#\s*((\w+\/)*(\w+\.h))\s*$''')
+
+ for line in fh:
+ thisline =3D thisline + 1
+ line =3D line.strip()
+
+ filenamematch =3D filenameprog.match(line)
+ if filenamematch is not None:
+ groupfile =3D filenamematch.group(1)
+ elif line =3D=3D "":
+ if len(group) > 0:
+ if check_sorting(group, symfile, lineno, groupfile, la=
stgroup):
+ ret =3D 1
+
+ group =3D []
+ lineno =3D thisline
+ lastgroup =3D groupfile
+ elif line[0] =3D=3D '#':
+ # Ignore comments
+ pass
+ else:
+ line =3D line.strip(";")
+ group.append(line)
+
+ if len(group) > 0:
+ if check_sorting(group, symfile, lineno, groupfile, lastgroup):
+ ret =3D 1
+
+ lastgroup =3D None
+
+sys.exit(ret)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219323; cv=none;
d=zoho.com; s=zohoarc;
b=QKxZG3OPVcU7hHVVpUa7bjdN8mpY9+3mp9RYCFTMejWb/YTCg5MCqC4Ym3F1iJ6qv4FgzLc9jQJ7aFC0TL59i+DODUIqtP0yVu6Rd2DJ3hjOxeJr0xIm/4m2ZSg1omabj63MQ2omEvTNEULZv/b0xrKq3CXgId/zUzaOssox/d0=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219323;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=5TwPzFeiyAFzyh+2ZlgemWayWN4hN9bNAXJKUoIdNzA=;
b=GIWAJJhyJ6XAcvewA8miogm/uFFpiqnvbyY+sa1Cw0srq0Qk5ZHCnGFi4gt2cgfn/+8nbVYVp32s+acKaqHtxEdkmYGsVxWMSLgbORcRF+tfU2wxdnTLrjJ3MObNr7Dv3FX3Fe6EyT11OkYroDRXUtgmhtP8qHhWiijyIuVTfVM=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219323127566.3663973972822;
Wed, 11 Sep 2019 09:28:43 -0700 (PDT)
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 2F5B8A371AD;
Wed, 11 Sep 2019 16:28:41 +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 0B08E1F9;
Wed, 11 Sep 2019 16:28:41 +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 C339E249B0;
Wed, 11 Sep 2019 16:28:40 +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 x8BGSLIZ013145 for ;
Wed, 11 Sep 2019 12:28:21 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 9890E6012A; Wed, 11 Sep 2019 16:28:21 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 08AE96017E;
Wed, 11 Sep 2019 16:28:20 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:21 +0100
Message-Id: <20190911162333.8668-13-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 12/24] src: rewrite symfile library checker in
Python
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-Type: text/plain; charset="utf-8"
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.6.2 (mx1.redhat.com [10.5.110.68]);
Wed, 11 Sep 2019 16:28:42 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-symfile.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 10 +++---
src/check-symfile.pl | 70 --------------------------------------
src/check-symfile.py | 80 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 75 deletions(-)
delete mode 100755 src/check-symfile.pl
create mode 100755 src/check-symfile.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 4bdd16af22..a145f69140 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -275,11 +275,11 @@ PDWTAGS =3D \
# rule for libvirt.la. However, checking symbols relies on Linux ELF layo=
ut
if WITH_LINUX
check-symfile: libvirt.syms libvirt.la
- $(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt.syms \
- .libs/libvirt.so
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-symfile.py \
+ libvirt.syms .libs/libvirt.so
check-admin-symfile: libvirt_admin.syms libvirt-admin.la
- $(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt_admin.syms \
- .libs/libvirt-admin.so
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-symfile.py \
+ libvirt_admin.syms .libs/libvirt-admin.so
else ! WITH_LINUX
check-symfile:
check-admin-symfile:
@@ -290,7 +290,7 @@ check-symsorting:
check-admin-symsorting:
$(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-symsorting.py \
$(srcdir) $(ADMIN_SYM_FILES)
-EXTRA_DIST +=3D check-symfile.pl check-symsorting.py
+EXTRA_DIST +=3D check-symfile.py check-symsorting.py
=20
# Keep this list synced with RPC_PROBE_FILES
PROTOCOL_STRUCTS =3D \
diff --git a/src/check-symfile.pl b/src/check-symfile.pl
deleted file mode 100755
index 4f88300864..0000000000
--- a/src/check-symfile.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env perl
-
-# Copyright (C) 2012-2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-
-die "syntax: $0 SYMFILE ELFLIB(S)" unless int(@ARGV) >=3D 2;
-
-my $symfile =3D shift @ARGV;
-my @elflibs =3D @ARGV;
-
-my %wantsyms;
-my %gotsyms;
-
-my $ret =3D 0;
-
-open SYMFILE, $symfile or die "cannot read $symfile: $!";
-
-while () {
- next if /{/;
- next if /}/;
- next if /global:/;
- next if /local:/;
- next if /^\s*$/;
- next if /^\s*#/;
- next if /\*/;
-
- die "malformed line $_" unless /^\s*(\S+);$/;
-
- if (exists $wantsyms{$1}) {
- print STDERR "Symbol $1 is listed twice\n";
- $ret =3D 1;
- } else {
- $wantsyms{$1} =3D 1;
- }
-}
-close SYMFILE;
-
-foreach my $elflib (@elflibs) {
- open NM, "-|", "nm", $elflib or die "cannot run 'nm $elflib': $!";
-
- while () {
- next unless /^\S+\s(?:[TBD])\s(\S+)\s*$/;
-
- $gotsyms{$1} =3D 1;
- }
-
- close NM;
-}
-
-foreach my $sym (keys(%wantsyms)) {
- next if exists $gotsyms{$sym};
-
- print STDERR "Expected symbol $sym is not in ELF library\n";
- $ret =3D 1;
-}
-
-exit($ret);
diff --git a/src/check-symfile.py b/src/check-symfile.py
new file mode 100755
index 0000000000..3154619bfe
--- /dev/null
+++ b/src/check-symfile.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+
+from __future__ import print_function
+
+import re
+import subprocess
+import sys
+
+if len(sys.argv) < 3:
+ print("syntax: %s SYMFILE ELFLIB(S)" % sys.argv[0], file=3Dsys.stderr)
+
+symfile =3D sys.argv[1]
+elflibs =3D sys.argv[2:]
+
+wantsyms =3D {}
+gotsyms =3D {}
+
+ret =3D 0
+
+with open(symfile, "r") as fh:
+ for line in fh:
+ line =3D line.strip()
+ if line.find("{") !=3D -1:
+ continue
+ if line.find("}") !=3D -1:
+ continue
+ if line in ["global:", "local:"]:
+ continue
+ if line =3D=3D "":
+ continue
+ if line[0] =3D=3D '#':
+ continue
+ if line.find("*") !=3D -1:
+ continue
+
+ line =3D line.strip(";")
+
+ if line in wantsyms:
+ print("Symbol $1 is listed twice", file=3Dsys.stderr)
+ ret =3D 1
+ else:
+ wantsyms[line] =3D True
+
+for elflib in elflibs:
+ nm =3D subprocess.Popen(["nm", elflib], shell=3DFalse, stdout=3Dsubpro=
cess.PIPE).stdout
+
+ symprog =3D re.compile(r'''^\S+\s(?:[TBD])\s(\S+)\s*$''')
+ for line in nm:
+ line =3D line.decode("utf-8")
+ symmatch =3D symprog.match(line)
+ if symmatch is None:
+ continue
+
+ gotsyms[symmatch.group(1)] =3D True
+
+
+for sym in wantsyms.keys():
+ if sym in gotsyms:
+ continue
+
+ print("Expected symbol '%s' is not in ELF library" % sym, file=3Dsys.s=
tderr)
+ ret =3D 1
+
+sys.exit(ret)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219310; cv=none;
d=zoho.com; s=zohoarc;
b=Exu2TD28PrYjsKnZz4q7V1G1XEa/wG3/EC12+Mz7Ow9G76aj2hdTJ0rIk5wlOY2nb/usKQj4160zVTWRTSKrixZipk/U75to/a1PnCxFdsw2zJ3+TjtrtLYmQISJ2bWkY5K7pdp6+7henSXt2Zo1y6TI3GVFHGI5DV7uiPXymhg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219310;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=jZcPI/CU8B2ZE/yZFRTPfGmap46W3G+n4LealSAIBXE=;
b=I1ybQiYfLs0l53JQ5HN3Vi0Ma/T4DpzdnmDXqP7wnRhQoQOSu3xkidwDZKdilUGv0yiCz3A/bSSvGkXAEt/prgO1etpV/cm1dwdw7VuiY5d6P9+s/IqAoToa+WWfWzO4DnwQJhfF9GItpqbFYY8qhLUCqwnqku/InmDZ/aBGxtQ=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219310696100.23271838242272;
Wed, 11 Sep 2019 09:28:30 -0700 (PDT)
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 F186D30983DF;
Wed, 11 Sep 2019 16:28:28 +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 C02186013A;
Wed, 11 Sep 2019 16:28:28 +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 7625D24F35;
Wed, 11 Sep 2019 16:28:28 +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 x8BGSMqx013152 for ;
Wed, 11 Sep 2019 12:28:22 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 7A7026012A; Wed, 11 Sep 2019 16:28:22 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id DEFC0601A5;
Wed, 11 Sep 2019 16:28:21 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:22 +0100
Message-Id: <20190911162333.8668-14-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 13/24] src: rewrite systemtap probe generator
in Python
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-Type: text/plain; charset="utf-8"
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.42]);
Wed, 11 Sep 2019 16:28:29 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the dtrace2systemtap.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 9 ++-
src/dtrace2systemtap.pl | 130 -------------------------------------
src/dtrace2systemtap.py | 140 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 135 deletions(-)
delete mode 100755 src/dtrace2systemtap.pl
create mode 100755 src/dtrace2systemtap.py
diff --git a/src/Makefile.am b/src/Makefile.am
index a145f69140..8b046cafe4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -605,7 +605,6 @@ nodist_libvirt_la_SOURCES =3D libvirt_probes.h
if WITH_REMOTE
nodist_libvirt_driver_remote_la_SOURCES =3D libvirt_probes.h
endif WITH_REMOTE
-DTRACE2SYSTEMTAP_FLAGS =3D --with-modules
=20
BUILT_SOURCES +=3D libvirt_probes.h libvirt_probes.stp libvirt_functions.s=
tp
=20
@@ -640,10 +639,10 @@ RPC_PROBE_FILES +=3D $(srcdir)/rpc/virnetprotocol.x \
libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.pl
$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gensystemtap.pl $(RPC_PROBE_FILES) > =
$@
=20
-%_probes.stp: %_probes.d $(srcdir)/dtrace2systemtap.pl \
+%_probes.stp: %_probes.d $(srcdir)/dtrace2systemtap.py \
$(top_builddir)/config.status
- $(AM_V_GEN)$(PERL) -w $(srcdir)/dtrace2systemtap.pl \
- $(DTRACE2SYSTEMTAP_FLAGS) $(bindir) $(sbindir) $(libdir) $< > $@
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/dtrace2systemtap.py \
+ $(bindir) $(sbindir) $(libdir) $< > $@
=20
CLEANFILES +=3D libvirt_probes.h libvirt_probes.o libvirt_probes.lo \
libvirt_functions.stp libvirt_probes.stp
@@ -764,7 +763,7 @@ endif LIBVIRT_INIT_SCRIPT_SYSTEMD
endif WITH_LIBVIRTD
=20
=20
-EXTRA_DIST +=3D dtrace2systemtap.pl
+EXTRA_DIST +=3D dtrace2systemtap.py
=20
=20
if WITH_LIBVIRTD
diff --git a/src/dtrace2systemtap.pl b/src/dtrace2systemtap.pl
deleted file mode 100755
index c5fce248b4..0000000000
--- a/src/dtrace2systemtap.pl
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2011-2012 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-#
-# Generate a set of systemtap probe definitions corresponding to
-# DTrace probe markers in libvirt.so
-#
-# perl dtrace2systemtap.pl probes.d > libvirt_probes.stp
-#
-
-use strict;
-use warnings;
-
-my $file;
-my @files;
-my %files;
-
-my $with_modules =3D 0;
-if ($ARGV[0] eq "--with-modules") {
- # set if we want to honor the "module" setting in the .d file
- $with_modules =3D 1;
- shift @ARGV;
-}
-
-my $bindir =3D shift @ARGV;
-my $sbindir =3D shift @ARGV;
-my $libdir =3D shift @ARGV;
-
-my $probe;
-my $args;
-
-# Read the DTraceprobes definition
-while (<>) {
- next if m,^\s*$,;
-
- next if /^\s*provider\s+\w+\s*{\s*$/;
- next if /^\s*};\s*$/;
-
- if (m,^\s*\#,) {
- if (m,^\s*\#\s*file:\s*(\S+)\s*$,) {
- $file =3D $1;
- push @files, $file;
- $files{$file} =3D { prefix =3D> undef, probes =3D> [] };
- } elsif (m,^\s*\#\s*prefix:\s*(\S+)\s*$,) {
- $files{$file}->{prefix} =3D $1;
- } elsif (m,^\s*\#\s*binary:\s*(\S+)\s*$,) {
- $files{$file}->{binary} =3D $1;
- } elsif (m,^\s*\#\s*module:\s*(\S+)\s*$,) {
- $files{$file}->{module} =3D $1;
- } else {
- # ignore unknown comments
- }
- } else {
- if (m,\s*probe\s+([a-zA-Z0-9_]+)\((.*?)(\);)?$,) {
- $probe =3D $1;
- $args =3D $2;
- if ($3) {
- push @{$files{$file}->{probes}}, [$probe, $args];
- $probe =3D $args =3D undef;
- }
- } elsif ($probe) {
- if (m,^(.*?)(\);)?$,) {
- $args .=3D $1;
- if ($2) {
- push @{$files{$file}->{probes}}, [$probe, $args];
- $probe =3D $args =3D undef;
- }
- } else {
- die "unexpected data $_ on line $.";
- }
- } else {
- die "unexpected data $_ on line $.";
- }
- }
-}
-
-# Write out the SystemTap probes
-foreach my $file (@files) {
- my $prefix =3D $files{$file}->{prefix};
- my @probes =3D @{$files{$file}->{probes}};
-
- print "# $file\n\n";
- foreach my $probe (@probes) {
- my $name =3D $probe->[0];
- my $args =3D $probe->[1];
-
- my $pname =3D $name;
- $pname =3D~ s/${prefix}_/libvirt.$prefix./;
-
- my $binary =3D "$libdir/libvirt.so";
- if (exists $files{$file}->{binary}) {
- $binary =3D $sbindir . "/" . $files{$file}->{binary};
- }
- if ($with_modules && exists $files{$file}->{module}) {
- $binary =3D $libdir . "/" . $files{$file}->{module};
- }
-
- print "probe $pname =3D process(\"$binary\").mark(\"$name\") {\n";
-
- my @args =3D split /,/, $args;
- for (my $i =3D 0 ; $i <=3D $#args ; $i++) {
- my $arg =3D $args[$i];
- my $isstr =3D $arg =3D~ /char\s+\*/;
- $arg =3D~ s/^.*\s\*?(\S+)$/$1/;
-
- if ($isstr) {
- print " $arg =3D user_string(\$arg", $i + 1, ");\n";
- } else {
- print " $arg =3D \$arg", $i + 1, ";\n";
- }
- }
- print "}\n\n";
- }
- print "\n";
-}
diff --git a/src/dtrace2systemtap.py b/src/dtrace2systemtap.py
new file mode 100755
index 0000000000..9dc9aaf9e5
--- /dev/null
+++ b/src/dtrace2systemtap.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2011-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+#
+# Generate a set of systemtap probe definitions corresponding to
+# DTrace probe markers in libvirt.so
+#
+# python dtrace2systemtap.py probes.d > libvirt_probes.stp
+#
+
+from __future__ import print_function
+
+import re
+import sys
+
+file =3D None
+filelist =3D []
+files =3D {}
+
+bindir =3D sys.argv[1]
+sbindir =3D sys.argv[2]
+libdir =3D sys.argv[3]
+dtrace =3D sys.argv[4]
+
+probe =3D None
+args =3D None
+
+# Read the DTraceprobes definition
+
+with open(dtrace, "r") as fh:
+ lineno =3D 0
+ for line in fh:
+ lineno =3D lineno + 1
+ line =3D line.strip()
+ if line =3D=3D "":
+ continue
+ if line.find("provider ") !=3D -1 and line.find("{") !=3D -1:
+ continue
+ if line.find("};") !=3D -1:
+ continue
+
+ if line.startswith("#"):
+ m =3D re.match(r'''^\#\s*file:\s*(\S+)$''', line)
+ if m is not None:
+ file =3D m.group(1)
+ filelist.append(file)
+ files[file] =3D { "prefix": None, "probes": [] }
+ continue
+
+ m =3D re.match(r'''^\#\s*prefix:\s*(\S+)$''', line)
+ if m is not None:
+ files[file]["prefix"] =3D m.group(1)
+ continue
+
+ m =3D re.match(r'''^\#\s*binary:\s*(\S+)$''', line)
+ if m is not None:
+ files[file]["binary"] =3D m.group(1)
+ continue
+
+ m =3D re.match(r'''^\#\s*module:\s*(\S+)$''', line)
+ if m is not None:
+ files[file]["module"] =3D m.group(1)
+
+ # ignore unknown comments
+ else:
+ m =3D re.match(r'''probe\s+([a-zA-Z0-9_]+)\((.*?)(\);)?$''', l=
ine)
+ if m is not None:
+ probe =3D m.group(1)
+ args =3D m.group(2)
+ if m.group(3) is not None:
+ files[file]["probes"].append([probe, args])
+ probe =3D None
+ args =3D None
+ elif probe is not None:
+ m =3D re.match(r'''^(.*?)(\);)?$''', line)
+ if m is not None:
+ args =3D args + m.group(1)
+ if m.group(2) is not None:
+ files[file]["probes"].append([probe, args])
+ probe =3D None
+ args =3D None
+ else:
+ raise Exception("unexpected data %s on line %d" % (lin=
e, lineno))
+ else:
+ raise Exception("unexpected data %s on line %d" % (line, l=
ineno))
+
+# Write out the SystemTap probes
+for file in filelist:
+ prefix =3D files[file]["prefix"]
+ probes =3D files[file]["probes"]
+
+ print("# %s\n" % file)
+ for probe in probes:
+ name =3D probe[0]
+ args =3D probe[1]
+
+ pname =3D name.replace(prefix + "_", "libvirt." + prefix + ".")
+
+ binary =3D libdir + "/libvirt.so"
+ if "binary" in files[file]:
+ binary =3D sbindir + "/" + files[file]["binary"]
+ if "module" in files[file]:
+ binary =3D libdir + "/" + files[file]["module"]
+
+ print("probe %s =3D process(\"%s\").mark(\"%s\") {" % (pname, bina=
ry, name))
+
+ argbits =3D args.split(",")
+ for idx in range(len(argbits)):
+ arg =3D argbits[idx]
+ isstr =3D False
+ if arg.find("char *") !=3D -1:
+ isstr =3D True
+
+ m =3D re.match(r'''^.*\s\*?(\S+)$''', arg)
+ if m is not None:
+ arg =3D m.group(1)
+ else:
+ raise Exception("Malformed arg %s" % arg)
+
+ if isstr:
+ print(" %s =3D user_string($arg%d);" % (arg, idx + 1))
+ else:
+ print(" %s =3D $arg%d;" % (arg, idx + 1))
+ print("}\n")
+ print("")
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219315; cv=none;
d=zoho.com; s=zohoarc;
b=Frsa4k9RM+DpnfkG3VoU5urj+y52GXDp+IX6a7TKX7Y2/rKsmhearIk0rTNs/c5+9xsmw/vuXBlsueaOgbVvVTy35dsvwZ3fQdH4Yep7VT0Swm1Q33U7VGul8PdeifcydI5iY57YA917vJdiWJXiDN1Uv1AsA950VTJ94suwOP8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219315;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=/2aDAgp2p+UN4rNHQpVHuE5WncxU9l9zOCCAvXjXSuo=;
b=XwZQX1mzWDx01iG+AOxaBw00ve5zO0bgcgpM2Q7pNWssEw02Gjsjma4WeEM9IVEzOt7+uEUDc8wl8gbUFNUnt6VvdiAJs9Y5CR2ZZVM/T8yaqnWfVDs7IkIkYcB6UFHEC3zwmUXVYg5WkuyzsK+ms6LwqI5nVkCkIRokyLvd+o8=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219315524292.1782594875432;
Wed, 11 Sep 2019 09:28:35 -0700 (PDT)
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 9AA9B2D6A0B;
Wed, 11 Sep 2019 16:28:33 +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 6CA43100194E;
Wed, 11 Sep 2019 16:28:33 +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 2C406180BAA1;
Wed, 11 Sep 2019 16:28:33 +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 x8BGSNM6013165 for ;
Wed, 11 Sep 2019 12:28:23 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 5D244601A5; Wed, 11 Sep 2019 16:28:23 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id BFF8F6017E;
Wed, 11 Sep 2019 16:28:22 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:23 +0100
Message-Id: <20190911162333.8668-15-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 14/24] src: rewrite systemtap function
generator in Python
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-Type: text/plain; charset="utf-8"
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.29]);
Wed, 11 Sep 2019 16:28:34 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the gensystemtap.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
cfg.mk | 4 +-
src/Makefile.am | 5 +-
src/rpc/Makefile.inc.am | 2 +-
src/rpc/gensystemtap.pl | 193 ----------------------------------------
src/rpc/gensystemtap.py | 174 ++++++++++++++++++++++++++++++++++++
5 files changed, 179 insertions(+), 199 deletions(-)
delete mode 100755 src/rpc/gensystemtap.pl
create mode 100755 src/rpc/gensystemtap.py
diff --git a/cfg.mk b/cfg.mk
index 3e63fee9ff..45b16ee8c3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -407,6 +407,7 @@ sc_prohibit_risky_id_promotion:
# since gnulib has more guarantees for snprintf portability
sc_prohibit_sprintf:
@prohibit=3D'\<[s]printf\>' \
+ in_vc_files=3D'\.[ch]$$' \
halt=3D'use snprintf, not sprintf' \
$(_sc_search_regexp)
=20
@@ -1267,9 +1268,6 @@ exclude_file_name_regexp--sc_prohibit_readlink =3D \
=20
exclude_file_name_regexp--sc_prohibit_setuid =3D ^src/util/virutil\.c|tool=
s/virt-login-shell\.c$$
=20
-exclude_file_name_regexp--sc_prohibit_sprintf =3D \
- ^(cfg\.mk|docs/hacking\.html\.in|.*\.stp|.*\.pl)$$
-
exclude_file_name_regexp--sc_prohibit_strncpy =3D ^src/util/virstring\.c$$
=20
exclude_file_name_regexp--sc_prohibit_strtol =3D ^examples/.*$$
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b046cafe4..539d8b0f58 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -636,8 +636,9 @@ RPC_PROBE_FILES +=3D $(srcdir)/rpc/virnetprotocol.x \
$(srcdir)/remote/qemu_protocol.x \
$(srcdir)/admin/admin_protocol.x
=20
-libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.pl
- $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gensystemtap.pl $(RPC_PROBE_FILES) > =
$@
+libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.py
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/rpc/gensystemtap.py \
+ $(RPC_PROBE_FILES) > $@
=20
%_probes.stp: %_probes.d $(srcdir)/dtrace2systemtap.py \
$(top_builddir)/config.status
diff --git a/src/rpc/Makefile.inc.am b/src/rpc/Makefile.inc.am
index b8ca53c69a..b43ee4ab7a 100644
--- a/src/rpc/Makefile.inc.am
+++ b/src/rpc/Makefile.inc.am
@@ -3,7 +3,7 @@
EXTRA_DIST +=3D \
rpc/gendispatch.pl \
rpc/genprotocol.pl \
- rpc/gensystemtap.pl \
+ rpc/gensystemtap.py \
rpc/virnetprotocol.x \
rpc/virkeepaliveprotocol.x \
$(NULL)
diff --git a/src/rpc/gensystemtap.pl b/src/rpc/gensystemtap.pl
deleted file mode 100755
index 6693d4d6f5..0000000000
--- a/src/rpc/gensystemtap.pl
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2011-2012 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-# Generate a set of systemtap functions for translating various
-# RPC enum values into strings
-#
-# perl gensystemtap.pl */*.x > libvirt_functions.stp
-#
-
-use strict;
-
-my %funcs;
-
-my %type;
-my %status;
-my %auth;
-
-my $instatus =3D 0;
-my $intype =3D 0;
-my $inauth =3D 0;
-while (<>) {
- if (/enum\s+virNetMessageType/) {
- $intype =3D 1;
- } elsif (/enum\s+virNetMessageStatus/) {
- $instatus =3D 1;
- } elsif (/enum remote_auth_type/) {
- $inauth =3D 1;
- } elsif (/}/) {
- $instatus =3D $intype =3D $inauth =3D 0;
- } elsif ($instatus) {
- if (/^\s+VIR_NET_(\w+)\s*=3D\s*(\d+),?$/) {
- $status{$2} =3D lc $1;
- }
- } elsif ($intype) {
- if (/^\s+VIR_NET_(\w+)\s*=3D\s*(\d+),?$/) {
- $type{$2} =3D lc $1;
- }
- } elsif ($inauth) {
- if (/^\s+REMOTE_AUTH_(\w+)\s*=3D\s*(\d+),?$/) {
- $auth{$2} =3D lc $1;
- }
- } else {
- if (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROGRAM\s*=3D\s*0x([a-fA-F0-9]+=
)\s*;/) {
- $funcs{lc $1} =3D { id =3D> hex($2), version =3D> undef, progs=
=3D> [] };
- } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_(?:PROGRAM|PROTOCOL)_VERSI=
ON\s*=3D\s*(\d+)\s*;/) {
- $funcs{lc $1}->{version} =3D $2;
- } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROC_(.*?)\s+=3D\s+(\d+)/)=
{
- $funcs{lc $1}->{progs}->[$3] =3D lc $2;
- }
- }
-}
-
-print <{id}, ") {\n";
- print " programstr =3D \"", $prog, "\"\n";
-}
-print <{id}, " && version =
=3D=3D ", $funcs{$prog}->{version}, ") {\n";
-
- my $pfirst =3D 1;
- for (my $id =3D 1 ; $id <=3D $#{$funcs{$prog}->{progs}} ; $id++) {
- my $cond =3D $pfirst ? "if" : "} else if";
- $pfirst =3D 0;
- print " $cond (proc =3D=3D $id) {\n";
- print " procstr =3D \"", $funcs{$prog}->{progs}->[$id], "=
\";\n";
- }
- print " } else {\n";
- print " procstr =3D \"unknown\";\n";
- print " verbose =3D 1;\n";
- print " }\n";
-}
-print <.
+#
+# Generate a set of systemtap functions for translating various
+# RPC enum values into strings
+#
+# python gensystemtap.py */*.x > libvirt_functions.stp
+#
+
+from __future__ import print_function
+
+import re
+import sys
+
+funcs =3D {}
+
+types =3D {}
+status =3D {}
+auth =3D {}
+
+def load_file(fh):
+ instatus =3D False
+ intype =3D False
+ inauth =3D False
+
+ for line in fh:
+ if re.match(r'''\s*enum\s+virNetMessageType\s*''', line):
+ intype =3D True
+ elif re.match(r'''\s*enum\s+virNetMessageStatus\s*''', line):
+ instatus =3D True
+ elif re.match(r'''\s*enum remote_auth_type.*''', line):
+ inauth =3D True
+ elif line.find("}") !=3D -1:
+ intype =3D False
+ instatus =3D False
+ inauth =3D False
+ elif instatus:
+ m =3D re.match(r'''^\s+VIR_NET_(\w+)\s*=3D\s*(\d+),?$''', line)
+ if m is not None:
+ status[m.group(2)] =3D m.group(1).lower()
+ elif intype:
+ m =3D re.match(r'''^\s+VIR_NET_(\w+)\s*=3D\s*(\d+),?$''', line)
+ if m is not None:
+ types[m.group(2)] =3D m.group(1).lower()
+ elif inauth:
+ m =3D re.match(r'''^\s+REMOTE_AUTH_(\w+)\s*=3D\s*(\d+),?$''', =
line)
+ if m is not None:
+ auth[m.group(2)] =3D m.group(1).lower()
+ else:
+ m =3D re.match(r'''^.*?(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROGRAM\s=
*=3D\s*0x([a-fA-F0-9]+)\s*;''', line)
+ if m is not None:
+ funcs[m.group(1).lower()] =3D {
+ "id": int(m.group(2), 16),
+ "version": None,
+ "progs": []
+ }
+ continue
+
+ m =3D re.match(r'''^.*?(?:VIR_)?(\w+?)(?:_PROTOCOL)?_(?:PROGRA=
M|PROTOCOL)_VERSION\s*=3D\s*(\d+)\s*;''', line)
+ if m is not None:
+ funcs[m.group(1).lower()]["version"] =3D m.group(2)
+ continue
+
+ m =3D re.match(r'''^.*?(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROC_(.*?=
)\s+=3D\s+(\d+)''', line)
+ if m is not None:
+ funcs[m.group(1).lower()]["progs"].insert(int(m.group(3)),=
m.group(2).lower())
+
+for file in sys.argv[1:]:
+ with open(file, "r") as fh:
+ load_file(fh)
+
+
+def genfunc(name, varname, types):
+ print("function %s(%s, verbose)" % (name, varname))
+ print("{")
+
+ first =3D True
+ for typename in sorted(types.keys()):
+ cond =3D "} else if"
+ if first:
+ cond =3D "if"
+ first =3D False
+
+ print(" %s (%s =3D=3D %s) {" % (cond, varname, typename))
+ print(" %sstr =3D \"%s\"" % (varname, types[typename]))
+
+ print(" } else {")
+ print(" %sstr =3D \"unknown\";" % varname)
+ print(" verbose =3D 1;")
+ print(" }")
+ print(" if (verbose) {")
+ print(" %sstr =3D %sstr . sprintf(\":%%d\", %s)" % (varname, varn=
ame, varname))
+ print(" }")
+ print(" return %sstr;" % varname)
+ print("}")
+
+genfunc("libvirt_rpc_auth_name", "type", auth)
+genfunc("libvirt_rpc_type_name", "type", types)
+genfunc("libvirt_rpc_status_name", "status", status)
+
+print("function libvirt_rpc_program_name(program, verbose)")
+print("{")
+
+first =3D True
+for funcname in sorted(funcs.keys()):
+ cond =3D "} else if"
+ if first:
+ cond =3D "if"
+ first =3D False
+
+ print(" %s (program =3D=3D %s) {" % (cond, funcs[funcname]["id"]))
+ print(" programstr =3D \"%s\"" % funcname)
+
+print(" } else {")
+print(" programstr =3D \"unknown\";")
+print(" verbose =3D 1;")
+print(" }")
+print(" if (verbose) {")
+print(" programstr =3D programstr . sprintf(\":%d\", program)")
+print(" }")
+print(" return programstr;")
+print("}")
+
+print("function libvirt_rpc_procedure_name(program, version, proc, verbose=
)")
+print("{")
+
+first =3D True
+for prog in sorted(funcs.keys()):
+ cond =3D "} else if"
+ if first:
+ cond =3D "if"
+ first =3D False
+
+ print(" %s (program =3D=3D %s && version =3D=3D %s) {" % (cond, funcs=
[prog]["id"], funcs[prog]["version"]))
+
+ pfirst =3D True
+ for id in range(len(funcs[prog]["progs"])):
+ pcond =3D "} else if"
+ if pfirst:
+ pcond =3D "if"
+ pfirst =3D False
+
+ print(" %s (proc =3D=3D %s) {" % (pcond, id + 1))
+ print(" procstr =3D \"%s\";" % funcs[prog]["progs"][id])
+
+ print(" } else {")
+ print(" procstr =3D \"unknown\";")
+ print(" verbose =3D 1;")
+ print(" }")
+
+print(" } else {")
+print(" procstr =3D \"unknown\";")
+print(" verbose =3D 1;")
+print(" }")
+print(" if (verbose) {")
+print(" procstr =3D procstr . sprintf(\":%d\", proc)")
+print(" }")
+print(" return procstr;")
+print("}")
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219326; cv=none;
d=zoho.com; s=zohoarc;
b=BHyvSiFDyvzKhaSPFUBjy2DRER6uEwUcXvfuCjq8+NYZqcSPe9Ynimp8xHAQkohVJtWDlsCTJC7ye8qzOSwalpXjj6QJI5ijCvlNjduljc8AiozY5c0ULLale6U6LlkLVFuPwdX38vwcKIFnZylqvm2fqUE8lD8XT2iyrGVzIvM=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219326;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=f7GirJqm58nyBZKPXHXjW0AQOyfexHJb0T1ujdcVStE=;
b=hmme6P2vIoGGheNz3ScZmUvHJqgMaTj09JTSlT0a9u0Q8BymOs9GaGrVTvAgCN/XLmwFY7D/vjf/XxnnRs1c55zIcSvWXWI7vFEY27LgrEGE+InPZRLYz3p9VinK+VQMKQWxLRkzr+qF6UJAJBLPaiI/kpVbcjCgYTGY94H2NQ8=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219326749515.7126206640746;
Wed, 11 Sep 2019 09:28:46 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com
[10.5.11.23])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 2580B8AC6F6;
Wed, 11 Sep 2019 16:28:45 +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 F11E119C70;
Wed, 11 Sep 2019 16:28: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 B5CCD206CC;
Wed, 11 Sep 2019 16:28:44 +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 x8BGSPTL013185 for ;
Wed, 11 Sep 2019 12:28:25 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 3D2066017E; Wed, 11 Sep 2019 16:28:25 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id A1DD7601A5;
Wed, 11 Sep 2019 16:28:23 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:24 +0100
Message-Id: <20190911162333.8668-16-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 15/24] src: rewrite driver name checker in
Python
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-Type: text/plain; charset="utf-8"
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.23
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]);
Wed, 11 Sep 2019 16:28:45 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-drivername.pl tool in Python.
This was mostly a straight conversion, manually going line-by-line
to change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
In testing though it was discovered the existing code was broken
since it hadn't been updated after driver.h was split into many
files. Since the old code is being thrown away, the fix was done
as part of the rewrite rather than split into a separate commit.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 18 +++++--
src/check-drivername.pl | 83 -----------------------------
src/check-drivername.py | 112 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 127 insertions(+), 86 deletions(-)
delete mode 100755 src/check-drivername.pl
create mode 100644 src/check-drivername.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 539d8b0f58..58d228eb4f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -336,15 +336,27 @@ check-protocol:
endif !WITH_REMOTE
EXTRA_DIST +=3D $(PROTOCOL_STRUCTS)
=20
+DRIVERS =3D \
+ $(srcdir)/driver-hypervisor.h \
+ $(srcdir)/driver-interface.h \
+ $(srcdir)/driver-network.h \
+ $(srcdir)/driver-nodedev.h \
+ $(srcdir)/driver-nwfilter.h \
+ $(srcdir)/driver-secret.h \
+ $(srcdir)/driver-state.h \
+ $(srcdir)/driver-storage.h \
+ $(srcdir)/driver-stream.h \
+ $(NULL)
+
check-drivername:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-drivername.pl \
- $(srcdir)/driver.h \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-drivername.py \
+ $(DRIVERS) \
$(srcdir)/libvirt_public.syms \
$(srcdir)/libvirt_admin_public.syms \
$(srcdir)/libvirt_qemu.syms \
$(srcdir)/libvirt_lxc.syms
=20
-EXTRA_DIST +=3D check-drivername.pl
+EXTRA_DIST +=3D check-drivername.py
=20
check-driverimpls:
$(AM_V_GEN)$(PERL) $(srcdir)/check-driverimpls.pl \
diff --git a/src/check-drivername.pl b/src/check-drivername.pl
deleted file mode 100755
index 3a62193e33..0000000000
--- a/src/check-drivername.pl
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-
-use strict;
-use warnings;
-
-my $drvfile =3D shift;
-my @symfiles =3D @ARGV;
-
-my %symbols;
-
-foreach my $symfile (@symfiles) {
- open SYMFILE, "<", $symfile
- or die "cannot read $symfile: $!";
- while () {
- if (/^\s*(vir\w+)\s*;\s*$/) {
- $symbols{$1} =3D 1;
- }
- }
-
- close SYMFILE;
-}
-
-open DRVFILE, "<", $drvfile
- or die "cannot read $drvfile: $!";
-
-my $status =3D 0;
-
-while () {
- next if /virDrvConnectSupportsFeature/;
- if (/\*(virDrv\w+)\s*\)/) {
-
- my $drv =3D $1;
-
- next if $drv =3D~ /virDrvState/;
- next if $drv =3D~ /virDrvDomainMigrate(Prepare|Perform|Confirm|Beg=
in|Finish)/;
-
- my $sym =3D $drv;
- $sym =3D~ s/virDrv/vir/;
-
- unless (exists $symbols{$sym}) {
- print "Driver method name $drv doesn't match public API name\n=
";
- $status =3D 1;
- }
- } elsif (/^\*(vir\w+)\s*\)/) {
- my $name =3D $1;
- print "Bogus name $1\n";
- $status =3D 1;
- } elsif (/^\s*(virDrv\w+)\s+(\w+);\s*/) {
- my $drv =3D $1;
- my $field =3D $2;
-
- my $tmp =3D $drv;
- $tmp =3D~ s/virDrv//;
- $tmp =3D~ s/^NWFilter/nwfilter/;
- $tmp =3D~ s/^(\w)/lc $1/e;
-
- unless ($tmp eq $field) {
- print "Driver struct field $field should be named $tmp\n";
- $status =3D 1;
- }
- }
-}
-
-close DRVFILE;
-
-exit $status;
diff --git a/src/check-drivername.py b/src/check-drivername.py
new file mode 100644
index 0000000000..e87202be6d
--- /dev/null
+++ b/src/check-drivername.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2013-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+
+from __future__ import print_function
+
+import re
+import sys
+
+drvfiles =3D []
+symfiles =3D []
+for arg in sys.argv:
+ if arg.endswith(".h"):
+ drvfiles.append(arg)
+ else:
+ symfiles.append(arg)
+
+symbols =3D {}
+
+for symfile in symfiles:
+ with open(symfile, "r") as fh:
+ for line in fh:
+ m =3D re.match(r'''^\s*(vir\w+)\s*;\s*$''', line)
+ if m is not None:
+ symbols[m.group(1)] =3D True
+
+status =3D 0
+for drvfile in drvfiles:
+ with open(drvfile, "r") as fh:
+ for line in fh:
+ if line.find("virDrvConnectSupportsFeature") !=3D -1:
+ continue
+
+ m =3D re.match(r'''.*\*(virDrv\w+)\s*\).*''', line)
+ if m is not None:
+ drv =3D m.group(1)
+
+ skip =3D [
+ "virDrvStateInitialize",
+ "virDrvStateCleanup",
+ "virDrvStateReload",
+ "virDrvStateStop",
+ "virDrvConnectURIProbe",
+ "virDrvDomainMigratePrepare",
+ "virDrvDomainMigratePrepare2",
+ "virDrvDomainMigratePrepare3",
+ "virDrvDomainMigratePrepare3Params",
+ "virDrvDomainMigratePrepareTunnel",
+ "virDrvDomainMigratePrepareTunnelParams",
+ "virDrvDomainMigratePrepareTunnel3",
+ "virDrvDomainMigratePrepareTunnel3Params",
+ "virDrvDomainMigratePerform",
+ "virDrvDomainMigratePerform3",
+ "virDrvDomainMigratePerform3Params",
+ "virDrvDomainMigrateConfirm",
+ "virDrvDomainMigrateConfirm3",
+ "virDrvDomainMigrateConfirm3Params",
+ "virDrvDomainMigrateBegin",
+ "virDrvDomainMigrateBegin3",
+ "virDrvDomainMigrateBegin3Params",
+ "virDrvDomainMigrateFinish",
+ "virDrvDomainMigrateFinish2",
+ "virDrvDomainMigrateFinish3",
+ "virDrvDomainMigrateFinish3Params",
+ "virDrvStreamInData",
+ ]
+ if drv in skip:
+ continue
+
+ sym =3D drv.replace("virDrv", "vir")
+
+ if sym not in symbols:
+ print("Driver method name %s doesn't match public API =
name" % drv)
+ continue
+
+ m =3D re.match(r'''^\*(vir\w+)\s*\)''', line)
+ if m is not None:
+ name =3D m.group(1)
+ print("Bogus name %s" % name)
+ status =3D 1
+ continue
+
+ m =3D re.match(r'''^\s*(virDrv\w+)\s+(\w+);\s*''', line)
+ if m is not None:
+ drv =3D m.group(1)
+ field =3D m.group(2)
+
+ tmp =3D drv.replace("virDrv", "")
+ if tmp.startswith("NWFilter"):
+ tmp =3D "nwfilter" + tmp[8:]
+ tmp =3D tmp[0:1].lower() + tmp[1:]
+
+ if tmp !=3D field:
+ print("Driver struct field %s should be named %s" % (f=
ield, tmp))
+ status =3D 1
+
+sys.exit(status)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219320; cv=none;
d=zoho.com; s=zohoarc;
b=EEO/QlcqteOFzu1/flOusFfjI+5TpE62Q9Yuuk+tlYDs0y5wS47ocgHsVVii3y7wGSR4BHWJsWEhYJmZ279g4GGVFXsbRb+AP0Ig5FPmn5+iJS+4lqVKWXEaj2SYAxKHz8fTFgfzK0dW4wR5M8FRiwQ7gzk4fyKJQ9aLu7337mU=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219320;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=qt2vUb3CX7SRhiiEzZcRFCKpH0UcAOB84YdiDSqMpkk=;
b=iN0UNfz3k05d2HRGqut6Y/vPJnhuNUdS+wn22Owx0HKRlIkRTGFFBLiDf9S3wU7rmOK6ewu97PZxcgMZmsN17NxTDjzHTnFBlPRtQIOhhjzMl2S9QZda/wgH6sxnLq1l0FJALnxV8cjZcgWmdVhol6bkIncmvvXuw2XjJYM0Z/E=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219320653840.706111068529;
Wed, 11 Sep 2019 09:28:40 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id DAC7231752BB;
Wed, 11 Sep 2019 16:28: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 B6DCC60872;
Wed, 11 Sep 2019 16:28:37 +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 740B2180BAA7;
Wed, 11 Sep 2019 16:28:37 +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 x8BGSPd8013180 for ;
Wed, 11 Sep 2019 12:28:25 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 1F4946017E; Wed, 11 Sep 2019 16:28:25 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 82E61601B3;
Wed, 11 Sep 2019 16:28:24 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:25 +0100
Message-Id: <20190911162333.8668-17-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 16/24] src: rewrite driver impl checker in
Python
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-Type: text/plain; charset="utf-8"
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]);
Wed, 11 Sep 2019 16:28:38 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-driverimpls.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 4 +-
src/check-driverimpls.pl | 80 ---------------------------------
src/check-driverimpls.py | 96 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+), 82 deletions(-)
delete mode 100755 src/check-driverimpls.pl
create mode 100755 src/check-driverimpls.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 58d228eb4f..17d8885fe8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -359,7 +359,7 @@ check-drivername:
EXTRA_DIST +=3D check-drivername.py
=20
check-driverimpls:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-driverimpls.pl \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-driverimpls.py \
$(filter /%,$(DRIVER_SOURCE_FILES)) \
$(filter $(srcdir)/%,$(DRIVER_SOURCE_FILES)) \
$(addprefix $(srcdir)/,$(filter-out $(srcdir)/%, \
@@ -375,7 +375,7 @@ check-aclperms:
$(srcdir)/access/viraccessperm.h \
$(srcdir)/access/viraccessperm.c
=20
-EXTRA_DIST +=3D check-driverimpls.pl check-aclrules.pl check-aclperms.py
+EXTRA_DIST +=3D check-driverimpls.py check-aclrules.pl check-aclperms.py
=20
check-local: check-protocol check-symfile check-symsorting \
check-drivername check-driverimpls check-aclrules \
diff --git a/src/check-driverimpls.pl b/src/check-driverimpls.pl
deleted file mode 100755
index 3c0d54724c..0000000000
--- a/src/check-driverimpls.pl
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-
-use strict;
-use warnings;
-
-my $intable =3D 0;
-my $table;
-my $mainprefix;
-
-my $status =3D 0;
-while (<>) {
- if ($intable) {
- if (/}/) {
- $intable =3D 0;
- $table =3D undef;
- $mainprefix =3D undef;
- } elsif (/\.(\w+)\s*=3D\s*(\w+),?/) {
- my $api =3D $1;
- my $impl =3D $2;
-
- next if $api eq "no";
- next if $api eq "name";
- next if $impl eq "NULL";
-
- my $suffix =3D $impl;
- my $prefix =3D $impl;
- $prefix =3D~ s/^([a-z]+)(.*?)$/$1/;
-
- if (defined $mainprefix) {
- if ($mainprefix ne $prefix) {
- print "$ARGV:$. Bad prefix '$prefix' for API '$api', e=
xpecting '$mainprefix'\n";
- $status =3D 1;
- }
- } else {
- $mainprefix =3D $prefix;
- }
-
- if ($api !~ /^$mainprefix/) {
- $suffix =3D~ s/^[a-z]+//;
- $suffix =3D~ s/^([A-Z]+)/lc $1/e;
- }
-
- if ($api ne $suffix) {
- my $want =3D $api;
- $want =3D~ s/^nwf/NWF/;
- if ($api !~ /^$mainprefix/) {
- $want =3D~ s/^([a-z])/uc $1/e;
- $want =3D $mainprefix . $want;
- }
- print "$ARGV:$. Bad impl name '$impl' for API '$api', expe=
cting '$want'\n";
- $status =3D 1;
- }
- }
- } elsif (/^(?:static\s+)?(vir(?:\w+)?Driver)\s+(?!.*;)/) {
- next if $1 eq "virNWFilterCallbackDriver" ||
- $1 eq "virNWFilterTechDriver" ||
- $1 eq "virConnectDriver";
- $intable =3D 1;
- $table =3D $1;
- }
-}
-
-exit $status;
diff --git a/src/check-driverimpls.py b/src/check-driverimpls.py
new file mode 100755
index 0000000000..b02398276f
--- /dev/null
+++ b/src/check-driverimpls.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2013-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+
+from __future__ import print_function
+
+import re
+import sys
+
+def checkdriverimpls(filename):
+ intable =3D False
+ table =3D None
+ mainprefix =3D None
+
+ errs =3D False
+ with open(filename, "r") as fh:
+ lineno =3D 0
+ for line in fh:
+ lineno =3D lineno + 1
+ if intable:
+ if line.find("}") !=3D -1:
+ intable =3D False
+ table =3D None
+ mainprefix =3D None
+ continue
+
+ m =3D re.match(r'''\s*\.(\w+)\s*=3D\s*(\w+),?\s*/''', line)
+ if m is not None:
+ api =3D m.group(1)
+ impl =3D m.group(2)
+
+ if api in ["no", "name"]:
+ continue
+ if impl in ["NULL"]:
+ continue
+
+ suffix =3D impl
+ prefix =3D re.sub(r'''^([a-z]+)(.*?)$''', r'''\1''', i=
mpl)
+
+ if mainprefix is not None:
+ if mainprefix !=3D prefix:
+ print("%s:%d Bad prefix '%s' for API '%s', exp=
ecting '%s'" % (
+ filename, lineno, prefix, api, mainprefix)=
, file=3Dsys.stderr)
+ errs =3D True
+ else:
+ mainprefix =3D prefix
+
+ if not api.startswith(mainprefix):
+ suffix =3D re.sub(r'''^[a-z]+''', "", suffix)
+ suffix =3D re.sub(r'''^([A-Z]+)''', lambda m: m.gr=
oup(1).lower(), suffix)
+
+ if api !=3D suffix:
+ want =3D api
+ if want.startswith("nwf"):
+ want =3D "NWF" + want[3:]
+
+ if not api.startswith(mainprefix):
+ want =3D re.sub(r'''^([a-z])''', lambda m: m.g=
roup(1).upper(), want)
+ want =3D mainprefix + want
+
+ print ("%s:%d Bad impl name '%s' for API '%s', exp=
ecting '%s'" % (
+ filename, lineno, impl, api, want), file=3Dsys=
.stderr)
+ errs =3D True
+ else:
+ m =3D re.match(r'''^(?:static\s+)?(vir(?:\w+)?Driver)\s+(?=
!.*;)''', line)
+ if m is not None:
+ drv =3D m.group(1)
+ if drv in ["virNWFilterCallbackDriver",
+ "virNWFilterTechDriver",
+ "virConnectDriver"]:
+ continue
+ intable =3D True
+ table =3D drv
+
+ return errs
+
+status =3D 0
+for filename in sys.argv[1:]:
+ if checkdriverimpls(filename):
+ status =3D 1
+sys.exit(status)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219330; cv=none;
d=zoho.com; s=zohoarc;
b=b33XuichBqdAnDwa6violqvw/I9ZARK9nwxHWPQ1MDSrhxFW5W5uqWNTIK/qFN81uxTtkf4isX4cjkSRyRYqYZe+1k9BPLvi1TShPkaWsunGrtwtdGQjk3JY/hS7zGSMaDiDKZEvA4Jh1STA2Ke4Pd5wX6IQqY6grzTM0iRotJc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219330;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=Wdu1+SUtSv4a0PeNvfdrNeBoGm8LY++PT1sivMshxLw=;
b=cNCMNcusm4+RVFvSotPlrfOgZ4dd6+15l/nhNYr/2n+nSaVusODsRVbvMgdtT3ooeBeKGPS+pv5gJy2WzbQ/FGXeGBBl05nyBJ8mV/BC2Ka/SA89HLsFvWMYd8U4yD2iqIh/gD9Iq5pJDH3KX6yKjwrQ8kHKmxsHRIoGKOCQXIk=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 156821933047277.25569465190802;
Wed, 11 Sep 2019 09:28:50 -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 58DAC30860BF;
Wed, 11 Sep 2019 16:28:48 +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 359FF5C231;
Wed, 11 Sep 2019 16:28: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 EE2D01803B37;
Wed, 11 Sep 2019 16:28:47 +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 x8BGSQKk013198 for ;
Wed, 11 Sep 2019 12:28:26 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 013476013A; Wed, 11 Sep 2019 16:28:26 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id 649676017E;
Wed, 11 Sep 2019 16:28:25 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:26 +0100
Message-Id: <20190911162333.8668-18-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 17/24] src: rewrite ACL rule checker in Python
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-Type: text/plain; charset="utf-8"
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.44]);
Wed, 11 Sep 2019 16:28:49 +0000 (UTC)
As part of an goal to eliminate Perl from libvirt build tools,
rewrite the check-aclrules.pl tool in Python.
This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.
Signed-off-by: Daniel P. Berrang=C3=A9
---
src/Makefile.am | 4 +-
src/check-aclrules.pl | 252 ------------------------------------------
src/check-aclrules.py | 244 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 246 insertions(+), 254 deletions(-)
delete mode 100755 src/check-aclrules.pl
create mode 100755 src/check-aclrules.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 17d8885fe8..7319aee3b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -366,7 +366,7 @@ check-driverimpls:
$(filter-out /%,$(DRIVER_SOURCE_FILES))))
=20
check-aclrules:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-aclrules.pl \
+ $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(srcdir)/check-aclrules.py \
$(REMOTE_PROTOCOL) \
$(addprefix $(srcdir)/,$(filter-out /%,$(STATEFUL_DRIVER_SOURCE_FILES)))
=20
@@ -375,7 +375,7 @@ check-aclperms:
$(srcdir)/access/viraccessperm.h \
$(srcdir)/access/viraccessperm.c
=20
-EXTRA_DIST +=3D check-driverimpls.py check-aclrules.pl check-aclperms.py
+EXTRA_DIST +=3D check-driverimpls.py check-aclrules.py check-aclperms.py
=20
check-local: check-protocol check-symfile check-symsorting \
check-drivername check-driverimpls check-aclrules \
diff --git a/src/check-aclrules.pl b/src/check-aclrules.pl
deleted file mode 100755
index 0d4cac17ca..0000000000
--- a/src/check-aclrules.pl
+++ /dev/null
@@ -1,252 +0,0 @@
-#!/usr/bin/env perl
-#
-# Copyright (C) 2013-2014 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# .
-#
-# This script validates that the driver implementation of any
-# public APIs contain ACL checks.
-#
-# As the script reads each source file, it attempts to identify
-# top level function names.
-#
-# When reading the body of the functions, it looks for anything
-# that looks like an API called named XXXEnsureACL. It will
-# validate that the XXX prefix matches the name of the function
-# it occurs in.
-#
-# When it later finds the virDriverPtr table, for each entry
-# point listed, it will validate if there was a previously
-# detected EnsureACL call recorded.
-#
-use strict;
-use warnings;
-
-my $status =3D 0;
-
-my $brace =3D 0;
-my $maybefunc;
-my $intable =3D 0;
-my $table;
-
-my %acls;
-my %aclfilters;
-
-my %whitelist =3D (
- "connectClose" =3D> 1,
- "connectIsEncrypted" =3D> 1,
- "connectIsSecure" =3D> 1,
- "connectIsAlive" =3D> 1,
- "networkOpen" =3D> 1,
- "networkClose" =3D> 1,
- "nwfilterOpen" =3D> 1,
- "nwfilterClose" =3D> 1,
- "secretOpen" =3D> 1,
- "secretClose" =3D> 1,
- "storageOpen" =3D> 1,
- "storageClose" =3D> 1,
- "interfaceOpen" =3D> 1,
- "interfaceClose" =3D> 1,
- "connectURIProbe" =3D> 1,
- "localOnly" =3D> 1,
- "domainQemuAttach" =3D> 1,
- );
-
-# XXX this vzDomainMigrateConfirm3Params looks
-# bogus - determine why it doesn't have a valid
-# ACL check.
-my %implwhitelist =3D (
- "vzDomainMigrateConfirm3Params" =3D> 1,
- );
-
-my $lastfile;
-
-sub fixup_name {
- my $name =3D shift;
-
- $name =3D~ s/Nwfilter/NWFilter/;
- $name =3D~ s/Xml$/XML/;
- $name =3D~ s/Uri$/URI/;
- $name =3D~ s/Uuid$/UUID/;
- $name =3D~ s/Id$/ID/;
- $name =3D~ s/Mac$/MAC/;
- $name =3D~ s/Cpu$/CPU/;
- $name =3D~ s/Os$/OS/;
- $name =3D~ s/Nmi$/NMI/;
- $name =3D~ s/Pm/PM/;
- $name =3D~ s/Fstrim$/FSTrim/;
- $name =3D~ s/Scsi/SCSI/;
- $name =3D~ s/Wwn$/WWN/;
-
- return $name;
-}
-
-sub name_to_ProcName {
- my $name =3D shift;
-
- my @elems;
- if ($name =3D~ /_/ || (lc $name) eq "open" || (lc $name) eq "close") {
- @elems =3D split /_/, $name;
- @elems =3D map lc, @elems;
- @elems =3D map ucfirst, @elems;
- } else {
- @elems =3D $name;
- }
- @elems =3D map { fixup_name($_) } @elems;
- my $procname =3D join "", @elems;
-
- $procname =3D~ s/^([A-Z])/lc $1/e;
-
- return $procname;
-}
-
-
-my $proto =3D shift @ARGV;
-
-open PROTO, "<$proto" or die "cannot read $proto";
-
-my %filtered;
-my $incomment =3D 0;
-my $filtered =3D 0;
-while () {
- if (m,/\*\*,) {
- $incomment =3D 1;
- $filtered =3D 0;
- } elsif ($incomment) {
- if (m,\*\s\@aclfilter,) {
- $filtered =3D 1;
- } elsif ($filtered &&
- m,REMOTE_PROC_(.*)\s+=3D\s*\d+,) {
- my $api =3D name_to_ProcName($1);
- # Event filtering is handled in daemon/remote.c instead of dri=
vers
- if (! m,_EVENT_REGISTER,) {
- $filtered{$api} =3D 1;
- }
- $incomment =3D 0;
- }
- }
-}
-
-close PROTO;
-
-while (<>) {
- if (!defined $lastfile ||
- $lastfile ne $ARGV) {
- %acls =3D ();
- $brace =3D 0;
- $maybefunc =3D undef;
- $lastfile =3D $ARGV;
- }
- if ($brace =3D=3D 0) {
- # Looks for anything which appears to be a function
- # body name. Doesn't matter if we pick up bogus stuff
- # here, as long as we don't miss valid stuff
- if (m,\b(\w+)\(,) {
- $maybefunc =3D $1;
- }
- } elsif ($brace > 0) {
- if (m,(\w+)EnsureACL,) {
- # Record the fact that maybefunc contains an
- # ACL call, and make sure it is the right call!
- my $func =3D $1;
- $func =3D~ s/^vir//;
- if (!defined $maybefunc) {
- print "$ARGV:$. Unexpected check '$func' outside function\=
n";
- $status =3D 1;
- } else {
- unless ($maybefunc =3D~ /$func$/i) {
- print "$ARGV:$. Mismatch check 'vir${func}EnsureACL' f=
or function '$maybefunc'\n";
- $status =3D 1;
- }
- }
- $acls{$maybefunc} =3D 1;
- } elsif (m,(\w+)CheckACL,) {
- # Record the fact that maybefunc contains an
- # ACL filter call, and make sure it is the right call!
- my $func =3D $1;
- $func =3D~ s/^vir//;
- if (!defined $maybefunc) {
- print "$ARGV:$. Unexpected check '$func' outside function\=
n";
- $status =3D 1;
- } else {
- unless ($maybefunc =3D~ /$func$/i) {
- print "$ARGV:$. Mismatch check 'vir${func}CheckACL' fo=
r function '$maybefunc'\n";
- $status =3D 1;
- }
- }
- $aclfilters{$maybefunc} =3D 1;
- } elsif (m,\b(\w+)\(,) {
- # Handles case where we replaced an API with a new
- # one which adds new parameters, and we're left with
- # a simple stub calling the new API.
- my $callfunc =3D $1;
- if (exists $acls{$callfunc}) {
- $acls{$maybefunc} =3D 1;
- }
- if (exists $aclfilters{$callfunc}) {
- $aclfilters{$maybefunc} =3D 1;
- }
- }
- }
-
- # Pass the vir*DriverPtr tables and make sure that
- # every func listed there, has an impl which calls
- # an ACL function
- if ($intable) {
- if (/\}/) {
- $intable =3D 0;
- $table =3D undef;
- } elsif (/\.(\w+)\s*=3D\s*(\w+),?/) {
- my $api =3D $1;
- my $impl =3D $2;
-
- next if $impl eq "NULL";
-
- if ($api ne "no" &&
- $api ne "name" &&
- $table ne "virStateDriver" &&
- !exists $acls{$impl} &&
- !exists $whitelist{$api} &&
- !exists $implwhitelist{$impl}) {
- print "$ARGV:$. Missing ACL check in function '$impl' for =
'$api'\n";
- $status =3D 1;
- }
-
- if (exists $filtered{$api} &&
- !exists $aclfilters{$impl}) {
- print "$ARGV:$. Missing ACL filter in function '$impl' for=
'$api'\n";
- $status =3D 1;
- }
- }
- } elsif (/^(?:static\s+)?(vir(?:\w+)?Driver)\s+/) {
- if ($1 ne "virNWFilterCallbackDriver" &&
- $1 ne "virNWFilterTechDriver" &&
- $1 ne "virDomainConfNWFilterDriver") {
- $intable =3D 1;
- $table =3D $1;
- }
- }
-
-
- my $count;
- $count =3D s/{//g;
- $brace +=3D $count;
- $count =3D s/}//g;
- $brace -=3D $count;
-} continue {
- close ARGV if eof;
-}
-
-exit $status;
diff --git a/src/check-aclrules.py b/src/check-aclrules.py
new file mode 100755
index 0000000000..0f4c210851
--- /dev/null
+++ b/src/check-aclrules.py
@@ -0,0 +1,244 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2013-2019 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see
+# .
+#
+# This script validates that the driver implementation of any
+# public APIs contain ACL checks.
+#
+# As the script reads each source file, it attempts to identify
+# top level function names.
+#
+# When reading the body of the functions, it looks for anything
+# that looks like an API called named XXXEnsureACL. It will
+# validate that the XXX prefix matches the name of the function
+# it occurs in.
+#
+# When it later finds the virDriverPtr table, for each entry
+# point listed, it will validate if there was a previously
+# detected EnsureACL call recorded.
+#
+
+from __future__ import print_function
+
+import re
+import sys
+
+whitelist =3D {
+ "connectClose": True,
+ "connectIsEncrypted": True,
+ "connectIsSecure": True,
+ "connectIsAlive": True,
+ "networkOpen": True,
+ "networkClose": True,
+ "nwfilterOpen": True,
+ "nwfilterClose": True,
+ "secretOpen": True,
+ "secretClose": True,
+ "storageOpen": True,
+ "storageClose": True,
+ "interfaceOpen": True,
+ "interfaceClose": True,
+ "connectURIProbe": True,
+ "localOnly": True,
+ "domainQemuAttach": True,
+}
+
+# XXX this vzDomainMigrateConfirm3Params looks
+# bogus - determine why it doesn't have a valid
+# ACL check.
+implwhitelist =3D {
+ "vzDomainMigrateConfirm3Params": True,
+}
+
+lastfile =3D None
+
+def fixup_name(name):
+ name.replace("Nwfilter", "NWFilter")
+ name.replace("Pm", "PM")
+ name.replace("Scsi", "SCSI")
+ if name.endswith("Xml"):
+ name =3D name[:-3] + "XML"
+ elif name.endswith("Uri"):
+ name =3D name[:-3] + "URI"
+ elif name.endswith("Uuid"):
+ name =3D name[:-4] + "UUID"
+ elif name.endswith("Id"):
+ name =3D name[:-2] + "ID"
+ elif name.endswith("Mac"):
+ name =3D name[:-3] + "MAC"
+ elif name.endswith("Cpu"):
+ name =3D name[:-3] + "MAC"
+ elif name.endswith("Os"):
+ name =3D name[:-2] + "OS"
+ elif name.endswith("Nmi"):
+ name =3D name[:-3] + "NMI"
+ elif name.endswith("Fstrim"):
+ name =3D name[:-6] + "FSTrim"
+ elif name.endswith("Wwn"):
+ name =3D name[:-3] + "WWN"
+
+ return name
+
+
+def name_to_ProcName(name):
+ elems =3D []
+ if name.find("_") !=3D -1 or name.lower() in ["open", "close"]:
+ elems =3D [n.lower().capitalize() for n in name.split("_")]
+ else:
+ elems =3D [name]
+
+ elems =3D [fixup_name(n) for n in elems]
+ procname =3D "".join(elems)
+
+ return procname[0:1].lower() + procname[1:]
+
+
+proto =3D sys.argv[1]
+
+filteredmap =3D {}
+with open(proto, "r") as fh:
+ incomment =3D False
+ filtered =3D False
+
+ for line in fh:
+ if line.find("/**") !=3D -1:
+ incomment =3D True
+ filtered =3D False
+ elif incomment:
+ if line.find("* @aclfilter") !=3D -1:
+ filtered =3D True
+ elif filtered:
+ m =3D re.match(r'''.*REMOTE_PROC_(.*)\s+=3D\s*\d+.*''', li=
ne)
+ if m is not None:
+ api =3D name_to_ProcName(m.group(1))
+ # Event filtering is handled in daemon/remote.c instea=
d of drivers
+ if line.find("_EVENT_REGISTER") =3D=3D -1:
+ filteredmap[api] =3D True
+ incomment =3D False
+
+def process_file(filename):
+ brace =3D 0
+ maybefunc =3D None
+ intable =3D False
+ table =3D None
+
+ acls =3D {}
+ aclfilters =3D {}
+ errs =3D False
+ with open(filename, "r") as fh:
+ lineno =3D 0
+ for line in fh:
+ lineno =3D lineno + 1
+ if brace =3D=3D 0:
+ # Looks for anything which appears to be a function
+ # body name. Doesn't matter if we pick up bogus stuff
+ # here, as long as we don't miss valid stuff
+ m =3D re.match(r'''.*\b(\w+)\(.*''', line)
+ if m is not None:
+ maybefunc =3D m.group(1)
+ elif brace > 0:
+ ensureacl =3D re.match(r'''.*?(\w+)EnsureACL.*''', line)
+ checkacl =3D re.match(r'''.*?(\w+)CheckACL.*''', line)
+ stub =3D re.match(r'''.*?\b(\w+)\(.*''', line)
+ if ensureacl is not None:
+ # Record the fact that maybefunc contains an
+ # ACL call, and make sure it is the right call!
+ func =3D ensureacl.group(1)
+ if func.startswith("vir"):
+ func =3D func[3:]
+
+ if maybefunc is None:
+ print("%s:%d Unexpected check '%s' outside functio=
n" % (filename, lineno, func), file=3Dsys.stderr)
+ errs =3D True
+ else:
+ if not maybefunc.lower().endswith(func.lower()):
+ print("%s:%d Mismatch check 'vir%sEnsureACL' f=
or function '%s'" % (filename, lineno, func, maybefunc), file=3Dsys.stderr)
+ errs =3D True
+ acls[maybefunc] =3D True
+ elif checkacl:
+ # Record the fact that maybefunc contains an
+ # ACL filter call, and make sure it is the right call!
+ func =3D checkacl.group(1)
+ if func.startswith("vir"):
+ func =3D func[3:]
+
+ if maybefunc is None:
+ print("%s:%d Unexpected check '%s' outside functio=
n" % (filename, lineno, func), file=3Dsys.stderr)
+ errs =3D True
+ else:
+ if not maybefunc.lower().endswith(func.lower()):
+ print("%s:%d Mismatch check 'vir%sEnsureACL' f=
or function '%s'" % (filename, lineno, func, maybefunc), file=3Dsys.stderr)
+ errs =3D True
+ aclfilters[maybefunc] =3D True
+ elif stub:
+ # Handles case where we replaced an API with a new
+ # one which adds new parameters, and we're left with
+ # a simple stub calling the new API.
+ callfunc =3D stub.group(1)
+ if callfunc in acls:
+ acls[maybefunc] =3D True
+
+ if callfunc in aclfilters:
+ aclfilters[maybefunc] =3D True
+
+ # Pass the vir*DriverPtr tables and make sure that
+ # every func listed there, has an impl which calls
+ # an ACL function
+ if intable:
+ assign =3D re.match(r'''.*?\.(\w+)\s*=3D\s*(\w+),?.*''', l=
ine)
+ if line.find("}") !=3D -1:
+ intable =3D False
+ table =3D None
+ elif assign is not None:
+ api =3D assign.group(1)
+ impl =3D assign.group(2)
+
+ if (impl !=3D "NULL" and
+ api not in ["no", "name"] and
+ table !=3D "virStateDriver"):
+ if (impl not in acls and
+ api not in whitelist and
+ impl not in implwhitelist):
+ print("%s:%d Missing ACL check in function '%s=
' for '%s'" % (filename, lineno, impl, api), file=3Dsys.stderr)
+ errs =3D True
+
+ if api in filteredmap and impl not in aclfilters:
+ print("%s:%d Missing ACL filter in function '%=
s' for '%s'" % (filename, lineno, impl, api), file=3Dsys.stderr)
+ errs =3D True
+ else:
+ m =3D re.match(r'''^(?:static\s+)?(vir(?:\w+)?Driver)\s+''=
', line)
+ if m is not None:
+ name =3D m.group(1)
+ if name not in ["virNWFilterCallbackDriver",
+ "virNWFilterTechDriver",
+ "virDomainConfNWFilterDriver"]:
+ intable =3D True
+ table =3D name
+
+ if line.find("{") !=3D -1:
+ brace =3D brace + 1
+ if line.find("}") !=3D -1:
+ brace =3D brace - 1
+
+ return errs
+
+status =3D 0
+for filename in sys.argv[2:]:
+ if process_file(filename):
+ status =3D 1
+
+sys.exit(status)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue Apr 23 16:08:15 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;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass(p=none dis=none) header.from=redhat.com
ARC-Seal: i=1; a=rsa-sha256; t=1568219324; cv=none;
d=zoho.com; s=zohoarc;
b=dzixl2Zi/lS+Vjshf5zDfYr4iX7goaH7xkTLzPs+cLBKOtvm9zrxN5wNfKgvrztlgklFUcFPg0se6o7AhI0IIX3Vpdl5MCbOG0B1H7qCECz0mIt+zhHVkmphlDwAw1/nSVc9/QEX9wUA3yng0+LEYFmgZC4XNzKAVpYvXMgz8IM=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1568219324;
h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results;
bh=AIVAfthXEtA3Z9d6b+Wd/7JIwgOT38/fHkhTTaY0NQY=;
b=OOvf33k6lH9at4giJ58O3Bq9rpZf1qWBiBTkHMx1jQ6/AV0qKo7YG+fE8ypLVp3G64QsvhC8gRF0Dgm+OBPk5YsdMS7loWn+IKOLUWcbxmxmP7OTVjy3dexED/vdIJN0Wj1RLy88rA3GwzczHvBdy6NWN+JfcpPvPP6WdZiLZUQ=
ARC-Authentication-Results: i=1; mx.zoho.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=pass header.from= (p=none dis=none)
header.from=
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1568219324734408.9302541141278;
Wed, 11 Sep 2019 09:28:44 -0700 (PDT)
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 82F043098215;
Wed, 11 Sep 2019 16:28:42 +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 1A96A1001959;
Wed, 11 Sep 2019 16:28:42 +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 CD5661806B09;
Wed, 11 Sep 2019 16:28:41 +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 x8BGSTsA013225 for ;
Wed, 11 Sep 2019 12:28:29 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 7A417601B3; Wed, 11 Sep 2019 16:28:29 +0000 (UTC)
Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com
[10.33.9.32])
by smtp.corp.redhat.com (Postfix) with ESMTP id DE91E6017E;
Wed, 11 Sep 2019 16:28:26 +0000 (UTC)
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?=
To: libvir-list@redhat.com
Date: Wed, 11 Sep 2019 17:23:27 +0100
Message-Id: <20190911162333.8668-19-berrange@redhat.com>
In-Reply-To: <20190911162333.8668-1-berrange@redhat.com>
References: <20190911162333.8668-1-berrange@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH v2 18/24] src: rewrite polkit ACL generator in
Python
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: ,