aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-04 20:19:35 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-04 20:19:35 +0000
commitdf751fa8bfed4408ca091a7badd75c5ab80f71de (patch)
tree5c45ae730f07c0ffc2057778a2ebd1c1419ac5a3 /vl.c
parent8d371d4bceb308c29a5db4c21c984e06c9d56371 (diff)
Add ballooning infrastructure.
Balloon devices allow you to ask the guest to allocate memory. This allows you to release that memory. It's mostly useful for freeing up large chunks of memory from cooperative guests. Ballooning is supported by both Xen and VirtIO. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5873 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 2b5366e7ec..1cee2a793f 100644
--- a/vl.c
+++ b/vl.c
@@ -40,6 +40,7 @@
#include "audio/audio.h"
#include "migration.h"
#include "kvm.h"
+#include "balloon.h"
#include <unistd.h>
#include <fcntl.h>
@@ -514,6 +515,31 @@ void hw_error(const char *fmt, ...)
va_end(ap);
abort();
}
+
+/***************/
+/* ballooning */
+
+static QEMUBalloonEvent *qemu_balloon_event;
+void *qemu_balloon_event_opaque;
+
+void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque)
+{
+ qemu_balloon_event = func;
+ qemu_balloon_event_opaque = opaque;
+}
+
+void qemu_balloon(ram_addr_t target)
+{
+ if (qemu_balloon_event)
+ qemu_balloon_event(qemu_balloon_event_opaque, target);
+}
+
+ram_addr_t qemu_balloon_status(void)
+{
+ if (qemu_balloon_event)
+ return qemu_balloon_event(qemu_balloon_event_opaque, 0);
+ return 0;
+}
/***********************************************************/
/* keyboard/mouse */