From: Vincent Hanquez Date: Fri, 28 Aug 2009 14:40:58 +0000 (+0100) Subject: add a script that will trigger (if here) pre and post flr on a PCI device. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=08e2966c2f149587c8fa278cb39fe3e7a8ec59d4;p=xenclient%2Ftoolstack.git add a script that will trigger (if here) pre and post flr on a PCI device. --- diff --git a/xenops/device.ml b/xenops/device.ml index ce6dbdb..3bdf973 100644 --- a/xenops/device.ml +++ b/xenops/device.ml @@ -892,7 +892,7 @@ let grant_access_resources xc domid resources v = ) ) resources -let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = +let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?(flrscript=None) pcidevs domid devid = let pcidevs = List.map (fun (domain, bus, slot, func) -> let (irq, resources, driver) = get_from_system domain bus slot func in { domain = domain; bus = bus; slot = slot; func = func; @@ -919,6 +919,7 @@ let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = frontend = { domid = domid; kind = Pci; devid = devid }; } in + let others = (match flrscript with None -> [] | Some script -> [ ("script", script) ]) in let xsdevs = List.mapi (fun i dev -> sprintf "dev-%d" i, sprintf "%04x:%02x:%02x.%02x" dev.domain dev.bus dev.slot dev.func; ) pcidevs in @@ -934,11 +935,11 @@ let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = "backend-id", "0"; "state", string_of_int (Xenbus.int_of Xenbus.Initialising); ] in - Generic.add_device ~xs device (xsdevs @ backendlist) frontendlist; + Generic.add_device ~xs device (others @ xsdevs @ backendlist) frontendlist; () -let add ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = - try add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid +let add ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?flrscript pcidevs domid devid = + try add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?flrscript pcidevs domid devid with exn -> raise (Cannot_add (pcidevs, exn)) @@ -1020,11 +1021,25 @@ let enumerate_devs ~xs (x: device) = ) [] (Array.to_list devs)) let reset ~xs (x: device) = + let backend_path = backend_path_of_device ~xs x in + let script = try Some (xs.Xs.read (backend_path ^ "/script")) with _ -> None in + let callscript = + match script with + | None -> (fun _ _ -> ()) + | Some script -> + let f s devstr = + try ignore (Forkhelpers.execute_command_get_output ~withpath:true script [ s; devstr; ]) + with _ -> () + in + f + in debug "Device.Pci.reset %s" (string_of_device x); let pcidevs = enumerate_devs ~xs x in List.iter (fun (domain, bus, slot, func) -> let devstr = sprintf "%.4x:%.2x:%.2x.%.1x" domain bus slot func in - do_flr devstr + callscript "flr-pre" devstr; + do_flr devstr; + callscript "flr-post" devstr ) pcidevs; () diff --git a/xenops/device.mli b/xenops/device.mli index 8b3b03f..eb96ddc 100644 --- a/xenops/device.mli +++ b/xenops/device.mli @@ -130,7 +130,7 @@ sig exception Cannot_use_pci_with_no_pciback of t list val add : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> msitranslate:int - -> pci_power_mgmt:int -> dev list -> Xc.domid -> int -> unit + -> pci_power_mgmt:int -> ?flrscript:(string option) -> dev list -> Xc.domid -> int -> unit val release : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> dev list -> Xc.domid -> int -> unit val reset : xs:Xs.xsh -> device -> unit diff --git a/xenvm/vmact.ml b/xenvm/vmact.ml index feee559..38f73fd 100644 --- a/xenvm/vmact.ml +++ b/xenvm/vmact.ml @@ -230,7 +230,8 @@ let add_devices xc xs domid state restore = | None -> cfg.global_pci_power_mgmt | Some i -> i in - Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate ~pci_power_mgmt devs domid devid + let flrscript = cfg.global_pci_script in + Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate ~pci_power_mgmt ~flrscript devs domid devid ) pcis; if (not cfg.hvm) then ( diff --git a/xenvm/vmconfig.ml b/xenvm/vmconfig.ml index d687393..b6b40b8 100644 --- a/xenvm/vmconfig.ml +++ b/xenvm/vmconfig.ml @@ -146,6 +146,7 @@ type config = { extra_vm_watches: string list; global_pci_msitranslate: int; global_pci_power_mgmt: int; + global_pci_script: string option; sound: string option; inject_sci: int; qemu_pv: bool; @@ -461,6 +462,7 @@ let get cfg field = | "oem-features" -> string_of_int cfg.oem_features | "pci-msitranslate" -> string_of_int cfg.global_pci_msitranslate | "pci-power-management" -> string_of_int cfg.global_pci_power_mgmt + | "pci-script" -> string_of_string_option cfg.global_pci_script | "inject-sci" -> string_of_int cfg.inject_sci | "sound" -> string_of_string_option cfg.sound | "notify" -> string_of_notify cfg.notify @@ -496,6 +498,7 @@ let set cfg field value = | "oem-features" -> { cfg with oem_features = int_of_string value } | "pci-msitranslate" -> { cfg with global_pci_msitranslate = int_of_string value } | "pci-power-management" -> { cfg with global_pci_power_mgmt = int_of_string value } + | "pci-script" -> { cfg with global_pci_script = string_option_of_string value } | "inject-sci" -> { cfg with inject_sci = int_of_string value } | "sound" -> { cfg with sound = string_option_of_string value } | "notify" -> { cfg with notify = config_notify_of_string value } @@ -572,6 +575,7 @@ let empty = vpt_align = None; global_pci_msitranslate = 0; global_pci_power_mgmt = 0; + global_pci_script = None; inject_sci = 0; sound = None; qemu_pv = true;