[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/12] migration: fix multifd_send_pages() next channel
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 12/12] migration: fix multifd_send_pages() next channel |
Date: |
Wed, 17 Jun 2020 19:37:33 +0100 |
From: Laurent Vivier <lvivier@redhat.com>
multifd_send_pages() loops around the available channels,
the next channel to use between two calls to multifd_send_pages() is stored
inside a local static variable, next_channel.
It works well, except if the number of channels decreases between two calls
to multifd_send_pages(). In this case, the loop can try to access the
data of a channel that doesn't exist anymore.
The problem can be triggered if we start a migration with a given number of
channels and then we cancel the migration to restart it with a lower number.
This ends generally with an error like:
qemu-system-ppc64: .../util/qemu-thread-posix.c:77: qemu_mutex_lock_impl:
Assertion `mutex->initialized' failed.
This patch fixes the error by capping next_channel with the current number
of channels before using it.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20200617113154.593233-1-lvivier@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/multifd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/migration/multifd.c b/migration/multifd.c
index 5a3e4d0d46..d0441202aa 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -415,6 +415,12 @@ static int multifd_send_pages(QEMUFile *f)
}
qemu_sem_wait(&multifd_send_state->channels_ready);
+ /*
+ * next_channel can remain from a previous migration that was
+ * using more channels, so ensure it doesn't overflow if the
+ * limit is lower now.
+ */
+ next_channel %= migrate_multifd_channels();
for (i = next_channel;; i = (i + 1) % migrate_multifd_channels()) {
p = &multifd_send_state->params[i];
--
2.26.2
- [PULL 04/12] tests/migration: mem leak fix, (continued)
- [PULL 04/12] tests/migration: mem leak fix, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 03/12] hmp: Make json format optional for qom-set, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 05/12] tests/migration: fix unreachable path in stress test, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 02/12] qom-hmp-cmds: fix a memleak in hmp_qom_get, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 06/12] monitor/hmp-cmds: add units for migrate_parameters, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 07/12] monitor/hmp-cmds: don't silently output when running 'migrate_set_downtime' fails, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 08/12] monitor/hmp-cmds: delete redundant Error check before invoke hmp_handle_error(), Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 10/12] monitor/hmp-cmds: improvements for the 'info migrate', Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 09/12] monitor/hmp-cmds: add 'goto end' to reduce duplicate code., Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 11/12] docs/xbzrle: update 'cache miss rate' and 'encoding rate' to docs, Dr. David Alan Gilbert (git), 2020/06/17
- [PULL 12/12] migration: fix multifd_send_pages() next channel,
Dr. David Alan Gilbert (git) <=
- Re: [PULL 00/12] migration, HMP and virtiofs queue, no-reply, 2020/06/17
- Re: [PULL 00/12] migration, HMP and virtiofs queue, Peter Maydell, 2020/06/18