XBZRLE is not effective when migrating to file.

Disabling it automatically will remove the need to update the
command line to allow loading a guest from a file that was in XBZRLE format.

Signed-off-by: Orit Wasserman <[email protected]>
---
 include/migration/migration.h | 1 +
 migration-exec.c              | 6 ++++++
 migration.c                   | 9 +++++++++
 3 files changed, 16 insertions(+)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index a8c9639..8577a0f 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -129,6 +129,7 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t 
*new_buf, int slen,
 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
 
 int migrate_use_xbzrle(void);
+void migrate_disable_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 
 int64_t xbzrle_cache_resize(int64_t new_size);
diff --git a/migration-exec.c b/migration-exec.c
index a051a6e..98ba41a 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -61,6 +61,12 @@ void exec_start_outgoing_migration(MigrationState *s, const 
char *command, Error
 {
     FILE *f;
 
+    /* there is no point in using XBZRLE when migrating to file */
+    if (migrate_use_xbzrle()) {
+        DPRINTF("XBZRLE active during migrate to file - disabling\n");
+        migrate_disable_xbzrle();
+    }
+
     f = popen(command, "w");
     if (f == NULL) {
         error_setg_errno(errp, errno, "failed to popen the migration target");
diff --git a/migration.c b/migration.c
index 77c1971..e32635e 100644
--- a/migration.c
+++ b/migration.c
@@ -510,6 +510,15 @@ int migrate_use_xbzrle(void)
     return s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE];
 }
 
+void migrate_disable_xbzrle(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE] = false;
+}
+
 int64_t migrate_xbzrle_cache_size(void)
 {
     MigrationState *s;
-- 
1.7.11.7


Reply via email to