Skip to content

Commit

Permalink
[PV PCI passthrough]: workaround logging crash in xenlight ocaml bind…
Browse files Browse the repository at this point in the history
…ings by shelling out to "xl pci-attach"

We will eventually use the API directly. Leaving the old code in there for
reference and with explicit warnings.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
  • Loading branch information
David Scott committed Nov 26, 2011
1 parent 7f88136 commit b258509
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions ocaml/xenops/device.ml
Expand Up @@ -1099,26 +1099,47 @@ let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?(flrscript=None) pcide
Generic.add_device ~xs device (others @ xsdevs @ backendlist) frontendlist []; Generic.add_device ~xs device (others @ xsdevs @ backendlist) frontendlist [];
() ()


let add_xl ~msitranslate ~pci_power_mgmt pcidevs domid = (* XXX: this will crash because of the logging policy within the
Xenlight ocaml bindings. *)
let add_libxl ~msitranslate ~pci_power_mgmt pcidevs domid =
List.iter List.iter
(fun (domain, bus, dev, func) -> (fun (domain, bus, dev, func) ->
Xenlight.pci_add { try
(* XXX: I don't think we can guarantee how the C compiler will Xenlight.pci_add {
lay out bitfields. (* XXX: I don't think we can guarantee how the C compiler will
unsigned int reserved1:2; lay out bitfields.
unsigned int reg:6; unsigned int reserved1:2;
unsigned int func:3; unsigned int reg:6;
unsigned int dev:5; unsigned int func:3;
unsigned int bus:8; unsigned int dev:5;
unsigned int reserved2:7; unsigned int bus:8;
unsigned int enable:1; unsigned int reserved2:7;
*) unsigned int enable:1;
Xenlight.v = (func lsl 8) lor (dev lsl 11) lor (bus lsl 16); *)
domain = domain; Xenlight.v = (func lsl 8) lor (dev lsl 11) lor (bus lsl 16);
vdevfn = 0; domain = domain;
msitranslate = msitranslate = 1; vdevfn = 0;
power_mgmt = pci_power_mgmt = 1; msitranslate = msitranslate = 1;
} domid power_mgmt = pci_power_mgmt = 1;
} domid
with e ->
debug "Xenlight.pci_add: %s" (Printexc.to_string e);
raise e
) pcidevs

(* XXX: we don't want to use the 'xl' command here because the "interface"
isn't considered as stable as the C API *)
let add_xl ~msitranslate ~pci_power_mgmt pcidevs domid =
List.iter
(fun dev ->
try
let (_, _) = Forkhelpers.execute_command_get_output
"/usr/sbin/xl"
[ "pci-attach"; string_of_int domid; to_string dev ] in
()
with e ->
debug "xl pci-attach: %s" (Printexc.to_string e);
raise e
) pcidevs ) pcidevs


let add ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?flrscript pcidevs domid devid = let add ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt ?flrscript pcidevs domid devid =
Expand Down

0 comments on commit b258509

Please sign in to comment.