Blame SOURCES/kvm-Add-check-for-cache-size-smaller-than-page-size.patch

0a122b
From 34f122742b3b75db66c9f2a022179136dbc534e4 Mon Sep 17 00:00:00 2001
0a122b
From: Orit Wasserman <owasserm@redhat.com>
0a122b
Date: Tue, 11 Feb 2014 15:20:47 +0100
0a122b
Subject: [PATCH 13/28] Add check for cache size smaller than page size
0a122b
0a122b
RH-Author: Orit Wasserman <owasserm@redhat.com>
0a122b
Message-id: <1392132047-5103-1-git-send-email-owasserm@redhat.com>
0a122b
Patchwork-id: 57207
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH] Add check for cache size smaller than page size
0a122b
Bugzilla: 1017096
0a122b
RH-Acked-by: Juan Quintela <quintela@redhat.com>
0a122b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
0a122b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
Bugzilla: 1017096
0a122b
Upstream: merged
0a122b
Brew:http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7028464
0a122b
0a122b
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
0a122b
Reviewed-by: Juan Quintela <quintela@redhat.com>
0a122b
Signed-off-by: Juan Quintela <quintela@redhat.com>
0a122b
(cherry picked from commit c91e681a558fc21073ffc491b5a022d5f340fa0b)
0a122b
---
0a122b
 arch_init.c |  4 ++++
0a122b
 migration.c | 10 +++++++++-
0a122b
 2 files changed, 13 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 arch_init.c |    4 ++++
0a122b
 migration.c |   10 +++++++++-
0a122b
 2 files changed, 13 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/arch_init.c b/arch_init.c
0a122b
index 31aac84..c3207bf 100644
0a122b
--- a/arch_init.c
0a122b
+++ b/arch_init.c
0a122b
@@ -178,6 +178,10 @@ static struct {
0a122b
 
0a122b
 int64_t xbzrle_cache_resize(int64_t new_size)
0a122b
 {
0a122b
+    if (new_size < TARGET_PAGE_SIZE) {
0a122b
+        return -1;
0a122b
+    }
0a122b
+
0a122b
     if (XBZRLE.cache != NULL) {
0a122b
         return cache_resize(XBZRLE.cache, new_size / TARGET_PAGE_SIZE) *
0a122b
             TARGET_PAGE_SIZE;
0a122b
diff --git a/migration.c b/migration.c
0a122b
index 21f7247..6487fe2 100644
0a122b
--- a/migration.c
0a122b
+++ b/migration.c
0a122b
@@ -474,6 +474,7 @@ void qmp_migrate_cancel(Error **errp)
0a122b
 void qmp_migrate_set_cache_size(int64_t value, Error **errp)
0a122b
 {
0a122b
     MigrationState *s = migrate_get_current();
0a122b
+    int64_t new_size;
0a122b
 
0a122b
     /* Check for truncation */
0a122b
     if (value != (size_t)value) {
0a122b
@@ -482,7 +483,14 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
0a122b
         return;
0a122b
     }
0a122b
 
0a122b
-    s->xbzrle_cache_size = xbzrle_cache_resize(value);
0a122b
+    new_size = xbzrle_cache_resize(value);
0a122b
+    if (new_size < 0) {
0a122b
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
0a122b
+                  "is smaller than page size");
0a122b
+        return;
0a122b
+    }
0a122b
+
0a122b
+    s->xbzrle_cache_size = new_size;
0a122b
 }
0a122b
 
0a122b
 int64_t qmp_query_migrate_cache_size(Error **errp)
0a122b
-- 
0a122b
1.7.1
0a122b