qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: fix small leaks
@ 2017-08-01 16:04 Marc-André Lureau
  2017-08-02  6:09 ` Peter Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Marc-André Lureau @ 2017-08-01 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau, Juan Quintela, Dr. David Alan Gilbert

Spotted thanks to valgrind and tests/device-introspect-test:

==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
==11711==    by 0x695693: migration_instance_init (migration.c:2226)
==11711==    by 0x717C4B: object_init_with_type (object.c:344)
==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
==11711==    by 0x7182EB: object_new_with_type (object.c:483)
==11711==    by 0x718328: object_new (object.c:493)
==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 migration/migration.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/migration/migration.c b/migration/migration.c
index 085c32c994..c3fe0ed9ca 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
     dc->props = migration_properties;
 }
 
+static void migration_instance_finalize(Object *obj)
+{
+    MigrationState *ms = MIGRATION_OBJ(obj);
+    MigrationParameters *params = &ms->parameters;
+
+    g_free(params->tls_hostname);
+    g_free(params->tls_creds);
+}
+
 static void migration_instance_init(Object *obj)
 {
     MigrationState *ms = MIGRATION_OBJ(obj);
@@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
     .class_size = sizeof(MigrationClass),
     .instance_size = sizeof(MigrationState),
     .instance_init = migration_instance_init,
+    .instance_finalize = migration_instance_finalize,
 };
 
 static void register_migration_types(void)
-- 
2.14.0.rc0.1.g40ca67566

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-08-01 16:04 [Qemu-devel] [PATCH] migration: fix small leaks Marc-André Lureau
@ 2017-08-02  6:09 ` Peter Xu
  2017-08-02  6:58 ` Juan Quintela
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Peter Xu @ 2017-08-02  6:09 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, Dr. David Alan Gilbert, Juan Quintela

On Tue, Aug 01, 2017 at 05:04:18PM +0100, Marc-André Lureau wrote:
> Spotted thanks to valgrind and tests/device-introspect-test:
> 
> ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> ==11711==    by 0x718328: object_new (object.c:493)
> ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks,

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-08-01 16:04 [Qemu-devel] [PATCH] migration: fix small leaks Marc-André Lureau
  2017-08-02  6:09 ` Peter Xu
