Skip to content

fix: use annotation for MirageOS net device name#690

Merged
cmainas merged 2 commits into
urunc-dev:main-pr690from
pocopepe:fix/315-mirage-net-annotation
Jul 24, 2026
Merged

fix: use annotation for MirageOS net device name#690
cmainas merged 2 commits into
urunc-dev:main-pr690from
pocopepe:fix/315-mirage-net-annotation

Conversation

@pocopepe

Copy link
Copy Markdown
Contributor

Description

mirageos unikernels declare their network device names at build time through the solo5 manifest. the problem was urunc always hardcoded "service" as the device name, so if you built a unikernel with a different name it would just fail.
i added a new annotation com.urunc.unikernel.netDev so image builders can set the name at build time and urunc picks it up at runtime. if the annotation isn't there it falls back to "service" so existing images still work.

block device naming and multi network support i left for follow up prs as discussed.

Related issues

How was this tested?

go test ./pkg/unikontainers/unikernels/... -v -run TestMirageNetDevName

=== RUN   TestMirageNetDevName
=== RUN   TestMirageNetDevName/uses_net_device_name_from_annotation
=== PAUSE TestMirageNetDevName/uses_net_device_name_from_annotation
=== RUN   TestMirageNetDevName/falls_back_to_service_when_annotation_is_absent
=== PAUSE TestMirageNetDevName/falls_back_to_service_when_annotation_is_absent
=== CONT  TestMirageNetDevName/uses_net_device_name_from_annotation
=== CONT  TestMirageNetDevName/falls_back_to_service_when_annotation_is_absent
--- PASS: TestMirageNetDevName (0.00s)
    --- PASS: TestMirageNetDevName/uses_net_device_name_from_annotation (0.00s)
    --- PASS: TestMirageNetDevName/falls_back_to_service_when_annotation_is_absent (0.00s)
PASS
ok      github.com/urunc-dev/urunc/pkg/unikontainers/unikernels (cached)

LLM usage

Claude Sonnet 4.6

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

@netlify

netlify Bot commented May 16, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 1fd8c85
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a6302c74a06e40008e95524

@cmainas

cmainas commented May 18, 2026

Copy link
Copy Markdown
Contributor

Hello @pocopepe ,

this is not enough testing for such PR. You need to build a mirage unikernel with multiple network interfaces and then spawn it with urunc again with multiple network interfaces.

@pocopepe

Copy link
Copy Markdown
Contributor Author

My bad, I just tested it with a mirage unikernel built to declare a non default net device name being eth0 being neteth0:fix and another with no annotation specified neteth0:bug.

With the annotation:

$ sudo nerdctl run --rm --runtime io.containerd.urunc.v2 neteth0:fix
WARN[0000] cannot set cgroup manager to "systemd" for runtime "io.containerd.urunc.v2"
            |      ___|
  __|  _ \  |  _ \ __ \
