Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a network adapter based on guest os and hypervisor cpu architecture #260

Open
der-eismann opened this issue Nov 14, 2024 · 4 comments
Open
Assignees
Milestone

Comments

@der-eismann
Copy link

der-eismann commented Nov 14, 2024

Overview of the Issue

I thought I was going crazy. I tried to create a box with Fedora 40 and most settings on default, however it always had a kernel panic when booting. But when I create the VM via the GUI it worked fine. I tried to find the issue for ~30 mins until I saw that this plugin used the e1000 network adapter as default while the GUI used e1000e as default.
IMHO e1000e should be the default because as VMware says

Emulated version of the Intel 82574 Gigabit Ethernet NIC. E1000E is the default adapter for Windows 8 and Windows Server 2012.

Both OSes were released over 10 years ago and are not even supported anymore. Using a default that may not even work on modern systems is not good.
But if we don't want to change the default, at least mention e1000e in the docs.

Reproduction Steps

  1. Execute packer build

Plugin and Packer version

packer 1.11.2 & plugin 1.1.0

Simplified Packer Buildfile

source "vmware-iso" "fedora-vmware-arm64" {
  guest_os_type    = "arm-fedora-64"
  version          = 21
  iso_checksum     = "690731ac6abba81413d97517baa80841cb122d07b296ec3f2935848be45be8fe"
  iso_url          = "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/aarch64/iso/Fedora-Server-netinst-aarch64-40-1.14.iso"
  usb              = true
  vmx_data = {
    "usb_xhci.present" = "true"
  }
  cdrom_adapter_type = "sata"
  disk_adapter_type  = "nvme"
  # try with and without the next line
  # network_adapter_type = "e1000e"
}

Operating system and Environment details

macOS 15.1 as host with VMware Fusion 13.6.1 and Fedora 40 as guest

Log Fragments and crash.log files

None

@tenthirtyam tenthirtyam self-assigned this Nov 14, 2024
@tenthirtyam tenthirtyam added this to the v1.1.1 milestone Nov 14, 2024
@tenthirtyam
Copy link
Collaborator

tenthirtyam commented Nov 24, 2024

Based on a cursory review of this issue, it's may be best to either:

A. Remove the default selection and instead require this be selected from a list of supported options, which would be a breaking change.

B. Automatically select, if not provided, from a map of supported operating systems and their default network adapter selection with a default fallback if by chance not listed.

I'm leaning towards Option A.

Ryan Johnson
Distinguished Engineer, VMware by Broadcom

@tenthirtyam
Copy link
Collaborator

tenthirtyam commented Dec 9, 2024

re: Option B, for example, maybe something like this:

var networkAdapterMap map[string]string
var defaultAdapterType string

if runtime.GOARCH == "arm64" {
    networkAdapterMap = map[string]string{
        // Linux
        "alma":       "e1000e",
        "centos":     "e1000e",
        "debian":     "e1000e",
        "fedora":     "e1000e",
        "photon":     "vmxnet3",
        "rhel":       "e1000e",
        "rocky":      "e1000e",
        "ubuntu":     "e1000e",
        "other":      "e1000e",
        // Windows
        "windows":    "vmxnet3",
    }
    defaultAdapterType = "e1000e"
} else {
    networkAdapterMap = map[string]string{
        // Linux
        "alma":       "vmxnet3",
        "debian":     "e1000",
        "fedora":     "vmxnet3",
        "photon":     "vmxnet3",
        "rhel":       "vmxnet3",
        "rocky":      "vmxnet3",
        "ubuntu":     "e1000",
        "other":      "vmxnet3",
        // Windows
        "windows":    "vmxnet3",
    }
    defaultAdapterType = "vmxnet3"
}

adapterType := defaultAdapterType
guestOSTypeLower := strings.ToLower(config.GuestOSType)

for osType, adapter := range networkAdapterMap {
    if strings.Contains(guestOSTypeLower, osType) {
        adapterType = adapter
        break
    }
}

templateData.Network_Adapter = adapterType

This would get rather tedious to manage with upstream changed though.

Thoughts @lbajolet-hashicorp?

@tenthirtyam
Copy link
Collaborator

@der-eismann After taking another look at this on both Intel and Apple Silicon, this also dictates the adapter used by default.

For example, using Fedora 64-bit:

  • Intel: Default is vmxnet3.
  • Apple Silicon: Default is e1000e.

Therefore the selection must consider the CPU architecture.

Lucas and I will need to determine if we should include the ability to select the appropriate network adapter type (similar to above) or remove the default and require an input.

@tenthirtyam tenthirtyam changed the title Mention e1000e network adapter and use as default Select a network adapter based on guest os and hypervisor cpu architecture Dec 10, 2024
@tenthirtyam
Copy link
Collaborator

tenthirtyam commented Dec 10, 2024

Updated the issue from "Mention e1000e network adapter and use as default` to "Use a network adapter based on guest os and hypervisor cpu architecture".

@tenthirtyam tenthirtyam changed the title Select a network adapter based on guest os and hypervisor cpu architecture Use a network adapter based on guest os and hypervisor cpu architecture Dec 10, 2024
@tenthirtyam tenthirtyam modified the milestones: v1.1.1, v2.0.0 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants