ppggff / vagrant-qemu

Use Vagrant to manage machines using QEMU. Test with Apple Silicon / M1 and CentOS aarch64 image
MIT License
424 stars 33 forks source link

Issue with virtio-net-device when using x86_64 arch #1

Closed cpats007 closed 2 years ago

cpats007 commented 2 years ago

Hi

I'm trying to find a good way to get Vagrant working with an M1 Mac and came across your plugin, which I thought could be the answer. I've managed to get past a few stumbling blocks, but I'm now hitting another one with the network configuration which I think I have a solution for.

The error I am getting is this:

Stderr: qemu-system-x86_64: -device virtio-net-device,netdev=net0: No 'virtio-bus' bus found for device 'virtio-net-device'

This seems to stem from the fact that when setting up a "PC" machine with x86 architecture the bus isn't loaded / enabled. I've checked in your source code (I'm not really a Ruby dev) and can see that you specify the virtio-net-device as hard coded in there. I have tried running the commands locally, but replacing virtio-net-device with virtio-net-pci and this results in the machine firing up and working.

Not only this but I can also check in vagrant status and the machine shows as running and I can use vagrant ssh to log into it - which is a massive step forward for me ha ha.

I'm going to try and check out the code and see if I can make a few changes and build a new version of the plugin but if not, would it be possible to parametrise the network selection options? I was thinking something like this:

Original:

cmd += %W(-device virtio-net-device,netdev=net0)

New:

cmd += %W(-device #{options[:net_device]},netdev=net0)

and then obviously adding the defaults in:

@net_device = "virtio-net-device" if @net_device == UNSET_VALUE

If I can manage to make the change in a PR then I will but as I said, not really a Ruby dev ha ha (many other languages, just not Ruby)

Great work though if we can get this running !! 👍

ppggff commented 2 years ago

Fisrt issue !!

ppggff commented 2 years ago

Good to know that someone can use it.

I haven't tested the x86 VM yet, and sure enough there is something wrong with it.

I'll think about it over the weekend and add some more configuration to be able to build qemu commands more flexibly.

Help with PR is very welcome, I'm also writing ruby programs for the first time :)

cpats007 commented 2 years ago

Ha ha no problem - I've managed to build in the changes I have suggested and tested it and we have a fully booting VM running CentOS on x86_64 - kind of ;) so the issue I am having now is the guest machine not being able to access the internet through the host. I can ping the host gateway on 10.0.2.2 which is working as expected, but nothing is working in terms of internet access which makes installing and provisioning the guest via Vagrant bootstrap pretty much impossible heh.

Don't suppose you have any ideas of settings to change? I'm currently trying to fire up alternative QEMU images with different net settings to see if any of those will afford me internet connectivity but not looking good so far

update: by default the resolv.conf file notes the nameserver as 10.0.2.3 which doesn't seem to be working - I have managed to change that to 8.8.8.8 in the guest machine, and internet is working - I could try doing this in the Vagrant file which may help, but this seems to be a QEMU issue possibly rather than a plugin issue - so we're still looking good ha ha

ppggff commented 2 years ago

Can you provide the box you are using? I'll test it locally.

cpats007 commented 2 years ago

Sure, at the moment I'm just using the standard centos/7 box

So as of now, I have a script that updates the resolv.conf file when Vagrant is provisioning, and internet access works fine. I'm having issues installing packages but that could be something else although I do think some of it is related, but in general things are starting to work

cpats007 commented 2 years ago

I also just tried to push some changes to a new branch today for the net_device updates but I don't have permissions so I'll leave that with you :) or let me create branches ha ha

ppggff commented 2 years ago

you should make a pull request in the github way: fork, commit to the fork, make pull request between fork and this repo

ppggff commented 2 years ago

@cpats007 Fixed in 0.1.6 with new config 'net_device', and set it to 'virtio-net-pci'. You can update plugin by vagrant plugin update Thanks very much.

cpats007 commented 2 years ago

Hi - no problem - looks pretty much the same as my changes 😃 saw your other message around the way GitHub does PR's also so will fork this out as the new one and do it from there. I'm just trying to get NFS working now also as everything seems to be good with this now, but SMB is very slow - I want to know if it's a problem with the fact that SMB is very slow, or whether it's the applications etc.

I guess we can close this issue now as it has been resolved hah 😄