OpenNebula / one

The open source Cloud & Edge Computing Platform bringing real freedom to your Enterprise Cloud 🚀
http://opennebula.io
Apache License 2.0
1.19k stars 472 forks source link

Default NIC model_type virtio is not being setted when attach new NIC to the VM #6575

Closed Franco-Sparrow closed 1 month ago

Franco-Sparrow commented 2 months ago

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.

WhatsApp Image 2024-04-27 at 10 46 56 PM

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

Additional context Add any other context about the problem here.

Progress Status

nachowork90 commented 2 months ago

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!

Franco-Sparrow commented 2 months ago

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

ibrahimkahn commented 1 month ago

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.

rsmontero commented 1 month ago

So @Franco-Sparrow, changing to load_remote_env fixed for you?

Franco-Sparrow commented 1 month ago

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.

rsmontero commented 1 month ago

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.