qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/3] Migration patches
@ 2020-07-13 17:52 Juan Quintela
  2020-07-13 17:52 ` [PULL 1/3] migration: fix memory leak in qmp_migrate_set_parameters Juan Quintela
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Juan Quintela @ 2020-07-13 17:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Juan Quintela, Dr. David Alan Gilbert, quintela

The following changes since commit 9f526fce49c6ac48114ed04914b5a76e4db75785:

  Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-misc-110720-2' into staging (2020-07-12 15:32:05 +0100)

are available in the Git repository at:

  https://github.com/juanquintela/qemu.git tags/migration-pull-request

for you to fetch changes up to eb9bd46ff658e05e2c0c71fc308f3b811afa87e1:

  migration/migration.c: Remove superfluous breaks (2020-07-13 18:15:36 +0200)

----------------------------------------------------------------
Migration Pull request

It includes several fixes:

- fix qemu_fclose(denis)
- remove superfluous breaks (liao)
- fix memory leak (zheng)

Please apply

[v1 & v2]

There was one error on the huawei address of the 1st patch and mail
was bouncing.  Fixed.

----------------------------------------------------------------

Denis V. Lunev (1):
  migration/savevm: respect qemu_fclose() error code in save_snapshot()

Liao Pingfang (1):
  migration/migration.c: Remove superfluous breaks

Zheng Chuan (1):
  migration: fix memory leak in qmp_migrate_set_parameters

 migration/migration.c | 6 ++----
 migration/savevm.c    | 8 ++++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

-- 
2.25.4




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

* [PULL 1/3] migration: fix memory leak in qmp_migrate_set_parameters
  2020-07-13 17:52 [PULL 0/3] Migration patches Juan Quintela
@ 2020-07-13 17:52 ` Juan Quintela
  2020-07-13 17:52 ` [PULL 2/3] migration/savevm: respect qemu_fclose() error code in save_snapshot() Juan Quintela
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Juan Quintela @ 2020-07-13 17:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: HaiLiang, Juan Quintela, Dr. David Alan Gilbert, Zheng Chuan,
	quintela, KeQian Zhu

From: Zheng Chuan <zhengchuan@huawei.com>

"tmp.tls_hostname" and "tmp.tls_creds" allocated by migrate_params_test_apply()
is forgot to free at the end of qmp_migrate_set_parameters(). Fix that.

The leak stack:
Direct leak of 2 byte(s) in 2 object(s) allocated from:
   #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
   #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
   #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
   #3 0xaaaac52447fb in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1377)
   #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
   #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c:165)
   #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
   #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
   #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
   #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
   #10 0xaaaac55cae0f in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
   #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
   #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
   #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
   #14 0xaaaac47f45ef(/usr/bin/qemu-kvm-4.1.0+0x8455ef)
   #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
   #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)

Direct leak of 2 byte(s) in 2 object(s) allocated from:
   #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
   #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
   #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
   #3 0xaaaac5244893 in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1382)
   #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
   #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c)
   #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
   #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
   #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
   #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
   #10 0xaaaac55cae0f in in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
   #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
   #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
   #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
   #14 0xaaaac47f45ef (/usr/bin/qemu-kvm-4.1.0+0x8455ef)
   #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
   #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Reviewed-by: KeQian Zhu <zhukeqian1@huawei.com>
Reviewed-by: HaiLiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 4e658c397e..08519de56f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1343,12 +1343,12 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
 
     if (params->has_tls_creds) {
         assert(params->tls_creds->type == QTYPE_QSTRING);
-        dest->tls_creds = g_strdup(params->tls_creds->u.s);
+        dest->tls_creds = params->tls_creds->u.s;
     }
 
     if (params->has_tls_hostname) {
         assert(params->tls_hostname->type == QTYPE_QSTRING);
-        dest->tls_hostname = g_strdup(params->tls_hostname->u.s);
+        dest->tls_hostname = params->tls_hostname->u.s;
     }
 
     if (params->has_max_bandwidth) {
-- 
2.25.4



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

* [PULL 2/3] migration/savevm: respect qemu_fclose() error code in save_snapshot()
  2020-07-13 17:52 [PULL 0/3] Migration patches Juan Quintela
  2020-07-13 17:52 ` [PULL 1/3] migration: fix memory leak in qmp_migrate_set_parameters Juan Quintela
