From patchwork Wed May 21 16:42:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 891540 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp2221182wrm; Wed, 21 May 2025 09:46:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfdBWBAWAB81OBjQ0W9JsNjDn/VI8d8EAwBLSU4varHfcZVij4qIFEmLY8CDvmCUn21DlzzA==@linaro.org X-Google-Smtp-Source: AGHT+IHuPAYVlqlmJrBMyJEu2CdTwzLmatX9dCkU1zJIXOo/zfk/ElhfNaHfobD7GsWi/sDU//7v X-Received: by 2002:a05:6602:4012:b0:864:8761:8219 with SMTP id ca18e2360f4ac-86a2322982cmr2591601139f.10.1747845978931; Wed, 21 May 2025 09:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747845978; cv=none; d=google.com; s=arc-20240605; b=ZAJXKb5GuuCG243YBYagDpywk4OYT9XTUZ4lpvHFw4V+R0pt6SovP3mXVaIE+JE60a 7OShnlPGX41ibgDejUWPK7BE2ffBTwjsxdTZf+HTEW6WZr/An57YKglkSjRs+HzoD1FO oruM04KW8s9Q+y3Mj8V1d2n2/n+AibI1YOkVYa5d+Zjde3uXryma43i60/koZMJYF2vR Ihgkf7yG1afzvsuwbIR2hp0V/QF6LioqSA1NcMJzKQaOepvzceGaWaCSAJr+SmNGQ/Rf Y+MMCrXEJi4lw7shQ6IRtfT1FF4Q7ltS0rZ9SrEhxD9PHs6gc82smtPXgVUwArKlCjSN NCow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XSaW7EPhU0xD/RI/rQjLR4sQyzmwUKCWSad6bmNOlRE=; fh=n8n4ZOouvJPGKyhPzYbRbAv3WQ3VfBu7CHa502r5QDY=; b=NEXt1rDZbGok8yXeHExyoqXdgM037B9jbneVXFnPA2jkya+VGiwHMibmTbTlufBJED vjroH3XDAaOp342HziyXTY5HcgzTwWYuy5zGhUiVCAjRfA1Ngq/ZvOu91uTnHfgTkFSX MrQtZPBwEU47lLl8jefGejp7gMZLkBwy6kOy/XwrDxeSiw89vXA5xUTGngTK23MnlRBb bF5gTEZzc9CTwTK1yi4JXbCNSTmkYlOerxyzkQ5D0bHLdNh2RdA+GgorrHbG0oqLmah0 Xt1FbHAEVvjsmF0yE4WNkTcxbw65pRRfuF3G39m6yE0qq0d/DRDc3KJOUcHdGtEm9PTH djHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sq3GLCWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4fbcfac9c77si9214395173.61.2025.05.21.09.46.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 May 2025 09:46:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sq3GLCWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHmX4-0000Sj-EV; Wed, 21 May 2025 12:43:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHmX3-0000Rf-0s for qemu-devel@nongnu.org; Wed, 21 May 2025 12:43:05 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uHmWy-00069G-GD for qemu-devel@nongnu.org; Wed, 21 May 2025 12:43:04 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ad5a11c2942so288673266b.3 for ; Wed, 21 May 2025 09:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1747845777; x=1748450577; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XSaW7EPhU0xD/RI/rQjLR4sQyzmwUKCWSad6bmNOlRE=; b=sq3GLCWuTQmqwuC+hqOXawrF1Yy00Etf7/QfAokCiLs/QVcofvg/XEhTdEz+mnCnCW QFVFnM7mHxPl6C3BbC7YeUlQfoyXK7Vh4yCNqgw4KqieWHJydrH/CxIRHYutUh0PP6lC 9rrCVN0IYnCQitmVzbBJEPDlSnnwmfa1Ir+JLQpG7vCbIxbvXurP/JmZ+XNvrVaYOEgp /fwk12UKrUirtp+NH1QhB+YOIiIss3k4RZhMwFIRe2WrEEiFmicOMppyiY7eVFgxtLsS BraDcvz6lF5XWIPyLOejYZ3UZOCK8+K4OsvpGVa8iBNIEe4P2KC2PxRyf2ZGggJshDcu 07fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747845777; x=1748450577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XSaW7EPhU0xD/RI/rQjLR4sQyzmwUKCWSad6bmNOlRE=; b=ji337QKzx2+L68Ol5TGZlAhaeWaBnxQhP9nUq0julZxbvI6/4RaKCAVQnViGDCHwl7 Rq8hXDz5Q/C2CnHWVw8kwrJuJ6TxtpF846qA0TrRVdCZul6oMIkvI3bmzhuiNTOyB4bz lXjnxW/xjsHdCnNKXUECCmhjhQt3Wik4WOkhS/nlrxGDhpKOyiLOv8D6a/Iv4FS0aO9c 6gksJvjq8PxYjqMo1TyVbObInmsTYB2LvcEc3/6SwZjwE7kTQ1LaZWH7bOl7xsq2OCPh 8EDxQSmma7lzaWjaKpqKYbC9BNF7X1NCX+G5KNfpl4QFIJUgfMUw6yh9VNBE9jOxpnAt G0GQ== X-Gm-Message-State: AOJu0YwRw+0P+pYrLdBZFapQEd0Q9i/FJtP43RfWsrpSh1kAzH70z1Mj lI9FW+31SSi3PcxLHfAN1gKJmlePe32S1zVnGevAv1irc/gEp3HQyaH25/RFzJ5Lbdo= X-Gm-Gg: ASbGncvXN3kx0ItiO+QihTRNJg4w7ZSr9JCy3s3uZ49oyGyXkU5auTv/XfiNVtJUcwK 3fSJWdNqnh2VSJxiufFzQP0xJOxrnTPG1FPKUeQ3x1l26SHHVmI8UtmUgj0hcexmXPHviuo8z4R IoUSGq29fnlkhaGjTgUeFduhKtyQxzpuIFunjCmeg1/+6rzKSKk9PTnvhL2zl0Fl1OvxkjwZ8SS uz/EQ4lI7aFRJs+XDJ7ZwUBwsl9KS1xRCrWllcz8mNN9/4sHsyj7mbMnMBqryxVUzDzcMj+MgCp 2kLXnVFUiQNVDiCK9hn/kSfDZFL1N81PMCp0ZADyHzamrDACcVVe X-Received: by 2002:a17:907:7205:b0:ad2:2dc9:e3d3 with SMTP id a640c23a62f3a-ad536ffc80dmr2466608366b.57.1747845776846; Wed, 21 May 2025 09:42:56 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d4967e2sm919240766b.128.2025.05.21.09.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 May 2025 09:42:55 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A7C2C5F9F5; Wed, 21 May 2025 17:42:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Thomas Huth , Paolo Bonzini , Akihiko Odaki , John Snow , Fabiano Rosas , Peter Xu , =?utf-8?q?Ma?= =?utf-8?q?rc-Andr=C3=A9_Lureau?= , Alexandre Iooss , Markus Armbruster , David Hildenbrand , Laurent Vivier , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , Mahmoud Mandour , Sriram Yagnaraman , Dmitry Osipenko , Gustavo Romero , "Michael S. Tsirkin" , Eric Auger Subject: [PATCH v3 06/20] tests/functional: Add PCI hotplug test for aarch64 Date: Wed, 21 May 2025 17:42:36 +0100 Message-Id: <20250521164250.135776-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250521164250.135776-1-alex.bennee@linaro.org> References: <20250521164250.135776-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero Add a functional test, aarch64_hotplug_pci, to exercise PCI hotplug and hot-unplug on arm64. Signed-off-by: Gustavo Romero Reviewed-by: Daniel P. Berrangé Reviewed-by: Eric Auger Message-Id: <20250512144629.182340-1-gustavo.romero@linaro.org> [AJB: add qemu-arm link] Signed-off-by: Alex Bennée --- v2 - add qemu-arm link to MAINTAINERS --- MAINTAINERS | 6 ++ tests/functional/meson.build | 1 + tests/functional/test_aarch64_hotplug_pci.py | 74 ++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100755 tests/functional/test_aarch64_hotplug_pci.py diff --git a/MAINTAINERS b/MAINTAINERS index 7060cf49b9..818d7b9d5f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2078,6 +2078,12 @@ S: Supported F: include/hw/pci/pcie_doe.h F: hw/pci/pcie_doe.c +ARM PCI Hotplug +M: Gustavo Romero +L: qemu-arm@nongnu.org +S: Supported +F: tests/functional/test_aarch64_hotplug_pci.py + ACPI/SMBIOS M: Michael S. Tsirkin M: Igor Mammedov diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 52b4706cfe..2d68840fa2 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -83,6 +83,7 @@ tests_aarch64_system_quick = [ tests_aarch64_system_thorough = [ 'aarch64_aspeed_ast2700', 'aarch64_aspeed_ast2700fc', + 'aarch64_hotplug_pci', 'aarch64_imx8mp_evk', 'aarch64_raspi3', 'aarch64_raspi4', diff --git a/tests/functional/test_aarch64_hotplug_pci.py b/tests/functional/test_aarch64_hotplug_pci.py new file mode 100755 index 0000000000..fa1bb62c8f --- /dev/null +++ b/tests/functional/test_aarch64_hotplug_pci.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# The test hotplugs a PCI device and checks it on a Linux guest. +# +# Copyright (c) 2025 Linaro Ltd. +# +# Author: +# Gustavo Romero +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern +from qemu_test import BUILD_DIR + +class HotplugPCI(LinuxKernelTest): + + ASSET_KERNEL = Asset( + ('https://ftp.debian.org/debian/dists/stable/main/installer-arm64/' + 'current/images/netboot/debian-installer/arm64/linux'), + '3821d4db56d42c6a4eac62f31846e35465940afd87746b4cfcdf5c9eca3117b2') + + ASSET_INITRD = Asset( + ('https://ftp.debian.org/debian/dists/stable/main/installer-arm64/' + 'current/images/netboot/debian-installer/arm64/initrd.gz'), + '2583ec22b45265ad69e82f198674f53d4cd85be124fe012eedc2fd91156bc4b4') + + def test_hotplug_pci(self): + + self.set_machine('virt') + self.vm.add_args('-m', '512M') + self.vm.add_args('-cpu', 'cortex-a57') + self.vm.add_args('-append', + 'console=ttyAMA0,115200 init=/bin/sh') + self.vm.add_args('-device', + 'pcie-root-port,bus=pcie.0,chassis=1,slot=1,id=pcie.1') + self.vm.add_args('-bios', self.build_file('pc-bios', + 'edk2-aarch64-code.fd')) + + # BusyBox prompt + prompt = "~ #" + self.launch_kernel(self.ASSET_KERNEL.fetch(), + self.ASSET_INITRD.fetch(), + wait_for=prompt) + + # Check for initial state: 2 network adapters, lo and enp0s1. + exec_command_and_wait_for_pattern(self, + 'ls -l /sys/class/net | wc -l', + '2') + + # Hotplug one network adapter to the root port, i.e. pcie.1 bus. + self.vm.cmd('device_add', + driver='virtio-net-pci', + bus='pcie.1', + addr=0, + id='na') + # Wait for the kernel to recognize the new device. + self.wait_for_console_pattern('virtio-pci') + self.wait_for_console_pattern('virtio_net') + + # Check if there is a new network adapter. + exec_command_and_wait_for_pattern(self, + 'ls -l /sys/class/net | wc -l', + '3') + + self.vm.cmd('device_del', id='na') + exec_command_and_wait_for_pattern(self, + 'ls -l /sys/class/net | wc -l', + '2') + +if __name__ == '__main__': + LinuxKernelTest.main()