All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] function to execute qmp commands
@ 2015-08-31 23:28 Programmingkid
  2015-09-01  6:19 ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Programmingkid @ 2015-08-31 23:28 UTC (permalink / raw)
  To: qemu-devel qemu-devel

Is there a function that can execute a qmp command in QEMU?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] function to execute qmp commands
  2015-08-31 23:28 [Qemu-devel] function to execute qmp commands Programmingkid
@ 2015-09-01  6:19 ` Markus Armbruster
  2015-09-01 14:09   ` Programmingkid
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2015-09-01  6:19 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

Programmingkid <programmingkidx@gmail.com> writes:

> Is there a function that can execute a qmp command in QEMU?

Sure you want to do that, and not call the C interface instead?  Let me
explain how QMP works:

* QMP core: receive JSON, parse, find handler function (defined in
  qmp-commands.hx), call it

* The handler function is of type

      void (*)(QDict *params, QObject **ret_data, Error **errp);

  It's normally an function generated from QAPI schema that unmarshals
  the arguments, calls the real function, and marshals result on success
  or forwards the error on failure.

  The point of this marshalling business is to have a real function with
  a nice C interface rather than this QDict / QObject stuff.

* QMP core: format and send reply.

Handler function example: query-command-line-options

qmp-commands.hx points to
qmp_marshal_input_query_command_line_options(), which calls
qmp_query_command_line_options().  The latter looks like this:

    CommandLineOptionInfoList *
    qmp_query_command_line_options(bool has_option,
                                   const char *option,
                                   Error **errp)

That's the function you want to call from C.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] function to execute qmp commands
  2015-09-01  6:19 ` Markus Armbruster
@ 2015-09-01 14:09   ` Programmingkid
  0 siblings, 0 replies; 3+ messages in thread
From: Programmingkid @ 2015-09-01 14:09 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel qemu-devel


On Sep 1, 2015, at 2:19 AM, Markus Armbruster wrote:

> Programmingkid <programmingkidx@gmail.com> writes:
> 
>> Is there a function that can execute a qmp command in QEMU?
> 
> Sure you want to do that, and not call the C interface instead?  Let me
> explain how QMP works:
> 
> * QMP core: receive JSON, parse, find handler function (defined in
>  qmp-commands.hx), call it
> 
> * The handler function is of type
> 
>      void (*)(QDict *params, QObject **ret_data, Error **errp);
> 
>  It's normally an function generated from QAPI schema that unmarshals
>  the arguments, calls the real function, and marshals result on success
>  or forwards the error on failure.
> 
>  The point of this marshalling business is to have a real function with
>  a nice C interface rather than this QDict / QObject stuff.
> 
> * QMP core: format and send reply.
> 
> Handler function example: query-command-line-options
> 
> qmp-commands.hx points to
> qmp_marshal_input_query_command_line_options(), which calls
> qmp_query_command_line_options().  The latter looks like this:
> 
>    CommandLineOptionInfoList *
>    qmp_query_command_line_options(bool has_option,
>                                   const char *option,
>                                   Error **errp)
> 
> That's the function you want to call from C.

Thank you very much for the help.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-01 14:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-31 23:28 [Qemu-devel] function to execute qmp commands Programmingkid
2015-09-01  6:19 ` Markus Armbruster
2015-09-01 14:09   ` Programmingkid

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.