#include "balloon.h"
#include "trace.h"
#include "qmp-commands.h"
+#include "qjson.h"
static QEMUBalloonEvent *balloon_event_fn;
static QEMUBalloonStatus *balloon_stat_fn;
return 1;
}
+void qemu_balloon_changed(int64_t actual)
+{
+ QObject *data;
+
+ data = qobject_from_jsonf("{ 'actual': %" PRId64 " }",
+ actual);
+
+ monitor_protocol_event(QEVENT_BALLOON_CHANGE, data);
+
+ qobject_decref(data);
+}
+
+
BalloonInfo *qmp_query_balloon(Error **errp)
{
BalloonInfo *info;
return info;
}
-/**
- * do_balloon(): Request VM to change its memory allocation
- */
-int do_balloon(Monitor *mon, const QDict *params,
- MonitorCompletion cb, void *opaque)
+void qmp_balloon(int64_t value, Error **errp)
{
- int64_t target;
- int ret;
-
if (kvm_enabled() && !kvm_has_sync_mmu()) {
- qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
- return -1;
+ error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
+ return;
}
- target = qdict_get_int(params, "value");
- if (target <= 0) {
- qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
- return -1;
+ if (value <= 0) {
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
+ return;
}
- ret = qemu_balloon(target);
- if (ret == 0) {
- qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
- return -1;
+
+ if (qemu_balloon(value) == 0) {
+ error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon");
}
-
- cb(opaque, NULL);
- return 0;
}