Message ID | 20180207190334.16516-6-drjones@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 07/02/2018 20:03, Andrew Jones wrote: > Wrap migration starting and waiting into a function in order to > encapsulate the protocol. > > Signed-off-by: Andrew Jones <drjones@redhat.com> > --- > 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 I don't think this belongs in libcflat.h. Maybe userinput.h? Paolo
On Wed, Feb 14, 2018 at 12:45:31PM +0100, Paolo Bonzini wrote: > On 07/02/2018 20:03, Andrew Jones wrote: > > Wrap migration starting and waiting into a function in order to > > encapsulate the protocol. > > > > Signed-off-by: Andrew Jones <drjones@redhat.com> > > --- > > 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 > > I don't think this belongs in libcflat.h. Maybe userinput.h? > Yeah, IMO it'd be nice to completely kill libcflat.h. I'm not sure how many user input type functions we'll add to the framework, so I'm a bit concerned userinput.h will be a one prototype header. Well, unless you want to throw command line parsing in there too. How about we try to better use the concept of util.h? Maybe rename it to test-util.h or something else (userinput.h?) first? (Side note, we could definitely use a lib/report.h for all the report prototypes.) Thanks, drew
On 14/02/2018 13:44, Andrew Jones wrote: > Yeah, IMO it'd be nice to completely kill libcflat.h. I'm not sure how > many user input type functions we'll add to the framework, so I'm a bit > concerned userinput.h will be a one prototype header. Well, unless you > want to throw command line parsing in there too. How about we try to > better use the concept of util.h? Maybe rename it to test-util.h or > something else (userinput.h?) first? test-util.[hc] gets my vote. Paolo
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
Wrap migration starting and waiting into a function in order to encapsulate the protocol. Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/libcflat.h | 7 +++++++ powerpc/sprs.c | 4 +--- scripts/arch-run.bash | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-)