From patchwork Tue Apr 4 14:59:25 2023 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: 670043 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp2493646wrt; Tue, 4 Apr 2023 08:01:50 -0700 (PDT) X-Google-Smtp-Source: AKy350Yc8XCIoxpF0sTY2sDaxxdyCRGouguZ2bc+sKS9b/i+7z/AKGZ8DSOn46xk0Zs70g3K0/Ir X-Received: by 2002:a17:902:ce8d:b0:1a2:1042:cadc with SMTP id f13-20020a170902ce8d00b001a21042cadcmr3262638plg.18.1680620510420; Tue, 04 Apr 2023 08:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680620510; cv=none; d=google.com; s=arc-20160816; b=N6gna/DKzJvb9OGJQJGWLUOwVaGg1EO6vDVHp4YDi486Q1noL9nzeTikAaVzSx6X18 IwvFQ2nRKzWNPIj4ZyPjpr1Q0/NnEXhlN3ameInTe1ohsMWwToNCiXaeVWunCgKkE8tI JW9ofVWwZrWPg3RjFDRdcezBN2cNSWcTZuf4Klklfl93hKCiHEnENxnW+t5xDos55Rz/ U6QRvL33rBeNwpdSV41f2o8sxChLia4UxGvYG4hDB90ZRlJ1hEbPMgpzY2mz8tC+ZQc2 sNSK3UIpqVWQJf6qHkjAItoWKWDGfKMmwzuibojfTCKDxca2yVc/5z/2vlnT8kvwQHJS k+yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=begeEv6PzHWw3JSOB2kgWACzTnnU0szOMJ+RXUWQ8A8=; b=vS5qM0w0UgFdls4/e8PdwQW8xl5+g9Oh7Q6AP/xBX9SiUZmEmVkWEMPUGefcfNUvN8 wMDOsInXIZZbea1ffxC987YSspVvL39dzDY+GCIK32Fk0yWeXIfbxtfTfC+mSyAHFq8B 110PmeYZ/ky/gb9XuBCXuV8yRNemw4yqdu1zgVwRuGtWUSTKtvDmNdNIRFRFqd/ZbZJt gswQMFcgEsfpv2Pe2rEuN5JK7B/u+ylycQBJLRD69JU43KNZueXnxnJ1Ax7e8f7m0xfP 8tYDy00Dq1NTxp41eerbKKu81lkPYWxfBVkreT9aFnbGRTjeg2MP6/x1vgcRrrRfVb50 +QPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="E/Ca0Bd7"; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k5-20020a67e3c5000000b00425a6c94841si2080331vsm.740.2023.04.04.08.01.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Apr 2023 08:01:50 -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="E/Ca0Bd7"; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pji8m-0004b0-B7; Tue, 04 Apr 2023 11:00:08 -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 1pji8L-0004Jc-OF for qemu-devel@nongnu.org; Tue, 04 Apr 2023 10:59:45 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pji8F-0005Cd-7F for qemu-devel@nongnu.org; Tue, 04 Apr 2023 10:59:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id y14so33174157wrq.4 for ; Tue, 04 Apr 2023 07:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680620369; 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=begeEv6PzHWw3JSOB2kgWACzTnnU0szOMJ+RXUWQ8A8=; b=E/Ca0Bd7C4CXGFCDNsOJDB649tVI0gVBga77QPwxXTrFMx2LTp/uNm3f38qC6Zv8F+ w74iAgHTgiGHcbqenRue9Jidd+uWx0iI9nCCMLpDlsqnvow/co2U69LIy28979mZyKMX EJHV6QzHJ4VYDRgLucIfoIiyTnpfXqfQZRT+CfbEEN3tPJFiqvsf9gQ/+kPlIY53iLv4 E2Ew8+V5uLWeY0KvZwooepdGMTqLis8VnXPzVsR6tRNbuW1RcZ8itGajZDSItPltopnf vBJFYnEz5Q2EVQUjBsPFFpmh2JsUNHV4m/r/EEVoSOx7m9pmorWzOkPdS/nwBh1slRn1 Iueg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680620369; 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=begeEv6PzHWw3JSOB2kgWACzTnnU0szOMJ+RXUWQ8A8=; b=LqKe94nCiBtIrTl8cmVSX+7JQ3QrxR3mm+Q8brt54zBslK2gstTAmHloOouu7fW8al Gh3QDZ50uXYhDb155iKALpbM5S5XWYGM+DcmSHEG2SpCIE8f4UA1zMSNcXvclCf6uWpF 27LQy8Lsd9H60JLR7tPb63LzXiZ5VfrAwTdGF7hRtGz03FYsJHltXesKqlTpjApPeGQJ khU01ciGB5FTJecueNgcP6mTFQbrdaus8BkcGcPXRStABeU+bkoTJP0t7dWPbotFlLTJ Cn5YQwoHeYQ5vl0GGdGDbL3B9ZdAXYVTwKZL3g/JFXSuZdnwEKW2VyJMivTHM0JBQdBD Xykg== X-Gm-Message-State: AAQBX9eFpRee+UefpVQgT0BVjS8Z0grXan4IXhX47cLei/Y/lwmEeTUo w3UwnJiF0swuUdo8I3/9WsbNIQ== X-Received: by 2002:adf:dd8d:0:b0:2d7:d4b:b33 with SMTP id x13-20020adfdd8d000000b002d70d4b0b33mr1891316wrl.21.1680620369444; Tue, 04 Apr 2023 07:59:29 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a12-20020a056000100c00b002cea8664304sm12362109wrx.91.2023.04.04.07.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 07:59:27 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0EA191FFC1; Tue, 4 Apr 2023 15:59:26 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, David Woodhouse , =?utf-8?q?Alex_Benn=C3=A9e?= , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal , Paolo Bonzini , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PULL 10/10] tests/avocado: Test Xen guest support under KVM Date: Tue, 4 Apr 2023 15:59:25 +0100 Message-Id: <20230404145925.2638152-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404145925.2638152-1-alex.bennee@linaro.org> References: <20230404145925.2638152-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: David Woodhouse Exercise guests with a few different modes for interrupt delivery. In particular we want to cover: • Xen event channel delivery via GSI to the I/O APIC • Xen event channel delivery via GSI to the i8259 PIC • MSIs routed to PIRQ event channels • GSIs routed to PIRQ event channels As well as some variants of normal non-Xen stuff like MSI to vAPIC and PCI INTx going to the I/O APIC and PIC, which ought to still work even in Xen mode. Signed-off-by: David Woodhouse Signed-off-by: Alex Bennée Message-Id: <20230403134920.2132362-12-alex.bennee@linaro.org> diff --git a/tests/avocado/kvm_xen_guest.py b/tests/avocado/kvm_xen_guest.py new file mode 100644 index 0000000000..5391283113 --- /dev/null +++ b/tests/avocado/kvm_xen_guest.py @@ -0,0 +1,171 @@ +# KVM Xen guest functional tests +# +# Copyright © 2021 Red Hat, Inc. +# Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Author: +# David Woodhouse +# Alex Bennée +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os + +from qemu.machine import machine + +from avocado_qemu import LinuxSSHMixIn +from avocado_qemu import QemuSystemTest +from avocado_qemu import wait_for_console_pattern + +class KVMXenGuest(QemuSystemTest, LinuxSSHMixIn): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:q35 + :avocado: tags=accel:kvm + :avocado: tags=kvm_xen_guest + """ + + KERNEL_DEFAULT = 'printk.time=0 root=/dev/xvda console=ttyS0' + + kernel_path = None + kernel_params = None + + # Fetch assets from the kvm-xen-guest subdir of my shared test + # images directory on fileserver.linaro.org where you can find + # build instructions for how they where assembled. + def get_asset(self, name, sha1): + base_url = ('https://fileserver.linaro.org/s/' + 'kE4nCFLdQcoBF9t/download?' + 'path=%2Fkvm-xen-guest&files=' ) + url = base_url + name + # use explicit name rather than failing to neatly parse the + # URL into a unique one + return self.fetch_asset(name=name, locations=(url), asset_hash=sha1) + + def common_vm_setup(self): + # We also catch lack of KVM_XEN support if we fail to launch + self.require_accelerator("kvm") + + self.vm.set_console() + + self.vm.add_args("-accel", "kvm,xen-version=0x4000a,kernel-irqchip=split") + self.vm.add_args("-smp", "2") + + self.kernel_path = self.get_asset("bzImage", + "367962983d0d32109998a70b45dcee4672d0b045") + self.rootfs = self.get_asset("rootfs.ext4", + "f1478401ea4b3fa2ea196396be44315bab2bb5e4") + + def run_and_check(self): + self.vm.add_args('-kernel', self.kernel_path, + '-append', self.kernel_params, + '-drive', f"file={self.rootfs},if=none,format=raw,id=drv0", + '-device', 'xen-disk,drive=drv0,vdev=xvda', + '-device', 'virtio-net-pci,netdev=unet', + '-netdev', 'user,id=unet,hostfwd=:127.0.0.1:0-:22') + + try: + self.vm.launch() + except machine.VMLaunchFailure as e: + if "Xen HVM guest support not present" in e.output: + self.cancel("KVM Xen support is not present " + "(need v5.12+ kernel with CONFIG_KVM_XEN)") + elif "Property 'kvm-accel.xen-version' not found" in e.output: + self.cancel("QEMU not built with CONFIG_XEN_EMU support") + else: + raise e + + self.log.info('VM launched, waiting for sshd') + console_pattern = 'Starting dropbear sshd: OK' + wait_for_console_pattern(self, console_pattern, 'Oops') + self.log.info('sshd ready') + self.ssh_connect('root', '', False) + + self.ssh_command('cat /proc/cmdline') + self.ssh_command('dmesg | grep -e "Grant table initialized"') + + def test_kvm_xen_guest(self): + """ + :avocado: tags=kvm_xen_guest + """ + + self.common_vm_setup() + + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks') + self.run_and_check() + self.ssh_command('grep xen-pirq.*msi /proc/interrupts') + + def test_kvm_xen_guest_nomsi(self): + """ + :avocado: tags=kvm_xen_guest_nomsi + """ + + self.common_vm_setup() + + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks pci=nomsi') + self.run_and_check() + self.ssh_command('grep xen-pirq.* /proc/interrupts') + + def test_kvm_xen_guest_noapic_nomsi(self): + """ + :avocado: tags=kvm_xen_guest_noapic_nomsi + """ + + self.common_vm_setup() + + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks noapic pci=nomsi') + self.run_and_check() + self.ssh_command('grep xen-pirq /proc/interrupts') + + def test_kvm_xen_guest_vapic(self): + """ + :avocado: tags=kvm_xen_guest_vapic + """ + + self.common_vm_setup() + self.vm.add_args('-cpu', 'host,+xen-vapic') + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks') + self.run_and_check() + self.ssh_command('grep xen-pirq /proc/interrupts') + self.ssh_command('grep PCI-MSI /proc/interrupts') + + def test_kvm_xen_guest_novector(self): + """ + :avocado: tags=kvm_xen_guest_novector + """ + + self.common_vm_setup() + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks' + + ' xen_no_vector_callback') + self.run_and_check() + self.ssh_command('grep xen-platform-pci /proc/interrupts') + + def test_kvm_xen_guest_novector_nomsi(self): + """ + :avocado: tags=kvm_xen_guest_novector_nomsi + """ + + self.common_vm_setup() + + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks pci=nomsi' + + ' xen_no_vector_callback') + self.run_and_check() + self.ssh_command('grep xen-platform-pci /proc/interrupts') + + def test_kvm_xen_guest_novector_noapic(self): + """ + :avocado: tags=kvm_xen_guest_novector_noapic + """ + + self.common_vm_setup() + self.kernel_params = (self.KERNEL_DEFAULT + + ' xen_emul_unplug=ide-disks' + + ' xen_no_vector_callback noapic') + self.run_and_check() + self.ssh_command('grep xen-platform-pci /proc/interrupts')