Skip to content

Commit c135976

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 d27a118 commit c135976

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

@@ -3717,9 +3717,13 @@ module VBD = struct
37173717
persistent=
37183718
{
37193719
vm_t.VmExtra.persistent with
3720+
(* Index by id_of vbd rather than vbd.id as VmExtra is
3721+
already indexed by VM id, so the VM id part of
3722+
vbd.id is unnecessary and causes issues finding the
3723+
attached_vdi when the VM is renamed. *)
37203724
attached_vdis=
3721-
(vbd.Vbd.id, vdi)
3722-
:: List.remove_assoc vbd.Vbd.id
3725+
(id_of vbd, vdi)
3726+
:: List.remove_assoc (id_of vbd)
37233727
vm_t.persistent.attached_vdis
37243728
}
37253729
}
@@ -3741,7 +3745,7 @@ module VBD = struct
37413745

37423746
let activate task vm vbd =
37433747
let vmextra = DB.read_exn vm in
3744-
match List.assoc_opt vbd.id vmextra.persistent.attached_vdis with
3748+
match List.assoc_opt (id_of vbd) vmextra.persistent.attached_vdis with
37453749
| None ->
37463750
debug "No attached_vdi info, so not activating"
37473751
| Some vdi ->
@@ -3892,7 +3896,7 @@ module VBD = struct
38923896
)
38933897
vm
38943898
)
3895-
(fun () -> cleanup_attached_vdis vm vbd.id)
3899+
(fun () -> cleanup_attached_vdis vm (id_of vbd))
38963900

38973901
let deactivate task vm vbd force =
38983902
with_xc_and_xs (fun xc xs ->
@@ -4056,7 +4060,7 @@ module VBD = struct
40564060
| _ ->
40574061
()
40584062
) ;
4059-
cleanup_attached_vdis vm vbd.id
4063+
cleanup_attached_vdis vm (id_of vbd)
40604064

40614065
let insert task vm vbd d =
40624066
on_frontend

0 commit comments

Comments
 (0)