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

[Xen-API] [PATCH 6 of 9] PoC: libxc+ocaml: add interfaces to manipulate various properties of HVM guests



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294742832 0
# Node ID 62138b63f5c3a586ad3697c2c6bd1da44016c80a
# Parent  4370aef36fb02c95dbe5e6ca96dba69a4faa7d62
PoC: libxc+ocaml: add interfaces to manipulate various properties of HVM guests

* set timer mode
* set hpet
* set vpt align
* get ACPI
* set/get ACPI S state (allows send s3resume)

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

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

diff -r 4370aef36fb0 -r 62138b63f5c3 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
@@ -1472,6 +1472,38 @@ int xc_domain_set_access_required(xc_int
     return do_domctl(xch, &domctl);
 }
 
+int xc_domain_send_s3resume(xc_interface *xch, unsigned int domid)
+{
+    return xc_set_hvm_param(xch, domid, HVM_PARAM_ACPI_S_STATE, 0);
+}
+
+int xc_domain_set_timer_mode(xc_interface *xch, unsigned int domid, int mode)
+{
+    return xc_set_hvm_param(xch, domid,
+                            HVM_PARAM_TIMER_MODE, (unsigned long) mode);
+}
+
+int xc_domain_set_hpet(xc_interface *xch, unsigned int domid, int hpet)
+{
+    return xc_set_hvm_param(xch, domid, HVM_PARAM_HPET_ENABLED, (unsigned 
long) hpet);
+}
+
+int xc_domain_set_vpt_align(xc_interface *xch, unsigned int domid, int 
vpt_align)
+{
+    return xc_set_hvm_param(xch, domid, HVM_PARAM_HPET_ENABLED, (unsigned 
long) vpt_align);
+}
+
+int xc_domain_get_acpi_s_state(xc_interface *xch, unsigned int domid)
+{
+    int ret;
+    unsigned long value;
+
+    ret = xc_get_hvm_param(xch, domid, HVM_PARAM_ACPI_S_STATE, &value);
+    if (ret != 0)
+        ERROR("get acpi s-state");
+    return value;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 4370aef36fb0 -r 62138b63f5c3 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
@@ -600,6 +600,12 @@ int xc_domain_hvm_setcontext(xc_interfac
                              uint8_t *hvm_ctxt,
                              uint32_t size);
 
+int xc_domain_send_s3resume(xc_interface *xch, unsigned int domid);
+int xc_domain_set_timer_mode(xc_interface *xch, unsigned int domid, int mode);
+int xc_domain_set_hpet(xc_interface *xch, unsigned int domid, int hpet);
+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);
+
 /**
  * This function returns information about the execution context of a
  * particular vcpu of a domain.
diff -r 4370aef36fb0 -r 62138b63f5c3 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
@@ -241,6 +241,13 @@ external domain_deassign_device: handle 
 external domain_test_assign_device: handle -> domid -> (int * int * int * int) 
-> bool
        = "stub_xc_domain_test_assign_device"
 
+external domain_set_timer_mode: handle -> domid -> int -> unit = 
"stub_xc_domain_set_timer_mode"
+external domain_set_hpet: handle -> domid -> int -> unit = 
"stub_xc_domain_set_hpet"
+external domain_set_vpt_align: handle -> domid -> int -> unit = 
"stub_xc_domain_set_vpt_align"
+
+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"
+
 (** check if some hvm domain got pv driver or not *)
 external hvm_check_pvdriver: handle -> domid -> bool
        = "stub_xc_hvm_check_pvdriver"
diff -r 4370aef36fb0 -r 62138b63f5c3 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
@@ -158,6 +158,14 @@ external domain_deassign_device: handle 
 external domain_test_assign_device: handle -> domid -> (int * int * int * int) 
-> bool
        = "stub_xc_domain_test_assign_device"
 
+external domain_set_timer_mode: handle -> domid -> int -> unit = 
"stub_xc_domain_set_timer_mode"
+external domain_set_hpet: handle -> domid -> int -> unit = 
"stub_xc_domain_set_hpet"
+external domain_set_vpt_align: handle -> domid -> int -> unit = 
"stub_xc_domain_set_vpt_align"
+
+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 hvm_check_pvdriver : handle -> domid -> bool
   = "stub_xc_hvm_check_pvdriver"
 external version : handle -> version = "stub_xc_version_version"
diff -r 4370aef36fb0 -r 62138b63f5c3 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
@@ -1194,6 +1194,59 @@ CAMLprim value stub_xc_watchdog(value xc
        CAMLreturn(Val_int(ret));
 }
 
+CAMLprim value stub_xc_domain_get_acpi_s_state(value xch, value domid)
+{
+        CAMLparam2(xch, domid);
+        int ret;
+
+        ret = xc_domain_get_acpi_s_state(_H(xch), _D(domid));
+        if (ret < 0)
+                failwith_xc(_H(xch));
+
+        CAMLreturn(Val_int(ret));
+}
+
+CAMLprim value stub_xc_domain_send_s3resume(value xch, value domid)
+{
+        CAMLparam2(xch, domid);
+        xc_domain_send_s3resume(_H(xch), _D(domid));
+        CAMLreturn(Val_unit);
+}
+
+
+CAMLprim value stub_xc_domain_set_timer_mode(value xch, value id, value mode)
+{
+        CAMLparam3(xch, id, mode);
+        int ret;
+
+        ret = xc_domain_set_timer_mode(_H(xch), _D(id), Int_val(mode));
+        if (ret < 0)
+                failwith_xc(_H(xch));
+        CAMLreturn(Val_unit);
+}
+
+CAMLprim value stub_xc_domain_set_hpet(value xch, value id, value mode)
+{
+        CAMLparam3(xch, id, mode);
+        int ret;
+
+        ret = xc_domain_set_hpet(_H(xch), _D(id), Int_val(mode));
+        if (ret < 0)
+                failwith_xc(_H(xch));
+        CAMLreturn(Val_unit);
+}
+
+CAMLprim value stub_xc_domain_set_vpt_align(value xch, value id, value mode)
+{
+        CAMLparam3(xch, id, mode);
+        int ret;
+
+        ret = xc_domain_set_vpt_align(_H(xch), _D(id), Int_val(mode));
+        if (ret < 0)
+                failwith_xc(_H(xch));
+        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


 


Rackspace

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