ram: add support for dirty page tracking
PATCH 1/1 ram: add support for dirty page tracking
In production, the VM with insentive memory activity maybe failed to migrate, because of the change of memory in the VM greater than the throughtput of the network interface, and we want to identify it before migration.
1. dirty tracking start:
virsh qemu-monitor-command <domain> --hmp dirty_track
2. wait some time, stop dirty tracking:
virsh qemu-monitor-command <domain> --hmp dirty_track_stop Dirty rate: 607 pages/s
Signed-off-by Bingsong Si <[email protected]>
--- hmp-commands.hx | 26 +++++++++++++++ include/monitor/hmp.h | 2 ++ migration/migration.c | 5 +++ migration/ram.c | 65 ++++++++++++++++++++++++++++++++++++ migration/ram.h | 5 +++ migration/savevm.c | 77 +++++++++++++++++++++++++++++++++++++++++++ migration/savevm.h | 2 ++ 7 files changed, 182 insertions(+)
hmp-commands.hx +26 -0
@@ -1819,6 +1819,32 @@ SRST Set QOM property *property* of object at location *path* to value *value* ERST + { + .name = "dirty_track", + .args_type = "", + .params = "", + .help = "track dirty pages rate", + .cmd = hmp_dirty_track, + }, + +SRST +``dirty_track`` + Track dirty pages rate. +ERST + + { + .name = "dirty_track_stop", + .args_type = "", + .params = "", + .help = "stop current dirty pages track", + .cmd = hmp_dirty_track_stop, + }, + +SRST +``dirty_track_stop`` + Stop current dirty pages track. +ERST + { .name = "info", .args_type = "item:s?",
include/monitor/hmp.h +2 -0
@@ -130,5 +130,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);void hmp_info_vm_generation_id (Monitor *mon,const QDict *qdict);void hmp_info_memory_size_summary (Monitor *mon,const QDict *qdict);void hmp_info_sev (Monitor *mon,const QDict *qdict); +void hmp_dirty_track (Monitor *mon,const QDict *qdict); +void hmp_dirty_track_stop (Monitor *mon,const QDict *qdict);#endif
migration/migration.c +5 -0
@@ -1964,6 +1964,11 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, {Error *local_err =NULL ; +if (dirty_track_is_running ()) { +error_setg (errp,"There is a dirty tracking process in progress" ); +return false; + } +if (resume) {if (s->state !=MIGRATION_STATUS_POSTCOPY_PAUSED ) { error_setg(errp, "Cannot resume if there is no "
migration/ram.c +65 -0
71 lines not on this page · raw message
migration/ram.h +5 -0
@@ -69,4 +69,9 @@ void colo_flush_ram_cache(void);void colo_release_ram_cache (void );void colo_incoming_start_dirty_log (void ); +void dirty_track_init (void ); +uint64_t dirty_track_dirty_pages (void ); +void dirty_track_sync (void ); +void dirty_track_cleanup (void ); +#endif
migration/savevm.c +77 -0
95 lines not on this page · raw message
migration/savevm.h +2 -0
@@ -65,4 +65,6 @@ void qemu_loadvm_state_cleanup(void);int qemu_loadvm_state_main (QEMUFile *f,MigrationIncomingState *mis);int qemu_load_device_state (QEMUFile *f); +bool dirty_track_is_running (void ); +#endif
Signature · 1 line
2.18.4