@@ -252,6 +252,10 @@ static xmlrpc_value *va_hello(xmlrpc_env *env,
return result;
}
+static xmlrpc_value *va_capabilities(xmlrpc_env *env,
+ xmlrpc_value *params,
+ void *user_data);
+
typedef struct RPCFunction {
xmlrpc_value *(*func)(xmlrpc_env *env, xmlrpc_value *param, void *unused);
const char *func_name;
@@ -266,6 +270,8 @@ static RPCFunction guest_functions[] = {
.func_name = "va.shutdown" },
{ .func = va_ping,
.func_name = "va.ping" },
+ { .func = va_capabilities,
+ .func_name = "va.capabilities" },
{ NULL, NULL }
};
static RPCFunction host_functions[] = {
@@ -273,6 +279,8 @@ static RPCFunction host_functions[] = {
.func_name = "va.ping" },
{ .func = va_hello,
.func_name = "va.hello" },
+ { .func = va_capabilities,
+ .func_name = "va.capabilities" },
{ NULL, NULL }
};
@@ -287,6 +295,35 @@ static void va_register_functions(xmlrpc_env *env, xmlrpc_registry *registry,
}
}
+/* va_capabilities(): return server capabilities
+ * rpc return values:
+ * - version: virtagent version
+ * - methods: list of supported RPCs
+ */
+static xmlrpc_value *va_capabilities(xmlrpc_env *env,
+ xmlrpc_value *params,
+ void *user_data)
+{
+ int i;
+ xmlrpc_value *result = NULL, *methods;
+ RPCFunction *func_list = va_server_data->is_host ?
+ host_functions : guest_functions;
+
+ /* provide a list of supported RPCs. we don't want to rely on
+ * system.methodList since introspection methods won't support
+ * client metadata, which we may eventually come to rely upon
+ */
+ methods = xmlrpc_array_new(env);
+ for (i = 0; func_list[i].func != NULL; ++i) {
+ xmlrpc_array_append_item(env, methods,
+ xmlrpc_string_new(env, func_list[i].func_name));
+ }
+
+ result = xmlrpc_build_value(env, "{s:s,s:A}", "version", VA_VERSION,
+ "methods", methods);
+ return result;
+}
+
int va_server_init(VAServerData *server_data, bool is_host)
{
RPCFunction *func_list = is_host ? host_functions : guest_functions;
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- virtagent-server.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-)