qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Shraddha Kamat <sh2008ka@gmail.com>
Cc: Adam Litke <agl@us.ibm.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] QMP command implementation help
Date: Mon, 17 Dec 2012 10:09:36 -0200	[thread overview]
Message-ID: <20121217100936.56a24ffd@doriath.home> (raw)
In-Reply-To: <1355723470.17969.19.camel@oc2826874472.ibm.com>

On Mon, 17 Dec 2012 11:21:10 +0530
Shraddha Kamat <sh2008ka@gmail.com> 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");
+}

      reply	other threads:[~2012-12-17 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17  5:51 [Qemu-devel] QMP command implementation help Shraddha Kamat
2012-12-17 12:09 ` Luiz Capitulino [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121217100936.56a24ffd@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=agl@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sh2008ka@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).