From: Tomasz Wroblewski Date: Fri, 4 Dec 2009 14:30:46 +0000 (+0000) Subject: Add pci-list implementation X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1d19db1633c5b71a91a6a1f18802e905dd01f393;p=xenclient%2Ftoolstack.git Add pci-list implementation --- diff --git a/xenvm/vmact.ml b/xenvm/vmact.ml index d9fc864..2bdf2cf 100644 --- a/xenvm/vmact.ml +++ b/xenvm/vmact.ml @@ -161,6 +161,9 @@ let cd_insert_real ~xs state virtpath physpath = 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) = @@ -270,7 +273,18 @@ let add_devices xc xs domid state restore = | 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 ( @@ -783,3 +797,15 @@ let add_pci state id domain bus slot func bind msitranslate power_mgmt = 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) diff --git a/xenvm/vmstate.ml b/xenvm/vmstate.ml index 1f58b7e..b0408ae 100644 --- a/xenvm/vmstate.ml +++ b/xenvm/vmstate.ml @@ -65,6 +65,7 @@ type vm_state = { 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; @@ -93,6 +94,7 @@ let state_init uuid config_path cfg = vm_vnc_port = (-1); vm_tap2_disks = []; vm_nics = []; + vm_pcis = []; vm_on_suspend_action = ActionSuspend; vm_cfg = cfg; vm_next_cfg = None; diff --git a/xenvm/xenvm.ml b/xenvm/xenvm.ml index 8f48136..cb5146e 100644 --- a/xenvm/xenvm.ml +++ b/xenvm/xenvm.ml @@ -495,8 +495,10 @@ let do_task state (task, args) = 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