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

[PATCH v2 3/9] tools/ocaml: check domain_getinfolist in the bindings test



Call domain_getinfolist() and check the domaininfo record of each
domain, including the arch_config variant, i.e. the
xen_arm_arch_domainconfig record, or the xen_x86_arch_domainconfig
record and its flag lists. Also print every field.

Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
Changes in v2:
- New patch split out of the v1 patch
---
 tools/ocaml/tests/bindings/main.ml | 50 ++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tools/ocaml/tests/bindings/main.ml 
b/tools/ocaml/tests/bindings/main.ml
index f4ebb2b1e2..9c85829275 100644
--- a/tools/ocaml/tests/bindings/main.ml
+++ b/tools/ocaml/tests/bindings/main.ml
@@ -27,6 +27,12 @@ let check_enum name v ~nr =
     fail "%s: not one of the %d constructors" name nr;
   ok
 
+(* XEN_DOMCTL_CONFIG_GIC_* *)
+let string_of_gic_version = function
+  | 1 -> "GICv2"
+  | 2 -> "GICv3"
+  | v -> fail "unknown gic_version %d" v; "unknown"
+
 let string_of_cap_flag = function
   | CAP_HVM -> "hvm"
   | CAP_PV -> "pv"
@@ -71,6 +77,49 @@ let test_physinfo () =
     check_block "arch_capabilities" a ~tag:1 ~size:1;
     printf "  x86: %d arch capability flags\n" (List.length flags)
 
+let test_domain_getinfolist () =
+  printf "Test domain_getinfolist\n";
+
+  let doms = domain_getinfolist xch 0 in
+  if doms = [] then fail "no domains, expected at least d0";
+
+  let check_dom (d : domaininfo) =
+    let name = sprintf "d%d" d.domid in
+
+    check_record name d ~size:17;
+    if Array.length d.handle <> 16 then
+      fail "%s: handle has %d bytes, expected 16"
+        name (Array.length d.handle);
+
+    printf "  %s: dying %b, shutdown %b (code %d), paused %b, blocked %b, 
running %b, hvm %b\n"
+      name d.dying d.shutdown d.shutdown_code
+      d.paused d.blocked d.running d.hvm_guest;
+    printf "  %s: pages %nd/%nd, shared_info_frame %Ld, cpu_time %Ld\n"
+      name d.total_memory_pages d.max_memory_pages
+      d.shared_info_frame d.cpu_time;
+    printf "  %s: vcpus %d (max id %d), ssidref %ld\n"
+      name d.nr_online_vcpus d.max_vcpu_id d.ssidref;
+
+    match d.arch_config with
+    | ARM arm as a ->
+      check_block (name ^ " arch_config") a ~tag:0 ~size:1;
+      check_record (name ^ " xen_arm_arch_domainconfig") arm ~size:2;
+      printf "  %s: ARM %s, nr_spis %d\n" name
+        (string_of_gic_version arm.gic_version) arm.nr_spis
+    | X86 x86 as a ->
+      check_block (name ^ " arch_config") a ~tag:1 ~size:1;
+      check_record (name ^ " xen_x86_arch_domainconfig") x86 ~size:2;
+      List.iter (fun f -> ignore (check_enum (name ^ " emulation flag") f 
~nr:11))
+        x86.emulation_flags;
+      List.iter (fun f -> ignore (check_enum (name ^ " misc flag") f ~nr:1))
+        x86.misc_flags;
+      printf "  %s: x86, %d emulation flags, %d misc flags\n" name
+        (List.length x86.emulation_flags)
+        (List.length x86.misc_flags)
+  in
+
+  List.iter check_dom doms
+
 let run name f =
   try f () with
   | Xenctrl.Error e -> fail "%s: Xenctrl.Error %s" name e
@@ -81,6 +130,7 @@ let () =
 
   run "version" test_xenversion;
   run "physinfo" test_physinfo;
+  run "domain_getinfolist" test_domain_getinfolist;
 
   printf "Starting GC.compact()\n%!";
   Gc.compact ();
-- 
2.53.0



--
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

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