[PATCH] qemu: add return value check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alex Jia <ajia@xxxxxxxxxx>

* 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. 

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0a5a13d..ec994a5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2580,8 +2580,14 @@ qemuMigrationFinish(struct qemud_driver *driver,
             vm->persistent = 1;
             if (mig->persistent)
                 vm->newDef = vmdef = mig->persistent;
-            else
+            else {
                 vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
+                if (!vmdef) {
+                    qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                                    _("can't get vmdef"));
+                    goto endjob;
+                }
+            }
             if (virDomainSaveConfig(driver->configDir, vmdef) < 0) {
                 /* Hmpf.  Migration was successful, but making it persistent
                  * was not.  If we report successful, then when this domain
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]