]> xenbits.xen.org Git - xenclient/toolstack.git/commitdiff
Add pci-list implementation
authorTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Fri, 4 Dec 2009 14:30:46 +0000 (14:30 +0000)
committerTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Fri, 4 Dec 2009 14:30:46 +0000 (14:30 +0000)
xenvm/vmact.ml
xenvm/vmstate.ml
xenvm/xenvm.ml

index d9fc864ed78e3ec23276bbd0d5602872cf67054a..2bdf2cf826461cc07a2460d3c97cc5093981eae4 100644 (file)
@@ -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)
index 1f58b7e85168904d2b9018fb738602e5090e3d68..b0408ae5e51fa01366573c6a56a4b27457b23c99 100644 (file)
@@ -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;
index 8f48136c798fe6a271f059abc7ae787c10a240be..cb5146efdade346e2b08754308f8c06524512c5a 100644 (file)
@@ -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