Patchwork [RFC,v5,18/21] virtagent: add "hello" notification function for guest agent

login
register
mail settings
Submitter Michael Roth
Date Dec. 3, 2010, 6:03 p.m.
Message ID <1291399402-20366-19-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/74197/
State New
Headers show

Comments

Michael Roth - Dec. 3, 2010, 6:03 p.m.
This tells the host RPC server (QEMU) that we're up and running

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 virtagent.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 virtagent.h |    1 +
 2 files changed, 48 insertions(+), 0 deletions(-)

Patch

diff --git a/virtagent.c b/virtagent.c
index 887ad02..e120068 100644
--- a/virtagent.c
+++ b/virtagent.c
@@ -576,3 +576,50 @@  int va_client_init_capabilities(void)
     return va_do_rpc(&env, "system.listMethods", params,
                      do_agent_capabilities_cb, NULL, NULL);
 }
+
+static void va_send_hello_cb(const char *resp_data,
+                             size_t resp_data_len,
+                             MonitorCompletion *mon_cb,
+                             void *mon_data)
+{
+    xmlrpc_value *resp = NULL;
+    xmlrpc_env env;
+
+    TRACE("called");
+
+    if (resp_data == NULL) {
+        LOG("error handling RPC request");
+        return;
+    }
+
+    xmlrpc_env_init(&env);
+    resp = xmlrpc_parse_response(&env, resp_data, resp_data_len);
+    if (va_rpc_has_error(&env)) {
+        LOG("error parsing RPC response");
+        return;
+    }
+
+    xmlrpc_DECREF(resp);
+}
+
+int va_send_hello(void)
+{
+    xmlrpc_env env;
+    xmlrpc_value *params;
+    int ret;
+
+    TRACE("called");
+
+    xmlrpc_env_init(&env);
+    params = xmlrpc_build_value(&env, "()");
+    if (va_rpc_has_error(&env)) {
+        return -1;
+    }
+
+    ret = va_do_rpc(&env, "va.hello", params, va_send_hello_cb, NULL, NULL);
+    if (ret) {
+        qerror_report(QERR_VA_FAILED, ret, strerror(ret));
+    }
+    xmlrpc_DECREF(params);
+    return ret;
+}
diff --git a/virtagent.h b/virtagent.h
index 440fe6d..398b211 100644
--- a/virtagent.h
+++ b/virtagent.h
@@ -43,5 +43,6 @@  void do_agent_capabilities_print(Monitor *mon, const QObject *qobject);
 int do_agent_capabilities(Monitor *mon, const QDict *mon_params,
                   MonitorCompletion cb, void *opaque);
 int va_client_init_capabilities(void);
+int va_send_hello(void);
 
 #endif /* VIRTAGENT_H */