diff mbox

[4/5] Disable XBZRLE during migrate to file if it is active

Message ID 1359542158-30060-5-git-send-email-owasserm@redhat.com
State New
Headers show

Commit Message

Orit Wasserman Jan. 30, 2013, 10:35 a.m. UTC
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 <owasserm@redhat.com>
---
 include/migration/migration.h | 1 +
 migration-exec.c              | 6 ++++++
 migration.c                   | 9 +++++++++
 3 files changed, 16 insertions(+)

Comments

Eric Blake Jan. 30, 2013, 5:59 p.m. UTC | #1
On 01/30/2013 03:35 AM, Orit Wasserman wrote:
> XBZRLE is not effective when migrating to file.

Why not?  When doing a live migration to file, the same sector of memory
can be visited more than once in the migration stream, and thus
compressing the later pages should make the saved file smaller.  I'm not
sure I buy this argument of XBZRLE being incompatible with migration to
file, at least without not more explanation why it fails.
Orit Wasserman Jan. 30, 2013, 6:29 p.m. UTC | #2
On 01/30/2013 07:59 PM, Eric Blake wrote:
> On 01/30/2013 03:35 AM, Orit Wasserman wrote:
>> XBZRLE is not effective when migrating to file.
> 
> Why not?  When doing a live migration to file, the same sector of memory
> can be visited more than once in the migration stream, and thus
> compressing the later pages should make the saved file smaller.  I'm not
> sure I buy this argument of XBZRLE being incompatible with migration to
> file, at least without not more explanation why it fails.
> 
Users usually use compression when migrating to file (like gzip), double compression
is usually much less effective.
Migration fails because the XBZRLE capability is not set,
this is happens when we load the file in the command line ( -incoming "exec:gzip -c -d vm.gz").
Paolo suggest a better workaround which doesn't require disabling XBZRLE,
see v2 of the series.

Orit
diff mbox

Patch

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;