# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294742832 0
# Node ID 8110fd3fc41eb6730d53df9d4ef221d65a079df4
# Parent 62138b63f5c3a586ad3697c2c6bd1da44016c80a
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>
diff -r 62138b63f5c3 -r 8110fd3fc41e tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c Tue Jan 11 10:47:12 2011 +0000
+++ b/tools/libxc/xc_domain.c Tue Jan 11 10:47:12 2011 +0000
@@ -1504,6 +1504,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 62138b63f5c3 -r 8110fd3fc41e tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Tue Jan 11 10:47:12 2011 +0000
+++ b/tools/libxc/xenctrl.h Tue Jan 11 10:47:12 2011 +0000
@@ -606,6 +606,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 62138b63f5c3 -r 8110fd3fc41e tools/ocaml/libs/xc/xc.ml
--- a/tools/ocaml/libs/xc/xc.ml Tue Jan 11 10:47:12 2011 +0000
+++ b/tools/ocaml/libs/xc/xc.ml Tue Jan 11 10:47:12 2011 +0000
@@ -248,6 +248,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 62138b63f5c3 -r 8110fd3fc41e tools/ocaml/libs/xc/xc.mli
--- a/tools/ocaml/libs/xc/xc.mli Tue Jan 11 10:47:12 2011 +0000
+++ b/tools/ocaml/libs/xc/xc.mli Tue Jan 11 10:47:12 2011 +0000
@@ -166,6 +166,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 62138b63f5c3 -r 8110fd3fc41e tools/ocaml/libs/xc/xc_stubs.c
--- a/tools/ocaml/libs/xc/xc_stubs.c Tue Jan 11 10:47:12 2011 +0000
+++ b/tools/ocaml/libs/xc/xc_stubs.c Tue Jan 11 10:47:12 2011 +0000
@@ -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);
+}
+
CAMLprim value stub_xc_get_boot_cpufeatures(value xch)
{
CAMLparam1(xch);
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|