mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
migration: split migration hooks out of QEMUFileOps
The QEMUFileOps struct contains the I/O subsystem callbacks and the migration stage hooks. Split the hooks out into a separate QEMUFileHooks struct to make it easier to refactor the I/O side of QEMUFile without affecting the hooks. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <1461751518-12128-6-git-send-email-berrange@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
baf51e7739
commit
0436e09f96
4 changed files with 31 additions and 12 deletions
|
@ -80,6 +80,12 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
|||
return f;
|
||||
}
|
||||
|
||||
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
|
||||
{
|
||||
f->hooks = hooks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get last error for stream f
|
||||
*
|
||||
|
@ -149,8 +155,8 @@ void ram_control_before_iterate(QEMUFile *f, uint64_t flags)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
if (f->ops->before_ram_iterate) {
|
||||
ret = f->ops->before_ram_iterate(f, f->opaque, flags, NULL);
|
||||
if (f->hooks && f->hooks->before_ram_iterate) {
|
||||
ret = f->hooks->before_ram_iterate(f, f->opaque, flags, NULL);
|
||||
if (ret < 0) {
|
||||
qemu_file_set_error(f, ret);
|
||||
}
|
||||
|
@ -161,8 +167,8 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
if (f->ops->after_ram_iterate) {
|
||||
ret = f->ops->after_ram_iterate(f, f->opaque, flags, NULL);
|
||||
if (f->hooks && f->hooks->after_ram_iterate) {
|
||||
ret = f->hooks->after_ram_iterate(f, f->opaque, flags, NULL);
|
||||
if (ret < 0) {
|
||||
qemu_file_set_error(f, ret);
|
||||
}
|
||||
|
@ -173,8 +179,8 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data)
|
|||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (f->ops->hook_ram_load) {
|
||||
ret = f->ops->hook_ram_load(f, f->opaque, flags, data);
|
||||
if (f->hooks && f->hooks->hook_ram_load) {
|
||||
ret = f->hooks->hook_ram_load(f, f->opaque, flags, data);
|
||||
if (ret < 0) {
|
||||
qemu_file_set_error(f, ret);
|
||||
}
|
||||
|
@ -193,9 +199,9 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
|
|||
ram_addr_t offset, size_t size,
|
||||
uint64_t *bytes_sent)
|
||||
{
|
||||
if (f->ops->save_page) {
|
||||
int ret = f->ops->save_page(f, f->opaque, block_offset,
|
||||
offset, size, bytes_sent);
|
||||
if (f->hooks && f->hooks->save_page) {
|
||||
int ret = f->hooks->save_page(f, f->opaque, block_offset,
|
||||
offset, size, bytes_sent);
|
||||
|
||||
if (ret != RAM_SAVE_CONTROL_DELAYED) {
|
||||
if (bytes_sent && *bytes_sent > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue