Skip to content

Commit

Permalink
LibVirt machinery should create the KVM domain
Browse files Browse the repository at this point in the history
Currently, LibVirt machinery can determine the snapshot and revert
the VM state to it, but it jumps straight to waiting for a state
change without actually issuing a create call to the domain being
used. This is likely due to it expecting a live-state snapshot to
be instantiated which automatically starts the instance.

Add a conditional call self.vms[label].create() after resolving VM
snapshot state and prior to entering the wait state. If the VM
power state is still off, try to create the KVM domain with basic
error handling. This should not case race conditions as preceeding
snapshot operations are serialized and complete prior to returning.
  • Loading branch information
RageLtMan committed Nov 28, 2016
1 parent 71bd9a9 commit 697c7e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/cuckoo/common/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ def start(self, label):
self._disconnect(conn)
raise CuckooMachineError("No snapshot found for virtual machine "
"{0}".format(label))
# Attempt to boot the VM (create domain) if it's powered off
# This should address use of offline snapshots for fast clones/other uses.
if self._status(label) == self.POWEROFF:
try:
self.vms[label].create()
except libvirt.libvirtError:
raise CuckooMachineError("Unable to create domain for "
"virtual machine {0}".format(label))
finally:
self._disconnect(conn)

# Check state.
self._wait_status(label, self.RUNNING)
Expand Down

0 comments on commit 697c7e4

Please sign in to comment.