From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 3/5] monitor: do_balloon(): Check for errors
Date: Mon, 14 Dec 2009 18:53:22 -0200 [thread overview]
Message-ID: <1260824004-2941-4-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1260824004-2941-1-git-send-email-lcapitulino@redhat.com>
do_balloon() should check for ballooning availability as
do_info_balloon() does.
Noted by Daniel P. Berrange <berrange@redhat.com>.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/monitor.c b/monitor.c
index d5041dc..920ccff 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2053,14 +2053,34 @@ static void do_info_status(Monitor *mon, QObject **ret_data)
vm_running, singlestep);
}
+static ram_addr_t balloon_get_value(void)
+{
+ ram_addr_t actual;
+
+ if (kvm_enabled() && !kvm_has_sync_mmu()) {
+ qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
+ return 0;
+ }
+
+ actual = qemu_balloon_status();
+ if (actual == 0) {
+ qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
+ return 0;
+ }
+
+ return actual;
+}
+
/**
* do_balloon(): Request VM to change its memory allocation
*/
static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
- int value = qdict_get_int(qdict, "value");
- ram_addr_t target = value;
- qemu_balloon(target << 20);
+ if (balloon_get_value()) {
+ /* ballooning is active */
+ ram_addr_t value = qdict_get_int(qdict, "value");
+ qemu_balloon(value << 20);
+ }
}
static void monitor_print_balloon(Monitor *mon, const QObject *data)
@@ -2088,14 +2108,11 @@ static void do_info_balloon(Monitor *mon, QObject **ret_data)
{
ram_addr_t actual;
- actual = qemu_balloon_status();
- if (kvm_enabled() && !kvm_has_sync_mmu())
- qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
- else if (actual == 0)
- qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
- else
+ actual = balloon_get_value();
+ if (actual != 0) {
*ret_data = qobject_from_jsonf("{ 'balloon': %" PRId64 "}",
(int64_t) actual);
+ }
}
static qemu_acl *find_acl(Monitor *mon, const char *name)
--
1.6.6.rc2.5.g49666
next prev parent reply other threads:[~2009-12-14 20:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 20:53 [Qemu-devel] [FOR 0.12 0/5]: Misc QMP related fixes Luiz Capitulino
2009-12-14 20:53 ` [Qemu-devel] [PATCH 1/5] QDict: Fix size update Luiz Capitulino
2009-12-14 20:53 ` [Qemu-devel] [PATCH 2/5] monitor: Use 'device' in eject Luiz Capitulino
2009-12-14 20:53 ` Luiz Capitulino [this message]
2009-12-14 20:53 ` [Qemu-devel] [PATCH 4/5] monitor: Avoid readline functions in QMP Luiz Capitulino
2009-12-15 9:50 ` Markus Armbruster
2009-12-15 9:54 ` Markus Armbruster
2009-12-15 12:08 ` Luiz Capitulino
2009-12-15 14:03 ` Markus Armbruster
2009-12-15 14:17 ` [Qemu-devel] " Jan Kiszka
2009-12-14 20:53 ` [Qemu-devel] [PATCH 5/5] monitor: Catch printing to non-existent monitor Luiz Capitulino
2009-12-15 9:42 ` Markus Armbruster
2009-12-15 12:02 ` Luiz Capitulino
2009-12-15 13:56 ` Markus Armbruster
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=1260824004-2941-4-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/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).