Commit Graph
300 Commits
Author SHA1 Message Date
YueGuobin a40503e44b fix(qemu): release the datapath under the execution lock
QEMU's process monitor calls stop() by itself when the process dies, so an
API stop and a process-death stop run concurrently in the normal case — and
the datapath release sat outside _execute_lock, letting both stops sweep the
adapter TAP map at the same time. Whichever finished first cleared
_kernel_taps under the other's iterator, which died with "dictionary changed
size during iteration" (the monitor's task, so it surfaced as "Task exception
was never retrieved") with the rest of its sweep, the orphan-bridge removal
and uBridge's shutdown skipped.

Keep the previous fix's ordering (process side first, then the devices) and
hold the lock across the release: serialized, the second stop finds uBridge
gone and sweeps nothing. Reproduced deterministically with two concurrent
stop() calls, the first parked mid-sweep — it raised at qemu_vm.py:1659
before the change, and every TAP is swept exactly once after it.
2026-10-06 00:21:09 +08:00
YueGuobin 0b78d313eb fix(qemu): release the datapath after the process is gone
QEMU is the guest side of every adapter TAP, and uBridge's tap delete
refuses a device another process holds open ('Device or resource busy') —
a best-effort delete whose failure is suppressed. QEMU's stop did the
delete first and stopped the process after, so every node stop or project
delete leaked the persistent TAPs: found by inspecting the host after a
project delete (16 taps left behind, carrier down, no holder), and the
held-tap behaviour reproduced against uBridge directly.

Stop the QEMU process first, then remove the TAPs and the per-link kernel
bridges — process side first, then the devices, the same lesson as IOU's
reverse stop order. Verified live: node stop and project delete now leave
no taps and no processes behind, while a restart recreates the TAPs.

The adapter anchor naming also goes through the shared
utils.kernel_anchor helper, like the other node types.
2026-10-06 00:21:09 +08:00
YueGuobin a1fcd29bce fix(qemu): build a command line for a headless node
_console_options() fell through the "none" branch and returned None, so
_build_command() blew up on `command.extend(None)`: a QEMU node with
console_type "none" -- offered by the GUI, and what API/MCP-driven labs use
to skip the console entirely -- failed to start with a 500 and a traceback.

Return an empty list, exactly like _aux_options() already does, and cover it
with a test that builds the command line for a headless node. Verified on a
live instance: such a node now starts (204) with `console: null` and no
-serial device in the QEMU command line.
2026-10-06 00:21:08 +08:00
YueGuobin 7d2d8c6747 feat(qemu): anchor QEMU adapters on a persistent TAP
QEMU had no host-side interface at all: every adapter was a local UDP tunnel
into uBridge (-netdev socket plus two UDP ports per adapter), so a link could
only ever be a userspace relay. Each adapter now owns a persistent TAP
(gq{node_id[:8]}e{adapter}p{port}), created by uBridge before QEMU is launched
and handed to this user, and the netdev is that TAP -- the anchor role Docker's
veth host end plays. Links attach to it:

* kernel link (NIOBridge): brctl create/up/addif enslaves the TAP into the
  per-link bridge and capture, markers and tc filters are installed on it,
  verbatim through the shared KernelDatapathMixin -- a TAP and a veth host end
  are interchangeable there (an egress qdisc on either impairs traffic entering
  the node, and PACKET_OUTGOING on either is the node receiving);
* relay link: bridge add_nio_ethernet plus add_nio_udp -- AF_PACKET, never the
  TAP NIO, which would take the fd QEMU itself holds.

