qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC][PATCH v7 11/16] virtagent: add va_ping HMP/QMP comman


From: Michael Roth
Subject: [Qemu-devel] [RFC][PATCH v7 11/16] virtagent: add va_ping HMP/QMP command
Date: Mon, 7 Mar 2011 14:10:37 -0600

Signed-off-by: Michael Roth <address@hidden>
---
 hmp-commands.hx |   16 ++++++++++++++++
 qmp-commands.hx |   32 ++++++++++++++++++++++++++++++++
 virtagent.c     |   45 +++++++++++++++++++++++++++++++++++++++++++++
 virtagent.h     |    3 +++
 4 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 86817e2..f22117a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1380,6 +1380,22 @@ STEXI
 Fetch and re-negotiate guest agent capabilties
 ETEXI
 
+    {
+        .name       = "va_ping",
+        .args_type  = "",
+        .params     = "",
+        .help       = "Ping the guest agent",
+        .user_print = do_va_ping_print,
+        .mhandler.cmd_async = do_va_ping,
+        .flags      = MONITOR_CMD_ASYNC,
+    },
+
+STEXI
address@hidden va_ping
address@hidden va_ping
+Ping the guest agent
+ETEXI
+
 STEXI
 @end table
 ETEXI
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e1092dd..0379b61 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -891,6 +891,38 @@ Example:
 EQMP
 
     {
+        .name       = "va_ping",
+        .args_type  = "",
+        .params     = "",
+        .help       = "Ping the guest agent",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_async = do_va_ping,
+        .flags      = MONITOR_CMD_ASYNC,
+    },
+
+STEXI
address@hidden va_ping
address@hidden va_ping
+Ping the guest agent
+ETEXI
+SQMP
+va_ping
+--------
+
+Ping the guest agent
+
+Arguments:
+
+(none)
+
+Example:
+
+-> { "execute": "va_ping" }
+<- { "return": {"status": "ok" }}
+
+EQMP
+
+    {
         .name       = "qmp_capabilities",
         .args_type  = "",
         .params     = "",
diff --git a/virtagent.c b/virtagent.c
index 670309b..baf3c0e 100644
--- a/virtagent.c
+++ b/virtagent.c
@@ -431,6 +431,51 @@ int do_va_capabilities(Monitor *mon, const QDict *params,
     return ret;
 }
 
+void do_va_ping_print(Monitor *mon, const QObject *data)
+{
+    QDict *ret = qobject_to_qdict(data);
+
+    TRACE("called");
+
+    if (!data) {
+        return;
+    }
+    monitor_printf(mon, "status: %s\n", qdict_get_str(ret, "status"));
+}
+
+static void do_va_ping_cb(QDict *resp,
+                          MonitorCompletion *mon_cb,
+                          void *mon_data)
+{
+    QDict *ret = qdict_new();
+    const char *status;
+
+    if (va_check_response_ok(resp, NULL)) {
+        status = "success";
+    } else {
+        status = "error or timeout";
+    }
+    qdict_put_obj(ret, "status", QOBJECT(qstring_from_str(status)));
+
+    if (mon_cb) {
+        mon_cb(mon_data, QOBJECT(ret));
+    }
+    QDECREF(ret);
+}
+
+/*
+ * do_va_ping(): Ping the guest agent
+ */
+int do_va_ping(Monitor *mon, const QDict *params,
+               MonitorCompletion cb, void *opaque)
+{
+    int ret = va_do_rpc("ping", params, do_va_ping_cb, cb, opaque);
+    if (ret) {
+        qerror_report(QERR_VA_FAILED, ret, strerror(-ret));
+    }
+    return ret;
+}
+
 /* RPC client functions called outside of HMP/QMP */
 
 int va_client_init_capabilities(void)
diff --git a/virtagent.h b/virtagent.h
index 1652fdc..a58d8ba 100644
--- a/virtagent.h
+++ b/virtagent.h
@@ -42,5 +42,8 @@ int do_agent_shutdown(Monitor *mon, const QDict *mon_params,
 void do_va_capabilities_print(Monitor *mon, const QObject *qobject);
 int do_va_capabilities(Monitor *mon, const QDict *mon_params,
                        MonitorCompletion cb, void *opaque);
+void do_va_ping_print(Monitor *mon, const QObject *qobject);
+int do_va_ping(Monitor *mon, const QDict *mon_params,
+               MonitorCompletion cb, void *opaque);
 
 #endif /* VIRTAGENT_H */
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]