Repository navigation
Increase PCIe port limit in workshop VMs - #1073
Open
jonathan-conder wants to merge 3 commits into
Open
jonathan-conder wants to merge 3 commits into
jonathan-conder wants to merge 3 commits into
Conversation
jonathan-conder
changed the base branch from
main
to
feature/autoconnect-vm-mounts
October 5, 2026 05:08
jonathan-conder
added this pull request to stack #1071
October 5, 2026 05:08
jonathan-conder
force-pushed
the
fix/vm-pci-port-limit
branch
from
October 6, 2026 05:20
3826174 to
27f4b82
Compare
jonathan-conder
force-pushed
the
fix/vm-pci-port-limit
branch
from
October 7, 2026 06:01
27f4b82 to
56818f6
Compare
jonathan-conder
force-pushed
the
fix/vm-pci-port-limit
branch
3 times, most recently
from
October 11, 2026 23:05
a48176b to
54f1e99
Compare
My original motivation for disabling secure boot was performance, but it turned out not to make much difference. Was still worth doing anyway.
Originally it seemed like a no-brainer to disable this, no one is going to attach a PS/2 keyboard to a workshop. However, it turns out this controller is responsible for some unrelated functionality, including a CPU reset command. This is used when the UEFI firmware in a LXD VM detects changes in the efivar MemoryTypeInformation. The default memory reservation is not always enough if limits.max_bus_ports is high. The upshot is that, with lots of mount plugs, we need to enable i8042; otherwise the CPU reset does nothing and the VM boot times out. On top of that, we can no longer abort awaitReadyEvent when LXD reports an instance shutdown event. Instead, we wait a few seconds to see if the instance is restarting or just stopping for good. It should be possible for LXD to distinguish between a reboot event and a shutdown, but it doesn't provide that information currently (outside debug logs).
jonathan-conder
force-pushed
the
fix/vm-pci-port-limit
branch
2 times, most recently
from
October 13, 2026 04:09
3c4eede to
69da66a
Compare
jonathan-conder
marked this pull request as ready for review
October 13, 2026 04:26
jonathan-conder
requested review from
akcano and
dmitry-lyfar
and
a lite review from Copilot
October 13, 2026 04:26
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The VM snapshot fixture will fail, and the reboot test does not verify that startup survives a completed reboot.
2 open findings
What changed in this PR
This PR raises PCIe port and CPU limits for LXD virtual-machine workshops with many SDK mounts and allows startup to wait through an initial reboot.
Changes:
- Scale VM port and CPU limits with the number of SDKs.
- Add reboot and limit tests.
- Document VM connection limits and add PCIe to the documentation wordlist.
| File | Description |
|---|---|
internal/workshop/lxd/tests/integration/workshop_test.go |
Adds reboot and default-port integration tests. |
internal/workshop/lxd/lxd_backend.go |
Sets VM limits and waits for startup after a reboot. |
internal/workshop/lxd/lxd_backend_test.go |
Tests VM limit calculations. |
docs/reference/workshops.rst |
Describes VM port and processor limits. |
docs/how-to/customize-workshops/use-virtual-machines.rst |
Explains virtual-hardware constraints. |
docs/.custom_wordlist.txt |
Adds “PCIe” to the wordlist. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| } | ||
| maxBusPorts := min(minPorts+portsPerSdk*regularSdks, maxPorts) | ||
| cfg["limits.max_bus_ports"] = fmt.Sprint(maxBusPorts) |
Comment on lines
+892
to
+893
| _, err = fs.Stat("/var/lib/workshop-test-rebooted") | ||
| c.Assert(err, check.IsNil) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Increases the default PCIe port limit for workshops with several SDKs. This is needed to accomodate the SDK mounts themselves, and any connected mount plugs.
With a lot of SDKs (i.e. a lot of PCIe ports), LXD's patched OVMF firmware likes to reboot the instance to reallocate enough memory for them in a contiguous block. We probably should have already supported mid-boot reboots since it's not as uncommon as you might think, e.g.: https://github.com/canonical/lxd/blob/85f897013ccdb0f8f44d434a3b655d2edcefcfae/lxd-agent/main_agent.go#L98-L113
Unfortunately LXD doesn't tell us if the instance is rebooting or just powering down; in any case we probably shouldn't wait for it to reboot indefinitely. 10s seems to be enough time, in a nested VM it only takes about 3s to go from no QEMU to "QEMU running," we don't need to wait for systemd or anything.
Self-review quick check
Docs
Procedure:
Content:
tutorial/andhow-to/sections).docs/.coverage.yamlupdated, coverage tags added (.. artefact).Or: