Skip to content
This repository
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 22 additions and 22 deletions. Show diff stats Hide diff stats

  1. +22 22 modules/machinemanagers/virtualbox.py
44 modules/machinemanagers/virtualbox.py
@@ -79,28 +79,28 @@ def stop(self, label):
79 79 log.debug("Stopping vm %s" % label)
80 80
81 81 if self._status(label) in [self.POWEROFF, self.ABORTED]:
82   - log.debug("Trying to stop an already stopped vm %s" % label)
83   - else:
84   - try:
85   - proc = subprocess.Popen([self.options.virtualbox.path, "controlvm", label, "poweroff"],
86   - stdout=subprocess.PIPE,
87   - stderr=subprocess.PIPE)
88   - # Sometimes VBoxManage stucks when stopping vm so we needed
89   - # to add a timeout and kill it after that.
90   - stop_me = 0
91   - while proc.poll() is None:
92   - if stop_me < self.options.virtualbox.timeout:
93   - time.sleep(1)
94   - stop_me += 1
95   - else:
96   - log.debug("Stopping vm %s timeouted. Killing" % label)
97   - proc.terminate()
98   -
99   - if proc.returncode != 0 and stop_me < self.options.virtualbox.timeout:
100   - log.debug("VBoxManage exited with error powering off the machine")
101   - except OSError as e:
102   - raise CuckooMachineError("VBoxManage failed powering off the machine: %s" % e)
103   - self._wait_status(label, [self.POWEROFF, self.ABORTED])
  82 + raise CuckooMachineError("Trying to stop an already stopped vm %s" % label)
  83 +
  84 + try:
  85 + proc = subprocess.Popen([self.options.virtualbox.path, "controlvm", label, "poweroff"],
  86 + stdout=subprocess.PIPE,
  87 + stderr=subprocess.PIPE)
  88 + # Sometimes VBoxManage stucks when stopping vm so we needed
  89 + # to add a timeout and kill it after that.
  90 + stop_me = 0
  91 + while proc.poll() is None:
  92 + if stop_me < self.options.virtualbox.timeout:
  93 + time.sleep(1)
  94 + stop_me += 1
  95 + else:
  96 + log.debug("Stopping vm %s timeouted. Killing" % label)
  97 + proc.terminate()
  98 +
  99 + if proc.returncode != 0 and stop_me < self.options.virtualbox.timeout:
  100 + log.debug("VBoxManage exited with error powering off the machine")
  101 + except OSError as e:
  102 + raise CuckooMachineError("VBoxManage failed powering off the machine: %s" % e)
  103 + self._wait_status(label, [self.POWEROFF, self.ABORTED])
104 104
105 105 def _list(self):
106 106 """Lists virtual machines installed.

No commit comments for this range

Something went wrong with that request. Please try again.