From nobody Sun Nov 9 16:22:02 2025 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 1551158374219650.4731016827194; Mon, 25 Feb 2019 21:19:34 -0800 (PST) Received: from localhost ([127.0.0.1]:49149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyV9Q-0007ds-6z for importer@patchew.org; Tue, 26 Feb 2019 00:19:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyUkm-0004vY-O3 for qemu-devel@nongnu.org; Mon, 25 Feb 2019 23:54:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyUkl-0002LG-Kq for qemu-devel@nongnu.org; Mon, 25 Feb 2019 23:54:04 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:56229) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyUkj-0001Cr-Fg; Mon, 25 Feb 2019 23:54:03 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 447mfJ0qMrz9sN1; Tue, 26 Feb 2019 15:53:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1551156792; bh=8rAnDHnUV2pDx9mh5LCVdHgt4Sv6fwh2/VtwW//EtZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buiYaDd2G/dfQw2Ft7JiGBrFrbv6hvBemAS9wsMVab2ojB6Rn6BWDp3M3711L2JA1 XWBNZbp2+55N4YRoQYYpbLi7IXs9qVjPhVJsy+KA77mJ3GBaDUunD+xmtL3v+UJMX2 Y0rcMfZUeC/dLZKsAStWGB+kbLbnJHY1FgcgKivA= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 26 Feb 2019 15:52:29 +1100 Message-Id: <20190226045304.25618-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226045304.25618-1-david@gibson.dropbear.id.au> References: <20190226045304.25618-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 15/50] tests/device-plug: Add CCW unplug test for s390x 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, Thomas Huth , Cornelia Huck , David Hildenbrand , gkurz@kaod.org, "Michael S . Tsirkin" , qemu-devel@nongnu.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: David Hildenbrand As CCW unplugs are surprise removals without asking the guest first, we can test this without any guest interaction. Reviewed-by: Michael S. Tsirkin Reviewed-by: Thomas Huth Signed-off-by: David Hildenbrand Message-Id: <20190218092202.26683-5-david@redhat.com> Acked-by: Cornelia Huck Signed-off-by: David Gibson --- tests/device-plug-test.c | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/device-plug-test.c b/tests/device-plug-test.c index cd9ada539d..d1a6c94af2 100644 --- a/tests/device-plug-test.c +++ b/tests/device-plug-test.c @@ -15,17 +15,26 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" =20 -static void device_del_request(QTestState *qtest, const char *id) +static void device_del_start(QTestState *qtest, const char *id) { - QDict *resp; + qtest_qmp_send(qtest, + "{'execute': 'device_del', 'arguments': { 'id': %s } }"= , id); +} + +static void device_del_finish(QTestState *qtest) +{ + QDict *resp =3D qtest_qmp_receive(qtest); =20 - resp =3D qtest_qmp(qtest, - "{'execute': 'device_del', 'arguments': { 'id': %s } = }", - id); g_assert(qdict_haskey(resp, "return")); qobject_unref(resp); } =20 +static void device_del_request(QTestState *qtest, const char *id) +{ + device_del_start(qtest, id); + device_del_finish(qtest); +} + static void system_reset(QTestState *qtest) { QDict *resp; @@ -77,8 +86,25 @@ static void test_pci_unplug_request(void) qtest_quit(qtest); } =20 +static void test_ccw_unplug(void) +{ + QTestState *qtest =3D qtest_initf("-device virtio-balloon-ccw,id=3Ddev= 0"); + + /* + * The DEVICE_DELETED events will be sent before the command + * completes. + */ + device_del_start(qtest, "dev0"); + wait_device_deleted_event(qtest, "dev0"); + device_del_finish(qtest); + + qtest_quit(qtest); +} + int main(int argc, char **argv) { + const char *arch =3D qtest_get_arch(); + g_test_init(&argc, &argv, NULL); =20 /* @@ -89,5 +115,10 @@ int main(int argc, char **argv) qtest_add_func("/device-plug/pci-unplug-request", test_pci_unplug_request); =20 + if (!strcmp(arch, "s390x")) { + qtest_add_func("/device-plug/ccw-unplug", + test_ccw_unplug); + } + return g_test_run(); } --=20 2.20.1