]> xenbits.xensource.com Git - xen.git/commitdiff
tools/ocaml/libs/xc: Backward compatible domid control at domain creation time
authorEdwin Török <edvin.torok@citrix.com>
Fri, 8 Jan 2021 11:57:37 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Jan 2021 18:01:34 +0000 (18:01 +0000)
One can specify the domid to use when creating the domain, but this was
hardcoded to 0.

Keep the existing `domain_create` function, and make domid an optional
argument.  When not specified, default to 0.

Controlling the domid can be useful during testing or migration.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/libs/xc/xenctrl.ml
tools/ocaml/libs/xc/xenctrl.mli
tools/ocaml/libs/xc/xenctrl_stubs.c

index e878699b0a1aa9338c02b0e8d550106790326d64..e0a47c476947ffc2820a35c7f75461b2ac7a3521 100644 (file)
@@ -179,9 +179,12 @@ let with_intf f =
                handle := Some h;
                f h
 
-external domain_create: handle -> domctl_create_config -> domid
+external domain_create_stub: handle -> domid -> domctl_create_config -> domid
        = "stub_xc_domain_create"
 
+let domain_create handle ?(domid=0) config =
+       domain_create_stub handle domid config
+
 external domain_sethandle: handle -> domid -> string -> unit
        = "stub_xc_domain_sethandle"
 
index e64907df8e7e4e56b4d11233cb43bce30c91f64c..84311fa33dea7a195eac74ee5bdda8a3132b9abf 100644 (file)
@@ -143,8 +143,8 @@ val get_handle: unit -> handle option
  * would invalidate the handle that with_intf passes to its argument. *)
 val close_handle: unit -> unit
 
-external domain_create : handle -> domctl_create_config -> domid
-  = "stub_xc_domain_create"
+val domain_create: handle -> ?domid:int -> domctl_create_config -> domid
+
 external domain_sethandle : handle -> domid -> string -> unit = "stub_xc_domain_sethandle"
 external domain_max_vcpus : handle -> domid -> int -> unit
   = "stub_xc_domain_max_vcpus"
index 94aba38a4211f8371a71f8d0f202b0a466a01356..9a8dbe5579ac54d1b004487dafe488b9b98b1311 100644 (file)
@@ -175,9 +175,9 @@ static unsigned int ocaml_list_to_c_bitmap(value l)
        return val;
 }
 
-CAMLprim value stub_xc_domain_create(value xch, value config)
+CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config)
 {
-       CAMLparam2(xch, config);
+       CAMLparam3(xch, wanted_domid, config);
        CAMLlocal2(l, arch_domconfig);
 
        /* Mnemonics for the named fields inside domctl_create_config */
@@ -191,7 +191,7 @@ CAMLprim value stub_xc_domain_create(value xch, value config)
 #define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
 #define VAL_ARCH                Field(config, 8)
 
-       uint32_t domid = 0;
+       uint32_t domid = Int_val(wanted_domid);
        int result;
        struct xen_domctl_createdomain cfg = {
                .ssidref = Int32_val(VAL_SSIDREF),