[PATCH kvm-unit-tests 5/8] lib: Introduce do_migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wrap migration starting and waiting into a function in order to
encapsulate the protocol.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 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




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux