[libvirt] [PATCH v2] qemu: add return value check

From: Alex Jia <ajia@redhat.com> * 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 | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index ef48d65..a009a57 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2582,7 +2582,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 @@ -2603,6 +2603,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; } -- 1.7.1

On 09/28/2011 02:00 AM, ajia@redhat.com wrote:
From: Alex Jia<ajia@redhat.com>
* 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 | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
ACK and pushed, after fixing your trailing whitespace bug that 'make syntax-check' tripped on. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 09/29/2011 01:10 AM, Eric Blake wrote:
On 09/28/2011 02:00 AM, ajia@redhat.com wrote:
From: Alex Jia<ajia@redhat.com>
* 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 | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
ACK and pushed, after fixing your trailing whitespace bug that 'make syntax-check' tripped on.
Eric, thanks a lot. Alex
participants (3)
-
ajia@redhat.com
-
Alex Jia
-
Eric Blake