Patchwork [RFC,v4,16/18] virtagent: add va_send_hello() client function

login
register
mail settings
Submitter Michael Roth
Date Nov. 16, 2010, 4:01 p.m.
Message ID <1289923320-5638-17-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/71424/
State New
Headers show

Comments

Michael Roth - Nov. 16, 2010, 4:01 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 |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 virtagent.h |    1 +
 2 files changed, 56 insertions(+), 0 deletions(-)

Patch

diff --git a/virtagent.c b/virtagent.c
index 4ec1b42..3be9082 100644
--- a/virtagent.c
+++ b/virtagent.c
@@ -728,3 +728,58 @@  int va_client_init_capabilities(void)
 
     return 0;
 }
+
+static void va_send_hello_cb(void *opaque)
+{
+    VARPCData *rpc_data = opaque;
+    xmlrpc_value *resp = NULL;
+    xmlrpc_env env;
+
+    TRACE("called");
+
+    if (rpc_data->status != VA_RPC_STATUS_OK) {
+        LOG("error handling RPC request");
+        return;
+    }
+
+    xmlrpc_env_init(&env);
+    resp = xmlrpc_parse_response(&env, rpc_data->resp_xml,
+                                 rpc_data->resp_xml_len);
+    if (rpc_has_error(&env)) {
+        LOG("error parsing RPC response");
+        return;
+    }
+
+    xmlrpc_DECREF(resp);
+}
+
+int va_send_hello(void)
+{
+    xmlrpc_env env;
+    xmlrpc_value *params;
+    VARPCData *rpc_data;
+    int ret;
+
+    TRACE("called");
+
+    xmlrpc_env_init(&env);
+    params = xmlrpc_build_value(&env, "(s)", "dummy");
+    if (rpc_has_error(&env)) {
+        return -1;
+    }
+
+    rpc_data = qemu_mallocz(sizeof(VARPCData));
+    rpc_data->cb = va_send_hello_cb;
+
+    ret = rpc_execute(&env, "va_hello", params, rpc_data);
+    if (ret == -EREMOTE) {
+        LOG("RPC Failed (%i): %s", env.fault_code,
+            env.fault_string);
+        return -1;
+    } else if (ret == -1) {
+        LOG("RPC communication error");
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/virtagent.h b/virtagent.h
index da4be60..83033e3 100644
--- a/virtagent.h
+++ b/virtagent.h
@@ -38,5 +38,6 @@  int do_agent_ping(Monitor *mon, const QDict *mon_params,
 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_send_hello(void);
 
 #endif /* VIRTAGENT_H */