]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi: Convert balloon
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 25 Nov 2011 16:38:09 +0000 (14:38 -0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Tue, 6 Dec 2011 13:40:01 +0000 (11:40 -0200)
Note that the command being dropped uses the deprecated MONITOR_CMD_ASYNC
API, but the new command is a regular synchronous command. There shouldn't
be visible differences though, as MONITOR_CMD_ASYNC is internal only.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
balloon.c
balloon.h
hmp-commands.hx
hmp.c
hmp.h
qapi-schema.json
qmp-commands.hx

index e1cd5fac4c292ae1bf504926ee77ddc7dffde810..0166744aa89ae67827e2ccf9579e3fb7ae8cf269 100644 (file)
--- a/balloon.c
+++ b/balloon.c
@@ -100,31 +100,19 @@ BalloonInfo *qmp_query_balloon(Error **errp)
     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) {
+    if (value <= 0) {
         qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
-        return -1;
+        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;
 }
index b36abeadf0547931b8e035b2b0ea4ffd66168244..b60fd5d9f22a05d608d1af063498f0cacfb392b5 100644 (file)
--- a/balloon.h
+++ b/balloon.h
@@ -24,7 +24,4 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
                             QEMUBalloonStatus *stat_func, void *opaque);
 void qemu_remove_balloon_handler(void *opaque);
 
-int do_balloon(Monitor *mon, const QDict *params,
-               MonitorCompletion cb, void *opaque);
-
 #endif
index 0bf88961b7714014a3ce9684e60bab1b29f2cdd6..ea52271f35df05ea42c0eb6a88bad89420b030ee 100644 (file)
@@ -1022,9 +1022,7 @@ ETEXI
         .args_type  = "value:M",
         .params     = "target",
         .help       = "request VM to change its memory allocation (in MB)",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_async = do_balloon,
-        .flags      = MONITOR_CMD_ASYNC,
+        .mhandler.cmd = hmp_balloon,
     },
 
 STEXI
diff --git a/hmp.c b/hmp.c
index 3893d59cf6c3db60507e92e5aa193e6a984f3700..e9d171124a039b224aad6ebfb192ba89426cd917 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -621,3 +621,15 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
     qmp_block_passwd(device, password, &errp);
     hmp_handle_error(mon, &errp);
 }
+
+void hmp_balloon(Monitor *mon, const QDict *qdict)
+{
+    int64_t value = qdict_get_int(qdict, "value");
+    Error *errp = NULL;
+
+    qmp_balloon(value, &errp);
+    if (error_is_set(&errp)) {
+        monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp));
+        error_free(errp);
+    }
+}
diff --git a/hmp.h b/hmp.h
index d6aa23288f697c95f506304ce064fcb47fe6d8a1..b0984acb2b9ef28e235920c6ef1c4a2c14574b50 100644 (file)
--- a/hmp.h
+++ b/hmp.h
@@ -43,5 +43,6 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
 void hmp_set_link(Monitor *mon, const QDict *qdict);
 void hmp_block_passwd(Monitor *mon, const QDict *qdict);
+void hmp_balloon(Monitor *mon, const QDict *qdict);
 
 #endif
index 569aa74a7cbbe48446b063a53dab45a0f64c6441..9bfdc3938d03f8fc8675a66bd34d95dc392c7ea6 100644 (file)
 # Since: 0.14.0
 ##
 { 'command': 'block_passwd', 'data': {'device': 'str', 'password': 'str'} }
+
+##
+# @balloon:
+#
+# Request the balloon driver to change its balloon size.
+#
+# @value: the target size of the balloon in bytes
+#
+# Returns: Nothing on success
+#          If the balloon driver is enabled but not functional because the KVM
+#            kernel module cannot support it, KvmMissingCap
+#          If no balloon device is present, DeviceNotActive
+#
+# Notes: This command just issues a request to the guest.  When it returns,
+#        the balloon size may not have changed.  A guest can change the balloon
+#        size independent of this command.
+#
+# Since: 0.14.0
+##
+{ 'command': 'balloon', 'data': {'value': 'int'} }
index bbf9bfcdd894d9c3956a95f1d16dfaa0d124dda8..7c377f015bb8baf33ade92fe52805db2d874f6a2 100644 (file)
@@ -703,11 +703,7 @@ EQMP
     {
         .name       = "balloon",
         .args_type  = "value:M",
-        .params     = "target",
-        .help       = "request VM to change its memory allocation (in MB)",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_async = do_balloon,
-        .flags      = MONITOR_CMD_ASYNC,
+        .mhandler.cmd_new = qmp_marshal_input_balloon,
     },
 
 SQMP