]> xenbits.xen.org Git - xenclient/toolstack.git/commitdiff
add a script that will trigger (if here) pre and post flr on a PCI device.
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Fri, 28 Aug 2009 14:40:58 +0000 (15:40 +0100)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Fri, 28 Aug 2009 14:40:58 +0000 (15:40 +0100)
xenops/device.ml
xenops/device.mli
xenvm/vmact.ml
xenvm/vmconfig.ml

index ce6dbdb1df3fbe789ac2c2575635c91bb73a50ed..3bdf973595f1d147b5b7d3b0fa1120d1032a6d8b 100644 (file)
@@ -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;
        ()
 
index 8b3b03fe428deb3021c850028fcbb82529ca7918..eb96ddc1eec37cb00f4c5179198d8668cf8bc235 100644 (file)
@@ -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
index feee559e471729343181b96fc204c450504515ba..38f73fd2576d4cb74a3ce163ae8a0d788e248c1b 100644 (file)
@@ -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 (
index d687393480e9147d59eaf56dfd65951e89a3ea28..b6b40b87abfaa4f9d159a8a70a8af54f5b3054c5 100644 (file)
@@ -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;