Skip to content
This repository
Browse code

CA-91480: Cancel vm_import cleans up temporary objects

Xapi_vm_helpers.destroy would fail if a VM had a reference to a non-existant
blob, which would happen when the VM had been imported. This would prevent the
rest of the function from running, leaving ghost objects in the database after
an import was cancelled.

Signed-off-by: Mike McClurg <mike.mcclurg@citrix.com>
  • Loading branch information...
commit fc9a4bf586cd8570eaf73a628cd8ca9d69761c9d 1 parent 1fa3fb2
authored October 26, 2012

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  ocaml/xapi/xapi_vm_helpers.ml
6  ocaml/xapi/xapi_vm_helpers.ml
@@ -151,8 +151,12 @@ let destroy  ~__context ~self =
151 151
   (* given the call to 'assert_operation_valid' *)
152 152
   debug "VM.destroy: deleting DB records";  
153 153
 
  154
+  (* Should we be destroying blobs? It's possible to create a blob and then
  155
+	 add its reference to multiple objects. Perhaps we want to just leave the
  156
+	 blob? Or only delete it if there is no other reference to it? Is that
  157
+	 even possible to know? *)
154 158
   let blobs = Db.VM.get_blobs ~__context ~self in
155  
-  List.iter (fun (name,_ref) -> Xapi_blob.destroy ~__context ~self:_ref) blobs;
  159
+  List.iter (fun (_,self) -> try Xapi_blob.destroy ~__context ~self with _ -> ()) blobs;
156 160
 
157 161
   let other_config = Db.VM.get_other_config ~__context ~self in
158 162
     if ((List.mem_assoc Xapi_globs.default_template_key other_config) &&

0 notes on commit fc9a4bf

Please sign in to comment.
Something went wrong with that request. Please try again.