The netdev type is fixed at launch, so this is all-or-nothing per VM: on the
TAP datapath every link type attaches to (or detaches from) a running VM,
including switching a link between the two datapaths. Stop un-persists the
TAPs (QEMU's open fd keeps each device alive until it exits) and removes the
per-link bridges; start sweeps leftovers first. A uBridge without the tap
module keeps the previous socket-netdev datapath, so an unupgraded install is
unaffected -- such a node simply cannot carry kernel links.
2026-10-06 00:21:08 +08:00
Mark Paronyan d5ad4c67c6 refactor: use f-strings in qemu compute modules 2026-10-03 19:44:00 +03:00
Mark Paronyan 1ed8320e31 Merge branch '3.1' into ruff/pr01-imports 2026-10-03 14:21:22 +03:00
grossmj 64e2a62a04 fix: improve warning message for missing mtools in config disk creation. Ref #2778 2026-10-02 16:08:38 +02:00
Mark Paronyan 38e9ddca09 style: sort imports in compute node modules 2026-10-02 12:43:26 +03:00
Mark Paronyan 95ada23395 refactor: replace percent formatting with format specifiers 2026-10-01 19:57:47 +03:00
Mark Paronyan 06899c92fc refactor: use iterable unpacking instead of concatenation 2026-10-01 19:57:46 +03:00
Mark Paronyan 2dc7479d11 style: remove f-strings without placeholders 2026-10-01 19:57:46 +03:00
Mark Paronyan 1a495ab318 refactor: replace getattr with attribute access 2026-10-01 19:57:42 +03:00
Mark Paronyan 525ef8ca57 fix(typing): resolve mypy errors in compute.qemu.qemu_vm 2026-09-28 12:37:28 +03:00
Mark Paronyan a0450b6bce refactor: ruff autofixes 2026-09-27 15:55:10 +03:00
Cristi da16dc9874 fix(qemu): Fixed missing image replacement for linked-clone nodes 2026-09-18 23:58:49 +03:00
YueGuobin f9f1a4d4d8 log: demote all per-node lifecycle INFO logs to DEBUG
Extend the docker_vm / base_node demotion to the remaining node types
and supporting layers:

  qemu_vm: MAC, adapters, disk image, RAM, priority, NIO added, created
  iou_vm:  application ID, adapters, serial, image, RAM, NIO added
  dynamips router: created, adapter, RAM, NVRAM, IOS, idle-PC, disk,
    MAC, NIO bound; hypervisor create/start/connect; nio_udp created
  builtin: ethernet_switch/hub, cloud, nat — created, NIO bound
  ubridge: hypervisor start/connect

At multi-node scale these per-node lines flood the log. Only the
project-open progress summary (loaded N nodes / creating N links)
now remains at INFO alongside genuinely exceptional events.
2026-08-11 01:05:53 +08:00
grossmj 544d15c87e fix: tests after merging 2026-08-08 16:50:19 +02:00
grossmj dff79f65d3 Merge branch '2.2' into 3.1
# Conflicts:
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/controller/import_project.py
#	gns3server/controller/project.py
#	gns3server/crash_report.py
#	gns3server/version.py
#	tests/compute/docker/test_docker_vm.py
#	tests/controller/test_import_project.py
#	tests/controller/test_project.py
2026-08-08 16:27:14 +02:00
YueGuobin b6959f8214 qemu: demote QEMU monitor connect and set_link logs to DEBUG 2026-08-03 00:17:34 +08:00
Jeremy Grossmann 7efef28d4f Merge branch '2.2' into bugfix/2838 2026-07-29 17:50:01 +02:00
grossmj d9140d2f8c fix(qemu): move the bios options after the network ones 2026-07-29 17:47:03 +02:00
grossmj e2657febf0 fix(qemu): fix addition of QEMU RNG device causes interface names to change 2026-07-29 17:23:28 +02:00
Iskander Nafikov 9562c9d828 fix(qemu): remove trailing space from RNG object argument 2026-07-28 00:27:55 +08:00
grossmj 7bc9ae4aa8 Fix typo with ovmf_firmware_dir 2026-07-21 17:34:05 +02:00
grossmj 1f6e00d29f Fix issues after merging 2026-07-21 17:20:46 +02:00
grossmj 7487ec14e0 Merge branch '2.2' into 3.1
# Conflicts:
#	CHANGELOG
#	conf/gns3_server.conf
#	gns3server/compute/docker/__init__.py
#	gns3server/compute/docker/docker_vm.py
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/controller/import_project.py
#	gns3server/crash_report.py
#	gns3server/version.py
2026-07-21 17:03:00 +02:00
grossmj 61c7f4469d Search for system UEFI that is compatible with Python < 3.12 2026-07-13 11:34:29 +02:00
grossmj 896b4fc56a UEFI improvements for Qemu VMs
* Add OVMF firmware directory configuration
* Automatically add a Random Number Generator (RNG) device when using uefi option is enabled
2026-07-13 11:08:17 +02:00
Jeremy Grossmann c3d202abc9 Merge branch '3.0' into ssh-console-support 2026-05-02 22:10:28 +08:00
YueGuobinandClaude Opus 4.6 ba220780a9 fix: improve hostname validation error messages with allowed characters
When a hostname validation fails, the error message now includes
the allowed character set to help users provide valid names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-02 13:09:04 +08:00
Cristi d64eca0418 feat(compute): add SSH console type support 2026-04-30 15:52:47 +03:00
grossmj 8b245c96f8 Qemu VMs: only compute MD5 checksums for existing disks 2026-03-04 18:54:52 +08:00
grossmj c66e851498 Fix for resizing Qemu VM disks 2026-02-23 17:10:15 +08:00
grossmj 60abbade27 Revert merged changes from 2.2 introduced by PR #2607 2026-02-21 21:35:12 +08:00
grossmj c5b9f379fe Merge remote-tracking branch 'origin/2.2' into 3.0
# Conflicts:
#	Dockerfile
#	dev-requirements.txt
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/version.py
#	requirements.txt
2026-02-20 16:28:53 +08:00
Patrik Olsson fe2014854e Take populated disks into consideration when calculating PCI device ID 2026-02-05 15:10:57 +01:00
grossmj 2cdaa1cd06 Fix tests 2025-05-14 17:19:18 +02:00
grossmj f2080979a1 Fix tests 2025-05-14 16:56:46 +02:00
grossmj df576f0668 Merge remote-tracking branch 'origin/2.2' into 3.0
# Conflicts:
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/schemas/template.py
2025-05-14 16:42:59 +02:00
grossmj 2b96e54629 Fix tests and require Qemu version >= 2.4 2025-04-30 13:38:52 +07:00
Tobias Stein cdf819f820 Fix adding pci_bridges to qemu vms
* Offset pci_device_id for network devices by 32 (formerly 4)
  to reserve first 32 IDs for non-netdev devices
  * This implies a new pci_bridge for the netdevs and
    the pci_device_ids starting at 0 (using modulo)
  * Fixes a bug in the creation of the qemu command
    when the number of qemu pcie devices (storage_controller, disks, …)
    was greater than 4 and the number of network devices
    saturated the 32 pcie ids of the root bridge
    causing qemu not to start.
2025-04-28 21:07:52 +02:00
Emmanuel Ferdman c05e6f4de4 Resolve deprecation warnings of regex library
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-04-26 00:15:16 -07:00
grossmj d9dcc2738d Merge remote-tracking branch 'origin/2.2' into 3.0
# Conflicts:
#	CHANGELOG
#	Dockerfile
#	README.md
#	gns3server/appliances/infix.gns3a
#	gns3server/compute/docker/docker_vm.py
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/controller/gns3vm/virtualbox_gns3_vm.py
#	gns3server/crash_report.py
#	gns3server/static/web-ui/index.html
#	gns3server/static/web-ui/main.9bcf455e62558dedfd48.js
#	gns3server/version.py
2025-04-21 20:13:31 +07:00
grossmj a5a663bc99 Remove OVMF_CODE_4M.secboot.fd and associated code 2025-04-18 17:31:31 +07:00
grossmj 2b7eb91694 Add edk2-stable202502 UEFI firmwares and try to first use firmwares from the ovmf package if installed. Fixes #2494 2025-04-18 17:13:29 +07:00
grossmj 684770a220 Prettify TPM error message 2025-04-18 15:25:50 +07:00
grossmj f6546bf1de Fix bug in qemu_stdout message 2025-04-18 15:19:06 +07:00
grossmj 355b97398b Reduce matching error for TPM result 2025-04-18 15:13:41 +07:00
grossmj 6242a0be80 Try to detect swtpm and AppArmor issue. Ref https://github.com/GNS3/gns3-gui/issues/3725 2025-04-18 15:06:49 +07:00
grossmj ec9dbd20b8 Merge branch '2.2' into 3.0
# Conflicts:
#	gns3server/compute/base_node.py
#	gns3server/compute/docker/docker_vm.py
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/crash_report.py
#	gns3server/version.py
2024-11-07 23:18:42 +10:00