hsXenCtrl 0.0.5 → 0.0.6
raw patch · 3 files changed
+47/−7 lines, 3 files
Files
- LICENSE +1/−1
- System/Xen/CBindings.hsc +45/−5
- hsXenCtrl.cabal +1/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) Thomas M. DuBuisson+Copyright (c) Thomas DuBuisson All rights reserved.
System/Xen/CBindings.hsc view
@@ -22,6 +22,8 @@ , xc_domain_sethandle , xc_sedf_domain_set , xc_domain_send_trigger+ , xc_vcpu_getinfo+ , VCPUInfo(..) -- Start Event Channel Functions , xc_evtchn_alloc_unbound , xc_evtchn_reset@@ -136,6 +138,7 @@ #include <xenctrl.h> #include <xen/sysctl.h>+#include <xen/domctl.h> xc_CORE_MAGIC :: CInt xc_CORE_MAGIC = 0xF00FEBED@@ -296,6 +299,36 @@ foreign import ccall unsafe "xenctrl.h xc_domain_hvm_setcontext" xc_domain_hvm_setcontext :: XCHandle -> DomId -> Ptr Word8 -> Word32 -> IO CInt +-- vcpu_info_t == xen_domctl_getvcpuinfo_t+data VCPUInfo =+ VCPUInfo {+ viVCPU :: Word32,+ viOnline :: Word8,+ viBlocked :: Word8,+ viRunning :: Word8,+ viCPUTime :: Word64,+ viCPU :: Word32+ } deriving (Eq, Ord, Show)++instance Storable VCPUInfo where+ sizeOf _ = (#size xen_domctl_getvcpuinfo_t)+ alignment _ = alignment (undefined :: Word64)+ peek ptr = do+ v <- (#peek xen_domctl_getvcpuinfo_t, vcpu) ptr+ o <- (#peek xen_domctl_getvcpuinfo_t, online) ptr + b <- (#peek xen_domctl_getvcpuinfo_t, blocked) ptr+ r <- (#peek xen_domctl_getvcpuinfo_t, running) ptr+ t <- (#peek xen_domctl_getvcpuinfo_t, cpu_time) ptr+ c <- (#peek xen_domctl_getvcpuinfo_t, cpu) ptr+ return $ VCPUInfo v o b r t c+ poke ptr (VCPUInfo v o b r t c) = do+ (#poke xen_domctl_getvcpuinfo_t, vcpu) ptr v+ (#poke xen_domctl_getvcpuinfo_t, online) ptr o+ (#poke xen_domctl_getvcpuinfo_t, blocked) ptr b+ (#poke xen_domctl_getvcpuinfo_t, running) ptr r+ (#poke xen_domctl_getvcpuinfo_t, cpu_time) ptr t+ (#poke xen_domctl_getvcpuinfo_t, cpu) ptr c+ -- TODO need to base VCPU_Guest_Context on arch specific info -- -- foreign import ccall unsafe "xenctrl.h xc_vcpu_setcontext"@@ -303,11 +336,10 @@ -- -- foreign import ccall unsafe"xenctrl.h xc_vcpu_getcontext" -- xc_vcpu_getcontext :: XCHandle -> DomId -> Word32 -> Ptr VCPU_Guest_Context -> IO CInt------ -- FIXME define VCPUInfo and make a storable instance--- foreign import ccall unsafe "xenctrl.h xc_vcpu_getinfo"--- xc_vcpu_getinfo :: XCHandle -> DomId -> Word32 -> Ptr VCPUInfo -> IO CInt +foreign import ccall unsafe "xenctrl.h xc_vcpu_getinfo"+ xc_vcpu_getinfo :: XCHandle -> DomId -> Word32 -> Ptr VCPUInfo -> IO CInt+ foreign import ccall unsafe "xenctrl.h xc_domain_setcpuweight" xc_domain_setcpuweight :: XCHandle -> DomId -> CFloat -> IO CInt @@ -412,7 +444,7 @@ data XCPhysInfo = XCPhysInfo { piThreadsPerCore :: Word32, piCoresPerSocket :: Word32,- piSocketsPerNode :: Word32,+ piNrCPUs :: Word32, piNrNodes :: Word32, piCPUkhz :: Word32, piTotalPages :: Word64,@@ -427,7 +459,11 @@ peek ptr = do t <- (#peek xen_sysctl_physinfo_t, threads_per_core) ptr c <- (#peek xen_sysctl_physinfo_t, cores_per_socket) ptr+#if XEN_SYSCTL_INTERFACE_VERSION < 6 s <- (#peek xen_sysctl_physinfo_t, sockets_per_node) ptr+#else+ s <- (#peek xen_sysctl_physinfo_t, nr_cpus) ptr+#endif nr <- (#peek xen_sysctl_physinfo_t, nr_nodes) ptr cpu <- (#peek xen_sysctl_physinfo_t, cpu_khz) ptr tp <- (#peek xen_sysctl_physinfo_t, total_pages) ptr@@ -439,7 +475,11 @@ poke ptr (XCPhysInfo t c s nr cpu tp fp sp hw) = do (#poke xen_sysctl_physinfo_t, threads_per_core) ptr t (#poke xen_sysctl_physinfo_t, cores_per_socket) ptr c+#if XEN_SYSCTL_INTERFACE_VERSION < 6 (#poke xen_sysctl_physinfo_t, sockets_per_node) ptr s+#else+ (#poke xen_sysctl_physinfo_t, nr_cpus) ptr s+#endif (#poke xen_sysctl_physinfo_t, nr_nodes) ptr nr (#poke xen_sysctl_physinfo_t, cpu_khz) ptr cpu (#poke xen_sysctl_physinfo_t, total_pages) ptr tp
hsXenCtrl.cabal view
@@ -1,5 +1,5 @@ name: hsXenCtrl-version: 0.0.5+version: 0.0.6 synopsis: FFI bindings to the Xen Control library. description: FFI bindings to xenctrl.h and perhaps more. The System.Xen.CBindings should provide direct access