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

Re: [libvirt] [PATCH v2 03/14] qemu: Move exit monitor calls in failure paths




On 02/27/2017 03:48 AM, Jiri Denemark wrote:
> On Thu, Feb 23, 2017 at 13:42:05 -0500, John Ferlan wrote:
>> Since qemuDomainObjExitMonitor can also generate error messages,
>> let's move it inside any error message saving code on error paths
>> for various hotplug add activities.
>>
>> Signed-off-by: John Ferlan <jferlan redhat com>
>> ---
>>  src/qemu/qemu_hotplug.c | 33 ++++++++++++++++-----------------
>>  1 file changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
>> index 97fb272..9e2f04b 100644
>> --- a/src/qemu/qemu_hotplug.c
>> +++ b/src/qemu/qemu_hotplug.c
> ...
>> @@ -2276,14 +2275,14 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
>>      orig_err = virSaveLastError();
>>      if (objAdded)
>>          ignore_value(qemuMonitorDelObject(priv->mon, objalias));
>> -    if (orig_err) {
>> -        virSetError(orig_err);
>> -        virFreeError(orig_err);
>> -    }
>>      if (qemuDomainObjExitMonitor(driver, vm) < 0) {
>>          mem = NULL;
>>          goto audit;
>>      }
>> +    if (orig_err) {
>> +        virSetError(orig_err);
>> +        virFreeError(orig_err);
>> +    }
>>  
>>   removedef:
>>      if ((id = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
> 
> This hunk adds a memory leak and doesn't prevent
> qemuDomainObjExitMonitor from overwriting the error message.
> 
> Jirka
> 

Always has to be one non-conformist...

I'll merge in the following diff:

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9e2f04b..0d629af 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2275,14 +2275,14 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
     orig_err = virSaveLastError();
     if (objAdded)
         ignore_value(qemuMonitorDelObject(priv->mon, objalias));
-    if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
         mem = NULL;
-        goto audit;
-    }
     if (orig_err) {
         virSetError(orig_err);
         virFreeError(orig_err);
     }
+    if (!mem)
+        goto audit;

  removedef:
     if ((id = virDomainMemoryFindByDef(vm->def, mem)) >= 0)


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