[libvirt] [PATCH] Resolve valgrind error

John Ferlan jferlan at redhat.com
Mon Apr 29 13:04:46 UTC 2013


On 04/29/2013 08:45 AM, Michal Privoznik wrote:
> On 29.04.2013 14:35, John Ferlan wrote:
>> As a result of commit id '19c345f2', 'make -C tests valgrind' has the
>> following for qemuxml2argvtest:
>>
>> ==22482== 197 (80 direct, 117 indirect) bytes in 1 blocks are definitely lost in loss record 101 of 120
>> ==22482==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
>> ==22482==    by 0x4C6F301: virAlloc (viralloc.c:124)
>> ==22482==    by 0x4C840FC: virSaveLastError (virerror.c:308)
>> ==22482==    by 0x431882: qemuBuildCommandLine (qemu_command.c:8204)
>> ==22482==    by 0x41E8F0: testCompareXMLToArgvHelper (qemuxml2argvtest.c:155)
>> ==22482==    by 0x41FE9F: virtTestRun (testutils.c:157)
>> ==22482==    by 0x419DEB: mymain (qemuxml2argvtest.c:654)
>> ==22482==    by 0x4204DA: virtTestMain (testutils.c:719)
>> ==22482==    by 0x39D0821A04: (below main) (libc-start.c:225)
>> ==22482==
>> ---
>>  src/qemu/qemu_command.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>> index d23bdfc..421a93c 100644
>> --- a/src/qemu/qemu_command.c
>> +++ b/src/qemu/qemu_command.c
>> @@ -8205,6 +8205,7 @@ error:
>>      for (i = 0; i <= last_good_net; i++)
>>          virDomainConfNWFilterTeardown(def->nets[i]);
>>      virSetError(originalError);
>> +    virFreeError(originalError);
>>      virCommandFree(cmd);
>>      return NULL;
>>  }
>>
> 
> ACK
> 
> Although, I think there are some other places where virSetError is not
> followed by virFreeError, e.g. src/network/bridge_driver.c:2143
> 
> Michal
> 

Right I saw that one too, but since it wasn't directly related to this
particular error I "passed" for now, but can generate a separate patch
for that. Unless of course it's felt I should use this opportunity to
handle both.

I also noted there's some inconsistent uses  - some places check the
return of virSaveLastError() before calling virSetError() although it
doesn't seem to cause issues since virCopyError() will "do the right
thing" if the buffer is empty...

John




More information about the libvir-list mailing list