1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/crash_report.py
#	gns3server/schemas/qemu.py
#	gns3server/schemas/qemu_template.py
#	gns3server/static/web-ui/index.html
#	gns3server/static/web-ui/main.1379a5647e8bc6d3e401.js
#	gns3server/version.py
#	tests/compute/qemu/test_qemu_vm.py
This commit is contained in:
grossmj 2023-07-13 10:09:26 +10:00
commit 3f691b60c9
16 changed files with 212 additions and 83 deletions

View File

@ -1,5 +1,14 @@
# Change Log
## 2.2.41 12/07/2023
* Bundle web-ui v2.2.41
* Catch urllib3 exceptions when sending crash report. Ref https://github.com/GNS3/gns3-gui/issues/3483
* Only fetch Qemu version once when starting Qemu + only add speed/duplex for virtio-net-pci with Qemu version >= 2.12
* Use recent OVMF firmware (stable-202305) and use flash drives to configure Qemu command line
* Remove the useless executable permissions to the file gns3server/disks/empty8G.qcow2
* Backport UEFI boot mode support for Qemu VMs
## 2.2.40.1 10/06/2023
* Re-bundle Web-Ui v2.2.40. Fixes #2239

View File

@ -0,0 +1,43 @@
{
"appliance_id": "8fecbf89-5cd1-4aea-b735-5f36cf0efbb7",
"name": "BIRD2",
"category": "router",
"description": "The BIRD project aims to develop a fully functional dynamic IP routing daemon primarily targeted on (but not limited to) Linux, FreeBSD and other UNIX-like systems and distributed under the GNU General Public License.",
"vendor_name": "CZ.NIC Labs",
"vendor_url": "https://bird.network.cz",
"documentation_url": "https://bird.network.cz/?get_doc&f=bird.html&v=20",
"product_name": "BIRD internet routing daemon",
"registry_version": 4,
"status": "stable",
"maintainer": "Bernhard Ehlers",
"maintainer_email": "dev-ehlers@mailbox.org",
"usage": "Username:\tgns3\nPassword:\tgns3\nTo become root, use \"sudo -s\".\n\nNetwork configuration:\nsudo nano /etc/network/interfaces\nsudo systemctl restart networking\n\nBIRD:\nRestart: sudo systemctl restart bird\nReconfigure: birdc configure",
"port_name_format": "eth{0}",
"qemu": {
"adapter_type": "virtio-net-pci",
"adapters": 4,
"ram": 512,
"hda_disk_interface": "scsi",
"arch": "x86_64",
"console_type": "telnet",
"kvm": "allow"
},
"images": [
{
"filename": "bird2-debian-2.0.12.qcow2",
"version": "2.0.12",
"md5sum": "435218a2e90cba921cc7fde1d64a9419",
"filesize": 287965184,
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "http://downloads.sourceforge.net/project/gns-3/Qemu%20Appliances/bird2-debian-2.0.12.qcow2"
}
],
"versions": [
{
"name": "2.0.12",
"images": {
"hda_disk_image": "bird2-debian-2.0.12.qcow2"
}
}
]
}

View File

