[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools/ocaml: Pass a full domctl_create_config into stub_xc_domain_create()



commit acc2a06c780e9e7ffa6373854735503b7d63a1d0
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Mar 12 10:40:33 2018 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Aug 15 19:40:28 2018 +0100

    tools/ocaml: Pass a full domctl_create_config into stub_xc_domain_create()
    
    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@xxxxxxxxxx>
    Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
---
 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 b3b33bb327..3b7526e4ae 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 35303ab61a..d103a33ee8 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 5274e56bce..b8ec239302 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_domainconfig */
+#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)
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.