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

[Xen-API] [PATCH 3 of 4] PoC: libxc+ocaml: add interfaces to send triggers to HVM guests



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294742832 0
# Node ID 03997417771be2aa122d7dac31256399f854c5b1
# Parent  b279ec057736ead1d7061f8ec8a29a8676dd56b4
PoC: libxc+ocaml: add interfaces to send triggers to HVM guests

* ACPI power button event
* ACPI sleep button event

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 b279ec057736 -r 03997417771b tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1562,6 +1562,36 @@ int xc_domain_get_acpi_s_state(xc_interf
     return value;
 }
 
+int xc_domain_trigger_power(xc_interface *xch, unsigned int domid)
+{
+    int ret;
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_sendtrigger;
+    domctl.domain = domid;
+    domctl.u.sendtrigger.trigger = XEN_DOMCTL_SENDTRIGGER_POWER;
+
+    ret = do_domctl(xch, &domctl);
+    if (ret != 0)
+        ERROR("power button failed");
+    return ret;
+}
+
+int xc_domain_trigger_sleep(xc_interface *xch, unsigned int domid)
+{
+    int ret;
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_sendtrigger;
+    domctl.domain = domid;
+    domctl.u.sendtrigger.trigger = XEN_DOMCTL_SENDTRIGGER_SLEEP;
+
+    ret = do_domctl(xch, &domctl);
+    if (ret != 0)
+        ERROR("sleep button failed");
+    return ret;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r b279ec057736 -r 03997417771b tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -638,6 +638,9 @@ int xc_domain_set_hpet(xc_interface *xch
 int xc_domain_set_vpt_align(xc_interface *xch, unsigned int domid, int 
vpt_align);
 int xc_domain_get_acpi_s_state(xc_interface *xch, unsigned int domid);
 
+int xc_domain_trigger_power(xc_interface *xch, unsigned int domid);
+int xc_domain_trigger_sleep(xc_interface *xch, unsigned int domid);
+
 /**
  * This function returns information about the execution context of a
  * particular vcpu of a domain.
diff -r b279ec057736 -r 03997417771b tools/ocaml/libs/xc/xenctrl.ml
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -244,6 +244,9 @@ external domain_set_vpt_align: handle ->
 external domain_send_s3resume: handle -> domid -> unit = 
"stub_xc_domain_send_s3resume"
 external domain_get_acpi_s_state: handle -> domid -> int = 
"stub_xc_domain_get_acpi_s_state"
 
+external domain_trigger_power: handle -> domid -> unit = 
"stub_xc_domain_trigger_power"
+external domain_trigger_sleep: handle -> domid -> unit = 
"stub_xc_domain_trigger_sleep"
+
 (** check if some hvm domain got pv driver or not *)
 external hvm_check_pvdriver: handle -> domid -> bool
        = "stub_xc_hvm_check_pvdriver"
diff -r b279ec057736 -r 03997417771b tools/ocaml/libs/xc/xenctrl.mli
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -150,6 +150,11 @@ external domain_send_s3resume: handle ->
   = "stub_xc_domain_send_s3resume"
 external domain_get_acpi_s_state: handle -> domid -> int = 
"stub_xc_domain_get_acpi_s_state"
 
+external domain_trigger_power: handle -> domid -> unit
+  = "stub_xc_domain_trigger_power"
+external domain_trigger_sleep: handle -> domid -> unit
+  = "stub_xc_domain_trigger_sleep"
+
 external hvm_check_pvdriver : handle -> domid -> bool
   = "stub_xc_hvm_check_pvdriver"
 external version : handle -> version = "stub_xc_version_version"
diff -r b279ec057736 -r 03997417771b tools/ocaml/libs/xc/xenctrl_stubs.c
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1247,6 +1247,20 @@ CAMLprim value stub_xc_domain_set_vpt_al
         CAMLreturn(Val_unit);
 }
 
+CAMLprim value stub_xc_domain_trigger_power(value xch, value domid)
+{
+       CAMLparam2(xch, domid);
+       xc_domain_trigger_power(_H(xch), _D(domid));
+       CAMLreturn(Val_unit);
+}
+
+CAMLprim value stub_xc_domain_trigger_sleep(value xch, value domid)
+{
+       CAMLparam2(xch, domid);
+       xc_domain_trigger_sleep(_H(xch), _D(domid));
+       CAMLreturn(Val_unit);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: t

_______________________________________________
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®.