Skip to content

Commit ad77270

Browse files
committed
CA-424021: Add GC rule for PCI records
PCI records should be destroyed if the associated host reference is invalid. This is needed to handle the case where a host is ejected from a pool. Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
1 parent 862b070 commit ad77270

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ocaml/xapi/db_gc_util.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ let gc_VGPU_types ~__context =
234234
(String.concat "; " (List.map Ref.string_of (List.map fst garbage))) ;
235235
List.iter (fun (self, _) -> Db.VGPU_type.destroy ~__context ~self) garbage
236236

237+
let gc_PCIs ~__context =
238+
Db.PCI.get_all ~__context
239+
|> List.iter (fun self ->
240+
if not (valid_ref __context (Db.PCI.get_host ~__context ~self)) then
241+
Db.PCI.destroy ~__context ~self
242+
)
243+
237244
let gc_Host_patches ~__context =
238245
gc_connector ~__context Db.Host_patch.get_all Db.Host_patch.get_record
239246
(fun x -> valid_ref __context x.host_patch_host)
@@ -627,6 +634,7 @@ let gc_subtask_list =
627634
; ("VGPUs", gc_VGPUs)
628635
; ("PGPUs", gc_PGPUs)
629636
; ("VGPU_types", gc_VGPU_types)
637+
; ("PCIs", gc_PCIs)
630638
; ("Host patches", gc_Host_patches)
631639
; ("Host CPUs", gc_host_cpus)
632640
; ("Host metrics", gc_host_metrics)

0 commit comments

Comments
 (0)