From: Vincent Hanquez Date: Mon, 10 Aug 2009 13:48:31 +0000 (+0100) Subject: add Vkb module X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3507d7f6f1a996076c7e8ec042e14952e24ea8f6;p=xenclient%2Ftoolstack.git add Vkb module --- diff --git a/xenops/device.ml b/xenops/device.ml index a70cd83..4daea8a 100644 --- a/xenops/device.ml +++ b/xenops/device.ml @@ -1071,17 +1071,51 @@ let clean_shutdown ~xs (x: device) = end +module Vkb = struct + +let add ~xc ~xs ~hvm ?(protocol=Protocol_Native) domid = + debug "Device.Vkb.add %d" domid; + + let frontend = { domid = domid; kind = Vkb; devid = 0 } in + let backend = { domid = 0; kind = Vkb; devid = 0 } in + let device = { backend = backend; frontend = frontend } in + + let back = [ + "frontend-id", sprintf "%u" domid; + "online", "1"; + "state", string_of_int (Xenbus.int_of Xenbus.Initialising); + ] in + let front = [ + "backend-id", string_of_int 0; + "protocol", (string_of_protocol protocol); + "state", string_of_int (Xenbus.int_of Xenbus.Initialising); + ] in + Generic.add_device ~xs device back front; + () + +let hard_shutdown ~xs (x: device) = + debug "Device.Vkb.hard_shutdown %s" (string_of_device x); + () + +let clean_shutdown ~xs (x: device) = + debug "Device.Vkb.clean_shutdown %s" (string_of_device x); + () + +end + let hard_shutdown ~xs (x: device) = match x.backend.kind with | Vif -> Vif.hard_shutdown ~xs x | Vbd | Tap -> Vbd.hard_shutdown ~xs x | Pci -> PCI.hard_shutdown ~xs x | Vfb -> Vfb.hard_shutdown ~xs x + | Vkb -> Vkb.hard_shutdown ~xs x let clean_shutdown ~xs (x: device) = match x.backend.kind with | Vif -> Vif.clean_shutdown ~xs x | Vbd | Tap -> Vbd.clean_shutdown ~xs x | Pci -> PCI.clean_shutdown ~xs x | Vfb -> Vfb.clean_shutdown ~xs x + | Vkb -> Vkb.clean_shutdown ~xs x let can_surprise_remove ~xs (x: device) = Generic.can_surprise_remove ~xs x diff --git a/xenops/device.mli b/xenops/device.mli index 4397689..55a308a 100644 --- a/xenops/device.mli +++ b/xenops/device.mli @@ -142,6 +142,11 @@ sig val add : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> ?protocol:protocol -> Xc.domid -> unit end +module Vkb : +sig + val add : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> ?protocol:protocol -> Xc.domid -> unit +end + module Dm : sig type disp_opt = diff --git a/xenops/device_common.ml b/xenops/device_common.ml index 75bdfac..339be0a 100644 --- a/xenops/device_common.ml +++ b/xenops/device_common.ml @@ -19,7 +19,7 @@ open Stringext open Hashtblext open Pervasiveext -type kind = Vif | Vbd | Tap | Pci | Vfb +type kind = Vif | Vbd | Tap | Pci | Vfb | Vkb type devid = int (** Represents one end of a device *) @@ -46,9 +46,9 @@ open D open Printf let string_of_kind = function - | Vif -> "vif" | Vbd -> "vbd" | Tap -> "tap" | Pci -> "pci" | Vfb -> "vfb" + | Vif -> "vif" | Vbd -> "vbd" | Tap -> "tap" | Pci -> "pci" | Vfb -> "vfb" | Vkb -> "vkb" let kind_of_string = function - | "vif" -> Vif | "vbd" -> Vbd | "tap" -> Tap | "pci" -> Pci | "vfb" -> Vfb + | "vif" -> Vif | "vbd" -> Vbd | "tap" -> Tap | "pci" -> Pci | "vfb" -> Vfb | "vkb" -> Vkb | x -> raise (Unknown_device_type x) let string_of_endpoint (x: endpoint) = @@ -100,9 +100,8 @@ let device_of_backend (backend: endpoint) (domu: Xc.domid) = let frontend = { domid = domu; kind = (match backend.kind with | Vbd | Tap -> Vbd - | Vif -> Vif - | Vfb -> Vfb - | Pci -> Pci); + | _ -> backend.kind + ); devid = backend.devid } in { backend = backend; frontend = frontend } diff --git a/xenops/device_common.mli b/xenops/device_common.mli index 1666e50..69d17a0 100644 --- a/xenops/device_common.mli +++ b/xenops/device_common.mli @@ -15,7 +15,7 @@ * GNU Lesser General Public License for more details. *) -type kind = Vif | Vbd | Tap | Pci | Vfb +type kind = Vif | Vbd | Tap | Pci | Vfb | Vkb type devid = int diff --git a/xenops/hotplug.ml b/xenops/hotplug.ml index af05bfc..4b2f972 100644 --- a/xenops/hotplug.ml +++ b/xenops/hotplug.ml @@ -92,7 +92,7 @@ let device_is_online ~xs (x: device) = and backend_request () = try ignore(xs.Xs.read (backend_shutdown_request_path_of_device ~xs x)); true with Xb.Noent -> false in match x.backend.kind with - | Pci | Vfb -> assert false (* PCI/Vfb backend doesn't create online node *) + | Pci | Vfb | Vkb -> assert false (* PCI/Vfb backend doesn't create online node *) | Vif -> backend_hotplug () | ( Vbd | Tap ) -> if backend_request ()