# HG changeset patch # User David Scott # Date 1263336662 0 # Node ID 59cc9bf262f2d433fb86941546c138c66184b510 # Parent eb25907b24f6e386beea49d6160e1c2381694b6d CA-36384: [experimental PCI passthrough]: add a Device.PCI.bind before calling Device.PCI.plug, just like we do with Device.PCI.add (coldplug). Call Vmops.plug_pcidevs on the reboot path. Signed-off-by: David Scott diff -r eb25907b24f6 -r 59cc9bf262f2 ocaml/xapi/vmops.ml --- a/ocaml/xapi/vmops.ml Tue Jan 12 22:51:01 2010 +0000 +++ b/ocaml/xapi/vmops.ml Tue Jan 12 22:51:02 2010 +0000 @@ -498,6 +498,7 @@ if (Xc.domain_getinfo xc domid).Xc.hvm_guest then begin List.iter (fun (devid, devices) -> + Device.PCI.bind devices; List.iter (fun ((a, b, c, d) as device) -> debug "hotplugging PCI device %04x:%02x:%02x.%01x into domid: %d" a b c d domid; @@ -1014,6 +1015,7 @@ progress_cb 0.80; debug "creating device emulator"; let vncport = create_device_emulator ~__context ~xc ~xs ~self:vm domid vifs snapshot in + if hvm then plug_pcidevs ~__context ~vm domid; create_console ~__context ~vM:vm ~vncport (); debug "writing memory policy"; write_memory_policy ~xs snapshot domid; diff -r eb25907b24f6 -r 59cc9bf262f2 ocaml/xapi/xapi_vm.ml --- a/ocaml/xapi/xapi_vm.ml Tue Jan 12 22:51:01 2010 +0000 +++ b/ocaml/xapi/xapi_vm.ml Tue Jan 12 22:51:02 2010 +0000 @@ -264,7 +264,6 @@ (fun xc xs -> Domain.unpause ~xc domid; ); - Vmops.plug_pcidevs ~__context ~vm domid; (* (* hack to get xmtest to work *) if Pool_role.is_master () then @@ -447,6 +446,7 @@ ); Db.VM.set_resident_on ~__context ~self:vm ~value:localhost; Db.VM.set_power_state ~__context ~self:vm ~value:`Running; + with exn -> error "Caught exception during %s: %s" api_call_name (ExnHelper.string_of_exn exn); with_xc_and_xs (fun xc xs -> Vmops.destroy ~__context ~xc ~xs ~self:vm domid `Halted); @@ -807,6 +807,8 @@ Vmops.restore ~__context ~xc ~xs ~self:vm domid; Db.VM.set_domid ~__context ~self:vm ~value:(Int64.of_int domid); + Vmops.plug_pcidevs ~__context ~vm domid; + debug "resume phase 3/3: %s unpausing domain" (if start_paused then "not" else ""); if not start_paused then begin @@ -820,7 +822,7 @@ localhost ); Db.VM.set_power_state ~__context ~self:vm - ~value:(if start_paused then `Paused else `Running) + ~value:(if start_paused then `Paused else `Running); (* ) *)