Default NIC model_type virtio is not being setted when attach new NIC to the VM
Description
When you instantiate a new VM with a given number of NICs or just one, and you dont specify the model type, Opennebula is configured to set by default to use virtio. This works when the VM is instantiated, but not when you add NICs after being instantiated, without specify the emulated model type of the NIC, which should relay on the default driver (virtio). Instead of this, the new NIC is configured for driver RTL-8100/8101L/8139 PCI fast Ethernet Adapter (rev 20), in other words, Realtek.
Issue confirmed for OpenNebula clusters running in 6.8.1 and 6.8.2.
To Reproduce
Create a new VM. After created, add a new NIC Verify the PCI devices on the VM with lspci.
Expected behavior Added a new NIC using virtio driver, as configured by default.
Details
- Affected Component: [Network]
- Hypervisor: [KVM]
- Version: [6.6.x, 6.8.x]
Additional context Add any other context about the problem here.
Progress Status
- [ ] Code committed
- [ ] Testing - QA
- [ ] Documentation (Release notes - resolved issues, compatibility, known issues)
Hi @Franco-Sparrow ,
I have found something curious:
https://github.com/OpenNebula/one/blob/1e23efbd622fe2e61bc63e143898e5b12c9e773b/src/vmm_mad/remotes/kvm/attach_nic#L55-L66
In the line 61 of the previews code, the environment loaded is the local one, but I assume that this action must run in the host, so I believe that the function that needs to called is the load_remote_env.
I will do some test and i will back to you! PD: This is not commonly used because only apply for day2 operations!
Thanks @nachowork90 🥇 I tested your configuration and it works now!!!
Hi @rsmontero, this is a confirmed issue that is present since 6.6.x. Please, give it a chance to this, we have verified on clusters using 6.6.3, 6.8.1 and 6.8.2.
PS: BTW, your commit when changing this file from bash to ruby is beautifull :)
Regards
I just encountered the same error related to model name of NIC on the same ON version as mentioned by the OP. In my case, the issue is intermittent. I encountered the error while instantiating Windows VM, where it would not boot with a NIC attached when NIC = "virtio" attribute is added to the template. The VM logs throws Model name has invalid characters error causing BOOT_FAILURE state. Removing the attribute from template works and the VM boots fine.
I'll try out your fix @nachowork90 and give feedback here. Thanks
Also, thank you @Franco-Sparrow for the bug report and @rsmontero for adding fix to next release.
So @Franco-Sparrow, changing to load_remote_env fixed for you?
Hi Sir @rsmontero
Yes, in my case I havent faced the issue that @ibrahimkahn explained, only when adding new nics and @nachowork90 's patch fixed the problem.
Thanks, fix is now merge. In the meantime @ibrahimkahn you can apply the patch manually to /var/lib/one/remotes/vmm/kvm/attach_nic and do a onehost forceupdate to propagate the changes.