From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33074 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Peowp-0007AT-Sz for qemu-devel@nongnu.org; Mon, 17 Jan 2011 08:16:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Peowi-0006Lc-RN for qemu-devel@nongnu.org; Mon, 17 Jan 2011 08:16:37 -0500 Received: from e3.ny.us.ibm.com ([32.97.182.143]:59141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Peowi-0006LV-Nh for qemu-devel@nongnu.org; Mon, 17 Jan 2011 08:16:32 -0500 Received: from d01dlp02.pok.ibm.com (d01dlp02.pok.ibm.com [9.56.224.85]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p0HCvG0w021765 for ; Mon, 17 Jan 2011 07:57:34 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id DD0F44DE803B for ; Mon, 17 Jan 2011 08:13:18 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0HDGV04392904 for ; Mon, 17 Jan 2011 08:16:31 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0HDGU7T031626 for ; Mon, 17 Jan 2011 08:16:31 -0500 From: Michael Roth Date: Mon, 17 Jan 2011 07:15:14 -0600 Message-Id: <1295270117-24760-21-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1295270117-24760-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1295270117-24760-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v6 20/23] virtagent: add va.capabilities RPC List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, marcel.mittelstaedt@de.ibm.com, mdroth@linux.vnet.ibm.com, markus_mueller@de.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com Signed-off-by: Michael Roth --- virtagent-server.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/virtagent-server.c b/virtagent-server.c index b7e51ed..5961905 100644 --- a/virtagent-server.c +++ b/virtagent-server.c @@ -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; -- 1.7.0.4