Patchwork [08/41] savevm: Factorize ram globals reset in its own function

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:47 a.m.
Message ID <1348217255-22441-9-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185630/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Orit Wasserman - Sept. 25, 2012, 8:37 a.m.
On 09/21/2012 11:47 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 52ccc7b..57f7f1a 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -482,6 +482,14 @@ static void ram_migration_cancel(void *opaque)
>      migration_end();
>  }
> 
> +
> +static void reset_ram_globals(void)
> +{
> +    last_block = NULL;
> +    last_offset = 0;
> +    sort_ram_list();
> +}
> +
>  #define MAX_WAIT 50 /* ms, half buffered_file limit */
> 
>  static int ram_save_setup(QEMUFile *f, void *opaque)
> @@ -491,9 +499,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
> 
>      memory_global_sync_dirty_bitmap(get_system_memory());
>      bytes_transferred = 0;
> -    last_block = NULL;
> -    last_offset = 0;
> -    sort_ram_list();
> +    reset_ram_globals();
> 
>      if (migrate_use_xbzrle()) {
>          XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
> 

Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/arch_init.c b/arch_init.c
index 52ccc7b..57f7f1a 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -482,6 +482,14 @@  static void ram_migration_cancel(void *opaque)
     migration_end();
 }

+
+static void reset_ram_globals(void)
+{
+    last_block = NULL;
+    last_offset = 0;
+    sort_ram_list();
+}
+
 #define MAX_WAIT 50 /* ms, half buffered_file limit */

 static int ram_save_setup(QEMUFile *f, void *opaque)
@@ -491,9 +499,7 @@  static int ram_save_setup(QEMUFile *f, void *opaque)

     memory_global_sync_dirty_bitmap(get_system_memory());
     bytes_transferred = 0;
-    last_block = NULL;
-    last_offset = 0;
-    sort_ram_list();
+    reset_ram_globals();

     if (migrate_use_xbzrle()) {
         XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /