From: Igor Redko <red...@virtuozzo.com> This patch adds hook_ram_sync() to QEMUFile abstraction. This hook can be used for passing information about dirty memory. An alternative is using existing hook_ram_load(). But this hook is designed for incoming VM migration, so using it for outcoming VM migration may complicate understanding of the code. On the other hand, using existing code decreases volume of the patchset and its impact.
Signed-off-by: Igor Redko <red...@virtuozzo.com> Reviewed-by: Anna Melekhova <an...@virtuozzo.com> Signed-off-by: Denis V. Lunev <d...@openvz.org> --- include/migration/migration.h | 1 + include/migration/qemu-file.h | 1 + migration/qemu-file.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 8334621..deb0d21 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -182,6 +182,7 @@ bool migrate_use_events(void); void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data); +void ram_control_sync_hook(QEMUFile *f, uint64_t flags, void *data); /* Whenever this is found in the data stream, the flags * will be passed to ram_control_load_hook in the incoming-migration diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 29a338d..770dd98 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -105,6 +105,7 @@ typedef struct QEMUFileOps { QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; + QEMURamHookFunc *hook_ram_sync; QEMURamSaveFunc *save_page; QEMUFileShutdownFunc *shut_down; } QEMUFileOps; diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 49addf6..a05d672 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -168,6 +168,18 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data) } } +void ram_control_sync_hook(QEMUFile *f, uint64_t flags, void *data) +{ + int ret = 0; + + if (f->ops->hook_ram_sync) { + ret = f->ops->hook_ram_sync(f, f->opaque, flags, data); + if (ret < 0) { + qemu_file_set_error(f, ret); + } + } +} + size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, uint64_t *bytes_sent) -- 2.1.4