diff options
| author | Chuan Zheng | 2020-09-16 08:21:57 +0200 |
|---|---|---|
| committer | Dr. David Alan Gilbert | 2020-09-25 13:45:57 +0200 |
| commit | 7df3aa30838c010ce9b2f587afdcd6609386f630 (patch) | |
| tree | a874150d0cd46b48ef80c06061caac11283bd52b /migration | |
| parent | migration/dirtyrate: setup up query-dirtyrate framwork (diff) | |
| download | qemu-7df3aa30838c010ce9b2f587afdcd6609386f630.tar.gz qemu-7df3aa30838c010ce9b2f587afdcd6609386f630.tar.xz qemu-7df3aa30838c010ce9b2f587afdcd6609386f630.zip | |
migration/dirtyrate: add DirtyRateStatus to denote calculation status
add DirtyRateStatus to denote calculating status.
Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Message-Id: <1600237327-33618-3-git-send-email-zhengchuan@huawei.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
atomic name fixup
Diffstat (limited to 'migration')
| -rw-r--r-- | migration/dirtyrate.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index bf7fd24e75..3edf000f45 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -22,6 +22,19 @@ #include "migration.h" #include "dirtyrate.h" +static int CalculatingState = DIRTY_RATE_STATUS_UNSTARTED; + +static int dirtyrate_set_state(int *state, int old_state, int new_state) +{ + assert(new_state < DIRTY_RATE_STATUS__MAX); + if (qatomic_cmpxchg(state, old_state, new_state) == old_state) { + return 0; + } else { + return -1; + } +} + + static void calculate_dirtyrate(struct DirtyRateConfig config) { /* todo */ @@ -31,8 +44,21 @@ static void calculate_dirtyrate(struct DirtyRateConfig config) void *get_dirtyrate_thread(void *arg) { struct DirtyRateConfig config = *(struct DirtyRateConfig *)arg; + int ret; + + ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTARTED, + DIRTY_RATE_STATUS_MEASURING); + if (ret == -1) { + error_report("change dirtyrate state failed."); + return NULL; + } calculate_dirtyrate(config); + ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_MEASURING, + DIRTY_RATE_STATUS_MEASURED); + if (ret == -1) { + error_report("change dirtyrate state failed."); + } return NULL; } |
