From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47209 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ7aK-0005xc-1N for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:43:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ7aI-00015B-UR for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:43:43 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:34767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ7aI-000141-Mc for qemu-devel@nongnu.org; Thu, 18 Nov 2010 11:43:42 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAIGQuY1026845 for ; Thu, 18 Nov 2010 11:26:56 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAIGhdwk092780 for ; Thu, 18 Nov 2010 11:43:39 -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 oAIGhcYJ003017 for ; Thu, 18 Nov 2010 11:43:39 -0500 Message-ID: <4CE557B9.5010501@linux.vnet.ibm.com> Date: Thu, 18 Nov 2010 10:43:37 -0600 From: Michael Roth MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH v4 14/18] virtagent: add client capabilities init function References: <1289923320-5638-1-git-send-email-mdroth@linux.vnet.ibm.com> <1289923320-5638-15-git-send-email-mdroth@linux.vnet.ibm.com> <4CE53688.9070607@redhat.com> In-Reply-To: <4CE53688.9070607@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, agl@linux.vnet.ibm.com, qemu-devel@nongnu.org, abeekhof@redhat.com On 11/18/2010 08:22 AM, Jes Sorensen wrote: > On 11/16/10 17:01, Michael Roth wrote: >> Non-monitor version of agent_capabilities monitor function. This is >> called by the local RPC server when it gets a "hello" from the guest >> agent to re-negotiate guest agent capabilities. >> >> Signed-off-by: Michael Roth >> --- >> virtagent.c | 34 ++++++++++++++++++++++++++++++++++ >> virtagent.h | 1 + >> 2 files changed, 35 insertions(+), 0 deletions(-) >> >> diff --git a/virtagent.c b/virtagent.c >> index e0f7f99..4ec1b42 100644 >> --- a/virtagent.c >> +++ b/virtagent.c >> @@ -694,3 +694,37 @@ int do_agent_capabilities(Monitor *mon, const QDict *mon_params, >> >> return 0; >> } >> + >> +/* non-HMP/QMP RPC client functions */ >> + >> +int va_client_init_capabilities(void) >> +{ >> + xmlrpc_env env; >> + xmlrpc_value *params; >> + VARPCData *rpc_data; >> + int ret; >> + >> + xmlrpc_env_init(&env); >> + >> + params = xmlrpc_build_value(&env, "()"); >> + if (rpc_has_error(&env)) { >> + return -1; >> + } >> + >> + rpc_data = qemu_mallocz(sizeof(VARPCData)); >> + rpc_data->cb = do_agent_capabilities_cb; >> + rpc_data->mon_cb = NULL; >> + rpc_data->mon_data = NULL; >> + >> + ret = rpc_execute(&env, "system.listMethods", params, rpc_data); >> + if (ret == -EREMOTE) { >> + LOG("RPC Failed (%i): %s\n", env.fault_code, >> + env.fault_string); >> + return -1; >> + } else if (ret == -1) { >> + LOG("RPC communication error\n"); >> + return -1; >> + } > > One of many examples that would have benefited from having a utility > function doing most of the work here. > Agreed, I should be able to trim quite a few lines out of virtagent.c with a bit more code re-use. > Cheers, > Jes