[libvirt] [PATCH 1/2] qemu: don't bootup guest in reboot operation if the migration job is running

Guannan Ren gren at redhat.com
Mon Jun 18 13:52:08 UTC 2012


After an reboot operation, the guest will shutdown first then bootup
in a separate thread from the eventloop thread. If we start the migration
job, according to the time gap between reboot and migrate command,
the system_reset action of bootup operation will probably block from the
migration job utill timeouts.

In this case, the solution is that we don't bootup the guest
on the source server, we pass the task to target machine.
---
 src/qemu/qemu_process.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1df3637..7c7132a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -632,14 +632,14 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                           virDomainObjPtr vm)
 {
     struct qemud_driver *driver = qemu_driver;
-    qemuDomainObjPrivatePtr priv;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    struct qemuDomainJobObj *job = &priv->job;
     virDomainEventPtr event = NULL;
 
     VIR_DEBUG("vm=%p", vm);
 
     virDomainObjLock(vm);
 
-    priv = vm->privateData;
     if (priv->gotShutdown) {
         VIR_DEBUG("Ignoring repeated SHUTDOWN event from domain %s",
                   vm->def->name);
@@ -668,6 +668,17 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     if (priv->agent)
         qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SHUTDOWN);
 
+    /*
+     * When a vm is in the job of migrating out and meanwhile
+     * the guest is shutting down for an reboot, we keep the
+     * shutdown state of the vm on the source server, letting
+     * the target machine do the booting work after migration.
+     */
+    if (priv->fakeReboot &&
+        job->asyncJob &&
+        job->asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
+        goto unlock;
+
     qemuProcessShutdownOrReboot(driver, vm);
 
 unlock:
-- 
1.7.7.5




More information about the libvir-list mailing list