From nobody Tue Feb 10 00:22:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552381068444361.26348790318866; Tue, 12 Mar 2019 01:57:48 -0700 (PDT) Received: from localhost ([127.0.0.1]:47568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3dE9-00035G-BS for importer@patchew.org; Tue, 12 Mar 2019 04:57:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3dC6-0001VE-7I for qemu-devel@nongnu.org; Tue, 12 Mar 2019 04:55:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3dC5-0001Ms-5m for qemu-devel@nongnu.org; Tue, 12 Mar 2019 04:55:30 -0400 Received: from ozlabs.org ([203.11.71.1]:36595) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3dC2-0001JT-Ou; Tue, 12 Mar 2019 04:55:29 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 44JTMH24hNz9sBp; Tue, 12 Mar 2019 19:55:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1552380923; bh=d8KRjn1xSKbxO4oU0mWeI6TBG8oCZxOpv6BCSAIySzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKAinBCKfltwatcDGFebNnjQSN2qT0HSkZ2zZzWrFohHe2UhcbQQ5mFGb0kKscclB fpuLucdiQ28qdj+8OXR5AU7cASgBT5bmhs7UDTnDpIft3HST5l4aRaL4pVB2HJk9Sy wI2vXFD/q6nrvnLY9BqglTim2/walQollUlHL0po= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 12 Mar 2019 19:54:03 +1100 Message-Id: <20190312085502.8203-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312085502.8203-1-david@gibson.dropbear.id.au> References: <20190312085502.8203-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 03/62] spapr: Simulate CAS for qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Michael Roth , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz The RTAS event hotplug code for machine types 2.8 and newer depends on the CAS negotiated ov5 in order to work properly. However, there's no CAS when running under qtest. There has been a tentative to trick the code by faking the OV5_HP_EVT bit, but it turned out to break other assumptions in the code and the change got reverted. Go for a more general approach and simulate a CAS when running under qtest. For simplicity, this pseudo CAS simple simulates the case where the guest supports the same features as the machine. It is done at reset time, just before we reset the DRCs, which could potentially exercise the unplug code. This allows to test unplug on spapr with both older and newer machine types. Suggested-by: Michael Roth Signed-off-by: Greg Kurz Message-Id: <155146875704.147873.10563808578795890265.stgit@bahia.lan> Tested-by: Michael Roth Reviewed-by: Michael Roth Signed-off-by: David Gibson --- hw/ppc/spapr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9e01226e18..f7d527464c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -29,6 +29,7 @@ #include "qapi/visitor.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" +#include "sysemu/qtest.h" #include "hw/hw.h" #include "qemu/log.h" #include "hw/fw-path-provider.h" @@ -1711,6 +1712,16 @@ static void spapr_machine_reset(void) */ spapr_irq_reset(spapr, &error_fatal); =20 + /* + * There is no CAS under qtest. Simulate one to please the code that + * depends on spapr->ov5_cas. This is especially needed to test device + * unplug, so we do that before resetting the DRCs. + */ + if (qtest_enabled()) { + spapr_ovec_cleanup(spapr->ov5_cas); + spapr->ov5_cas =3D spapr_ovec_clone(spapr->ov5); + } + /* DRC reset may cause a device to be unplugged. This will cause troub= les * if this device is used by another device (eg, a running vhost backe= nd * will crash QEMU if the DIMM holding the vring goes away). To avoid = such --=20 2.20.1