diff options
author | Juan Quintela <quintela@redhat.com> | 2023-05-15 21:56:58 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2023-05-18 18:40:51 +0200 |
commit | e1fde0e038bafd0bd05db7d43305b9b2f03c0683 (patch) | |
tree | 14c6f72e2e86867957e62c01ac2ec2363dcbcc58 /migration/migration-stats.h | |
parent | de37f8b9c21e1c6ef98eebb0b05bd83e5867bc6f (diff) | |
download | qemu-e1fde0e038bafd0bd05db7d43305b9b2f03c0683.zip qemu-e1fde0e038bafd0bd05db7d43305b9b2f03c0683.tar.gz qemu-e1fde0e038bafd0bd05db7d43305b9b2f03c0683.tar.bz2 |
migration: Move rate_limit_max and rate_limit_used to migration_stats
These way we can make them atomic and use this functions from any
place. I also moved all functions that use rate_limit to
migration-stats.
Functions got renamed, they are not qemu_file anymore.
qemu_file_rate_limit -> migration_rate_exceeded
qemu_file_set_rate_limit -> migration_rate_set
qemu_file_get_rate_limit -> migration_rate_get
qemu_file_reset_rate_limit -> migration_rate_reset
qemu_file_acct_rate_limit -> migration_rate_account.
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230515195709.63843-6-quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'migration/migration-stats.h')
-rw-r--r-- | migration/migration-stats.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/migration/migration-stats.h b/migration/migration-stats.h index e7f1269..7b64dc7 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -16,6 +16,12 @@ #include "qemu/stats64.h" /* + * Amount of time to allocate to each "chunk" of bandwidth-throttled + * data. + */ +#define BUFFER_DELAY 100 + +/* * If rate_limit_max is 0, there is special code to remove the rate * limit. */ @@ -76,6 +82,14 @@ typedef struct { */ Stat64 precopy_bytes; /* + * Maximum amount of data we can send in a cycle. + */ + Stat64 rate_limit_max; + /* + * Amount of data we have sent in the current cycle. + */ + Stat64 rate_limit_used; + /* * Total number of bytes transferred. */ Stat64 transferred; @@ -87,4 +101,36 @@ typedef struct { extern MigrationAtomicStats mig_stats; +/** + * migration_rate_account: Increase the number of bytes transferred. + * + * Report on a number of bytes the have been transferred that need to + * be applied to the rate limiting calcuations. + * + * @len: amount of bytes transferred + */ +void migration_rate_account(uint64_t len); + +/** + * migration_rate_get: Get the maximum amount that can be transferred. + * + * Returns the maximum number of bytes that can be transferred in a cycle. + */ +uint64_t migration_rate_get(void); + +/** + * migration_rate_reset: Reset the rate limit counter. + * + * This is called when we know we start a new transfer cycle. + */ +void migration_rate_reset(void); + +/** + * migration_rate_set: Set the maximum amount that can be transferred. + * + * Sets the maximum amount of bytes that can be transferred in one cycle. + * + * @new_rate: new maximum amount + */ +void migration_rate_set(uint64_t new_rate); #endif |