Message ID | 1384777531-14635-20-git-send-email-marcandre.lureau@gmail.com |
---|---|
State | New |
Headers | show |
Il 18/11/2013 13:25, Marc-André Lureau ha scritto: > +static int start_hold; > + > +void vm_start_hold(void) > +{ > + start_hold++; > +} > + > +void vm_start_release(void) > +{ > + start_hold--; > + vm_start(); > +} > + > void vm_start(void) > { > + if (start_hold != 0) { > + return; > + } > + This is interesting. I like it, but I think this sequence: vm_start_hold() vm_start_release() should not call vm_start(), while this: vm_start_hold() vm_start() vm_start_release() should call it. Also, vm_start_hold() should assert that the VM is not running. Paolo
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index cd5791e..a76a6e7 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -38,6 +38,8 @@ void vm_state_notify(int running, RunState state); #define VMRESET_REPORT true void vm_start(void); +void vm_start_hold(void); +void vm_start_release(void); int vm_stop(RunState state); int vm_stop_force_state(RunState state); diff --git a/vl.c b/vl.c index 4ad15b8..8905ba5 100644 --- a/vl.c +++ b/vl.c @@ -1690,8 +1690,25 @@ void vm_state_notify(int running, RunState state) } } +static int start_hold; + +void vm_start_hold(void) +{ + start_hold++; +} + +void vm_start_release(void) +{ + start_hold--; + vm_start(); +} + void vm_start(void) { + if (start_hold != 0) { + return; + } + if (!runstate_is_running()) { cpu_enable_ticks(); runstate_set(RUN_STATE_RUNNING);
This is a simple solution (or hack?) to allow the Spice block driver to hold the VM from starting before the migration state is completed. During migration, the destination qemu needs to initialize the NBD session. This requires waiting for the Spice client and communication before the VM is started, but using a running main loop. Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com> --- include/sysemu/sysemu.h | 2 ++ vl.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)