From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 102002D97A1 for ; Mon, 11 Aug 2025 20:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754943153; cv=none; b=N7o6iK437lWij991cAgZFOiIh7S45bMbL93SYKHEpRZ7HvXnAozJt2L4ziTi0r1hBgFpeuWubLS/EBqU3uDFtxCEWoM41ClhpANVL92k19OX9ZVFM+KAgaVjqOSIWYV7tPDIuS6N7RkD5p+v+d3/J+5V6ZpYF6udAsHQSGGgbHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754943153; c=relaxed/simple; bh=IFLXFvEWuhN5Vvhk0fpUMDNki3itSE8vtYbnSerjjbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U3AI+Sax0R5t8ZVQM4NTeju5NfVaWWatQXJ/p0QCMxmA6gVQkFGLmbiReJwatcf4Sz5AgqvR53SG9GV/DGuqYRYRy5Aib5ayvVKcfM0ccE4AzIV0a3GJ9pLS35qMLIDugJNtv6vTCE6RZE6jb+EURrXSZTy0F6+sCobR80HGfPk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=rz78M8fh; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rz78M8fh" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Htp+tdzU4K3BeH5KfBRNlPwAB+T5ZpxKZ4hYJoVW7zM=; b=rz78M8fhMMh69r9S4GduAUFmBA RYgJSmJvd6mJbujhAt0qviNtdEV7rAR/z5FcAbzUQbeUrD54ZxFNhXzBQdqvjgPMhtJqlRwV0AJAi 1hmUnpDHRfj7ubylO1bVzmEEl9pv9BT6TJBSyMWMr1K2XTvau1c/qpYlls5nO/M1B9+j3ed98Tg6F lsCKEdx5oHzACuYMbd9lrW5snkKQUOb6anDJaVjniaIEUbz4SmjHqI0MiqrtQJUu2gUf58tnEyj8g 2RV184cXyDe25agAt5c+UFO2ZpJT77cHIGFRg3MZupzcvbRI4/8gNa51hJOHnalhTl+ISoMlNHl1B ArfHXsOA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ulYsh-0000000904G-2FAc; Mon, 11 Aug 2025 20:12:31 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 6/8] gen_nodes: fix duplicate pcipassthrough keys in YAML output Date: Mon, 11 Aug 2025 13:12:28 -0700 Message-ID: <20250811201230.2145164-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250811201230.2145164-1-mcgrof@kernel.org> References: <20250811201230.2145164-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain The template was generating multiple 'pcipassthrough' keys for each device, causing YAML parsing warnings about duplicate mapping keys. Fixed by collecting all devices for a target guest first, then outputting a single 'pcipassthrough' key with all devices under it. This uses Jinja2's namespace feature to maintain state across loop iterations. Generated-by: Claude AI Signed-off-by: Luis Chamberlain --- .../roles/gen_nodes/templates/gen_nodes_list.j2 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/playbooks/roles/gen_nodes/templates/gen_nodes_list.j2 b/playbooks/roles/gen_nodes/templates/gen_nodes_list.j2 index e8f5e34..6ad2af1 100644 --- a/playbooks/roles/gen_nodes/templates/gen_nodes_list.j2 +++ b/playbooks/roles/gen_nodes/templates/gen_nodes_list.j2 @@ -1,18 +1,19 @@ {%- macro gen_pci_passthrough_each(n, device_list) -%} -{%- set found_pcie_devices_on_node = False -%} +{%- set ns = namespace(has_devices=false, device_index=1) -%} {%- for d in device_list %} {%- if n == d.target_guest -%} -{%- if not found_pcie_devices_on_node -%} -{% set found_pcie_devices_on_node = True %} +{%- if not ns.has_devices -%} +{%- set ns.has_devices = true %} pcipassthrough: -{% endif %} - passthrough{{ loop.index | string }}: +{% endif -%} + passthrough{{ ns.device_index | string }}: domain: {{ d.domain }} bus: {{ d.bus }} slot: {{ d.slot }} function: {{ d.function }} -{% endif %} -{% endfor -%} +{%- set ns.device_index = ns.device_index + 1 -%} +{%- endif %} +{%- endfor -%} {%- endmacro -%} {%- macro gen_pci_passthrough( device_list ) -%} {%- for d in device_list %} -- 2.47.2