xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xen.org
Cc: George.Dunlap@eu.citrix.com, wei.liu2@citrix.com,
	ian.jackson@eu.citrix.com, Juergen Gross <jgross@suse.com>
Subject: [PATCH 2/6] libxl: add libxl__qmp_run_command_flexarray() function
Date: Thu,  8 Sep 2016 09:20:22 +0200	[thread overview]
Message-ID: <1473319226-27221-3-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1473319226-27221-1-git-send-email-jgross@suse.com>

Add a function libxl__qmp_run_command_flexarray() to run a qmp command
with an array of arguments. The arguments are name-value pairs stored
in a flexarray.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/libxl/libxl_internal.h |  3 +++
 tools/libxl/libxl_qmp.c      | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 3f29aa6..ecbfdad 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1753,6 +1753,9 @@ typedef struct libxl__qmp_handler libxl__qmp_handler;
  */
 _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc,
                                                   uint32_t domid);
+_hidden int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid,
+                                             const char *cmd,
+                                             flexarray_t *array);
 /* ask to QEMU the serial port information and store it in xenstore. */
 _hidden int libxl__qmp_query_serial(libxl__qmp_handler *qmp);
 _hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pcidev);
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 0d8d5f4..f8addf9 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -827,6 +827,22 @@ static int qmp_run_command(libxl__gc *gc, int domid,
     return rc;
 }
 
+int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid,
+                                     const char *cmd, flexarray_t *array)
+{
+    libxl__json_object *args = NULL;
+    int i;
+    void *name, *value;
+
+    for (i = 0; i < array->count; i += 2) {
+        flexarray_get(array, i, &name);
+        flexarray_get(array, i + 1, &value);
+        qmp_parameters_add_string(gc, &args, (char *)name, (char *)value);
+    }
+
+    return qmp_run_command(gc, domid, cmd, args, NULL, NULL);
+}
+
 int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev)
 {
     libxl__qmp_handler *qmp = NULL;
-- 
2.6.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-08  7:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08  7:20 [PATCH 0/6] libxl: add HVM USB passthrough capability Juergen Gross
2016-09-08  7:20 ` [PATCH 1/6] libxl: rename libcl_pvusb.c to libxl_usb.c Juergen Gross
2016-09-09 10:00   ` Wei Liu
2016-09-08  7:20 ` Juergen Gross [this message]
2016-09-09 10:00   ` [PATCH 2/6] libxl: add libxl__qmp_run_command_flexarray() function Wei Liu
2016-09-08  7:20 ` [PATCH 3/6] libxl: dont pass array size to libxl__xs_kvs_of_flexarray() Juergen Gross
2016-09-09 10:00   ` Wei Liu
2016-09-12  9:18     ` Wei Liu
2016-09-08  7:20 ` [PATCH 4/6] libxl: add basic support for devices without backend Juergen Gross
2016-09-15 15:17   ` Wei Liu
2016-09-08  7:20 ` [PATCH 5/6] libxl: add HVM usb passthrough support Juergen Gross
2016-09-09 10:00   ` Wei Liu
2016-09-09 10:13     ` Juergen Gross
2016-09-15 14:22       ` Wei Liu
2016-09-12  8:51     ` George Dunlap
2016-09-15 15:38   ` Wei Liu
2016-09-16  8:51     ` Juergen Groß
2016-09-16 11:28       ` Wei Liu
2016-09-08  7:20 ` [PATCH 6/6] docs: add HVM USB passthrough documentation Juergen Gross
2016-09-15 15:38   ` Wei Liu

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=1473319226-27221-3-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).