Device.Vbd.media_insert ~xs ~virtpath ~physpath ~phystype:Device.Vbd.Phys state.vm_domid;
Xenvmlib.Ok
+let add_pci_to_vm ~xs state pci =
+ state.vm_pcis <- pci :: state.vm_pcis
+
let add_nic_to_vm ~xs state nic =
let netty = Netman.Bridge nic.nic_bridge in
let (_: Device_common.device) =
| Some i -> i
in
let flrscript = cfg.global_pci_script in
- Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate ~pci_power_mgmt ~flrscript devs domid devid
+ Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate ~pci_power_mgmt ~flrscript devs domid devid;
+ (* store actual parameters this is launched with with inside vm state *)
+ let pcis = List.map (fun (dom,bus,slot,func) -> {
+ Vmconfig.pci_bind = !bind;
+ Vmconfig.pci_domain = dom;
+ Vmconfig.pci_bus = bus;
+ Vmconfig.pci_slot = slot;
+ Vmconfig.pci_func = func;
+ Vmconfig.pci_msitranslate = Some msitranslate;
+ Vmconfig.pci_power_mgmt = Some pci_power_mgmt;
+ } ) devs in
+ List.iter (add_pci_to_vm ~xs state) pcis
) pcis;
if (not cfg.hvm) then (
set_new_config state cfg;
Xenvmlib.Ok
+let list_pci state =
+ let header = "pci-dom | bus | slot | func | bind | msi-trans | power-mgmt" in
+ let pci_dev_string p =
+ let bind = match p.pci_bind with true -> "y" | false -> "n"
+ and msi_trans = match p.pci_msitranslate with Some i -> i | _ -> -1
+ and power_mgmt = match p.pci_power_mgmt with Some i -> i | _ -> -1
+ in
+ Printf.sprintf "%7d |%4d |%5d |%5d |%5s |%10d |%11d"
+ p.pci_domain p.pci_bus p.pci_slot p.pci_func bind msi_trans power_mgmt in
+ let pci_lines = List.map pci_dev_string state.vm_pcis in
+ let msg = List.fold_left (fun x acc -> "\n" ^ acc ^ x) "" pci_lines in
+ Xenvmlib.Msg (header ^ msg)
mutable vm_vnc_port: int;
mutable vm_lifestate: vmlifestate;
mutable vm_tap2_disks: (Vmconfig.config_disk * string * string option) list;
+ mutable vm_pcis: Vmconfig.config_pci list;
mutable vm_nics: nic_state list;
mutable vm_on_suspend_action: Vmconfig.action;
mutable vm_cfg: Vmconfig.config;
vm_vnc_port = (-1);
vm_tap2_disks = [];
vm_nics = [];
+ vm_pcis = [];
vm_on_suspend_action = ActionSuspend;
vm_cfg = cfg;
vm_next_cfg = None;
Vmact.add_pci state id domain bus slot func bind msitranslate power_mgmt
| Tasks.DelDisk | Tasks.DelNic | Tasks.DelPCI ->
Xenvmlib.Error "not implemented"
- | Tasks.ListDisk | Tasks.ListNic | Tasks.ListPCI ->
+ | Tasks.ListDisk | Tasks.ListNic ->
Xenvmlib.Error "not implemented"
+ | Tasks.ListPCI ->
+ Vmact.list_pci state
| Tasks.Get ->
let field = Tasks.args_get_string args "field" in
Vmact.get state field