)
) 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;
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
"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))
) [] (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;
()
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
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;
| "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
| "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 }
vpt_align = None;
global_pci_msitranslate = 0;
global_pci_power_mgmt = 0;
+ global_pci_script = None;
inject_sci = 0;
sound = None;
qemu_pv = true;