From ca899c09e9315fd26c3a29fb3794d8f15d2154c1 Mon Sep 17 00:00:00 2001 From: David Scott Date: Wed, 9 Feb 2011 15:27:39 +0000 Subject: [PATCH] CA-48488: Re-interpret the n/xxxx:xx:xx.x PCI passthrough keys so that 'n' refers to a plug ordering. The previous meaning was 'PCI bus device' number which was only meaningful for PV guests (and of unknown use). The HVM PCI hotplug protocol doesn't seem to support this anyway. If we need it again, we can tweak the syntax. Signed-off-by: David Scott --- ocaml/xapi/vmops.ml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ocaml/xapi/vmops.ml b/ocaml/xapi/vmops.ml index d9134f56ac3..c69a537e53b 100644 --- a/ocaml/xapi/vmops.ml +++ b/ocaml/xapi/vmops.ml @@ -136,16 +136,14 @@ let create_vifs ~__context ~xs vifs = raise (Api_errors.Server_error (Api_errors.cannot_plug_vif, [ Ref.string_of vif.Vm_config.vif_ref ])) ) vifs +(* Confusion: the n/xxxx:xx:xx.x syntax originally meant PCI device + xxxx:xx:xx.x should be plugged into bus number n. HVM guests don't have + multiple PCI buses anyway. We reinterpret the 'n' to be a hotplug ordering *) let sort_pcidevs devs = - let ids = ref [] in - List.iter (fun (id, _) -> - if not (List.mem id !ids) then - ids := id :: !ids - ) devs; - + let ids = List.sort compare (Listext.List.setify (List.map fst devs)) in List.map (fun id -> id, (List.map snd (List.filter (fun (x, _) -> x = id) devs)) - ) !ids + ) ids let attach_pcis ~__context ~xc ~xs ~hvm domid pcis = Helpers.log_exn_continue "attach_pcis"