hashicorp / packer-plugin-qemu

Packer plugin for QEMU Builder
https://www.packer.io/docs/builders/qemu
Mozilla Public License 2.0
59 stars 42 forks source link

Add ability to set MAC address of adapter #69

Open Antoine-Gicquel opened 2 years ago

Antoine-Gicquel commented 2 years ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

It would be nice to make use of qemu's ability to set the mac address of a netdev. I think it would involve adding parameters in builder/qemu/step_run.go, and should be pretty straightforward. I currently am not skilled enough in Go / not familiar enough with the internals of Packer to feel confident about implementing this feature myself, but I would be pleased to help or to be guided at low level (like telling me which files to change precisely etc).

Use Case(s)

I would need it in order to control which IP address is given to the guest VM on a bridge (using dnsmasq for DHCP).

Potential configuration

source "qemu" "example" {
...
net_bridge = "virbr0"
net_mac = "00:00:00:00:00:00"
...
}

Potential References

Qemu documentation on setting a mac address with -netdev and -device ?

Antoine-Gicquel commented 2 years ago

For now, I found a hacky workaround, setting net_device like so : net_device = "virtio-net,mac=00:00:00:00:00:00"

It uses builder/qemu/step_run.go, line 252, to inject the argument in the qemu-system command.