Skip to content

Commit 53dffb0

Browse files
committed
xapi_vm_snapshot: do not leak CD VBDs
Because all the snapshot's CD VBDs are cloned in all cases, the reverted VM's CD VBDs must be destroyed in all cases, add them unconditionally to the VBDs being destroyed. Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent 1480fbd commit 53dffb0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

ocaml/xapi/xapi_vm_snapshot.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ let revert_vbds ~__context ~rpc ~session_id ~snapshot ~vm =
253253
let snap_disks_snapshot_of = VDISet.map get_snapshot_of snap_disks_all in
254254

255255
let vm_VBDs_all = Db.VM.get_VBDs ~__context ~self:vm |> VBDSet.of_list in
256-
let vm_VBDs_disk =
256+
let vm_VBDs_disk, vm_VBDs_CD =
257257
(* Filter VBDs to ensure that we don't read empty CDROMs *)
258-
VBDSet.filter
258+
VBDSet.partition
259259
(fun vbd -> Db.VBD.get_type ~__context ~self:vbd = `Disk)
260260
vm_VBDs_all
261261
in
@@ -309,7 +309,8 @@ let revert_vbds ~__context ~rpc ~session_id ~snapshot ~vm =
309309
in
310310

311311
let vm_vbds_to_be_destroyed =
312-
filter_vbds_from_vdis vm_VBDs_all vm_disks_to_be_destroyed
312+
let ( +++ ) = VBDSet.union in
313+
filter_vbds_from_vdis vm_VBDs_all vm_disks_to_be_destroyed +++ vm_VBDs_CD
313314
in
314315

315316
let snap_VBDs_reverted =

0 commit comments

Comments
 (0)