All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel@lists.sourceforge.net, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 2/3] QEMU: balloon: dont allow target larger than ram size
Date: Wed, 12 Mar 2008 16:17:22 -0300	[thread overview]
Message-ID: <20080312191945.337273117@localhost.localdomain> (raw)
In-Reply-To: 20080312191720.490529767@localhost.localdomain

[-- Attachment #1: larger-ram-size --]
[-- Type: text/plain, Size: 1064 bytes --]

Truncate the target size to be at most ram size.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm-userspace.balloon/qemu/hw/virtio-balloon.c
===================================================================
--- kvm-userspace.balloon.orig/qemu/hw/virtio-balloon.c
+++ kvm-userspace.balloon/qemu/hw/virtio-balloon.c
@@ -16,6 +16,7 @@
 #include "pc.h"
 #include "balloon.h"
 #include "sysemu.h"
+#include "console.h"
 
 #include <sys/mman.h>
 
@@ -115,6 +116,10 @@ static ram_addr_t virtio_balloon_to_targ
     VirtIOBalloon *dev = opaque;
 
     if (target) {
+        if (target > ram_size) {
+            term_printf("target larger than ram size, truncating\n");
+            target = ram_size;
+        }
 	dev->num_pages = (ram_size - target) >> TARGET_PAGE_BITS;
 	virtio_notify_config(&dev->vdev);
     }

-- 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2008-03-12 19:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 19:17 [patch 0/3] QEMU balloon support Marcelo Tosatti
2008-03-12 19:17 ` [patch 1/3] QEMU support for virtio balloon driver Marcelo Tosatti
2008-03-12 19:17 ` Marcelo Tosatti [this message]
2008-03-12 19:17 ` [patch 3/3] QEMU: balloon: zap any shadow mappings to a page before madvise(MADV_DONTNEED) Marcelo Tosatti
2008-03-16 14:00 ` [patch 0/3] QEMU balloon support Avi Kivity
2008-03-16 18:59   ` Marcelo Tosatti
2008-03-17 11:11     ` Avi Kivity
2008-03-17 13:08       ` Marcelo Tosatti
2008-03-17 14:56         ` Avi Kivity

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=20080312191945.337273117@localhost.localdomain \
    --to=mtosatti@redhat.com \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.