From patchwork Wed Nov 30 14:22:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13059966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 120AFC433FE for ; Wed, 30 Nov 2022 14:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiK3OXR (ORCPT ); Wed, 30 Nov 2022 09:23:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiK3OXF (ORCPT ); Wed, 30 Nov 2022 09:23:05 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2A513CD3 for ; Wed, 30 Nov 2022 06:23:01 -0800 (PST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AUCKRPc011460; Wed, 30 Nov 2022 14:22:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=egONSukQoF2qIrqjHYgWiDkisLKzEDJ70Hz6Epe/pMs=; b=ICTm+q++sZK8o3GNIdqQ54Lp3BWyMnNZhTVldeUUiAcA+JFaJJ07SB6N/UkeYjlAV1ZL WzzDB62qiNVKQvzalXGn+OxKwRxj15QSkohayJkKbYZe2n5RTIIQ4kPMQXuPvyYjtOAD NCwhIqiDY9VKp/qC+axWEuR1vV+nhkly+xxYBzpENxUGOK41FxU+Ll52JUoh6QjaeTcb sqAXQZMFv/FKRvhJuawI0h3aiipIxXTBaS+aTjwfwyZ0mpdGZJaDwVsbmA3XUB78H1eL lskdhGXEJmIQ2lXQmm2sXcF5r4/7q4gfuv3TEeUf4osfHJ1SgAda3iV04i+H7Gu/odeM 7w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m65abnmud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:56 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AUCQV9S027801; Wed, 30 Nov 2022 14:22:55 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m65abnmtb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:55 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AUEJxDL019961; Wed, 30 Nov 2022 14:22:53 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03fra.de.ibm.com with ESMTP id 3m3ae8v9yn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AUEMo436816484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Nov 2022 14:22:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CF25AE056; Wed, 30 Nov 2022 14:22:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5920DAE057; Wed, 30 Nov 2022 14:22:50 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Nov 2022 14:22:50 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev, lvivier@redhat.com Subject: [kvm-unit-tests PATCH v1 1/4] lib: add function to request migration Date: Wed, 30 Nov 2022 15:22:46 +0100 Message-Id: <20221130142249.3558647-2-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130142249.3558647-1-nrb@linux.ibm.com> References: <20221130142249.3558647-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: G_oX2jFULv0ruvivYnZHRs45i1ew7s1p X-Proofpoint-GUID: ELeoxyj86fcRxcTaj-k2S-0zhjJ2LaQY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-30_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 suspectscore=0 clxscore=1011 bulkscore=0 priorityscore=1501 adultscore=0 malwarescore=0 mlxlogscore=967 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211300099 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Migration tests can ask migrate_cmd to migrate them to a new QEMU process. Requesting migration and waiting for completion is hence a common pattern which is repeated all over the code base. Add a function which does all of that to avoid repeating the same pattern. Since migrate_cmd currently can only migrate exactly once, this function is called migrate_once() and is a no-op when it has been called before. This can simplify the control flow, especially when tests are skipped. Suggested-by: Claudio Imbrenda Signed-off-by: Nico Boehr --- lib/migrate.c | 34 ++++++++++++++++++++++++++++++++++ lib/migrate.h | 9 +++++++++ 2 files changed, 43 insertions(+) create mode 100644 lib/migrate.c create mode 100644 lib/migrate.h diff --git a/lib/migrate.c b/lib/migrate.c new file mode 100644 index 000000000000..50e78fb08865 --- /dev/null +++ b/lib/migrate.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Migration-related functions + * + * Copyright IBM Corp. 2022 + * Author: Nico Boehr + */ +#include +#include "migrate.h" + +/* static for now since we only support migrating exactly once per test. */ +static void migrate(void) +{ + puts("Please migrate me, then press return\n"); + (void)getchar(); + report_info("Migration complete"); +} + +/* + * Initiate migration and wait for it to complete. + * If this function is called more than once, it is a no-op. + * Since migrate_cmd can only migrate exactly once this function can + * simplify the control flow, especially when skipping tests. + */ +void migrate_once(void) +{ + static bool migrated; + + if (migrated) + return; + + migrated = true; + migrate(); +} diff --git a/lib/migrate.h b/lib/migrate.h new file mode 100644 index 000000000000..3c94e6af761c --- /dev/null +++ b/lib/migrate.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Migration-related functions + * + * Copyright IBM Corp. 2022 + * Author: Nico Boehr + */ + +void migrate_once(void); From patchwork Wed Nov 30 14:22:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13059965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FDB8C4332F for ; Wed, 30 Nov 2022 14:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiK3OXL (ORCPT ); Wed, 30 Nov 2022 09:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229760AbiK3OXF (ORCPT ); Wed, 30 Nov 2022 09:23:05 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC1D912D2E for ; Wed, 30 Nov 2022 06:23:01 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AUE5X0E005190; Wed, 30 Nov 2022 14:22:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=wzpoGDafi0okupBMlUbNNOCWDtawE0AesLmsYXJ4pc4=; b=CilTQUAvaiOB8E4MFoXoYFidEgEZYbXIOn1+AsFYEbgaIpZ3cDbIm5pyKn3V/iPdLAy9 iL8NPWGHx+QKZCigQ9VULOauHm5I21ndOQv5RdZUltY9zRVTcKFpZLUYbre9JEsOuX68 d51EUu8jyzCbGVh4uTEsd3a1mPtP1Ts5717sGSfaPWLHFB0/DU3mEBGBjgthoYqLSBs5 gk2t9/kuhmIPrr5nbC3H6y5AUGV8RjxUov3EwKe1xrE3FH3jW/cVVximpB/9lei03Zal 1NClWH41Md7G4+qbRg6OY+qi+JtKIiwN2c/+QclfgsfGze2vlV9VO5Curs8v0QxaRN62 NQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m68ms0djr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:56 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AUE6GWc007562; Wed, 30 Nov 2022 14:22:56 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m68ms0dj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:55 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AUEKkt6018134; Wed, 30 Nov 2022 14:22:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3m3a2hv943-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:54 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AUEMpYM54460682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Nov 2022 14:22:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BEFFAE056; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A85C6AE045; Wed, 30 Nov 2022 14:22:50 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Nov 2022 14:22:50 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev, lvivier@redhat.com Subject: [kvm-unit-tests PATCH v1 2/4] powerpc: use migrate_once() in migration tests Date: Wed, 30 Nov 2022 15:22:47 +0100 Message-Id: <20221130142249.3558647-3-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130142249.3558647-1-nrb@linux.ibm.com> References: <20221130142249.3558647-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eGNPun9jdh6klVhqiY24at0PH5oOgYAZ X-Proofpoint-GUID: 845wA4WoeSP7s0Q7K034BDktN5Q-ULrG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-30_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 adultscore=0 mlxlogscore=786 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211300099 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Nico Boehr Reviewed-by: Thomas Huth --- powerpc/Makefile.common | 1 + powerpc/sprs.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index 12c280c15fff..8ce00340b6be 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -36,6 +36,7 @@ cflatobjs += lib/getchar.o cflatobjs += lib/alloc_phys.o cflatobjs += lib/alloc.o cflatobjs += lib/devicetree.o +cflatobjs += lib/migrate.o cflatobjs += lib/powerpc/io.o cflatobjs += lib/powerpc/hcall.o cflatobjs += lib/powerpc/setup.o diff --git a/powerpc/sprs.c b/powerpc/sprs.c index d3c8780e8376..5cc1cd16cfda 100644 --- a/powerpc/sprs.c +++ b/powerpc/sprs.c @@ -21,6 +21,7 @@ */ #include #include +#include #include #include #include @@ -285,8 +286,7 @@ int main(int argc, char **argv) get_sprs(before); if (pause) { - puts("Now migrate the VM, then press a key to continue...\n"); - (void) getchar(); + migrate_once(); } else { puts("Sleeping...\n"); handle_exception(0x900, &dec_except_handler, &decr); From patchwork Wed Nov 30 14:22:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13059962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98132C433FE for ; Wed, 30 Nov 2022 14:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiK3OXG (ORCPT ); Wed, 30 Nov 2022 09:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbiK3OXE (ORCPT ); Wed, 30 Nov 2022 09:23:04 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67B8EF59B for ; Wed, 30 Nov 2022 06:22:59 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AUEIlkA026089; Wed, 30 Nov 2022 14:22:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=dEFN9QSljfhHLmR+suAn+4bXAUscDgZ1V80hCb7Y71I=; b=LKRjeh/s+QpTkrK9X7WIn2UL78JHNLSC7qACqw0/svReNGp9iry38ngdRKAxLB1P0i9l GLcrytaePEqvmMuvaL8RWGQZabMhqpPN3lyp3K+cSr5/u7ijfTkzdatgosrIx26hvx70 N8P1TLP7T8tAYcgDA4BOS/HacBWd1vmLNihXcjOuHNCxQt3MaeyDY0wYt9xM7tE03QXy /kkDEmnDFG/v9I5tj+VWPFllmt75EnS5vcccgY1uZDExNAFQyxYrA85aeEPwr3Wpqv6B KPTYo6QKRNqOI66YAok1r/CYelzmNRFXMG63dAFDphspVymfNk+9+fdg28OYxR921ydD YQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m68ms0djw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:56 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AUE5WCL005165; Wed, 30 Nov 2022 14:22:56 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m68ms0dj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:56 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AUEKESS011860; Wed, 30 Nov 2022 14:22:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3m3a2hwxst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:54 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AUEMpFK6422936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Nov 2022 14:22:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C71DAE051; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17DFFAE057; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev, lvivier@redhat.com Subject: [kvm-unit-tests PATCH v1 3/4] s390x: use migrate_once() in migration tests Date: Wed, 30 Nov 2022 15:22:48 +0100 Message-Id: <20221130142249.3558647-4-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130142249.3558647-1-nrb@linux.ibm.com> References: <20221130142249.3558647-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: e4eNzX42ZBIgjm2FR9m6Pc9sBxXKddfE X-Proofpoint-GUID: -qqsJQ1FIi5Av8ipoO5bh2t0SdAO4Vww X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-30_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 adultscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211300099 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org migrate_once() can simplify the control flow in migration-skey and migration-cmm. Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + s390x/migration-cmm.c | 27 +++++++++------------------ s390x/migration-sck.c | 4 ++-- s390x/migration-skey.c | 23 +++++++++-------------- s390x/migration.c | 7 ++----- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index bf1504f9d58c..52a9d821974e 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -85,6 +85,7 @@ cflatobjs += lib/alloc_page.o cflatobjs += lib/vmalloc.o cflatobjs += lib/alloc_phys.o cflatobjs += lib/getchar.o +cflatobjs += lib/migrate.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o cflatobjs += lib/s390x/sclp.o diff --git a/s390x/migration-cmm.c b/s390x/migration-cmm.c index aa7910ca76bf..64adc6ed9e14 100644 --- a/s390x/migration-cmm.c +++ b/s390x/migration-cmm.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -31,6 +32,11 @@ static void test_migration(void) BIT(ESSA_USAGE_VOLATILE) | BIT(ESSA_USAGE_POT_VOLATILE) /* ESSA_SET_POT_VOLATILE */ }; + if (!check_essa_available()) { + report_skip("ESSA is not available"); + return; + } + assert(NUM_PAGES % 4 == 0); for (i = 0; i < NUM_PAGES; i += 4) { essa(ESSA_SET_STABLE, (unsigned long)pagebuf[i]); @@ -39,8 +45,7 @@ static void test_migration(void) essa(ESSA_SET_POT_VOLATILE, (unsigned long)pagebuf[i + 3]); } - puts("Please migrate me, then press return\n"); - (void)getchar(); + migrate_once(); for (i = 0; i < NUM_PAGES; i++) { actual_state = essa(ESSA_GET_STATE, (unsigned long)pagebuf[i]); @@ -53,25 +58,11 @@ static void test_migration(void) int main(void) { - bool has_essa = check_essa_available(); - report_prefix_push("migration-cmm"); - if (!has_essa) { - report_skip("ESSA is not available"); - - /* - * If we just exit and don't ask migrate_cmd to migrate us, it - * will just hang forever. Hence, also ask for migration when we - * skip this test alltogether. - */ - puts("Please migrate me, then press return\n"); - (void)getchar(); - - goto done; - } test_migration(); -done: + migrate_once(); + report_prefix_pop(); return report_summary(); } diff --git a/s390x/migration-sck.c b/s390x/migration-sck.c index 2d9a195ab4c4..2a9c87071643 100644 --- a/s390x/migration-sck.c +++ b/s390x/migration-sck.c @@ -9,6 +9,7 @@ */ #include +#include #include static void test_sck_migration(void) @@ -30,8 +31,7 @@ static void test_sck_migration(void) report(!cc, "clock running after set"); report(now_after_set >= time_to_set, "TOD clock value is larger than what has been set"); - puts("Please migrate me, then press return\n"); - (void)getchar(); + migrate_once(); cc = stckf(&now_after_migration); report(!cc, "clock still set"); diff --git a/s390x/migration-skey.c b/s390x/migration-skey.c index b7bd82581abe..a655d30e8312 100644 --- a/s390x/migration-skey.c +++ b/s390x/migration-skey.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -23,6 +24,11 @@ static void test_migration(void) union skey expected_key, actual_key; int i, key_to_set, key_mismatches = 0; + if (test_facility(169)) { + report_skip("storage key removal facility is active"); + return; + } + for (i = 0; i < NUM_PAGES; i++) { /* * Storage keys are 7 bit, lowest bit is always returned as zero @@ -35,8 +41,7 @@ static void test_migration(void) set_storage_key(pagebuf[i], key_to_set, 1); } - puts("Please migrate me, then press return\n"); - (void)getchar(); + migrate_once(); for (i = 0; i < NUM_PAGES; i++) { actual_key.val = get_storage_key(pagebuf[i]); @@ -64,19 +69,9 @@ static void test_migration(void) int main(void) { report_prefix_push("migration-skey"); - if (test_facility(169)) { - report_skip("storage key removal facility is active"); - /* - * If we just exit and don't ask migrate_cmd to migrate us, it - * will just hang forever. Hence, also ask for migration when we - * skip this test altogether. - */ - puts("Please migrate me, then press return\n"); - (void)getchar(); - } else { - test_migration(); - } + test_migration(); + migrate_once(); report_prefix_pop(); return report_summary(); diff --git a/s390x/migration.c b/s390x/migration.c index a45296374cd8..fe6ea8369edb 100644 --- a/s390x/migration.c +++ b/s390x/migration.c @@ -8,6 +8,7 @@ * Nico Boehr */ #include +#include #include #include #include @@ -178,11 +179,7 @@ int main(void) mb(); flag_thread_complete = 0; - /* ask migrate_cmd to migrate (it listens for 'migrate') */ - puts("Please migrate me, then press return\n"); - - /* wait for migration to finish, we will read a newline */ - (void)getchar(); + migrate_once(); flag_migration_complete = 1; From patchwork Wed Nov 30 14:22:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13059964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65262C433FE for ; Wed, 30 Nov 2022 14:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbiK3OXJ (ORCPT ); Wed, 30 Nov 2022 09:23:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbiK3OXE (ORCPT ); Wed, 30 Nov 2022 09:23:04 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A8C764D for ; Wed, 30 Nov 2022 06:22:59 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AUD3l3u023937; Wed, 30 Nov 2022 14:22:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=av6sknw0sh2CwtrLPQcYTo1Uj96udfar3wYKz7JJt64=; b=bJsd/S0Hwx3HluinBSZjKa2u7nTqlVwBRAG5JcyhrVTXwvY2zjo1zOwCGTZwLS7v4Mqo LkDoI4NMFPk9bkk96IHfDjzuJu/wddS67jB6Ny4yjgyIyBmi9n6JSnqgpvKYHsdmp0A/ q/VAH3F7Q7yaM9bW86yQgAtQgvkVHfqQhmVf93aKM3EbZ/CiLGWn6sH0nayhJR7IYU86 5BlPsUWPJBI6tv3KL/bt/4vU8jSn9AXbKMW990vOEpUwCvYOa/ojF9MiLkxlmo9MFrj/ AXvA5M3WEDXS0WGnndfB425/0srxO/6W0J1sfh/jTwtg6CA6aBCPyXOWOHoqNjQq80lP VA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m67qu227y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:57 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AUEHOoF017358; Wed, 30 Nov 2022 14:22:56 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m67qu2272-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:56 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AUEK2Qx020090; Wed, 30 Nov 2022 14:22:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03fra.de.ibm.com with ESMTP id 3m3ae8v9yp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 14:22:54 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AUEMpaB56754540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Nov 2022 14:22:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC740AE057; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 678DAAE056; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Nov 2022 14:22:51 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev, lvivier@redhat.com Subject: [kvm-unit-tests PATCH v1 4/4] arm: use migrate_once() in migration tests Date: Wed, 30 Nov 2022 15:22:49 +0100 Message-Id: <20221130142249.3558647-5-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130142249.3558647-1-nrb@linux.ibm.com> References: <20221130142249.3558647-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tIP3vqSp-xdce9tdG647DOGAMVTSOspx X-Proofpoint-GUID: 7KNNlYiOh3vah4ffMoKXgSWUPlJadZHn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-30_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 priorityscore=1501 mlxlogscore=999 suspectscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211300099 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Some tests already shipped with their own do_migrate() function, remove it and instead use the new migrate_once() function. The control flow in the gib tests can be simplified due to migrate_once(). Signed-off-by: Nico Boehr Reviewed-by: Andrew Jones --- arm/Makefile.common | 1 + arm/debug.c | 14 ++++--------- arm/gic.c | 49 +++++++++++++-------------------------------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/arm/Makefile.common b/arm/Makefile.common index 38385e0c558e..1bbec64f2342 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -38,6 +38,7 @@ cflatobjs += lib/alloc_page.o cflatobjs += lib/vmalloc.o cflatobjs += lib/alloc.o cflatobjs += lib/devicetree.o +cflatobjs += lib/migrate.o cflatobjs += lib/pci.o cflatobjs += lib/pci-host-generic.o cflatobjs += lib/pci-testdev.o diff --git a/arm/debug.c b/arm/debug.c index e9f805632db7..21b0f5aeb590 100644 --- a/arm/debug.c +++ b/arm/debug.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -257,13 +258,6 @@ static void reset_debug_state(void) isb(); } -static void do_migrate(void) -{ - puts("Now migrate the VM, then press a key to continue...\n"); - (void)getchar(); - report_info("Migration complete"); -} - static noinline void test_hw_bp(bool migrate) { extern unsigned char hw_bp0; @@ -291,7 +285,7 @@ static noinline void test_hw_bp(bool migrate) isb(); if (migrate) { - do_migrate(); + migrate_once(); report(num_bp == get_num_hw_bp(), "brps match after migrate"); } @@ -335,7 +329,7 @@ static noinline void test_wp(bool migrate) isb(); if (migrate) { - do_migrate(); + migrate_once(); report(num_wp == get_num_wp(), "wrps match after migrate"); } @@ -369,7 +363,7 @@ static noinline void test_ss(bool migrate) isb(); if (migrate) { - do_migrate(); + migrate_once(); } asm volatile("msr daifclr, #8"); diff --git a/arm/gic.c b/arm/gic.c index 60457e29e73a..c950b0d1597c 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -12,6 +12,7 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include +#include #include #include #include @@ -779,23 +780,15 @@ static void test_its_trigger(void) static void test_its_migration(void) { struct its_device *dev2, *dev7; - bool test_skipped = false; cpumask_t mask; - if (its_setup1()) { - test_skipped = true; - goto do_migrate; - } + if (its_setup1()) + return; dev2 = its_get_device(2); dev7 = its_get_device(7); -do_migrate: - puts("Now migrate the VM, then press a key to continue...\n"); - (void)getchar(); - report_info("Migration complete"); - if (test_skipped) - return; + migrate_once(); stats_reset(); cpumask_clear(&mask); @@ -822,21 +815,17 @@ static void test_migrate_unmapped_collection(void) { struct its_collection *col = NULL; struct its_device *dev2 = NULL, *dev7 = NULL; - bool test_skipped = false; cpumask_t mask; int pe0 = 0; u8 config; - if (its_setup1()) { - test_skipped = true; - goto do_migrate; - } + if (its_setup1()) + return; if (!errata(ERRATA_UNMAPPED_COLLECTIONS)) { report_skip("Skipping test, as this test hangs without the fix. " "Set %s=y to enable.", ERRATA_UNMAPPED_COLLECTIONS); - test_skipped = true; - goto do_migrate; + return; } col = its_create_collection(pe0, pe0); @@ -847,12 +836,7 @@ static void test_migrate_unmapped_collection(void) its_send_mapti(dev2, 8192, 0, col); gicv3_lpi_set_config(8192, LPI_PROP_DEFAULT); -do_migrate: - puts("Now migrate the VM, then press a key to continue...\n"); - (void)getchar(); - report_info("Migration complete"); - if (test_skipped) - return; + migrate_once(); /* on the destination, map the collection */ its_send_mapc(col, true); @@ -887,15 +871,12 @@ static void test_its_pending_migration(void) struct its_collection *collection[2]; int *expected = calloc(nr_cpus, sizeof(int)); int pe0 = nr_cpus - 1, pe1 = nr_cpus - 2; - bool test_skipped = false; u64 pendbaser; void *ptr; int i; - if (its_prerequisites(4)) { - test_skipped = true; - goto do_migrate; - } + if (its_prerequisites(4)) + return; dev = its_create_device(2 /* dev id */, 8 /* nb_ites */); its_send_mapd(dev, true); @@ -942,12 +923,7 @@ static void test_its_pending_migration(void) gicv3_lpi_rdist_enable(pe0); gicv3_lpi_rdist_enable(pe1); -do_migrate: - puts("Now migrate the VM, then press a key to continue...\n"); - (void)getchar(); - report_info("Migration complete"); - if (test_skipped) - return; + migrate_once(); /* let's wait for the 256 LPIs to be handled */ mdelay(1000); @@ -994,14 +970,17 @@ int main(int argc, char **argv) } else if (!strcmp(argv[1], "its-migration")) { report_prefix_push(argv[1]); test_its_migration(); + migrate_once(); report_prefix_pop(); } else if (!strcmp(argv[1], "its-pending-migration")) { report_prefix_push(argv[1]); test_its_pending_migration(); + migrate_once(); report_prefix_pop(); } else if (!strcmp(argv[1], "its-migrate-unmapped-collection")) { report_prefix_push(argv[1]); test_migrate_unmapped_collection(); + migrate_once(); report_prefix_pop(); } else if (strcmp(argv[1], "its-introspection") == 0) { report_prefix_push(argv[1]);