@ 2017-08-02  6:58 ` Juan Quintela
  2017-08-02 10:26 ` Dr. David Alan Gilbert
  2017-12-27 12:25 ` Vladimir Sementsov-Ogievskiy
  3 siblings, 0 replies; 9+ messages in thread
From: Juan Quintela @ 2017-08-02  6:58 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, Dr. David Alan Gilbert

Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> Spotted thanks to valgrind and tests/device-introspect-test:
>
> ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> ==11711==    by 0x718328: object_new (object.c:493)
> ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-08-01 16:04 [Qemu-devel] [PATCH] migration: fix small leaks Marc-André Lureau
  2017-08-02  6:09 ` Peter Xu
  2017-08-02  6:58 ` Juan Quintela
@ 2017-08-02 10:26 ` Dr. David Alan Gilbert
  2017-12-27 12:25 ` Vladimir Sementsov-Ogievskiy
  3 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-08-02 10:26 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, Juan Quintela

* Marc-André Lureau (marcandre.lureau@redhat.com) wrote:
> Spotted thanks to valgrind and tests/device-introspect-test:
> 
> ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> ==11711==    by 0x718328: object_new (object.c:493)
> ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Queued for migration

> ---
>  migration/migration.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 085c32c994..c3fe0ed9ca 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
>      dc->props = migration_properties;
>  }
>  
> +static void migration_instance_finalize(Object *obj)
> +{
> +    MigrationState *ms = MIGRATION_OBJ(obj);
> +    MigrationParameters *params = &ms->parameters;
> +
> +    g_free(params->tls_hostname);
> +    g_free(params->tls_creds);
> +}
> +
>  static void migration_instance_init(Object *obj)
>  {
>      MigrationState *ms = MIGRATION_OBJ(obj);
> @@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
>      .class_size = sizeof(MigrationClass),
>      .instance_size = sizeof(MigrationState),
>      .instance_init = migration_instance_init,
> +    .instance_finalize = migration_instance_finalize,
>  };
>  
>  static void register_migration_types(void)
> -- 
> 2.14.0.rc0.1.g40ca67566
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-08-01 16:04 [Qemu-devel] [PATCH] migration: fix small leaks Marc-André Lureau
                   ` (2 preceding siblings ...)
  2017-08-02 10:26 ` Dr. David Alan Gilbert
@ 2017-12-27 12:25 ` Vladimir Sementsov-Ogievskiy
  2017-12-28  2:19   ` Peter Xu
  3 siblings, 1 reply; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2017-12-27 12:25 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: Dr. David Alan Gilbert, Juan Quintela

Hi all!

Hmm, looks like leak is not fixed here: I've checked it while running 
iotest 181, that
migration_instance_finalize is not called.

If I understand correct, to call it we need unref current_migration 
object somewhere.

Or, may be I'm missing something..

01.08.2017 19:04, Marc-André Lureau wrote:
> Spotted thanks to valgrind and tests/device-introspect-test:
>
> ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> ==11711==    by 0x718328: object_new (object.c:493)
> ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   migration/migration.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 085c32c994..c3fe0ed9ca 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
>       dc->props = migration_properties;
>   }
>   
> +static void migration_instance_finalize(Object *obj)
> +{
> +    MigrationState *ms = MIGRATION_OBJ(obj);
> +    MigrationParameters *params = &ms->parameters;
> +
> +    g_free(params->tls_hostname);
> +    g_free(params->tls_creds);
> +}
> +
>   static void migration_instance_init(Object *obj)
>   {
>       MigrationState *ms = MIGRATION_OBJ(obj);
> @@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
>       .class_size = sizeof(MigrationClass),
>       .instance_size = sizeof(MigrationState),
>       .instance_init = migration_instance_init,
> +    .instance_finalize = migration_instance_finalize,
>   };
>   
>   static void register_migration_types(void)


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-12-27 12:25 ` Vladimir Sementsov-Ogievskiy
@ 2017-12-28  2:19   ` Peter Xu
  2017-12-28  9:16     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Xu @ 2017-12-28  2:19 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Marc-André Lureau, qemu-devel, Dr. David Alan Gilbert,
	Juan Quintela

On Wed, Dec 27, 2017 at 03:25:23PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Hi all!
> 
> Hmm, looks like leak is not fixed here: I've checked it while running iotest
> 181, that
> migration_instance_finalize is not called.
> 
> If I understand correct, to call it we need unref current_migration object
> somewhere.
> 
> Or, may be I'm missing something..

I think you are right.

It does not matter much though since we don't dynamically allocate
migration object (there is only one and it lives forever).  Do you
want to post a patch?  I guess the safest place to unref it is at the
end of main() to make sure no one will be using it any more.

(Hmm, the incoming migration state is still static)

Thanks,

> 
> 01.08.2017 19:04, Marc-André Lureau wrote:
> > Spotted thanks to valgrind and tests/device-introspect-test:
> > 
> > ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> > ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> > ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> > ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> > ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> > ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> > ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> > ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> > ==11711==    by 0x718328: object_new (object.c:493)
> > ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> > ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> > ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> > ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   migration/migration.c | 10 ++++++++++
> >   1 file changed, 10 insertions(+)
> > 
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 085c32c994..c3fe0ed9ca 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
> >       dc->props = migration_properties;
> >   }
> > +static void migration_instance_finalize(Object *obj)
> > +{
> > +    MigrationState *ms = MIGRATION_OBJ(obj);
> > +    MigrationParameters *params = &ms->parameters;
> > +
> > +    g_free(params->tls_hostname);
> > +    g_free(params->tls_creds);
> > +}
> > +
> >   static void migration_instance_init(Object *obj)
> >   {
> >       MigrationState *ms = MIGRATION_OBJ(obj);
> > @@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
> >       .class_size = sizeof(MigrationClass),
> >       .instance_size = sizeof(MigrationState),
> >       .instance_init = migration_instance_init,
> > +    .instance_finalize = migration_instance_finalize,
> >   };
> >   static void register_migration_types(void)
> 
> 
> -- 
> Best regards,
> Vladimir
> 
> 

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-12-28  2:19   ` Peter Xu
@ 2017-12-28  9:16     ` Vladimir Sementsov-Ogievskiy
  2018-01-02 15:19       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2017-12-28  9:16 UTC (permalink / raw)
  To: Peter Xu
  Cc: Marc-André Lureau, qemu-devel, Dr. David Alan Gilbert,
	Juan Quintela

28.12.2017 05:19, Peter Xu wrote:
> On Wed, Dec 27, 2017 at 03:25:23PM +0300, Vladimir Sementsov-Ogievskiy wrote:
>> Hi all!
>>
>> Hmm, looks like leak is not fixed here: I've checked it while running iotest
>> 181, that
>> migration_instance_finalize is not called.
>>
>> If I understand correct, to call it we need unref current_migration object
>> somewhere.
>>
>> Or, may be I'm missing something..
> I think you are right.
>
> It does not matter much though since we don't dynamically allocate
> migration object (there is only one and it lives forever).  Do you
> want to post a patch?  I guess the safest place to unref it is at the
> end of main() to make sure no one will be using it any more.
>
> (Hmm, the incoming migration state is still static)
>
> Thanks,

Ok, I'll send a patch.

>
>> 01.08.2017 19:04, Marc-André Lureau wrote:
>>> Spotted thanks to valgrind and tests/device-introspect-test:
>>>
>>> ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
>>> ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
>>> ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
>>> ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
>>> ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
>>> ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
>>> ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
>>> ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
>>> ==11711==    by 0x718328: object_new (object.c:493)
>>> ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
>>> ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
>>> ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
>>> ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
>>>
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>>    migration/migration.c | 10 ++++++++++
>>>    1 file changed, 10 insertions(+)
>>>
>>> diff --git a/migration/migration.c b/migration/migration.c
>>> index 085c32c994..c3fe0ed9ca 100644
>>> --- a/migration/migration.c
>>> +++ b/migration/migration.c
>>> @@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
>>>        dc->props = migration_properties;
>>>    }
>>> +static void migration_instance_finalize(Object *obj)
>>> +{
>>> +    MigrationState *ms = MIGRATION_OBJ(obj);
>>> +    MigrationParameters *params = &ms->parameters;
>>> +
>>> +    g_free(params->tls_hostname);
>>> +    g_free(params->tls_creds);
>>> +}
>>> +
>>>    static void migration_instance_init(Object *obj)
>>>    {
>>>        MigrationState *ms = MIGRATION_OBJ(obj);
>>> @@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
>>>        .class_size = sizeof(MigrationClass),
>>>        .instance_size = sizeof(MigrationState),
>>>        .instance_init = migration_instance_init,
>>> +    .instance_finalize = migration_instance_finalize,
>>>    };
>>>    static void register_migration_types(void)
>>
>> -- 
>> Best regards,
>> Vladimir
>>
>>


-- 
Best regards,
Vladimir

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2017-12-28  9:16     ` Vladimir Sementsov-Ogievskiy
@ 2018-01-02 15:19       ` Dr. David Alan Gilbert
  2018-01-03  2:33         ` Peter Xu
  0 siblings, 1 reply; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2018-01-02 15:19 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: Peter Xu, Marc-André Lureau, qemu-devel, Juan Quintela

