mirror of
https://github.com/GNS3/gns3-server
synced 2025-02-03 03:41:34 +00:00
Close VirtualBox VM linked clone disks after the VM is unregistered. Fixes #145.
This commit is contained in:
parent
e7ae1776f4
commit
8503472c77
@ -110,7 +110,6 @@ class VirtualBox(BaseManager):
|
|||||||
raise VirtualBoxError("VBoxManage has timed out after {} seconds!".format(timeout))
|
raise VirtualBoxError("VBoxManage has timed out after {} seconds!".format(timeout))
|
||||||
|
|
||||||
if process.returncode:
|
if process.returncode:
|
||||||
# only the first line of the output is useful
|
|
||||||
vboxmanage_error = stderr_data.decode("utf-8", errors="ignore")
|
vboxmanage_error = stderr_data.decode("utf-8", errors="ignore")
|
||||||
raise VirtualBoxError("VirtualBox has returned an error: {}".format(vboxmanage_error))
|
raise VirtualBoxError("VirtualBox has returned an error: {}".format(vboxmanage_error))
|
||||||
|
|
||||||
|
@ -321,6 +321,7 @@ class VirtualBoxVM(BaseVM):
|
|||||||
|
|
||||||
if self._linked_clone:
|
if self._linked_clone:
|
||||||
hdd_table = []
|
hdd_table = []
|
||||||
|
hdd_files_to_close = []
|
||||||
if os.path.exists(self.working_dir):
|
if os.path.exists(self.working_dir):
|
||||||
hdd_files = yield from self._get_all_hdd_files()
|
hdd_files = yield from self._get_all_hdd_files()
|
||||||
vm_info = yield from self._get_vm_info()
|
vm_info = yield from self._get_vm_info()
|
||||||
@ -331,6 +332,7 @@ class VirtualBoxVM(BaseVM):
|
|||||||
port = match.group(2)
|
port = match.group(2)
|
||||||
device = match.group(3)
|
device = match.group(3)
|
||||||
if value in hdd_files:
|
if value in hdd_files:
|
||||||
|
hdd_files_to_close.append(value)
|
||||||
log.info("VirtualBox VM '{name}' [{id}] detaching HDD {controller} {port} {device}".format(name=self.name,
|
log.info("VirtualBox VM '{name}' [{id}] detaching HDD {controller} {port} {device}".format(name=self.name,
|
||||||
id=self.id,
|
id=self.id,
|
||||||
controller=controller,
|
controller=controller,
|
||||||
@ -351,6 +353,12 @@ class VirtualBoxVM(BaseVM):
|
|||||||
log.info("VirtualBox VM '{name}' [{id}] unregistering".format(name=self.name, id=self.id))
|
log.info("VirtualBox VM '{name}' [{id}] unregistering".format(name=self.name, id=self.id))
|
||||||
yield from self.manager.execute("unregistervm", [self._name])
|
yield from self.manager.execute("unregistervm", [self._name])
|
||||||
|
|
||||||
|
for hdd_file in hdd_files_to_close:
|
||||||
|
log.info("VirtualBox VM '{name}' [{id}] closing disk {disk}".format(name=self.name,
|
||||||
|
id=self.id,
|
||||||
|
disk=os.path.basename(hdd_file)))
|
||||||
|
yield from self.manager.execute("closemedium", ["disk", hdd_file])
|
||||||
|
|
||||||
if hdd_table:
|
if hdd_table:
|
||||||
try:
|
try:
|
||||||
hdd_info_file = os.path.join(self.working_dir, self._vmname, "hdd_info.json")
|
hdd_info_file = os.path.join(self.working_dir, self._vmname, "hdd_info.json")
|
||||||
|
Loading…
Reference in New Issue
Block a user