Skip to content

Commit

Permalink
migration: migration_thread_is_self
Browse files Browse the repository at this point in the history
Define and export migration_thread_is_self to eliminate a dependency
on MigrationState.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Link: https://lore.kernel.org/r/1710179338-294359-7-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
Steve Sistare authored and xzpeter committed Mar 11, 2024
1 parent 714f331 commit 6e78563
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/migration/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void migration_object_init(void);
void migration_shutdown(void);
bool migration_is_idle(void);
bool migration_is_active(void);
bool migration_thread_is_self(void);
bool migration_is_setup_or_active(void);
bool migrate_mode_is_cpr(MigrationState *);

Expand Down
7 changes: 7 additions & 0 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,13 @@ bool migration_is_active(void)
s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
}

bool migration_thread_is_self(void)
{
MigrationState *s = current_migration;

return qemu_thread_is_self(&s->thread);
}

bool migrate_mode_is_cpr(MigrationState *s)
{
return s->parameters.mode == MIG_MODE_CPR_REBOOT;
Expand Down
5 changes: 1 addition & 4 deletions system/dirtylimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "sysemu/kvm.h"
#include "trace.h"
#include "migration/misc.h"
#include "migration/migration.h"

/*
* Dirtylimit stop working if dirty page rate error
Expand Down Expand Up @@ -448,10 +447,8 @@ static void dirtylimit_cleanup(void)
*/
static bool dirtylimit_is_allowed(void)
{
MigrationState *ms = migrate_get_current();

if (migration_is_running() &&
(!qemu_thread_is_self(&ms->thread)) &&
!migration_thread_is_self() &&
migrate_dirty_limit() &&
dirtylimit_in_service()) {
return false;
Expand Down

0 comments on commit 6e78563

Please sign in to comment.