aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Bras <leobras@redhat.com>2022-10-25 01:47:28 -0300
committerJuan Quintela <quintela@redhat.com>2022-11-21 11:56:12 +0100
commit4cc47b439594327b213f9b6a67803f1a503c2cb7 (patch)
tree78c689392d130eb252122edc7477609779384eca
parenta216ec85b78ea96b51950665879524132f6e678c (diff)
downloadqemu-4cc47b439594327b213f9b6a67803f1a503c2cb7.zip
qemu-4cc47b439594327b213f9b6a67803f1a503c2cb7.tar.gz
qemu-4cc47b439594327b213f9b6a67803f1a503c2cb7.tar.bz2
migration/multifd/zero-copy: Create helper function for flushing
Move flushing code from multifd_send_sync_main() to a new helper, and call it in multifd_send_sync_main(). Signed-off-by: Leonardo Bras <leobras@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r--migration/multifd.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/migration/multifd.c b/migration/multifd.c
index 586ddc9..509bbbe 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -566,6 +566,23 @@ void multifd_save_cleanup(void)
multifd_send_state = NULL;
}
+static int multifd_zero_copy_flush(QIOChannel *c)
+{
+ int ret;
+ Error *err = NULL;
+
+ ret = qio_channel_flush(c, &err);
+ if (ret < 0) {
+ error_report_err(err);
+ return -1;
+ }
+ if (ret == 1) {
+ dirty_sync_missed_zero_copy();
+ }
+
+ return ret;
+}
+
int multifd_send_sync_main(QEMUFile *f)
{
int i;
@@ -616,17 +633,8 @@ int multifd_send_sync_main(QEMUFile *f)
qemu_mutex_unlock(&p->mutex);
qemu_sem_post(&p->sem);
- if (flush_zero_copy && p->c) {
- int ret;
- Error *err = NULL;
-
- ret = qio_channel_flush(p->c, &err);
- if (ret < 0) {
- error_report_err(err);
- return -1;
- } else if (ret == 1) {
- dirty_sync_missed_zero_copy();
- }
+ if (flush_zero_copy && p->c && (multifd_zero_copy_flush(p->c) < 0)) {
+ return -1;
}
}
for (i = 0; i < migrate_multifd_channels(); i++) {