\__ \ (   | | (   |  ) |
____/\___/ _|\___/____/
Solo5: Bindings version v0.10.1
Solo5: Memory map: 268 MB addressable:
...
Usage: neteth0 [--help] [OPTION]…
neteth0: unknown option '--ipv4' unknown option '--ipv4-gateway'
Solo5: solo5_exit(64) called

solo5 accepts --net:eth0=... and boots

Without the annotation:

$ sudo nerdctl run --rm --runtime io.containerd.urunc.v2 neteth0:bug
WARN[0000] cannot set cgroup manager to "systemd" for runtime "io.containerd.urunc.v2"
solo5-hvt: Resource not declared in manifest: 'service'
solo5-hvt: Resource not declared in manifest: 'service'
solo5-hvt: Invalid option: `--net:service=tap0_urunc'

urunc defaults to the old hardcoded service and solo5 rejects since the manifest only declares eth0. That's exactly the bug this PR fixes.
Also the pr only focuses on task 1 as mentioned in the description. If this works for you, I'm happy to extend it for block scope and multi interface handling

@cmainas

cmainas commented May 18, 2026

Copy link
Copy Markdown
Contributor

Thank you @pocopepe for the test. Would it be possible to share the image you built? Also, a small note: If the PR does not entirely fix an issue, you can mention the issue as related, but do not use "Fixes".

@pocopepe

Copy link
Copy Markdown
Contributor Author

@cmainas sorry, I assumed Fixes was part of the default template, new to the repo conventions. happy to amend the commit and update the pr description to use Related instead, want me to do that now?

Pushed images:

Comment on lines 103 to 106
if data.Net.Mask != "" {
m.Net.Address = "--ipv4=" + data.Net.IP + "/24"
m.Net.Gateway = "--ipv4-gateway=" + data.Net.Gateway
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Mirage you can "group" parameters to network devices. What this effectively means is that you can add a prefix to the command line options (often the interface name). An example is for an interface management you'd often add a group management and this would produce command line options --management-ipv4, --management-ipv4-gateway etc. Now, since a recent release of Mirage interfaces will by default use DHCP to acquire this information if it was not presented at boot time (or statically configured) instead of using a silly default of 10.0.0.2/24 and 10.0.0.1 as ipv4 and ipv4-gateway respectively.

So to configure extra interfaces there's no good way to do it, but I think a decent heuristic is for each interface that is not called "service" to use data.NetDevName as the group.

Finally, you can construct unikernels in whatever way you want so you are never guaranteed that the unikernel accepts these options.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah makes sense, pushed it as a new commit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this as a comment to explain the cli argument construction? It is useful information.

@cmainas cmainas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @pocopepe ,

thank you for the changes. I have added some comments, but overall it looks good.

Also thank you @reynir for the patience and reviewing PRs related to this issue.

Comment thread pkg/unikontainers/unikernels/mirage.go Outdated
case "hvt", "spt":
netOption := "--net:service=" + ifName
netOption += " --net-mac:service=" + mac
name := m.netDevName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason for this assignment.

Comment on lines 103 to 106
if data.Net.Mask != "" {
m.Net.Address = "--ipv4=" + data.Net.IP + "/24"
m.Net.Gateway = "--ipv4-gateway=" + data.Net.Gateway
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this as a comment to explain the cli argument construction? It is useful information.

Comment thread pkg/unikontainers/config.go Outdated
annotBlock = "com.urunc.unikernel.block"
annotBlockMntPoint = "com.urunc.unikernel.blkMntPoint"
annotMountRootfs = "com.urunc.unikernel.mountRootfs"
annotNetDev = "com.urunc.unikernel.netDev"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is Solo5 specific, I would suggest to add a Solo5 prefix (e.g. Solo5NetDevName).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefixed the Go identifiers as suggested. I'm assuming you want the annotation key to stay as com.urunc.unikernel.netDev?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I meant the annotation key to have a prefix

Comment thread pkg/unikontainers/config.go Outdated
Block string `json:"com.urunc.unikernel.block,omitempty"`
BlkMntPoint string `json:"com.urunc.unikernel.blkMntPoint,omitempty"`
MountRootfs string `json:"com.urunc.unikernel.mountRootfs"`
NetDev string `json:"com.urunc.unikernel.netDev,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmainas

cmainas commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Hello @pocopepe ,

just for clarification, I meant that we need to prefix the annotation key and not the struct filed name with the Solo5 prefix.

@pocopepe
pocopepe force-pushed the fix/315-mirage-net-annotation branch from a6eebad to 06d5ae1 Compare July 13, 2026 15:05
@pocopepe

Copy link
Copy Markdown
Contributor Author

Hey @cmainas , sorry about the delay. I've pushed the latest changes per requirement, and fixed it accordingly on my block devices pr as well

@cmainas

cmainas commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Hello @pocopepe ,

thank you for the changes. Everything looks good. Can you rebase over main and squash the commits so we can merge this?

I have also tested it adding the annotation in harbor.nbfc.io/nubificus/urunc/net-spt-mirage:latest and it worked well (failed to execute, but that was the intend). In the meantime, I will try to create a mirage unikernel with a different name for the network device.

@pocopepe
pocopepe force-pushed the fix/315-mirage-net-annotation branch from 06d5ae1 to b6a0087 Compare July 23, 2026 15:04
@cmainas

cmainas commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Hello @pocopepe ,

I forgot to mention that you should add yourself in https://github.com/urunc-dev/urunc/blob/main/.github/contributors.yaml

pocopepe added 2 commits July 24, 2026 10:42
Ref: urunc-dev#315
Signed-off-by: viju <avijusanjai@gmail.com>
Signed-off-by: viju <avijusanjai@gmail.com>
@pocopepe
pocopepe force-pushed the fix/315-mirage-net-annotation branch from b6a0087 to 1fd8c85 Compare July 24, 2026 06:14
@pocopepe

Copy link
Copy Markdown
Contributor Author

Hi @cmainas,
done, added myself to the list and did a little testing of my own locally, ran it end to end and worked as expected. oh and i fixed the spell check error and applied the same over to block devices (#753), both're rebased up to main. I could get started on the 3rd task of multiple devices once these two are merged.

@urunc-bot
urunc-bot Bot changed the base branch from main to main-pr690 July 24, 2026 07:04

@cmainas cmainas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pocopepe for all the changes and the PR.

annotBlock: "block1",
annotBlockMntPoint: "point1",
annotMountRootfs: "true",
annotNetDev: "management",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to understand why this was changed. But all good!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean in that way, using that word.

@cmainas
cmainas merged commit 871d6f3 into urunc-dev:main-pr690 Jul 24, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple block and network devices over Solo5/MirageOS

3 participants