Skip to content

Commit 3ae8ff9

Browse files
committed
Use just id_of vbd for attached_vdis key instead of the (VM, VBD) tuple
The VM id part of Vbd.id is unnecessary in the attached_vdis key as the DB is already indexed by the VM id. This also prevents problems when the VM is renamed. Signed-off-by: Steven Woods <[email protected]>
1 parent f7ee5aa commit 3ae8ff9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ocaml/xenopsd/xc/xenops_server_xen.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ module VmExtra = struct
187187
; pv_drivers_detected: bool [@default false]
188188
; xen_platform: (int * int) option (* (device_id, revision) for QEMU *)
189189
; platformdata: (string * string) list [@default []]
190-
; attached_vdis: (Vbd.id * attached_vdi) list [@default []]
190+
; attached_vdis: (string * attached_vdi) list [@default []]
191191
}
192192
[@@deriving rpcty]
193193

@@ -3682,9 +3682,13 @@ module VBD = struct
36823682
persistent=
36833683
{
36843684
vm_t.VmExtra.persistent with
3685+
(* Index by id_of vbd rather than vbd.id as VmExtra is
3686+
already indexed by VM id, so the VM id part of
3687+
vbd.id is unnecessary and causes issues finding the
3688+
attached_vdi when the VM is renamed. *)
36853689
attached_vdis=
3686-
(vbd.Vbd.id, vdi)
3687-
:: List.remove_assoc vbd.Vbd.id
3690+
(id_of vbd, vdi)
3691+
:: List.remove_assoc (id_of vbd)
36883692
vm_t.persistent.attached_vdis
36893693
}
36903694
}
@@ -3706,7 +3710,7 @@ module VBD = struct
37063710

37073711
let activate task vm vbd =
37083712
let vmextra = DB.read_exn vm in
3709-
match List.assoc_opt vbd.id vmextra.persistent.attached_vdis with
3713+
match List.assoc_opt (id_of vbd) vmextra.persistent.attached_vdis with
37103714
| None ->
37113715
debug "No attached_vdi info, so not activating"
37123716
| Some vdi ->
@@ -3857,7 +3861,7 @@ module VBD = struct
38573861
)
38583862
vm
38593863
)
3860-
(fun () -> cleanup_attached_vdis vm vbd.id)
3864+
(fun () -> cleanup_attached_vdis vm (id_of vbd))
38613865

38623866
let deactivate task vm vbd force =
38633867
with_xc_and_xs (fun xc xs ->
@@ -4021,7 +4025,7 @@ module VBD = struct
40214025
| _ ->
40224026
()
40234027
) ;
4024-
cleanup_attached_vdis vm vbd.id
4028+
cleanup_attached_vdis vm (id_of vbd)
40254029

40264030
let insert task vm vbd d =
40274031
on_frontend

0 commit comments

Comments
 (0)