@ -24,10 +24,17 @@
"kvm": "require"
},
"images": [
{
"filename": "c8000v-universalk9_8G_serial.17.06.05.qcow2",
"version": "17.06.05 8G",
"md5sum": "aeb15ab8e1cbd0cd76f7260a81442f98",
"filesize": 1777795072,
"download_url": "https://software.cisco.com/download/home/286327102/type/282046477/release/Bengaluru-17.6.5"
},
{
"filename": "c8000v-universalk9_8G_serial.17.06.01a.qcow2",
"version": "17.06.01a 8G",
"md5sum": "d8b8ae633d953ec1b6d8f18a09a4f4e7",
"md5sum": "e278fa644295c703976a86f7f1c1cd65",
"filesize": 1595277312,
"download_url": "https://software.cisco.com/download/home/286327102/type/282046477/release/Bengaluru-17.6.1a"
},
@ -47,6 +54,12 @@
}
],
"versions": [
{
"name": "17.06.05 8G",
"images": {
"hda_disk_image": "c8000v-universalk9_8G_serial.17.06.05.qcow2"
}
},
{
"name": "17.06.01a 8G",
"images": {

View File

@ -188,12 +188,12 @@
"download_url": "https://software.cisco.com/download/"
},
{
"filename": "OVMF-20160813.fd",
"version": "16.08.13",
"md5sum": "8ff0ef1ec56345db5b6bda1a8630e3c6",
"filesize": 2097152,
"download_url": "",
"direct_download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/OVMF-20160813.fd.zip/download",
"filename": "OVMF-edk2-stable202305.fd",
"version": "stable202305",
"md5sum": "6c4cf1519fec4a4b95525d9ae562963a",
"filesize": 4194304,
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/OVMF-edk2-stable202305.fd.zip/download",
"compression": "zip"
}
],
@ -201,161 +201,161 @@
{
"name": "9500v 10.1.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9500v64.10.1.1.qcow2"
}
},
{
"name": "9300v 10.1.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9300v.10.1.1.qcow2"
}
},
{
"name": "9500v 9.3.9",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9500v.9.3.9.qcow2"
}
},
{
"name": "9300v 9.3.9",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9300v.9.3.9.qcow2"
}
},
{
"name": "9300v 9.3.8",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9300v.9.3.8.qcow2"
}
},
{
"name": "9500v 9.3.7",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9500v.9.3.7.qcow2"
}
},
{
"name": "9500v 9.3.3",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9500v.9.3.3.qcow2"
}
},
{
"name": "9300v 9.3.3",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nexus9300v.9.3.3.qcow2"
}
},
{
"name": "9.3.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv.9.3.1.qcow2"
}
},
{
"name": "9.2.3",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.9.2.3.qcow2"
}
},
{
"name": "9.2.2",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.9.2.2.qcow2"
}
},
{
"name": "9.2.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.9.2.1.qcow2"
}
},
{
"name": "7.0.3.I7.9",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.9.qcow2"
}
},
{
"name": "7.0.3.I7.7",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.7.qcow2"
}
},
{
"name": "7.0.3.I7.6",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.6.qcow2"
}
},
{
"name": "7.0.3.I7.5",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.5.qcow2"
}
},
{
"name": "7.0.3.I7.4",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.4.qcow2"
}
},
{
"name": "7.0.3.I7.3",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.3.qcow2"
}
},
{
"name": "7.0.3.I7.2",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.2.qcow2"
}
},
{
"name": "7.0.3.I7.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I7.1.qcow2"
}
},
{
"name": "7.0.3.I6.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I6.1.qcow2"
}
},
{
"name": "7.0.3.I5.2",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I5.2.qcow2"
}
},
{
"name": "7.0.3.I5.1",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "nxosv-final.7.0.3.I5.1.qcow2"
}
}

View File

