[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] fix VBD create/destroy race



# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1268741973 0
# Node ID 1f355c3b5970c8df1c5b74b0b0996cdffa4fbe7a
# Parent  282bc9b84d78a67aea171d234873be6c63ddc307
CA-28958: fix a VBD create/destroy race in the VBD.device 'autodetect' choosing 
logic.

A parallel VBD.destroy can come in and delete a VBD just before we attempt to 
look up the device field. Obviously it doesn't matter what device this VBD was 
since it has just been deleted... so just ignore it.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 282bc9b84d78 -r 1f355c3b5970 ocaml/xapi/xapi_vm_helpers.ml
--- a/ocaml/xapi/xapi_vm_helpers.ml     Tue Mar 16 12:17:56 2010 +0000
+++ b/ocaml/xapi/xapi_vm_helpers.ml     Tue Mar 16 12:19:33 2010 +0000
@@ -778,10 +778,13 @@
 (** Given a VBD returns either Some devicename or None in the case where a 
device is set to
     autodetect and it hasn't been plugged in. *)
 let get_device_name_in_use ~__context ~self = 
-  let vbd_r = Db.VBD.get_record ~__context ~self in
-  match vbd_r.API.vBD_userdevice with
-  | "autodetect" -> Some vbd_r.API.vBD_device
-  | x -> Some x
+  try
+       let vbd_r = Db.VBD.get_record ~__context ~self in
+       match vbd_r.API.vBD_userdevice with
+       | "autodetect" -> Some vbd_r.API.vBD_device
+       | x -> Some x
+  with _ -> (* someone just destroyed the VBD *)
+         None
 
 exception Invalid_device of string
 let translate_vbd_device_to_number name =
1 file changed, 7 insertions(+), 4 deletions(-)
ocaml/xapi/xapi_vm_helpers.ml |   11 +++++++----


Attachment: xen-api.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.