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
--- hmp-commands.hx | 26 ++++++++++++++ include/monitor/hmp.h | 2 ++ migration/migration.c | 5 +++ migration/ram.c | 65 +++++++++++++++++++++++++++++++++ migration/ram.h | 5 +++ migration/savevm.c | 83 +++++++++++++++++++++++++++++++++++++++++++ migration/savevm.h | 2 ++ 7 files changed, 188 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 +83 -0
101 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
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
CC ui/vnc-palette.o
CC ui/vnc-enc-zrle.o
CC ui/vnc-auth-vencrypt.o
/tmp/qemu-test/src/migration/savevm.c:181:8: error: 'QemuThread' {aka 'struct QemuThread'} has no member named 'thread'
181 | { .thread = 0 },
| ^~~~~~/tmp/qemu-test/src/migration/savevm.c: In function 'dirty_track_is_running':/tmp/qemu-test/src/migration/savevm.c:2787:46: error: 'QemuThread' {aka 'struct QemuThread'} has no member named 'thread'
2787 | return !!current_dirty_track_state.thread.thread;
| ^/tmp/qemu-test/src/migration/savevm.c: In function 'hmp_dirty_track_stop':/tmp/qemu-test/src/migration/savevm.c:2817:41: error: 'QemuThread' {aka 'struct QemuThread'} has no member named 'thread'
2817 | if (current_dirty_track_state.thread.thread == 0) {
| ^/tmp/qemu-test/src/migration/savevm.c:2828:37: error: 'QemuThread' {aka 'struct QemuThread'} has no member named 'thread'
2828 | current_dirty_track_state.thread.thread = 0;
| ^/tmp/qemu-test/src/migration/savevm.c: In function 'dirty_track_is_running':/tmp/qemu-test/src/migration/savevm.c:2788:1: error: control reaches end of non-void function [-Werror=return-type]
2788 | }
| ^ cc1: all warnings being treated as errors CC ui/vnc-ws.o CC ui/vnc-jobs.o CC ui/win32-kbd-hook.o
make: *** [/tmp/qemu-test/src/rules.mak:69: migration/savevm.o] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=5c30b49d565c47b9a718072b03d4d878', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-g0jzomto/src/docker-src.2020-07-03-06.27.44.29989:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=5c30b49d565c47b9a718072b03d4d878
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-g0jzomto/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 2m48.392s
user 0m8.073s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]