Patchwork [v5,6/9] Add xbrle parameters to MigrationState

login
register
mail settings
Submitter Orit Wasserman
Date Jan. 3, 2012, 1:35 p.m.
Message ID <1325597745-29293-7-git-send-email-owasserm@redhat.com>
Download mbox | patch
Permalink /patch/134090/
State New
Headers show

Comments

Orit Wasserman - Jan. 3, 2012, 1:35 p.m.
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
 block-migration.c |    4 +++-
 hw/hw.h           |    4 +++-
 migration.c       |   15 +++++++++++++--
 migration.h       |    3 +++
 savevm.c          |   11 +++++++----
 sysemu.h          |    4 +++-
 6 files changed, 32 insertions(+), 9 deletions(-)

Patch

diff --git a/block-migration.c b/block-migration.c
index 2b7edbc..60f2d62 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -706,7 +706,9 @@  static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(int blk_enable, int shared_base, void *opaque)
+static void block_set_params(int blk_enable, int shared_base,
+                             int use_xbrle, int64_t xbrle_cache_size,
+                             void *opaque)
 {
     block_mig_state.blk_enable = blk_enable;
     block_mig_state.shared_base = shared_base;
diff --git a/hw/hw.h b/hw/hw.h
index efa04d1..ab0b92c 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -245,7 +245,9 @@  static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
 int64_t qemu_ftell(QEMUFile *f);
 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
 
-typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
+typedef void SaveSetParamsHandler(int blk_enable, int shared,
+                                  int use_xbrle, int64_t xbrle_cache_size,
+                                  void *opaque);
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
 typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage,
                                  void *opaque);
diff --git a/migration.c b/migration.c
index 412fdfe..ed47958 100644
--- a/migration.c
+++ b/migration.c
@@ -41,6 +41,11 @@  enum {
 
 #define MAX_THROTTLE  (32 << 20)      /* Migration speed throttling */
 
+/* Migration XBRLE cache size */
+#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)
+
+static int64_t migrate_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
+
 static NotifierList migration_state_notifiers =
     NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
 
@@ -365,7 +370,8 @@  void migrate_fd_connect(MigrationState *s)
                                       migrate_fd_close);
 
     DPRINTF("beginning savevm\n");
-    ret = qemu_savevm_state_begin(s->mon, s->file, s->blk, s->shared);
+    ret = qemu_savevm_state_begin(s->mon, s->file, s->blk, s->shared,
+                                  s->use_xbrle, s->xbrle_cache_size);
     if (ret < 0) {
         DPRINTF("failed, %d\n", ret);
         migrate_fd_error(s);
@@ -375,6 +381,8 @@  void migrate_fd_connect(MigrationState *s)
 }
 
 static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc)
+static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc,
+                                    int use_xbrle, int64_t xbrle_cache_size)
 {
     MigrationState *s = migrate_get_current();
     int64_t bandwidth_limit = s->bandwidth_limit;
@@ -383,6 +391,8 @@  static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc)
     s->bandwidth_limit = bandwidth_limit;
     s->blk = blk;
     s->shared = inc;
+    s->use_xbrle = use_xbrle;
+    s->xbrle_cache_size = xbrle_cache_size;
 
     /* s->mon is used for two things:
        - pass fd in fd migration
@@ -418,6 +428,7 @@  int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
     int detach = qdict_get_try_bool(qdict, "detach", 0);
     int blk = qdict_get_try_bool(qdict, "blk", 0);
     int inc = qdict_get_try_bool(qdict, "inc", 0);
+    int use_xbrle = qdict_get_try_bool(qdict, "xbrle", 0);
     const char *uri = qdict_get_str(qdict, "uri");
     int ret;
 
@@ -436,7 +447,7 @@  int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
         return -1;
     }
 
-    s = migrate_init(mon, detach, blk, inc);
+    s = migrate_init(mon, detach, blk, inc, use_xbrle, migrate_cache_size);
 
     if (strstart(uri, "tcp:", &p)) {
         ret = tcp_start_outgoing_migration(s, p);
diff --git a/migration.h b/migration.h
index 372b066..592af6a 100644
--- a/migration.h
+++ b/migration.h
@@ -34,6 +34,9 @@  struct MigrationState
     void *opaque;
     int blk;
     int shared;
+    int use_xbrle;
+    int64_t xbrle_cache_size;
+
 };
 
 void process_incoming_migration(QEMUFile *f);
diff --git a/savevm.c b/savevm.c
index f153c25..3650f56 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1277,7 +1277,8 @@  int register_savevm(DeviceState *dev,
                     void *opaque)
 {
     return register_savevm_live(dev, idstr, instance_id, version_id,
-                                NULL, NULL, save_state, load_state, opaque);
+                                arch_set_params, NULL, save_state,
+                                load_state, opaque);
 }
 
 void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
@@ -1554,7 +1555,8 @@  bool qemu_savevm_state_blocked(Monitor *mon)
 }
 
 int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
-                            int shared)
+                            int shared, int use_xbrle,
+                            int64_t xbrle_cache_size)
 {
     SaveStateEntry *se;
     int ret;
@@ -1563,7 +1565,8 @@  int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
         if(se->set_params == NULL) {
             continue;
 	}
-	se->set_params(blk_enable, shared, se->opaque);
+        se->set_params(blk_enable, shared, use_xbrle, xbrle_cache_size,
+                       se->opaque);
     }
     
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
@@ -1707,7 +1710,7 @@  static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
         goto out;
     }
 
-    ret = qemu_savevm_state_begin(mon, f, 0, 0);
+    ret = qemu_savevm_state_begin(mon, f, 0, 0, 0, 0);
     if (ret < 0)
         goto out;
 
diff --git a/sysemu.h b/sysemu.h
index 3806901..78e1074 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -67,7 +67,8 @@  void qemu_announce_self(void);
 
 bool qemu_savevm_state_blocked(Monitor *mon);
 int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
-                            int shared);
+                            int shared, int use_xbrle,
+                            int64_t xbrle_cache_size);
 int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
 int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
 void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
@@ -174,4 +175,5 @@  void register_devices(void);
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix);
 char *get_boot_devices_list(uint32_t *size);
+
 #endif