From nobody Thu Dec 18 23:01:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1678293603; cv=none; d=zohomail.com; s=zohoarc; b=HbpZxOG5GPB4vtneSA3HbmxujYrKz+nSA6ojb20D8t8Lr+ZxPyW5ILSCFxhi7bnk9RUkBcDOi+UuvhYTTmU+gotPdGNKX3ke+xADoigIuojUUnz+zGw28w7G9oJgpWH6jdt1+hs3lyEH8lSLO3EaOWMj/fNNIhuQGRoH6wcds1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678293603; 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; bh=oMYPiCSybvUZqaAmgNw+xjARNjEatA51yOqZwpHDbLc=; b=jmeZVNJDF5NC3MkcXSliNODvPZ8cjyxk+Ajbk8bFO2rJInBZKCV0Rk6KlAJHEwH1KcwekRXxnDToiAR/69CMWOJxMqWhubTXdAvd0Pk8ER66SfXJVgqe31+CJ455lT9F3IH92kH/JLjXnc38mevBbVj3TRJTswqQ00EoejVhHFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1678293603648494.73559736744755; Wed, 8 Mar 2023 08:40:03 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-BRJ4n1_EMhCCMDxdzte9oA-1; Wed, 08 Mar 2023 11:39:40 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 732E228237DB; Wed, 8 Mar 2023 16:39:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FFF3492B04; Wed, 8 Mar 2023 16:39:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 03F6519465B9; Wed, 8 Mar 2023 16:39:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9FF7A19465B9 for ; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 785EC1121330; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) Received: from virtlab420.virt.lab.eng.bos.redhat.com (virtlab420.virt.lab.eng.bos.redhat.com [10.19.152.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DA0F112132D; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678293602; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oMYPiCSybvUZqaAmgNw+xjARNjEatA51yOqZwpHDbLc=; b=VLPx9lG5Kzy2b7hN94lV6BeDINRvpOz5Sn2Pj8OQSL++7/cEBC2zwAtsCWzTS4D+UvjWZV kDNC2a5JWK7eL3xKPEz0H19GwlUHDxjgOL0DpfbrJ8CgUiTKFkO1RZQb1tytT/BtFkftcx alRjz2mArupxjncXI5B3B0xj6BNVA0Q= X-MC-Unique: BRJ4n1_EMhCCMDxdzte9oA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH 11/16] build: switch over to new rpc generator code Date: Wed, 8 Mar 2023 11:39:08 -0500 Message-Id: <20230308163913.338952-12-berrange@redhat.com> In-Reply-To: <20230308163913.338952-1-berrange@redhat.com> References: <20230308163913.338952-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678293604823100001 This replaces use of 'rpcgen' with our new python impl of the RPC code generator. Since the new impl generates code that matches our style/coding rules, and does not contain long standing bugs, we no longer need to post-process the output. Signed-off-by: Daniel P. Berrang=C3=A9 --- libvirt.spec.in | 1 - meson.build | 11 --- scripts/rpcgen/meson.build | 5 ++ scripts/rpcgen/rpcgen/meson.build | 7 ++ src/admin/meson.build | 8 +- src/locking/meson.build | 8 +- src/logging/meson.build | 8 +- src/lxc/meson.build | 12 ++- src/remote/meson.build | 8 +- src/rpc/genprotocol.pl | 121 ------------------------------ src/rpc/meson.build | 9 ++- 11 files changed, 52 insertions(+), 146 deletions(-) create mode 100644 scripts/rpcgen/rpcgen/meson.build delete mode 100755 src/rpc/genprotocol.pl diff --git a/libvirt.spec.in b/libvirt.spec.in index 84d2f1c65a..aca7e23512 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -377,7 +377,6 @@ BuildRequires: wireshark-devel %if %{with_libssh} BuildRequires: libssh-devel >=3D 0.8.1 %endif -BuildRequires: rpcgen BuildRequires: libtirpc-devel # Needed for the firewalld_reload macro %if %{with_firewalld_zone} diff --git a/meson.build b/meson.build index 9f660c7604..ef1f697e0b 100644 --- a/meson.build +++ b/meson.build @@ -743,10 +743,6 @@ required_programs =3D [ 'xsltproc', ] =20 -required_programs_groups =3D [ - { 'name': 'rpcgen', 'prog': [ 'rpcgen', 'portable-rpcgen' ] }, -] - if host_machine.system() =3D=3D 'freebsd' required_programs +=3D 'ifconfig' endif @@ -758,13 +754,6 @@ foreach name : required_programs set_variable('@0@_prog'.format(varname), prog) endforeach =20 -foreach item : required_programs_groups - prog =3D find_program(item.get('prog'), dirs: libvirt_sbin_path) - varname =3D item.get('name').underscorify() - conf.set_quoted(varname.to_upper(), prog.full_path()) - set_variable('@0@_prog'.format(varname), prog) -endforeach - # optional programs =20 optional_programs =3D [ diff --git a/scripts/rpcgen/meson.build b/scripts/rpcgen/meson.build index 52526bf812..65236457be 100644 --- a/scripts/rpcgen/meson.build +++ b/scripts/rpcgen/meson.build @@ -1,3 +1,5 @@ +subdir('rpcgen') + if pytest_prog.found() subdir('tests') =20 @@ -9,3 +11,6 @@ if pytest_prog.found() workdir: meson.current_source_dir(), ) endif + +rpcgen_prog =3D find_program('main.py') +rpcgen_src +=3D files(['main.py']) diff --git a/scripts/rpcgen/rpcgen/meson.build b/scripts/rpcgen/rpcgen/meso= n.build new file mode 100644 index 0000000000..5a0f59eecf --- /dev/null +++ b/scripts/rpcgen/rpcgen/meson.build @@ -0,0 +1,7 @@ +rpcgen_src =3D files([ + 'ast.py', + 'lexer.py', + 'generator.py', + 'parser.py', + 'visitor.py', +]) diff --git a/src/admin/meson.build b/src/admin/meson.build index 692cc128a3..e5e6a87706 100644 --- a/src/admin/meson.build +++ b/src/admin/meson.build @@ -13,8 +13,10 @@ admin_protocol_h =3D custom_target( 'admin_protocol.h', input: admin_driver_protocol, output: 'admin_protocol.h', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', ], ) admin_driver_generated +=3D admin_protocol_h @@ -23,8 +25,10 @@ admin_driver_generated +=3D custom_target( 'admin_protocol.c', input: admin_driver_protocol, output: 'admin_protocol.c', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3Dadmin_protocol.h', '@INPUT@', '@OUTPUT@= ', ], ) =20 diff --git a/src/locking/meson.build b/src/locking/meson.build index 72f7780438..529caa1b9e 100644 --- a/src/locking/meson.build +++ b/src/locking/meson.build @@ -18,8 +18,10 @@ lock_protocol_generated +=3D custom_target( 'lock_protocol.h', input: lock_protocol, output: 'lock_protocol.h', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', ], ) =20 @@ -27,8 +29,10 @@ lock_protocol_generated +=3D custom_target( 'lock_protocol.c', input: lock_protocol, output: 'lock_protocol.c', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3Dlock_protocol.h', '@INPUT@', '@OUTPUT@', ], ) =20 diff --git a/src/logging/meson.build b/src/logging/meson.build index fa6af50fa6..4f5ca92052 100644 --- a/src/logging/meson.build +++ b/src/logging/meson.build @@ -10,8 +10,10 @@ log_protocol_header_generated =3D custom_target( 'log_protocol.h', input: log_protocol, output: 'log_protocol.h', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@' + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', ], ) log_protocol_generated +=3D log_protocol_header_generated @@ -20,8 +22,10 @@ log_protocol_generated +=3D custom_target( 'log_protocol.c', input: log_protocol, output: 'log_protocol.c', + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@' + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3Dlog_protocol.h', '@INPUT@', '@OUTPUT@', ], ) =20 diff --git a/src/lxc/meson.build b/src/lxc/meson.build index 99d4a34213..3a21f1f006 100644 --- a/src/lxc/meson.build +++ b/src/lxc/meson.build @@ -21,14 +21,22 @@ lxc_monitor_protocol_generated +=3D custom_target( 'lxc_monitor_protocol_h', input: lxc_monitor_protocol, output: 'lxc_monitor_protocol.h', - command: [ genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@' ] + depend_files: rpcgen_src, + command: [ + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', + ] ) =20 lxc_monitor_protocol_generated +=3D custom_target( 'lxc_monitor_protocol_c', input: lxc_monitor_protocol, output: 'lxc_monitor_protocol.c', - command: [ genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@' ] + depend_files: rpcgen_src, + command: [ + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3Dlxc_monitor_protocol.h', '@INPUT@', '@O= UTPUT@', + ], ) =20 lxc_monitor_generated =3D custom_target( diff --git a/src/remote/meson.build b/src/remote/meson.build index eb4f7a0068..ce41591f5b 100644 --- a/src/remote/meson.build +++ b/src/remote/meson.build @@ -25,8 +25,10 @@ foreach name : [ 'remote', 'qemu', 'lxc' ] protocol_h, input: protocol_x, output: protocol_h, + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', ], ) =20 @@ -34,8 +36,10 @@ foreach name : [ 'remote', 'qemu', 'lxc' ] protocol_c, input: protocol_x, output: protocol_c, + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3D' + protocol_h, '@INPUT@', '@OUTPUT@', ], ) =20 diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl deleted file mode 100755 index 079627964f..0000000000 --- a/src/rpc/genprotocol.pl +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env perl -# -# Generate code for an XDR protocol, optionally applying -# fixups to the glibc rpcgen code so that it compiles -# with warnings turned on. -# -# This code is evil. Arguably better would be just to compile -# without -Werror. Update: The IXDR_PUT_LONG replacements are -# actually fixes for 64 bit, so this file is necessary. Arguably -# so is the type-punning fix. -# -# Copyright (C) 2007, 2011-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 -# . -# -# Richard Jones - -use strict; - -my $in_function =3D 0; -my @function =3D (); - -my $rpcgen =3D shift; -my $mode =3D shift; -my $xdrdef =3D shift; -my $target =3D shift; - -unlink $target; - -if ($rpcgen =3D~ /portable-rpcgen/) { - $rpcgen =3D "$rpcgen -o -"; -} -open RPCGEN, "-|", "$rpcgen $mode $xdrdef" - or die "cannot run $rpcgen $mode $xdrdef: $!"; -open TARGET, ">$target" - or die "cannot create $target: $!"; - -my $fixup =3D $^O eq "linux" || $^O eq "gnukfreebsd" || $^O eq "freebsd" |= | $^O eq "darwin"; - -if ($mode eq "-c") { - print TARGET "#include \n"; -} - -while () { - # We only want to fixup the GLibc rpcgen output - # So just print data unchanged, if non-Linux - unless ($fixup) { - print TARGET; - next; - } - - if (m/^{/) { - $in_function =3D 1; - print TARGET; - next; - } - - s/\t/ /g; - - # Fix VPATH builds - s,#include ".*/([^/]+)protocol\.h",#include "${1}protocol.h",; - - # Portability for Solaris RPC - s/u_quad_t/uint64_t/g; - s/quad_t/int64_t/g; - s/xdr_u_quad_t/xdr_uint64_t/g; - s/xdr_quad_t/xdr_int64_t/g; - s/(?]\bbuf\b/, @function; - @function =3D grep !/[^.>]\bbuf\b/, @function if @uses =3D=3D 1; - - # Remove decl of i, if i isn't used in the function. - @uses =3D grep /[^.>]\bi\b/, @function; - @function =3D grep !/[^.>]\bi\b/, @function if @uses =3D=3D 1; - - # The code uses 'IXDR_PUT_{U_,}LONG' but it's wrong in two - # ways: Firstly these functions are deprecated and don't - # work on 64 bit platforms. Secondly the return value should - # be ignored. Correct both these mistakes. - @function =3D - map { s/\bIXDR_PUT_((U_)?)LONG\b/(void)IXDR_PUT_$1INT32/; $_ } - map { s/\bXDR_INLINE\b/(int32_t*)XDR_INLINE/; $_ } - @function; - - print TARGET (join ("", @function)); - @function =3D (); - } - - unless ($in_function) { - print TARGET; - } else { - push @function, $_; - } -} - -close TARGET - or die "cannot save $target: $!"; -close RPCGEN - or die "cannot shutdown $rpcgen: $!"; - -chmod 0444, $target - or die "cannot set $target readonly: $!"; diff --git a/src/rpc/meson.build b/src/rpc/meson.build index 36a2809adf..d58f3caaf5 100644 --- a/src/rpc/meson.build +++ b/src/rpc/meson.build @@ -1,4 +1,3 @@ -genprotocol_prog =3D find_program('genprotocol.pl') gendispatch_prog =3D find_program('gendispatch.pl') =20 socket_sources =3D [ @@ -53,8 +52,10 @@ foreach name : [ 'virnet', 'virkeepalive' ] header_file, input: protocol_file, output: header_file, + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dheader', '@INPUT@', '@OUTPUT@', ], ) =20 @@ -62,8 +63,10 @@ foreach name : [ 'virnet', 'virkeepalive' ] source_file, input: protocol_file, output: source_file, + depend_files: rpcgen_src, command: [ - genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@', + meson_python_prog, python3_prog, rpcgen_prog, + '--mode=3Dsource', '--header=3D' + header_file, '@INPUT@', '@OUTPUT@= ', ], ) =20 --=20 2.39.1