qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Orit Wasserman <owasserm@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Orit Wasserman <owasserm@redhat.com>,
	quintela@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] Add check for cache size smaller than page size
Date: Tue,  7 Jan 2014 17:50:08 +0200	[thread overview]
Message-ID: <1389109808-19681-2-git-send-email-owasserm@redhat.com> (raw)
In-Reply-To: <1389109808-19681-1-git-send-email-owasserm@redhat.com>

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
 arch_init.c |  4 ++++
 migration.c | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch_init.c b/arch_init.c
index 5c55c68..e52c9ba 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -176,6 +176,10 @@ static struct {
 
 int64_t xbzrle_cache_resize(int64_t new_size)
 {
+    if (new_size < TARGET_PAGE_SIZE) {
+        return -1;
+    }
+
     if (XBZRLE.cache != NULL) {
         return cache_resize(XBZRLE.cache, new_size / TARGET_PAGE_SIZE) *
             TARGET_PAGE_SIZE;
diff --git a/migration.c b/migration.c
index 2b1ab20..f28aa1d 100644
--- a/migration.c
+++ b/migration.c
@@ -455,6 +455,7 @@ void qmp_migrate_cancel(Error **errp)
 void qmp_migrate_set_cache_size(int64_t value, Error **errp)
 {
     MigrationState *s = migrate_get_current();
+    int64_t new_size; 
 
     /* Check for truncation */
     if (value != (size_t)value) {
@@ -463,8 +464,14 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
         return;
     }
 
-    s->xbzrle_cache_size = xbzrle_cache_resize(value);
+    new_size = xbzrle_cache_resize(value);
+    if (new_size < 0) {
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+                  "is smaller than page size");
+        return;
+    }
+
+    s->xbzrle_cache_size = new_size;
 }
 
 int64_t qmp_query_migrate_cache_size(Error **errp)
-- 
1.8.3.1

  reply	other threads:[~2014-01-07 15:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 15:50 [Qemu-devel] [PATCH 1/2] Set xbzrle buffers to NULL after freeing them to avoid double free errors Orit Wasserman
2014-01-07 15:50 ` Orit Wasserman [this message]
2014-01-14 15:25   ` [Qemu-devel] [PATCH 2/2] Add check for cache size smaller than page size Juan Quintela
2014-01-14 15:25 ` [Qemu-devel] [PATCH 1/2] Set xbzrle buffers to NULL after freeing them to avoid double free errors Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389109808-19681-2-git-send-email-owasserm@redhat.com \
    --to=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).