WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

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

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] fix VBD create/destroy race
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Tue, 16 Mar 2010 12:22:35 +0000
Delivery-date: Tue, 16 Mar 2010 05:13:50 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# 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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] fix VBD create/destroy race, David Scott <=