@ 2020-07-13 17:52 ` Juan Quintela
  2020-07-13 17:52 ` [PULL 3/3] migration/migration.c: Remove superfluous breaks Juan Quintela
  2020-07-14 16:57 ` [PULL 0/3] Migration patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Juan Quintela @ 2020-07-13 17:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, Vladimir Sementsov-Ogievskiy,
	Juan Quintela, Dr. David Alan Gilbert, Max Reitz, Denis Plotnikov,
	quintela, Stefan Hajnoczi, Denis V. Lunev

From: "Denis V. Lunev" <den@openvz.org>

qemu_fclose() could return error, f.e. if bdrv_co_flush() will return
the error.

This validation will become more important once we will start waiting of
asynchronous IO operations, started from bdrv_write_vmstate(), which are
coming soon.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Juan Quintela <quintela@redhat.com>
CC: Denis Plotnikov <dplotnikov@virtuozzo.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/savevm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 6e01724605..45c9dd9d8a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2635,7 +2635,7 @@ int save_snapshot(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
-    int ret = -1;
+    int ret = -1, ret2;
     QEMUFile *f;
     int saved_vm_running;
     uint64_t vm_state_size;
@@ -2719,10 +2719,14 @@ int save_snapshot(const char *name, Error **errp)
     }
     ret = qemu_savevm_state(f, errp);
     vm_state_size = qemu_ftell(f);
-    qemu_fclose(f);
+    ret2 = qemu_fclose(f);
     if (ret < 0) {
         goto the_end;
     }
+    if (ret2 < 0) {
+        ret = ret2;
+        goto the_end;
+    }
 
     /* The bdrv_all_create_snapshot() call that follows acquires the AioContext
      * for itself.  BDRV_POLL_WHILE() does not support nested locking because
-- 
2.25.4



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

* [PULL 3/3] migration/migration.c: Remove superfluous breaks
  2020-07-13 17:52 [PULL 0/3] Migration patches Juan Quintela
  2020-07-13 17:52 ` [PULL 1/3] migration: fix memory leak in qmp_migrate_set_parameters Juan Quintela
  2020-07-13 17:52 ` [PULL 2/3] migration/savevm: respect qemu_fclose() error code in save_snapshot() Juan Quintela
@ 2020-07-13 17:52 ` Juan Quintela
  2020-07-14 16:57 ` [PULL 0/3] Migration patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Juan Quintela @ 2020-07-13 17:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Yi Wang, Thomas Huth, Juan Quintela, Philippe Mathieu-Daudé,
	Dr. David Alan Gilbert, quintela, Liao Pingfang

From: Liao Pingfang <liao.pingfang@zte.com.cn>

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/migration.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 08519de56f..2ed9923227 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -986,7 +986,6 @@ static void fill_source_migration_info(MigrationInfo *info)
         /* no migration has happened ever */
         /* do not overwrite destination migration status */
         return;
-        break;
     case MIGRATION_STATUS_SETUP:
         info->has_status = true;
         info->has_total_time = false;
@@ -1105,7 +1104,6 @@ static void fill_destination_migration_info(MigrationInfo *info)
     switch (mis->state) {
     case MIGRATION_STATUS_NONE:
         return;
-        break;
     case MIGRATION_STATUS_SETUP:
     case MIGRATION_STATUS_CANCELLING:
     case MIGRATION_STATUS_CANCELLED:
-- 
2.25.4



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

* Re: [PULL 0/3] Migration patches
  2020-07-13 17:52 [PULL 0/3] Migration patches Juan Quintela
                   ` (2 preceding siblings ...)
  2020-07-13 17:52 ` [PULL 3/3] migration/migration.c: Remove superfluous breaks Juan Quintela
@ 2020-07-14 16:57 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-07-14 16:57 UTC (permalink / raw)
  To: Juan Quintela; +Cc: Juan Quintela, QEMU Developers, Dr. David Alan Gilbert

On Mon, 13 Jul 2020 at 18:55, Juan Quintela <quintela@redhat.com> wrote:
>
> The following changes since commit 9f526fce49c6ac48114ed04914b5a76e4db75785:
>
>   Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-misc-110720-2' into staging (2020-07-12 15:32:05 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/juanquintela/qemu.git tags/migration-pull-request
>
> for you to fetch changes up to eb9bd46ff658e05e2c0c71fc308f3b811afa87e1:
>
>   migration/migration.c: Remove superfluous breaks (2020-07-13 18:15:36 +0200)
>
> ----------------------------------------------------------------
> Migration Pull request
>
> It includes several fixes:
>
> - fix qemu_fclose(denis)
> - remove superfluous breaks (liao)
> - fix memory leak (zheng)
>
> Please apply
>
> [v1 & v2]
>
> There was one error on the huawei address of the 1st patch and mail
> was bouncing.  Fixed.


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.

-- PMM


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

end of thread, other threads:[~2020-07-14 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-13 17:52 [PULL 0/3] Migration patches Juan Quintela
2020-07-13 17:52 ` [PULL 1/3] migration: fix memory leak in qmp_migrate_set_parameters Juan Quintela
2020-07-13 17:52 ` [PULL 2/3] migration/savevm: respect qemu_fclose() error code in save_snapshot() Juan Quintela
2020-07-13 17:52 ` [PULL 3/3] migration/migration.c: Remove superfluous breaks Juan Quintela
2020-07-14 16:57 ` [PULL 0/3] Migration patches Peter Maydell

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