From patchwork Mon Dec 17 12:09:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 206845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 59BB82C00A8 for ; Mon, 17 Dec 2012 23:09:54 +1100 (EST) Received: from localhost ([::1]:50339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkZW3-0006D1-6j for incoming@patchwork.ozlabs.org; Mon, 17 Dec 2012 07:09:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkZVt-0006Cv-4a for qemu-devel@nongnu.org; Mon, 17 Dec 2012 07:09:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkZVp-0005id-3J for qemu-devel@nongnu.org; Mon, 17 Dec 2012 07:09:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkZVo-0005h9-Qi for qemu-devel@nongnu.org; Mon, 17 Dec 2012 07:09:37 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBHC9ZNl028693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Dec 2012 07:09:35 -0500 Received: from doriath.home (ovpn-113-98.phx2.redhat.com [10.3.113.98]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBHC9X2p014079; Mon, 17 Dec 2012 07:09:33 -0500 Date: Mon, 17 Dec 2012 10:09:36 -0200 From: Luiz Capitulino To: Shraddha Kamat Message-ID: <20121217100936.56a24ffd@doriath.home> In-Reply-To: <1355723470.17969.19.camel@oc2826874472.ibm.com> References: <1355723470.17969.19.camel@oc2826874472.ibm.com> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Adam Litke , qemu-devel@nongnu.org, Markus Armbruster Subject: Re: [Qemu-devel] QMP command implementation help X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Mon, 17 Dec 2012 11:21:10 +0530 Shraddha Kamat wrote: > I am implementing couple of QMP commands to Qemu - so trying a > hello-world command first as shown here > https://github.com/qemu/qemu/blob/master/docs/writing-qmp-commands.txt > > Step 1 : > ======== > Added to qapi-schema.json file this : > { 'command': 'hello-world' } > > Step 2: > ======= > Added to qmp.c : > > void qmp_hello_world(Error **errp) > { > printf("Hello, world!\n"); > } > > Step 3 : > ======== > Added to qmp-commands.hx : > { > .name = "hello-world", > .args_type = "", > .mhandler.cmd_new = qmp_marshal_input_hello_world, > }, > > and build upstream Qemu-kvm : Shraddha, I've just followed the three steps above and things just worked for me: { "QMP": { "version": { "qemu": { "micro": 50, "minor": 3, "major": 1 }, "package": "" }, "capabilities": [ ] } } { "execute": "qmp_capabilities" } { "return": { } } { "execute": "hello-world" } { "return": { } } Patch below. There must something wrong with your tree. What's the qemu version you're using? diff --git a/qapi-schema.json b/qapi-schema.json index 5dfa052..717d201 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3017,3 +3017,5 @@ # Since: 1.3.0 ## { 'command': 'nbd-server-stop' } + +{ 'command': 'hello-world' } diff --git a/qmp-commands.hx b/qmp-commands.hx index 5c692d0..50db26e 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2654,3 +2654,9 @@ EQMP .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_target, }, + + { + .name = "hello-world", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_hello_world, + }, diff --git a/qmp.c b/qmp.c index e3a7f0b..e5bfc35 100644 --- a/qmp.c +++ b/qmp.c @@ -519,3 +519,8 @@ void qmp_add_client(const char *protocol, const char *fdname, error_setg(errp, "protocol '%s' is invalid", protocol); close(fd); } + +void qmp_hello_world(Error **errp) +{ + printf("Hello, world!\n"); +}