9ae3a8
From c964e085dac5d2e47974f1275a0557ec841aeaba Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <c964e085dac5d2e47974f1275a0557ec841aeaba.1387382496.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
From: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Date: Thu, 14 Nov 2013 22:53:15 +0100
9ae3a8
Subject: [PATCH 39/46] arch_init: make is_zero_page accept size
9ae3a8
9ae3a8
RH-Author: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Message-id: <1384469598-13137-40-git-send-email-ncroxon@redhat.com>
9ae3a8
Patchwork-id: 55717
9ae3a8
O-Subject: [RHEL7.0 PATCH 39/42] arch_init: make is_zero_page accept size
9ae3a8
Bugzilla: 1011720
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1011720
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
9ae3a8
9ae3a8
>From commit ID:
9ae3a8
commit dc3c26a479e5bd19c1b3c04f696b8f70ad57f0b7
9ae3a8
Author: Isaku Yamahata <yamahata@private.email.ne.jp>
9ae3a8
Date:   Sat Sep 21 01:23:36 2013 +0900
9ae3a8
9ae3a8
    arch_init: make is_zero_page accept size
9ae3a8
9ae3a8
    Later is_zero_page will be used for non TARGET_PAGE_SIZE
9ae3a8
    range.
9ae3a8
    And rename it to is_zero_range as it isn't page size any more.
9ae3a8
9ae3a8
    Signed-off-by: Isaku Yamahata <yamahata@private.email.ne.jp>
9ae3a8
    Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
---
9ae3a8
 arch_init.c |    9 ++++-----
9ae3a8
 1 files changed, 4 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 arch_init.c | 9 ++++-----
9ae3a8
 1 file changed, 4 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/arch_init.c b/arch_init.c
9ae3a8
index 26d0374..5ce9c61 100644
9ae3a8
--- a/arch_init.c
9ae3a8
+++ b/arch_init.c
9ae3a8
@@ -150,10 +150,9 @@ int qemu_read_default_config_files(bool userconfig)
9ae3a8
     return 0;
9ae3a8
 }
9ae3a8
 
9ae3a8
-static inline bool is_zero_page(uint8_t *p)
9ae3a8
+static inline bool is_zero_range(uint8_t *p, uint64_t size)
9ae3a8
 {
9ae3a8
-    return buffer_find_nonzero_offset(p, TARGET_PAGE_SIZE) ==
9ae3a8
-        TARGET_PAGE_SIZE;
9ae3a8
+    return buffer_find_nonzero_offset(p, size) == size;
9ae3a8
 }
9ae3a8
 
9ae3a8
 /* struct contains XBZRLE cache and a static page
9ae3a8
@@ -497,7 +496,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
9ae3a8
                         acct_info.dup_pages++;
9ae3a8
                     }
9ae3a8
                 }
9ae3a8
-            } else if (is_zero_page(p)) {
9ae3a8
+            } else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
9ae3a8
                 acct_info.dup_pages++;
9ae3a8
                 bytes_sent = save_block_hdr(f, block, offset, cont,
9ae3a8
                                             RAM_SAVE_FLAG_COMPRESS);
9ae3a8
@@ -849,7 +848,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
9ae3a8
  */
9ae3a8
 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
9ae3a8
 {
9ae3a8
-    if (ch != 0 || !is_zero_page(host)) {
9ae3a8
+    if (ch != 0 || !is_zero_range(host, TARGET_PAGE_SIZE)) {
9ae3a8
         memset(host, ch, size);
9ae3a8
 #ifndef _WIN32
9ae3a8
         if (ch == 0 &&
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8