]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Preserve original error during migration
authorJiri Denemark <jdenemar@redhat.com>
Fri, 20 Apr 2012 12:07:49 +0000 (14:07 +0200)
committerCole Robinson <crobinso@redhat.com>
Thu, 26 Apr 2012 18:14:55 +0000 (14:14 -0400)
In some cases (spotted with broken connection during tunneled migration)
we were overwriting the original error with worse or even misleading
errors generated when we were cleaning up after failed migration.

src/qemu/qemu_migration.c

index 07f5edb44b9fb26dec7d738fdebe50561bd8b24a..85907a6ee3bfe896e3394b3743837ff0637bf82d 100644 (file)
@@ -1732,6 +1732,7 @@ qemuMigrationRun(struct qemud_driver *driver,
     qemuMigrationIOThreadPtr iothread = NULL;
     int fd = -1;
     unsigned long migrate_speed = resource ? resource : priv->migMaxBandwidth;
+    virErrorPtr orig_err = NULL;
 
     VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=%lx, resource=%lu, "
@@ -1873,6 +1874,9 @@ qemuMigrationRun(struct qemud_driver *driver,
     ret = 0;
 
 cleanup:
+    if (ret < 0 && !orig_err)
+        orig_err = virSaveLastError();
+
     if (spec->fwdType != MIGRATION_FWD_DIRECT) {
         /* Close now to ensure the IO thread quits & is joinable */
         VIR_FORCE_CLOSE(fd);
@@ -1887,9 +1891,16 @@ cleanup:
 
     qemuMigrationCookieFree(mig);
 
+    if (orig_err) {
+        virSetError(orig_err);
+        virFreeError(orig_err);
+    }
+
     return ret;
 
 cancel:
+    orig_err = virSaveLastError();
+
     if (virDomainObjIsActive(vm)) {
         if (qemuDomainObjEnterMonitorAsync(driver, vm,
                                            QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {
@@ -2494,6 +2505,7 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
     virDomainEventPtr event = NULL;
     int ret = -1;
     int resume = 0;
+    virErrorPtr orig_err = NULL;
 
     if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
         goto cleanup;
@@ -2539,6 +2551,9 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
     resume = 0;
 
 endjob:
+    if (ret < 0)
+        orig_err = virSaveLastError();
+
     if (resume && virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
         /* we got here through some sort of failure; start the domain again */
         if (qemuProcessStartCPUs(driver, vm, conn,
@@ -2568,6 +2583,11 @@ endjob:
         vm = NULL;
     }
 
+    if (orig_err) {
+        virSetError(orig_err);
+        virFreeError(orig_err);
+    }
+
 cleanup:
     if (vm)
         virDomainObjUnlock(vm);