Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

CA-94616: Check SR Capabilities before suspending VM for checkpoint #933

Merged
merged 1 commit into from Dec 23, 2012

Conversation

Projects
None yet
2 participants
Contributor

siddharthv commented Dec 5, 2012

We check if the SR's on which a VM's VDI's reside has snapshot capability before actually suspending a VM for checkpoint operation.

@jonludlam jonludlam commented on the diff Dec 17, 2012

ocaml/xapi/xapi_vm_snapshot.ml
@@ -178,6 +178,28 @@ let checkpoint ~__context ~vm ~new_name =
try
(* Save the state of the vm *)
snapshot_info := Xapi_vm_clone.snapshot_info ~power_state ~is_a_snapshot:true;
+
+ (* Get all the VM's VDI's except CD's *)
+ let vbds = Db.VM.get_VBDs ~__context ~self:vm in
+ let vbds = List.filter (fun x -> Db.VBD.get_type ~__context ~self:x <> `CD) vbds in
+ let vdis = List.map (fun self -> Db.VBD.get_VDI ~__context ~self) vbds in
+
@jonludlam

jonludlam Dec 17, 2012

Owner

These VDIs may not all be in the database - destroying a VDI doesn't cause all of the VBDs referencing it to be immediately GC'd - we should wrap the Db.VDI.get_SR with an exception handler.

Owner

jonludlam commented Dec 18, 2012

From @siddharthv :
The entire patch is enclosed within a try with block.

Could you give me some more details as to why we need to wrap Db.VDI.get_SR with an exception handler and what we intend to do in it??

Owner

jonludlam commented Dec 18, 2012

The point is that a vdi that doesn't exist isn't necessarily an error, so we should cope with that. Dangling VBDs will be gc'd by db_gc, but it happens asynchronously. Although the current patch is enclosed by try/catch, that will just propagate the error in this case, when we should be ignoring the error.

Contributor

siddharthv commented Dec 18, 2012

Does this modification look good??

let vdi_sr = List.fold_left (fun x vdi -> try (Db.VDI.get_SR ~__context ~self:vdi) :: x with _ -> x) [] vdis in

Owner

jonludlam commented Dec 18, 2012

Yep, that looks good - alternatively you can use Listext.filter_map, which might look nicer perhaps.

It may fail later in the function due to this condition, but at least we aren't introducing another instance of this class of issue :-)

Owner

jonludlam commented Dec 23, 2012

This looks good now

@jonludlam jonludlam added a commit that referenced this pull request Dec 23, 2012

@jonludlam jonludlam Merge pull request #933 from siddharthv/CA-94616-trunk
CA-94616: Check SR Capabilities before suspending VM for checkpoint
3921792

@jonludlam jonludlam merged commit 3921792 into xapi-project:master Dec 23, 2012

1 check passed

default Merged build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment