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

[Xen-API] [PATCH 1 of 4] PoC: libxc+ocaml: add interface to detect PV drivers in HVM guests



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294742832 0
# Node ID 59aaebc4ef6422e5ff4a3ad54d05597e646cfc92
# Parent  a38d8f70a79bf368c1498f2a08894068f504bff7
PoC: libxc+ocaml: add interface to detect PV drivers in HVM guests

Required by xapi.

Taken from xen-api-libs.hg/xc and adjusted for upstream libxc+ocaml.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Rebased on top of xen-unstable.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

diff -r a38d8f70a79b -r 59aaebc4ef64 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -684,6 +684,26 @@ int xc_hvm_inject_trap(
     return rc;
 }
 
+int xc_hvm_check_pvdriver(xc_interface *xch, unsigned int domid)
+{
+    int ret;
+    unsigned long irq = 0;
+    xc_domaininfo_t info;
+
+    ret = xc_domain_getinfolist(xch, domid, 1, &info);
+    if (ret != 1) {
+        PERROR("domain getinfo failed");
+        return -1;
+    }
+
+    if ((!info.flags) & XEN_DOMINF_hvm_guest) {
+        ERROR("domain is not hvm");
+        return -1;
+    }
+    xc_get_hvm_param(xch, domid, HVM_PARAM_CALLBACK_IRQ, &irq);
+    return irq;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r a38d8f70a79b -r 59aaebc4ef64 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1631,6 +1631,8 @@ int xc_hvm_inject_trap(
     uint32_t type, uint32_t error_code, uint32_t insn_len,
     uint64_t cr2);
 
+int xc_hvm_check_pvdriver(xc_interface *xch, unsigned int domid);
+
 /*
  *  LOGGING AND ERROR REPORTING
  */
diff -r a38d8f70a79b -r 59aaebc4ef64 tools/ocaml/libs/xc/xenctrl.ml
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -237,6 +237,10 @@ external domain_deassign_device: handle 
 external domain_test_assign_device: handle -> domid -> (int * int * int * int) 
-> bool
        = "stub_xc_domain_test_assign_device"
 
+(** check if some hvm domain got pv driver or not *)
+external hvm_check_pvdriver: handle -> domid -> bool
+       = "stub_xc_hvm_check_pvdriver"
+
 external version: handle -> version = "stub_xc_version_version"
 external version_compile_info: handle -> compile_info
        = "stub_xc_version_compile_info"
diff -r a38d8f70a79b -r 59aaebc4ef64 tools/ocaml/libs/xc/xenctrl.mli
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -142,6 +142,8 @@ external domain_deassign_device: handle 
 external domain_test_assign_device: handle -> domid -> (int * int * int * int) 
-> bool
        = "stub_xc_domain_test_assign_device"
 
+external hvm_check_pvdriver : handle -> domid -> bool
+  = "stub_xc_hvm_check_pvdriver"
 external version : handle -> version = "stub_xc_version_version"
 external version_compile_info : handle -> compile_info
   = "stub_xc_version_compile_info"
diff -r a38d8f70a79b -r 59aaebc4ef64 tools/ocaml/libs/xc/xenctrl_stubs.c
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1112,6 +1112,17 @@ static uint32_t encode_sbdf(int domain, 
                ((uint32_t)func   &    0x7);
 }
 
+CAMLprim value stub_xc_hvm_check_pvdriver(value xch, value domid)
+{
+       CAMLparam2(xch, domid);
+       int ret;
+
+       ret = xc_hvm_check_pvdriver(_H(xch), _D(domid));
+       if (ret < 0)
+               failwith_xc(_H(xch));
+       CAMLreturn(Val_bool(ret));
+}
+
 CAMLprim value stub_xc_domain_test_assign_device(value xch, value domid, value 
desc)
 {
        CAMLparam3(xch, domid, desc);

_______________________________________________
Xen-api mailing list
Xen-api@xxxxxxxxxxxxx
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api


 


Rackspace

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