@ -8,8 +8,8 @@
"product_name": "Debian",
"registry_version": 4,
"status": "experimental",
"maintainer": "GNS3 Team",
"maintainer_email": "developers@gns3.net",
"maintainer": "Bernhard Ehlers",
"maintainer_email": "dev-ehlers@mailbox.org",
"usage": "Username:\tdebian\nPassword:\tdebian\nTo become root, use \"sudo -s\".\n\nNetwork configuration:\n- In \"/etc/network/interfaces\" comment out \"source-directory /run/network/interfaces.d\"\n- Remove \"/etc/network/interfaces.d/50-cloud-init\"\n- Create \"/etc/network/interfaces.d/10-ens4\", for example:\n\nauto ens4\n#iface ens4 inet dhcp\niface ens4 inet static\n address 10.1.1.100/24\n gateway 10.1.1.1\n dns-nameservers 10.1.1.1\n",
"symbol": "linux_guest.svg",
"port_name_format": "ens{port4}",
@ -24,20 +24,28 @@
},
"images": [
{
"filename": "debian-11-genericcloud-amd64-20221219-1234.qcow2",
"version": "11.6",
"md5sum": "bd6ddbccc89e40deb7716b812958238d",
"filesize": 258801664,
"download_url": "https://cloud.debian.org/images/cloud/bullseye/",
"direct_download_url": "https://cloud.debian.org/images/cloud/bullseye/20221219-1234/debian-11-genericcloud-amd64-20221219-1234.qcow2"
"filename": "debian-12-genericcloud-amd64-20230612-1409.qcow2",
"version": "12.0",
"md5sum": "524cf33a1284d6e3363bd4d843756386",
"filesize": 280166400,
"download_url": "https://cloud.debian.org/images/cloud/bookworm/",
"direct_download_url": "https://cloud.debian.org/images/cloud/bookworm/20230612-1409/debian-12-genericcloud-amd64-20230612-1409.qcow2"
},
{
"filename": "debian-10-genericcloud-amd64-20220911-1135.qcow2",
"filename": "debian-11-genericcloud-amd64-20230601-1398.qcow2",
"version": "11.7",
"md5sum": "1b24a841dc5ca9bcf40b94ad4b4775d4",
"filesize": 259063808,
"download_url": "https://cloud.debian.org/images/cloud/bullseye/",
"direct_download_url": "https://cloud.debian.org/images/cloud/bullseye/20230601-1398/debian-11-genericcloud-amd64-20230601-1398.qcow2"
},
{
"filename": "debian-10-genericcloud-amd64-20230601-1398.qcow2",
"version": "10.13",
"md5sum": "9d4d1175bef974caba79dd6ca33d500c",
"filesize": 234749952,
"md5sum": "ca799fb4011712f4686c422c1a9731cf",
"filesize": 228130816,
"download_url": "https://cloud.debian.org/images/cloud/buster/",
"direct_download_url": "https://cloud.debian.org/images/cloud/buster/20220911-1135/debian-10-genericcloud-amd64-20220911-1135.qcow2"
"direct_download_url": "https://cloud.debian.org/images/cloud/buster/20230601-1398/debian-10-genericcloud-amd64-20230601-1398.qcow2"
},
{
"filename": "debian-cloud-init-data.iso",
@ -50,16 +58,23 @@
],
"versions": [
{
"name": "11.6",
"name": "12.0",
"images": {
"hda_disk_image": "debian-11-genericcloud-amd64-20221219-1234.qcow2",
"hda_disk_image": "debian-12-genericcloud-amd64-20230612-1409.qcow2",
"cdrom_image": "debian-cloud-init-data.iso"
}
},
{
"name": "11.7",
"images": {
"hda_disk_image": "debian-11-genericcloud-amd64-20230601-1398.qcow2",
"cdrom_image": "debian-cloud-init-data.iso"
}
},
{
"name": "10.13",
"images": {
"hda_disk_image": "debian-10-genericcloud-amd64-20220911-1135.qcow2",
"hda_disk_image": "debian-10-genericcloud-amd64-20230601-1398.qcow2",
"cdrom_image": "debian-cloud-init-data.iso"
}
}

View File

@ -8,8 +8,8 @@
"product_name": "ipterm",
"registry_version": 4,
"status": "stable",
"maintainer": "GNS3 Team",
"maintainer_email": "developers@gns3.net",
"maintainer": "Bernhard Ehlers",
"maintainer_email": "dev-ehlers@mailbox.org",
"usage": "The /root directory is persistent.",
"symbol": "linux_guest.svg",
"docker": {

View File

@ -27,6 +27,15 @@
"options": "-nographic"
},
"images": [
{
"filename": "chr-7.10.1.img",
"version": "7.10.1",
"md5sum": "917729e79b9992562f4160d461b21cac",
"filesize": 134217728,
"download_url": "http://www.mikrotik.com/download",
"direct_download_url": "https://download.mikrotik.com/routeros/7.10.1/chr-7.10.1.img.zip",
"compression": "zip"
},
{
"filename": "chr-7.7.img",
"version": "7.7",
@ -83,6 +92,12 @@
}
],
"versions": [
{
"name": "7.10.1",
"images": {
"hda_disk_image": "chr-7.10.1.img"
}
},
{
"name": "7.7",
"images": {

View File

@ -25,6 +25,13 @@
"kvm": "require"
},
"images": [
{
"filename": "OPNsense-23.1-OpenSSL-nano-amd64.img",
"version": "23.1",
"md5sum": "db7d3b9fd3b94894623368db1041ff11",
"filesize": 3221225472,
"download_url": "https://opnsense.c0urier.net/releases/23.1/"
},
{
"filename": "OPNsense-22.1.2-OpenSSL-nano-amd64.img",
"version": "22.1.2",
@ -55,6 +62,12 @@
}
],
"versions": [
{
"name": "23.1",
"images": {
"hda_disk_image": "OPNsense-23.1-OpenSSL-nano-amd64.img"
}
},
{
"name": "22.1.2",
"images": {

View File

@ -24,6 +24,13 @@
"process_priority": "normal"
},
"images": [
{
"filename": "pfSense-CE-2.7.0-RELEASE-amd64.iso",
"version": "2.7.0",
"md5sum": "cb0b72ca864d06682265de5e5a72a1fb",
"filesize": 765218816,
"download_url": "https://www.pfsense.org/download/mirror.php?section=downloads"
},
{
"filename": "pfSense-CE-2.6.0-RELEASE-amd64.iso",
"version": "2.6.0",
@ -69,6 +76,13 @@
}
],
"versions": [
{
"name": "2.7.0",
"images": {
"hda_disk_image": "empty100G.qcow2",
"cdrom_image": "pfSense-CE-2.7.0-RELEASE-amd64.iso"
}
},
{
"name": "2.6.0",
"images": {

View File

@ -8,8 +8,8 @@
"product_name": "webterm",
"registry_version": 4,
"status": "stable",
"maintainer": "GNS3 Team",
"maintainer_email": "developers@gns3.net",
"maintainer": "Bernhard Ehlers",
"maintainer_email": "dev-ehlers@mailbox.org",
"usage": "The /root directory is persistent.",
"symbol": "firefox.svg",
"docker": {

View File

@ -38,12 +38,12 @@
"compression": "zip"
},
{
"filename": "OVMF-20160813.fd",
"version": "16.08.13",
"md5sum": "8ff0ef1ec56345db5b6bda1a8630e3c6",
"filesize": 2097152,
"download_url": "",
"direct_download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/OVMF-20160813.fd.zip/download",
"filename": "OVMF-edk2-stable202305.fd",
"version": "stable202305",
"md5sum": "6c4cf1519fec4a4b95525d9ae562963a",
"filesize": 4194304,
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/OVMF-edk2-stable202305.fd.zip/download",
"compression": "zip"
}
],
@ -51,7 +51,7 @@
{
"name": "2212",
"images": {
"bios_image": "OVMF-20160813.fd",
"bios_image": "OVMF-edk2-stable202305.fd",
"hda_disk_image": "WinDev2212Eval-disk1.vmdk"
}
}

View File

@ -115,6 +115,7 @@ class QemuVM(BaseNode):
self._local_udp_tunnels = {}
self._guest_cid = None
self._command_line_changed = False
self._qemu_version = None
# QEMU VM settings
if qemu_path:
@ -2089,8 +2090,7 @@ class QemuVM(BaseNode):
f"file={disk},if=none,id=drive{disk_index},index={disk_index},media=disk{extra_drive_options}",
]
)
qemu_version = await self.manager.get_qemu_version(self.qemu_path)
if qemu_version and parse_version(qemu_version) >= parse_version("4.2.0"):
if self._qemu_version and parse_version(self._qemu_version) >= parse_version("4.2.0"):
# The ide-drive device is deprecated since version 4.2.0
# https://qemu.readthedocs.io/en/latest/system/deprecated.html#ide-drive-since-4-2
options.extend(
@ -2281,7 +2281,19 @@ class QemuVM(BaseNode):
raise QemuError(f"bios image '{self._bios_image}' is not accessible")
options.extend(["-bios", self._bios_image.replace(",", ",,")])
elif self._uefi:
options.extend(["-bios", "OVMF.fd"]) # the OVMF bios image should be in the image directory
# get the OVMF firmware from the images directory
ovmf_firmware_path = self.manager.get_abs_image_path("OVMF_CODE.fd")
log.info("Configuring UEFI boot mode using OVMF file: '{}'".format(ovmf_firmware_path))
options.extend(["-drive", "if=pflash,format=raw,readonly,file={}".format(ovmf_firmware_path)])
# the node should have its own copy of OVMF_VARS.fd (the UEFI variables store)
ovmf_vars_node_path = os.path.join(self.working_dir, "OVMF_VARS.fd")
if not os.path.exists(ovmf_vars_node_path):
try:
shutil.copyfile(self.manager.get_abs_image_path("OVMF_VARS.fd"), ovmf_vars_node_path)
except OSError as e:
raise QemuError("Cannot copy OVMF_VARS.fd file to the node working directory: {}".format(e))
options.extend(["-drive", "if=pflash,format=raw,file={}".format(ovmf_vars_node_path)])
return options
def _linux_boot_options(self):
@ -2381,8 +2393,7 @@ class QemuVM(BaseNode):
pci_bridges = math.floor(pci_devices / 32)
pci_bridges_created = 0
if pci_bridges >= 1:
qemu_version = await self.manager.get_qemu_version(self.qemu_path)
if qemu_version and parse_version(qemu_version) < parse_version("2.4.0"):
if self._qemu_version and parse_version(self._qemu_version) < parse_version("2.4.0"):
raise QemuError(
"Qemu version 2.4 or later is required to run this VM with a large number of network adapters"
)
@ -2448,8 +2459,7 @@ class QemuVM(BaseNode):
if any(opt in self._options for opt in ["-display", "-nographic", "-curses", "-sdl" "-spice", "-vnc"]):
return []
version = await self.manager.get_qemu_version(self.qemu_path)
if version and parse_version(version) >= parse_version("3.0"):
if self._qemu_version and parse_version(self._qemu_version) >= parse_version("3.0"):
return ["-display", "none"]
else:
return ["-nographic"]
@ -2578,6 +2588,7 @@ class QemuVM(BaseNode):
(to be passed to subprocess.Popen())
"""
self._qemu_version = await self.manager.get_qemu_version(self.qemu_path)
vm_name = self._name.replace(",", ",,")
project_path = self.project.path.replace(",", ",,")
additional_options = self._options.strip()
@ -2599,10 +2610,9 @@ class QemuVM(BaseNode):
if await self._run_with_hardware_acceleration(self.qemu_path, self._options):
if sys.platform.startswith("linux"):
command.extend(["-enable-kvm"])
version = await self.manager.get_qemu_version(self.qemu_path)
# Issue on some combo Intel CPU + KVM + Qemu 2.4.0
# https://github.com/GNS3/gns3-server/issues/685
if version and parse_version(version) >= parse_version("2.4.0") and self.platform == "x86_64":
if self._qemu_version and parse_version(self._qemu_version) >= parse_version("2.4.0") and self.platform == "x86_64":
command.extend(["-machine", "smm=off"])
elif sys.platform.startswith("darwin"):
command.extend(["-enable-hax"])

Binary file not shown.

Binary file not shown.

0
gns3server/disks/empty8G.qcow2 Executable file → Normal file
View File

View File

@ -77,6 +77,7 @@ async def vm(compute_project, manager, fake_qemu_binary, fake_qemu_img_binary):
vm._ubridge_hypervisor = MagicMock()
vm._ubridge_hypervisor.is_running.return_value = True
vm.manager.config.settings.Qemu.enable_hardware_acceleration = False
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="6.2.0")
return vm
@ -143,7 +144,6 @@ async def test_is_running(vm, running_subprocess_mock):
@pytest.mark.asyncio
async def test_start(vm, running_subprocess_mock):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=running_subprocess_mock) as mock:
await vm.start()
@ -159,7 +159,6 @@ async def test_stop(vm, running_subprocess_mock):
future = asyncio.Future()
future.set_result(True)
process.wait.return_value = future
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
@ -250,7 +249,6 @@ async def test_port_remove_nio_binding(vm):
@pytest.mark.asyncio
async def test_close(vm, port_manager):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
await vm.start()
@ -371,7 +369,6 @@ async def test_disk_options(vm, tmpdir, fake_qemu_img_binary):
@pytest.mark.asyncio
async def test_cdrom_option(vm, tmpdir, fake_qemu_img_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm._cdrom_image = str(tmpdir / "test.iso")
open(vm._cdrom_image, "w+").close()
@ -383,26 +380,34 @@ async def test_cdrom_option(vm, tmpdir, fake_qemu_img_binary):
@pytest.mark.asyncio
async def test_bios_option(vm, tmpdir, fake_qemu_img_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm._bios_image = str(tmpdir / "test.img")
open(vm._bios_image, "w+").close()
options = await vm._build_command()
assert ' '.join(['-bios', str(tmpdir / "test.img")]) in ' '.join(options)
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Test not working on Windows")
@pytest.mark.asyncio
async def test_uefi_boot_mode_option(vm, tmpdir, fake_qemu_img_binary):
async def test_uefi_boot_mode_option(vm, tmpdir, images_dir, fake_qemu_img_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm._uefi = True
# create fake OVMF files
ovmf_code_path = os.path.join(images_dir, "OVMF_CODE.fd")
with open(ovmf_code_path, "w+") as f:
f.write('1')
ovmf_vars_path = os.path.join(images_dir, "OVMF_VARS.fd")
with open(ovmf_vars_path, "w+") as f:
f.write('1')
options = await vm._build_command()
assert ' '.join(['-bios', 'OVMF.fd']) in ' '.join(options)
assert ' '.join(["-drive", "if=pflash,format=raw,readonly,file={}".format(ovmf_code_path)]) in ' '.join(options)
assert ' '.join(["-drive", "if=pflash,format=raw,file={}".format(os.path.join(vm.working_dir, "OVMF_VARS.fd"))]) in ' '.join(options)
@pytest.mark.asyncio
async def test_uefi_with_bios_image_already_configured(vm, tmpdir, fake_qemu_img_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm._bios_image = str(tmpdir / "test.img")
vm._uefi = True
with pytest.raises(QemuError):
@ -431,7 +436,6 @@ async def test_spice_option(vm, fake_qemu_img_binary):
@pytest.mark.asyncio
async def test_tpm_option(vm, tmpdir, fake_qemu_img_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm._tpm = True
tpm_sock = os.path.join(vm.temporary_directory, "swtpm.sock")
with patch("os.path.exists", return_value=True) as os_path:
@ -528,7 +532,6 @@ async def test_control_vm_expect_text(vm, running_subprocess_mock):
@pytest.mark.asyncio
async def test_build_command(vm, fake_qemu_binary):
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
os.environ["DISPLAY"] = "0:0"
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
cmd = await vm._build_command()
@ -564,7 +567,6 @@ async def test_build_command_manual_uuid(vm):
If user has set a uuid we keep it
"""
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
vm.options = "-uuid e1c307a4-896f-11e6-81a5-3c07547807cc"
os.environ["DISPLAY"] = "0:0"
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
@ -703,7 +705,6 @@ async def test_build_command_two_adapters_mac_address(vm):
Should support multiple base vmac address
"""
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.5.0")
vm.adapters = 2
vm.mac_address = "00:00:ab:0e:0f:09"
mac_0 = vm._mac_address
@ -729,12 +730,9 @@ async def test_build_command_two_adapters_mac_address(vm):
async def test_build_command_large_number_of_adapters(vm):
"""
When we have more than 28 interface we need to add a pci bridge for
additional interfaces
additional interfaces (supported only with Qemu 2.4 and later)
"""
# It's supported only with Qemu 2.4 and later
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.4.0")
vm.adapters = 100
vm.mac_address = "00:00:ab:0e:0f:09"
mac_0 = vm._mac_address
@ -776,7 +774,6 @@ async def test_build_command_with_virtio_net_pci_adapter(vm):
Test virtio-net-pci adapter which has parameters speed=1000 & duplex=full hard-coded
"""
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.4.0")
vm.adapters = 1
vm.mac_address = "00:00:ab:0e:0f:09"
vm._adapter_type = "virtio-net-pci"