From: Rob Hoes <rob.hoes@citrix.com>
To: xen-devel@lists.xen.org
Cc: Rob Hoes <rob.hoes@citrix.com>,
ian.jackson@eu.citrix.com, ian.campbell@citrix.com,
dave.scott@eu.citrix.com
Subject: [PATCH v7 4/9] libxl: ocaml: allow device operations to be called asynchronously
Date: Tue, 10 Dec 2013 16:48:28 +0000 [thread overview]
Message-ID: <1386694113-26721-5-git-send-email-rob.hoes@citrix.com> (raw)
In-Reply-To: <1386694113-26721-1-git-send-email-rob.hoes@citrix.com>
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
CC: David Scott <dave.scott@eu.citrix.com>
---
tools/ocaml/libs/xl/genwrap.py | 6 +++---
tools/ocaml/libs/xl/xenlight_stubs.c | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index f5d2224..dd43069 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -22,9 +22,9 @@ builtins = {
"libxl_cpuid_policy_list": ("unit", "%(c)s = 0", "Val_unit"),
}
-DEVICE_FUNCTIONS = [ ("add", ["ctx", "t", "domid", "unit"]),
- ("remove", ["ctx", "t", "domid", "unit"]),
- ("destroy", ["ctx", "t", "domid", "unit"]),
+DEVICE_FUNCTIONS = [ ("add", ["ctx", "t", "domid", "?async:'a", "unit", "unit"]),
+ ("remove", ["ctx", "t", "domid", "?async:'a", "unit", "unit"]),
+ ("destroy", ["ctx", "t", "domid", "?async:'a", "unit", "unit"]),
]
functions = { # ( name , [type1,type2,....] )
diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c
index 39a9632..1a0fab3 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -405,15 +405,27 @@ void async_callback(libxl_ctx *ctx, int rc, void *for_callback)
#define STRINGIFY(x) _STRINGIFY(x)
#define _DEVICE_ADDREMOVE(type,op) \
-value stub_xl_device_##type##_##op(value ctx, value info, value domid) \
+value stub_xl_device_##type##_##op(value ctx, value info, value domid, \
+ value async, value unit) \
{ \
- CAMLparam3(ctx, info, domid); \
+ CAMLparam5(ctx, info, domid, async, unit); \
libxl_device_##type c_info; \
int ret, marker_var; \
+ libxl_asyncop_how ao_how; \
+ value *p; \
\
device_##type##_val(CTX, &c_info, info); \
\
- ret = libxl_device_##type##_##op(CTX, Int_val(domid), &c_info, 0); \
+ if (async != Val_none) { \
+ p = malloc(sizeof(value)); \
+ *p = Some_val(async); \
+ caml_register_global_root(p); \
+ ao_how.callback = async_callback; \
+ ao_how.u.for_callback = (void *) p; \
+ } \
+ \
+ ret = libxl_device_##type##_##op(CTX, Int_val(domid), &c_info, \
+ async != Val_none ? &ao_how : NULL); \
\
libxl_device_##type##_dispose(&c_info); \
\
--
1.7.10.4
next prev parent reply other threads:[~2013-12-10 16:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 16:48 libxl: ocaml: improve the bindings Rob Hoes
2013-12-10 16:48 ` [PATCH v7 1/9] libxl: ocaml: add simple test case for xentoollog Rob Hoes
2013-12-10 16:48 ` [PATCH v7 2/9] libxl: ocaml: implement some simple tests Rob Hoes
2013-12-10 16:48 ` [PATCH v7 3/9] libxl: ocaml: event management Rob Hoes
2013-12-11 13:07 ` Ian Campbell
2013-12-10 16:48 ` Rob Hoes [this message]
2013-12-10 16:48 ` [PATCH v7 5/9] libxl: ocaml: add disk and cdrom helper functions Rob Hoes
2013-12-10 16:48 ` [PATCH v7 6/9] libxl: ocaml: add VM lifecycle operations Rob Hoes
2013-12-10 16:48 ` [PATCH v7 7/9] libxl: ocaml: add console reader functions Rob Hoes
2013-12-10 16:48 ` [PATCH v7 8/9] libxl: ocaml: drop the ocaml heap lock before calling into libxl Rob Hoes
2013-12-10 16:48 ` [PATCH v7 9/9] libxl: ocaml: add some missing CAML macros Rob Hoes
2013-12-11 13:37 ` libxl: ocaml: improve the bindings Ian Campbell
2013-12-11 13:57 ` Rob Hoes
2013-12-11 14:11 ` Ian Campbell
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=1386694113-26721-5-git-send-email-rob.hoes@citrix.com \
--to=rob.hoes@citrix.com \
--cc=dave.scott@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.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).