From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=44452 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POZzH-00021p-3y for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POZzB-0003Cb-8A for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:02 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:38042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POZzB-0003CP-5b for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:57 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3Hjn4W018811 for ; Fri, 3 Dec 2010 12:46:32 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 94865728047 for ; Fri, 3 Dec 2010 13:03:56 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB3I3t1l1585172 for ; Fri, 3 Dec 2010 13:03:55 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB3I3tvW013361 for ; Fri, 3 Dec 2010 13:03:55 -0500 From: Michael Roth Date: Fri, 3 Dec 2010 12:03:07 -0600 Message-Id: <1291399402-20366-7-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v5 06/21] virtagent: base server definitions 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, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com Functions for managing server's RPC methods. Signed-off-by: Michael Roth --- virtagent-server.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ virtagent-server.h | 30 +++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 0 deletions(-) create mode 100644 virtagent-server.c create mode 100644 virtagent-server.h diff --git a/virtagent-server.c b/virtagent-server.c new file mode 100644 index 0000000..36fbae2 --- /dev/null +++ b/virtagent-server.c @@ -0,0 +1,62 @@ +/* + * virtagent - host/guest RPC server functions + * + * Copyright IBM Corp. 2010 + * + * Authors: + * Adam Litke + * Michael Roth + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ +#include +#include "qemu_socket.h" +#include "virtagent-common.h" + +static bool va_enable_syslog = false; /* enable syslog'ing of RPCs */ + +#define SLOG(msg, ...) do { \ + char msg_buf[1024]; \ + if (!va_enable_syslog) { \ + break; \ + } \ + snprintf(msg_buf, 1024, msg, ## __VA_ARGS__); \ + syslog(LOG_INFO, "virtagent, %s", msg_buf); \ +} while(0) + +typedef struct RPCFunction { + xmlrpc_value *(*func)(xmlrpc_env *env, xmlrpc_value *param, void *unused); + const char *func_name; +} RPCFunction; + +static RPCFunction guest_functions[] = { + { NULL, NULL } +}; +static RPCFunction host_functions[] = { + { NULL, NULL } +}; + +static void va_register_functions(xmlrpc_env *env, xmlrpc_registry *registry, + RPCFunction *list) +{ + int i; + for (i = 0; list[i].func != NULL; ++i) { + TRACE("adding func: %s", list[i].func_name); + xmlrpc_registry_add_method(env, registry, NULL, list[i].func_name, + list[i].func, NULL); + } +} + +int va_server_init(VAServerData *server_data, bool is_host) +{ + RPCFunction *func_list = is_host ? host_functions : guest_functions; + + va_enable_syslog = !is_host; /* enable logging for guest agent */ + xmlrpc_env_init(&server_data->env); + server_data->registry = xmlrpc_registry_new(&server_data->env); + va_register_functions(&server_data->env, server_data->registry, func_list); + + return 0; +} diff --git a/virtagent-server.h b/virtagent-server.h new file mode 100644 index 0000000..dc1870e --- /dev/null +++ b/virtagent-server.h @@ -0,0 +1,30 @@ +/* + * virt-agent - host/guest RPC daemon functions + * + * Copyright IBM Corp. 2010 + * + * Authors: + * Michael Roth + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include +#include + +#define GUEST_AGENT_SERVICE_ID "virtagent" +#define GUEST_AGENT_PATH "/tmp/virtagent-guest.sock" +#define HOST_AGENT_SERVICE_ID "virtagent-host" +#define HOST_AGENT_PATH "/tmp/virtagent-host.sock" +#define VA_GETFILE_MAX 1 << 30 +#define VA_FILEBUF_LEN 16384 +#define VA_DMESG_LEN 16384 + +typedef struct VAServerData { + xmlrpc_env env; + xmlrpc_registry *registry; +} VAServerData; + +int va_server_init(VAServerData *server_data, bool is_host); -- 1.7.0.4