]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: add return value check
authorAlex Jia <ajia@redhat.com>
Wed, 28 Sep 2011 08:00:49 +0000 (16:00 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 28 Sep 2011 17:06:34 +0000 (11:06 -0600)
* src/qemu/qemu_migration.c: if 'vmdef' is NULL, the function
  virDomainSaveConfig still dereferences it, it doesn't make
  sense, so should add return value check to make sure 'vmdef'
  is non-NULL before calling virDomainSaveConfig, in addition,
  in order to debug later, also should record error information
  into log.

Signed-off-by: Alex Jia <ajia@redhat.com>
src/qemu/qemu_migration.c

index be6d0e0f415b4289f64d1798d0c65efc64856044..1122daba949de90014169e00d27f3b401ed735ea 100644 (file)
@@ -2583,7 +2583,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
                 vm->newDef = vmdef = mig->persistent;
             else
                 vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
-            if (virDomainSaveConfig(driver->configDir, vmdef) < 0) {
+            if (!vmdef || virDomainSaveConfig(driver->configDir, vmdef) < 0) {
                 /* Hmpf.  Migration was successful, but making it persistent
                  * was not.  If we report successful, then when this domain
                  * shuts down, management tools are in for a surprise.  On the
@@ -2604,6 +2604,9 @@ qemuMigrationFinish(struct qemud_driver *driver,
                     if (newVM)
                         vm->persistent = 0;
                 }
+                if (!vmdef)
+                    qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                                    _("can't get vmdef"));
                 goto endjob;
             }