From a540ac83579381583438df85d6c54ee38b866de8 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Thu, 12 Dec 2024 10:29:21 +0000 Subject: [PATCH] CA-403633: Keep vPCI devices in the same order QEMU orders devices by the time of plugging. Parallelizing them introduces randomness, which breaks the assumption that devices are ordered in a deterministic way. Serialize all PCI and VUSB plugs to restore behaviour. Signed-off-by: Pau Ruiz Safont --- ocaml/xenopsd/lib/xenops_server.ml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ocaml/xenopsd/lib/xenops_server.ml b/ocaml/xenopsd/lib/xenops_server.ml index e5d8016bed..f4c784faa1 100644 --- a/ocaml/xenopsd/lib/xenops_server.ml +++ b/ocaml/xenopsd/lib/xenops_server.ml @@ -1630,12 +1630,11 @@ let rec atomics_of_operation = function ] ; [VM_create_device_model (id, false)] (* PCI and USB devices are hot-plugged into HVM guests via QEMU, so the - following operations occur after creating the device models *) - ; parallel_concat "Devices.plug (qemu)" ~id - [ - List.map (fun pci -> PCI_plug (pci.Pci.id, true)) pcis_other - ; List.map (fun vusb -> VUSB_plug vusb.Vusb.id) vusbs - ] + following operations occur after creating the device models. + The order of PCI devices depends on the order they are plugged, they + must be kept serialized. *) + ; List.map (fun pci -> PCI_plug (pci.Pci.id, true)) pcis_other + ; List.map (fun vusb -> VUSB_plug vusb.Vusb.id) vusbs (* At this point the domain is considered survivable. *) ; [VM_set_domain_action_request (id, None)] ] @@ -1698,10 +1697,10 @@ let rec atomics_of_operation = function ) ; [VM_create_device_model (id, true)] (* PCI and USB devices are hot-plugged into HVM guests via QEMU, so - the following operations occur after creating the device models *) - ; parallel_map "PCIs.plug" ~id pcis_other (fun pci -> - [PCI_plug (pci.Pci.id, true)] - ) + the following operations occur after creating the device models. + The order of PCI devices depends on the order they are plugged, they + must be kept serialized. *) + ; List.map (fun pci -> PCI_plug (pci.Pci.id, true)) pcis_other ] |> List.concat | VM_poweroff (id, timeout) ->