* Vladimir Sementsov-Ogievskiy (vsementsov@virtuozzo.com) wrote:
> 28.12.2017 05:19, Peter Xu wrote:
> > On Wed, Dec 27, 2017 at 03:25:23PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > Hi all!
> > > 
> > > Hmm, looks like leak is not fixed here: I've checked it while running iotest
> > > 181, that
> > > migration_instance_finalize is not called.
> > > 
> > > If I understand correct, to call it we need unref current_migration object
> > > somewhere.
> > > 
> > > Or, may be I'm missing something..
> > I think you are right.
> > 
> > It does not matter much though since we don't dynamically allocate
> > migration object (there is only one and it lives forever).  Do you
> > want to post a patch?  I guess the safest place to unref it is at the
> > end of main() to make sure no one will be using it any more.
> > 
> > (Hmm, the incoming migration state is still static)
> > 
> > Thanks,
> 
> Ok, I'll send a patch.

Be very very careful that it doesn't crash in cases like quit in the main thread
while a migration is still running.

I have no problem with this object living forever and letting it just
die with exit().

Dave


> > 
> > > 01.08.2017 19:04, Marc-André Lureau wrote:
> > > > Spotted thanks to valgrind and tests/device-introspect-test:
> > > > 
> > > > ==11711== 1 bytes in 1 blocks are definitely lost in loss record 6 of 14,537
> > > > ==11711==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
> > > > ==11711==    by 0x1E0CDBD8: g_malloc (gmem.c:94)
> > > > ==11711==    by 0x1E0E696E: g_strdup (gstrfuncs.c:363)
> > > > ==11711==    by 0x695693: migration_instance_init (migration.c:2226)
> > > > ==11711==    by 0x717C4B: object_init_with_type (object.c:344)
> > > > ==11711==    by 0x717E80: object_initialize_with_type (object.c:375)
> > > > ==11711==    by 0x7182EB: object_new_with_type (object.c:483)
> > > > ==11711==    by 0x718328: object_new (object.c:493)
> > > > ==11711==    by 0x4B8A29: qmp_device_list_properties (qmp.c:542)
> > > > ==11711==    by 0x4A9561: qmp_marshal_device_list_properties (qmp-marshal.c:1425)
> > > > ==11711==    by 0x819D4A: do_qmp_dispatch (qmp-dispatch.c:104)
> > > > ==11711==    by 0x819E82: qmp_dispatch (qmp-dispatch.c:131)
> > > > 
> > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > > ---
> > > >    migration/migration.c | 10 ++++++++++
> > > >    1 file changed, 10 insertions(+)
> > > > 
> > > > diff --git a/migration/migration.c b/migration/migration.c
> > > > index 085c32c994..c3fe0ed9ca 100644
> > > > --- a/migration/migration.c
> > > > +++ b/migration/migration.c
> > > > @@ -2214,6 +2214,15 @@ static void migration_class_init(ObjectClass *klass, void *data)
> > > >        dc->props = migration_properties;
> > > >    }
> > > > +static void migration_instance_finalize(Object *obj)
> > > > +{
> > > > +    MigrationState *ms = MIGRATION_OBJ(obj);
> > > > +    MigrationParameters *params = &ms->parameters;
> > > > +
> > > > +    g_free(params->tls_hostname);
> > > > +    g_free(params->tls_creds);
> > > > +}
> > > > +
> > > >    static void migration_instance_init(Object *obj)
> > > >    {
> > > >        MigrationState *ms = MIGRATION_OBJ(obj);
> > > > @@ -2282,6 +2291,7 @@ static const TypeInfo migration_type = {
> > > >        .class_size = sizeof(MigrationClass),
> > > >        .instance_size = sizeof(MigrationState),
> > > >        .instance_init = migration_instance_init,
> > > > +    .instance_finalize = migration_instance_finalize,
> > > >    };
> > > >    static void register_migration_types(void)
> > > 
> > > -- 
> > > Best regards,
> > > Vladimir
> > > 
> > > 
> 
> 
> -- 
> Best regards,
> Vladimir
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix small leaks
  2018-01-02 15:19       ` Dr. David Alan Gilbert
@ 2018-01-03  2:33         ` Peter Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Xu @ 2018-01-03  2:33 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Vladimir Sementsov-Ogievskiy, Marc-André Lureau, qemu-devel,
	Juan Quintela

On Tue, Jan 02, 2018 at 03:19:38PM +0000, Dr. David Alan Gilbert wrote:
> * Vladimir Sementsov-Ogievskiy (vsementsov@virtuozzo.com) wrote:
> > 28.12.2017 05:19, Peter Xu wrote:
> > > On Wed, Dec 27, 2017 at 03:25:23PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > > Hi all!
> > > > 
> > > > Hmm, looks like leak is not fixed here: I've checked it while running iotest
> > > > 181, that
> > > > migration_instance_finalize is not called.
> > > > 
> > > > If I understand correct, to call it we need unref current_migration object
> > > > somewhere.
> > > > 
> > > > Or, may be I'm missing something..
> > > I think you are right.
> > > 
> > > It does not matter much though since we don't dynamically allocate
> > > migration object (there is only one and it lives forever).  Do you
> > > want to post a patch?  I guess the safest place to unref it is at the
> > > end of main() to make sure no one will be using it any more.
> > > 
> > > (Hmm, the incoming migration state is still static)
> > > 
> > > Thanks,
> > 
> > Ok, I'll send a patch.
> 
> Be very very careful that it doesn't crash in cases like quit in the main thread
> while a migration is still running.

Agree.

> 
> I have no problem with this object living forever and letting it just
> die with exit().

Yes.  But if better, I am thinking whether we should always make sure
migration is completed/failed/cancelled before that point.  If we quit
QEMU with a working migration stream, logically we should stop it
before leaving, as part of QEMU's cleanup path.

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-01-03  2:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 16:04 [Qemu-devel] [PATCH] migration: fix small leaks Marc-André Lureau
2017-08-02  6:09 ` Peter Xu
2017-08-02  6:58 ` Juan Quintela
2017-08-02 10:26 ` Dr. David Alan Gilbert
2017-12-27 12:25 ` Vladimir Sementsov-Ogievskiy
2017-12-28  2:19   ` Peter Xu
2017-12-28  9:16     ` Vladimir Sementsov-Ogievskiy
2018-01-02 15:19       ` Dr. David Alan Gilbert
2018-01-03  2:33         ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).