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.lur...@gmail.com>
---
 include/sysemu/sysemu.h |  2 ++
 vl.c                    | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

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);
-- 
1.8.3.1


Reply via email to