mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
parent
9acb2ceda1
commit
c684c554bf
@ -48,6 +48,7 @@ class Qemu(BaseManager):
|
||||
|
||||
super().__init__()
|
||||
self._guest_cid_lock = asyncio.Lock()
|
||||
self.config_disk = "config.img"
|
||||
self._init_config_disk()
|
||||
|
||||
async def create_node(self, *args, **kwargs):
|
||||
@ -353,12 +354,10 @@ class Qemu(BaseManager):
|
||||
Initialize the default config disk
|
||||
"""
|
||||
|
||||
self.config_disk = "config.img"
|
||||
try:
|
||||
self.get_abs_image_path(self.config_disk)
|
||||
except (NodeError, ImageMissingError) as e:
|
||||
config_disk_zip = get_resource("compute/qemu/resources/{}.zip"
|
||||
.format(self.config_disk))
|
||||
except (NodeError, ImageMissingError):
|
||||
config_disk_zip = get_resource("compute/qemu/resources/{}.zip".format(self.config_disk))
|
||||
if config_disk_zip and os.path.exists(config_disk_zip):
|
||||
directory = self.get_images_directory()
|
||||
try:
|
||||
@ -366,5 +365,4 @@ class Qemu(BaseManager):
|
||||
except OSError as e:
|
||||
log.warning("Config disk creation: {}".format(e))
|
||||
else:
|
||||
log.warning("Config disk: image '{}' missing"
|
||||
.format(self.config_disk))
|
||||
log.warning("Config disk: image '{}' missing".format(self.config_disk))
|
||||
|
@ -132,13 +132,13 @@ class QemuVM(BaseNode):
|
||||
# config disk
|
||||
self.config_disk_name = self.manager.config_disk
|
||||
self.config_disk_image = ""
|
||||
if self.config_disk_name:
|
||||
if not shutil.which("mcopy"):
|
||||
log.warning("Config disk: 'mtools' are not installed.")
|
||||
self.config_disk_name = ""
|
||||
else:
|
||||
try:
|
||||
self.config_disk_image = self.manager.get_abs_image_path(
|
||||
self.config_disk_name)
|
||||
self.config_disk_image = self.manager.get_abs_image_path(self.config_disk_name)
|
||||
except (NodeError, ImageMissingError) as e:
|
||||
log.warning("Config disk: image '{}' missing"
|
||||
.format(self.config_disk_name))
|
||||
|
@ -337,6 +337,7 @@ def test_set_qemu_path_kvm_binary(vm, fake_qemu_binary):
|
||||
|
||||
async def test_set_platform(compute_project, manager):
|
||||
|
||||
manager.config_disk = None # avoids conflict with config.img support
|
||||
with patch("shutil.which", return_value="/bin/qemu-system-x86_64") as which_mock:
|
||||
with patch("gns3server.compute.qemu.QemuVM._check_qemu_path"):
|
||||
vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, platform="x86_64")
|
||||
|
@ -18,7 +18,7 @@
|
||||
import uuid
|
||||
import os
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, MagicMock
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
from gns3server.compute.vpcs import VPCS
|
||||
@ -41,6 +41,7 @@ async def vpcs(loop, port_manager):
|
||||
async def qemu(loop, port_manager):
|
||||
|
||||
Qemu._instance = None
|
||||
Qemu._init_config_disk = MagicMock() # do not create the config.img image
|
||||
qemu = Qemu.instance()
|
||||
qemu.port_manager = port_manager
|
||||
return qemu
|
||||
|
Loading…
Reference in New Issue
Block a user