Blob Blame Raw
From 34974722fc54eb326f5af4153dfa7f73dd7f4d70 Mon Sep 17 00:00:00 2001
From: Orit Wasserman <owasserm@redhat.com>
Date: Tue, 11 Feb 2014 15:32:35 +0100
Subject: [PATCH 14/28] XBZRLE cache size should not be larger than guest memory size

RH-Author: Orit Wasserman <owasserm@redhat.com>
Message-id: <1392132757-18587-2-git-send-email-owasserm@redhat.com>
Patchwork-id: 57209
O-Subject: [RHEL7 qemu-kvm PATCH 1/3] XBZRLE cache size should not be larger than guest memory size
Bugzilla: 1047448
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit a5615b14a66e86f620e90c8f4b3537c28bb328d4)
---
 migration.c | 7 +++++++
 1 file changed, 7 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 migration.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/migration.c b/migration.c
index 6487fe2..b6de990 100644
--- a/migration.c
+++ b/migration.c
@@ -483,6 +483,13 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
         return;
     }
 
+    /* Cache should not be larger than guest ram size */
+    if (value > ram_bytes_total()) {
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+                  "exceeds guest ram size ");
+        return;
+    }
+
     new_size = xbzrle_cache_resize(value);
     if (new_size < 0) {
         error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
-- 
1.7.1