From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH v2 01/12] tools/ocaml: Pass a full domctl_create_config into stub_xc_domain_create()
Date: Mon, 13 Aug 2018 11:00:58 +0100 [thread overview]
Message-ID: <1534154469-6076-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1534154469-6076-1-git-send-email-andrew.cooper3@citrix.com>
The underlying C function is about to make the same change, and the structure
is going to gain extra fields.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
---
v2:
* Fix indirection bug with xen_x86_arch_domctlconfig
---
tools/ocaml/libs/xc/xenctrl.ml | 14 +++++++---
tools/ocaml/libs/xc/xenctrl.mli | 13 +++++++---
tools/ocaml/libs/xc/xenctrl_stubs.c | 52 ++++++++++++++++++++++++-------------
3 files changed, 55 insertions(+), 24 deletions(-)
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index b3b33bb..3b7526e 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -56,6 +56,16 @@ type arch_domainconfig =
| ARM of xen_arm_arch_domainconfig
| X86 of xen_x86_arch_domainconfig
+type domain_create_flag = CDF_HVM | CDF_HAP
+
+type domctl_create_config =
+{
+ ssidref: int32;
+ handle: string;
+ flags: domain_create_flag list;
+ arch: arch_domainconfig;
+}
+
type domaininfo =
{
domid : domid;
@@ -120,8 +130,6 @@ type compile_info =
type shutdown_reason = Poweroff | Reboot | Suspend | Crash | Watchdog | Soft_reset
-type domain_create_flag = CDF_HVM | CDF_HAP
-
exception Error of string
type handle
@@ -135,7 +143,7 @@ let with_intf f =
interface_close xc;
r
-external domain_create: handle -> int32 -> domain_create_flag list -> string -> arch_domainconfig -> domid
+external domain_create: handle -> domctl_create_config -> domid
= "stub_xc_domain_create"
external domain_sethandle: handle -> domid -> string -> unit
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index 35303ab..d103a33 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -49,6 +49,15 @@ type arch_domainconfig =
| ARM of xen_arm_arch_domainconfig
| X86 of xen_x86_arch_domainconfig
+type domain_create_flag = CDF_HVM | CDF_HAP
+
+type domctl_create_config = {
+ ssidref: int32;
+ handle: string;
+ flags: domain_create_flag list;
+ arch: arch_domainconfig;
+}
+
type domaininfo = {
domid : domid;
dying : bool;
@@ -91,14 +100,12 @@ type compile_info = {
}
type shutdown_reason = Poweroff | Reboot | Suspend | Crash | Watchdog | Soft_reset
-type domain_create_flag = CDF_HVM | CDF_HAP
-
exception Error of string
type handle
external interface_open : unit -> handle = "stub_xc_interface_open"
external interface_close : handle -> unit = "stub_xc_interface_close"
val with_intf : (handle -> 'a) -> 'a
-external domain_create : handle -> int32 -> domain_create_flag list -> string -> arch_domainconfig -> domid
+external domain_create : handle -> domctl_create_config -> domid
= "stub_xc_domain_create"
external domain_sethandle : handle -> domid -> string -> unit = "stub_xc_domain_sethandle"
external domain_max_vcpus : handle -> domid -> int -> unit
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 5274e56..dbe9c3e 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -119,36 +119,46 @@ static void domain_handle_of_uuid_string(xen_domain_handle_t h,
#undef X
}
-CAMLprim value stub_xc_domain_create(value xch, value ssidref,
- value flags, value handle,
- value domconfig)
+CAMLprim value stub_xc_domain_create(value xch, value config)
{
- CAMLparam4(xch, ssidref, flags, handle);
+ CAMLparam2(xch, config);
+ CAMLlocal2(l, arch_domconfig);
+
+ /* Mnemonics for the named fields inside domctl_create_config */
+#define VAL_SSIDREF Field(config, 0)
+#define VAL_HANDLE Field(config, 1)
+#define VAL_FLAGS Field(config, 2)
+#define VAL_ARCH Field(config, 3)
uint32_t domid = 0;
- xen_domain_handle_t h;
int result;
- uint32_t c_ssidref = Int32_val(ssidref);
- unsigned int c_flags = 0;
- value l;
- xc_domain_configuration_t config = {};
+ struct xen_domctl_createdomain cfg = {
+ .ssidref = Int32_val(VAL_SSIDREF),
+ };
- domain_handle_of_uuid_string(h, String_val(handle));
+ domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE));
- for (l = flags; l != Val_none; l = Field(l, 1))
- c_flags |= 1u << Int_val(Field(l, 0));
+ for ( l = VAL_FLAGS; l != Val_none; l = Field(l, 1) )
+ cfg.flags |= 1u << Int_val(Field(l, 0));
- switch(Tag_val(domconfig)) {
+ arch_domconfig = Field(VAL_ARCH, 0);
+ switch ( Tag_val(VAL_ARCH) )
+ {
case 0: /* ARM - nothing to do */
caml_failwith("Unhandled: ARM");
break;
case 1: /* X86 - emulation flags in the block */
#if defined(__i386__) || defined(__x86_64__)
- for (l = Field(Field(domconfig, 0), 0);
- l != Val_none;
- l = Field(l, 1))
- config.emulation_flags |= 1u << Int_val(Field(l, 0));
+
+ /* Mnemonics for the named fields inside xen_x86_arch_domctlconfig */
+#define VAL_EMUL_FLAGS Field(arch_domconfig, 0)
+
+ for ( l = VAL_EMUL_FLAGS; l != Val_none; l = Field(l, 1) )
+ cfg.arch.emulation_flags |= 1u << Int_val(Field(l, 0));
+
+#undef VAL_EMUL_FLAGS
+
#else
caml_failwith("Unhandled: x86");
#endif
@@ -158,8 +168,14 @@ CAMLprim value stub_xc_domain_create(value xch, value ssidref,
caml_failwith("Unhandled domconfig type");
}
+#undef VAL_ARCH
+#undef VAL_FLAGS
+#undef VAL_HANDLE
+#undef VAL_SSIDREF
+
caml_enter_blocking_section();
- result = xc_domain_create(_H(xch), c_ssidref, h, c_flags, &domid, &config);
+ result = xc_domain_create(_H(xch), cfg.ssidref, cfg.handle, cfg.flags,
+ &domid, &cfg.arch);
caml_leave_blocking_section();
if (result < 0)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-08-13 10:00 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 10:00 [PATCH v2 00/12] Improvements to domain creation Andrew Cooper
2018-08-13 10:00 ` Andrew Cooper [this message]
2018-08-13 10:00 ` [PATCH v2 02/12] tools: Rework xc_domain_create() to take a full xen_domctl_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 03/12] xen/domctl: Merge set_max_evtchn into createdomain Andrew Cooper
2018-08-14 13:58 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 04/12] xen/evtchn: Pass max_evtchn_port into evtchn_init() Andrew Cooper
2018-08-14 14:07 ` Roger Pau Monné
2018-08-15 12:45 ` Jan Beulich
2018-08-15 12:57 ` Julien Grall
2018-08-13 10:01 ` [PATCH v2 05/12] tools: Pass grant table limits to XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 06/12] xen/gnttab: Pass max_{grant, maptrack}_frames into grant_table_create() Andrew Cooper
2018-08-14 14:17 ` Roger Pau Monné
2018-08-15 12:51 ` Jan Beulich
2018-08-15 13:04 ` Julien Grall
2018-08-15 13:08 ` Andrew Cooper
2018-08-15 13:32 ` Julien Grall
2018-08-15 19:03 ` Andrew Cooper
2018-08-16 8:59 ` Julien Grall
2018-08-29 9:38 ` [PATCH v3 6/12] " Andrew Cooper
2018-08-30 19:40 ` Julien Grall
2018-08-13 10:01 ` [PATCH v2 07/12] xen/domctl: Remove XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-14 14:19 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 08/12] xen/gnttab: Fold grant_table_{create, set_limits}() into grant_table_init() Andrew Cooper
2018-08-14 14:31 ` Roger Pau Monné
2018-08-15 12:54 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 09/12] xen/domain: Call arch_domain_create() as early as possible in domain_create() Andrew Cooper
2018-08-14 14:37 ` Roger Pau Monné
2018-08-15 12:56 ` Jan Beulich
2018-09-04 18:44 ` Rats nest with domain pirq initialisation Andrew Cooper
2018-09-05 7:24 ` Jan Beulich
2018-09-05 11:38 ` Jan Beulich
2018-09-05 12:04 ` Andrew Cooper
2018-09-05 12:25 ` Jan Beulich
2018-09-05 12:39 ` Andrew Cooper
2018-09-05 15:44 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 10/12] tools: Pass max_vcpus to XEN_DOMCTL_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 11/12] xen/dom0: Arrange for dom0_cfg to contain the real max_vcpus value Andrew Cooper
2018-08-14 15:05 ` Roger Pau Monné
2018-08-15 12:59 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 12/12] xen/domain: Allocate d->vcpu[] in domain_create() Andrew Cooper
2018-08-14 15:17 ` Roger Pau Monné
2018-08-15 13:17 ` Julien Grall
2018-08-15 13:50 ` Andrew Cooper
2018-08-15 13:52 ` Julien Grall
2018-08-15 13:56 ` Andrew Cooper
2018-08-15 13:11 ` Jan Beulich
2018-08-15 14:03 ` Andrew Cooper
2018-08-15 15:18 ` Jan Beulich
2018-08-29 10:36 ` Andrew Cooper
2018-08-29 12:10 ` Jan Beulich
2018-08-29 12:29 ` Andrew Cooper
2018-08-29 12:49 ` Jan Beulich
2018-08-29 14:40 ` [PATCH v3 " Andrew Cooper
2018-08-29 15:03 ` Jan Beulich
2018-08-31 10:33 ` Wei Liu
2018-08-31 10:42 ` Jan Beulich
2018-08-31 10:57 ` Julien Grall
2018-08-31 11:00 ` Juergen Gross
2018-08-31 10:58 ` Andrew Cooper
2018-08-30 19:46 ` Julien Grall
2018-08-30 20:04 ` Andrew Cooper
2018-08-14 13:12 ` [PATCH v2 00/12] Improvements to domain creation Christian Lindig
2018-08-14 13:34 ` Andrew Cooper
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=1534154469-6076-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@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).