Patchwork [v5,7/9] Add set_cachesize to change XBRLE cache size

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

Comments

Orit Wasserman - Jan. 3, 2012, 1:35 p.m.
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
 migration.c |   25 ++++++++++++++++++++++++-
 migration.h |    7 +++++++
 2 files changed, 31 insertions(+), 1 deletions(-)

Patch

diff --git a/migration.c b/migration.c
index ed47958..3d88cdd 100644
--- a/migration.c
+++ b/migration.c
@@ -380,7 +380,30 @@  void migrate_fd_connect(MigrationState *s)
     migrate_fd_put_ready(s);
 }
 
-static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc)
+void do_migrate_set_cachesize(Monitor *mon, const QDict *qdict)
+{
+    ssize_t bytes;
+    const char *value = qdict_get_str(qdict, "value");
+
+    bytes = strtosz(value, NULL);
+    if (bytes < 0) {
+        monitor_printf(mon, "invalid cache size: %s\n", value);
+        return;
+    }
+
+    /* On 32-bit hosts, QEMU is limited by virtual address space */
+    if (bytes > (2047 << 20) && HOST_LONG_BITS == 32) {
+        monitor_printf(mon, "cache can't exceed 2047 MB RAM limit on host\n");
+        return;
+    }
+    if (bytes != (uint64_t) bytes) {
+        monitor_printf(mon, "cache size too large\n");
+        return;
+    }
+
+    migrate_cache_size = bytes;
+}
+
 static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc,
                                     int use_xbrle, int64_t xbrle_cache_size)
 {
diff --git a/migration.h b/migration.h
index 592af6a..6de09c8 100644
--- a/migration.h
+++ b/migration.h
@@ -98,4 +98,11 @@  void migrate_add_blocker(Error *reason);
  */
 void migrate_del_blocker(Error *reason);
 
+void do_migrate_set_cachesize(Monitor *mon, const QDict *qdict);
+
+void arch_set_params(int blk_enable, int shared_base,
+        int use_xbrle, int64_t xbrle_cache_size, void *opaque);
+
+int xbrle_mig_active(void);
+
 #endif