]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Adjust EndAsyncJob for qemuDomainSaveInternal error path
authorJohn Ferlan <jferlan@redhat.com>
Mon, 26 Jan 2015 19:13:22 +0000 (14:13 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 29 Jan 2015 17:10:41 +0000 (12:10 -0500)
Commit id '540c339a' to fix issues with reference counting and transient
domains moved the qemuDomainObjEndAsyncJob call prior to the attempt to
restart the guest CPU's resulting in an error:

    error: Failed to save domain rhel70 to /tmp/pl/rhel70.save
    error: internal error: unexpected async job 3

when (ret != 0) - eg, the error path from qemuDomainSaveMemory.

This patch will adjust the logic to call the EndAsyncJob only after
we've tried to restart the guest CPUs. It also needs to adjust the
test for qemuDomainRemoveInactive to add the ret == 0 condition.

Additionally, if we get to endjob: because of some error earlier, then
we need to save that error in the event the CPU restart logic fails.
We don't want to return the error from CPU restart failure, rather we
want to return the error from the failed save that caused us to fall
into the retry to start the CPU logic.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_driver.c

index 1d3bee67f413360fd10f417d807a3b0b477ea60b..0174c875a6cf3915de2e188ba464ac58435a0eb2 100644 (file)
@@ -3208,9 +3208,9 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
                                      VIR_DOMAIN_EVENT_STOPPED,
                                      VIR_DOMAIN_EVENT_STOPPED_SAVED);
  endjob:
-    qemuDomainObjEndAsyncJob(driver, vm);
     if (ret != 0) {
         if (was_running && virDomainObjIsActive(vm)) {
+            virErrorPtr save_err = virSaveLastError();
             rc = qemuProcessStartCPUs(driver, vm, dom->conn,
                                       VIR_DOMAIN_RUNNING_SAVE_CANCELED,
                                       QEMU_ASYNC_JOB_SAVE);
@@ -3220,10 +3220,13 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
                                                           VIR_DOMAIN_EVENT_SUSPENDED,
                                                           VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
             }
+            virSetError(save_err);
+            virFreeError(save_err);
         }
-    } else if (!vm->persistent) {
-        qemuDomainRemoveInactive(driver, vm);
     }
+    qemuDomainObjEndAsyncJob(driver, vm);
+    if (ret == 0 && !vm->persistent)
+        qemuDomainRemoveInactive(driver, vm);
 
  cleanup:
     VIR_FREE(xml);