aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2020-09-23 11:56:46 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2020-09-23 16:07:44 +0100
commitd73415a315471ac0b127ed3fad45c8ec5d711de1 (patch)
treebae20b3a39968fdfb4340b1a39b533333a8e6fd0 /migration/migration.c
parented7db34b5aedba4487fd949b2e545eef954f093e (diff)
qemu/atomic.h: rename atomic_ to qatomic_
clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/migration/migration.c b/migration/migration.c
index 58a5452471..d9d1e0b190 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1595,7 +1595,7 @@ void qmp_migrate_start_postcopy(Error **errp)
* we don't error if migration has finished since that would be racy
* with issuing this command.
*/
- atomic_set(&s->start_postcopy, true);
+ qatomic_set(&s->start_postcopy, true);
}
/* shared migration helpers */
@@ -1603,7 +1603,7 @@ void qmp_migrate_start_postcopy(Error **errp)
void migrate_set_state(int *state, int old_state, int new_state)
{
assert(new_state < MIGRATION_STATUS__MAX);
- if (atomic_cmpxchg(state, old_state, new_state) == old_state) {
+ if (qatomic_cmpxchg(state, old_state, new_state) == old_state) {
trace_migrate_set_state(MigrationStatus_str(new_state));
migrate_generate_event(new_state);
}
@@ -1954,7 +1954,7 @@ void qmp_migrate_recover(const char *uri, Error **errp)
return;
}
- if (atomic_cmpxchg(&mis->postcopy_recover_triggered,
+ if (qatomic_cmpxchg(&mis->postcopy_recover_triggered,
false, true) == true) {
error_setg(errp, "Migrate recovery is triggered already");
return;
@@ -3329,7 +3329,7 @@ static MigIterateState migration_iteration_run(MigrationState *s)
if (pending_size && pending_size >= s->threshold_size) {
/* Still a significant amount to transfer */
if (!in_postcopy && pend_pre <= s->threshold_size &&
- atomic_read(&s->start_postcopy)) {
+ qatomic_read(&s->start_postcopy)) {
if (postcopy_start(s)) {
error_report("%s: postcopy failed to start", __func__);
}