From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 5/8] lib: Introduce do_migration Date: Wed, 7 Feb 2018 20:03:31 +0100 Message-ID: <20180207190334.16516-6-drjones@redhat.com> References: <20180207190334.16516-1-drjones@redhat.com> Cc: pbonzini@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38982 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754450AbeBGTDl (ORCPT ); Wed, 7 Feb 2018 14:03:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 502E340363AD for ; Wed, 7 Feb 2018 19:03:41 +0000 (UTC) In-Reply-To: <20180207190334.16516-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Wrap migration starting and waiting into a function in order to encapsulate the protocol. Signed-off-by: Andrew Jones --- lib/libcflat.h | 7 +++++++ powerpc/sprs.c | 4 +--- scripts/arch-run.bash | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libcflat.h b/lib/libcflat.h index c680b69a926e..29b39a54eb00 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -159,4 +159,11 @@ void print_binstr(unsigned long x); extern void setup_vm(void); +static inline void do_migration(void) +{ + report_info("Migration Start, migrate the VM and then press a key to continue..."); + while (getchar() == 0); + report_info("Migration Complete"); +} + #endif diff --git a/powerpc/sprs.c b/powerpc/sprs.c index 5b5a54032819..a75abdd7f8c1 100644 --- a/powerpc/sprs.c +++ b/powerpc/sprs.c @@ -284,9 +284,7 @@ int main(int argc, char **argv) get_sprs(before); if (pause) { - puts("Now migrate the VM, then press a key to continue...\n"); - while (getchar() == 0) - cpu_relax(); + do_migration(); } else { puts("Sleeping...\n"); handle_exception(0x900, &dec_except_handler, NULL); diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index e13af8e8064a..9d8687c42f2c 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -133,8 +133,8 @@ run_migration () -mon chardev=mon2,mode=control -incoming unix:${migsock} < <(cat ${fifo}) & incoming_pid=`jobs -l %+ | awk '{print$2}'` - # The test must prompt the user to migrate, so wait for the "migrate" keyword - while ! grep -q -i "migrate" < ${migout1} ; do + # Wait for the unit test to execute do_migration() + while ! grep -q "Migration Start" < ${migout1} ; do sleep 1 done -- 2.13.6