From nobody Mon Feb 9 22:18:45 2026 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=1696236704; cv=none; d=zohomail.com; s=zohoarc; b=cATnD4ArDL8N4DnL/Z9/edD14kc3YbLpKoufnlIrg9Y2o7/WrMZX8ugxLkuEov1534dlOZG9RTKYIIMFLBa/DvPy5SgwZJpIwF/p+7SD9xQz6CXhqhQyksmCAGEQG1F9srciTjDx9HSLGPn1A1Q9ZHqt78cNYtZZf2y1ivf3dbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696236704; 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=dA6ylHFoAJPvoy0WF2DM4GBruKo9sKzihm7jHTd1jXM=; b=kQwcGv/gsAlldLe8Tr1L0XWW3wPegLCyWGs/jEGpGkZXAbKRPft7ZF+5cmG5WW0Q3ExiFo2FTDJsOJ1SbxayQzr/CHfgwjM+lRzbdC8RE8n+jnf4gmpHqsP4gm1jKFwkrPbtH39jIJh8oLUOelPKX4+IwCFEc6s/eMUbxL4tnGo= 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 1696236704638502.6305202129272; Mon, 2 Oct 2023 01:51:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-JeAm9h-YPNWGjJCp56sk2g-1; Mon, 02 Oct 2023 04:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 845408582A5; Mon, 2 Oct 2023 08:51:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FF7DC154CC; Mon, 2 Oct 2023 08:51:31 +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 0598819465A2; Mon, 2 Oct 2023 08:51:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E2E4C1946A52 for ; Mon, 2 Oct 2023 08:51:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D39B5C158BA; Mon, 2 Oct 2023 08:51:29 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.226.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6AFDFC15BB8 for ; Mon, 2 Oct 2023 08:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696236703; 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=dA6ylHFoAJPvoy0WF2DM4GBruKo9sKzihm7jHTd1jXM=; b=bKI8e+u0yQxkQEmVH6FlfiqgRp0CrgCAB9tEyv99CtTQVKpnHUmxhgbfzTHa88p6RtN4eT PDWFZaDjelmMTZ2tGZvq+iGHnyCZzVaHfIFGFpq57HB/tpYi6d+MKx0sUtvnow/y1dwLRA pb6M74eH47zVkRX2kSQpN2/SzONtTX0= X-MC-Unique: JeAm9h-YPNWGjJCp56sk2g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 02/11] systemd: Support merging multiple units Date: Mon, 2 Oct 2023 10:51:17 +0200 Message-ID: <20231002085126.210149-3-abologna@redhat.com> In-Reply-To: <20231002085126.210149-1-abologna@redhat.com> References: <20231002085126.210149-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696236705877100011 Content-Type: text/plain; charset="utf-8"; x-default="true" In order to further deduplicate the contents of the various unit files, we need to be able to merge multiple additional units into the initial one. Luckily the merge logic is in no way constrained to working with just two units, so achieving this is pretty much just a matter of lifting the existing limitation on the number of arguments that the script accepts. As a special case, it's now also possible to call the script with just the base unit as argument. No merging will be performed in that case, obviously, but we'll still go through the basic validation and cleanup steps. This also fixes a bug in the check for the number of arguments: sys.argv also contains the name of the script, so we should have checked that its size was at least 3. The check is now written in a way that's less prone to misunderstandings. Signed-off-by: Andrea Bolognani --- scripts/merge-systemd-units.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/merge-systemd-units.py b/scripts/merge-systemd-units.py index bc3321230d..30e8757544 100755 --- a/scripts/merge-systemd-units.py +++ b/scripts/merge-systemd-units.py @@ -82,13 +82,18 @@ def merge_units(base, extra): return merged =20 =20 -if len(sys.argv) < 2: - print("usage: {} BASE EXTRA".format(sys.argv[0])) +prog =3D sys.argv[0] +args =3D sys.argv[1:] + +if len(args) < 1: + print("usage: {} BASE [EXTRA]...".format(prog)) sys.exit(1) =20 -base =3D parse_unit(sys.argv[1]) -extra =3D parse_unit(sys.argv[2]) +merged =3D parse_unit(args[0]) + +for arg in args[1:]: + extra =3D parse_unit(arg) =20 -merged =3D merge_units(base, extra) + merged =3D merge_units(merged, extra) =20 sys.stdout.write(format_unit(merged)) --=20 2.41.0