# Trying to test the FreeBSD waters on a QEMU/KVM VM on a Linux host, however I can't seem to get FreeBSD to work in regards to networking (12.2 STABLE)



## Sol33t303 (Apr 14, 2021)

So I'm running a QEMU/KVM VM to test out FreeBSD using Libvirt. It's so far been quite troublesome, first I was having issues with FreeBSD not recognizing virtio-devices (worked around this by on the host setting the chipset from "pc-q35-5.6" to "pc-q35-2.6", but I believe this is a separate issue, also btw does anybody know how I would setup virtio-gpu/virgl drivers for FreeBSD?) and now both on the installed system and the installer the networking does not appear to work. The virtio networking device is (now, after doing the previous issues workaround) detected fine, however it can't seem to get an IP from my host.

On my host I have all my VMs configured to connect to a network bridge that libvirt provides, the IP of the bridge is 192.168.122.1, and libvirt provides IPs to VMs via DNSmasq, I don't belive there is any issues in my host/VM configuration as I can attach a ubuntu VM disk image to the FreeBSD VM and boot it, and Ubuntu can connect to my network bridge with no issues, here is a screenshot of me running dhclient with Ubuntu booted on the VM:





And here is the equivalent command when the VM is booted into FreeBSD:




Here is also some output of "/etc/rc.d/netif start" (Don't what to do about ifconfig talking about requiring a netmask argument, tried to find some configuration file somewhere to give that info but couldn't find where I would need to put that):




If anymore info is need feel free to ask, like I said I'm not very experienced when it comes to the BSDs, but I have some good Linux experiance.


----------



## SirDice (Apr 14, 2021)

First things first as I feel you likely misunderstood the -STABLE moniker as most new users do. -STABLE is a development version. For normal, regular usage you should use one of the -RELEASE versions. The stable in -STABLE refers to the API/ABI, not its fitness to run. The -RELEASE versions can be easily updated or upgraded using freebsd-update(8). A -STABLE version can only be updated/upgraded by building from source.




Sol33t303 said:


> Here is also some output of "/etc/rc.d/netif start" (Don't what to do about ifconfig talking about requiring a netmask argument, tried to find some configuration file somewhere to give that info but couldn't find where I would need to put that):


On FreeBSD almost everything is enabled or configured through /etc/rc.conf. This is basically a shell script that only has variables in it. Post that /etc/rc.conf. And please don't post pictures of text, they're impossible to copy/paste or quote from.


----------



## Sol33t303 (Apr 14, 2021)

SirDice said:


> First things first as I feel you likely misunderstood the -STABLE moniker as most new users do. -STABLE is a development version. For normal, regular usage you should use one of the -RELEASE versions. The stable in -STABLE refers to the API/ABI, not its fitness to run. The -RELEASE versions can be easily updated or upgraded using freebsd-update(8). A -STABLE version can only be updated/upgraded by building from source.
> 
> 
> 
> On FreeBSD almost everything is enabled or configured through /etc/rc.conf. This is basically a shell script that only has variables in it. Post that /etc/rc.conf. And please don't post pictures of text, they're impossible to copy/paste or quote from.


Ah thanks for letting me know about STABLE vs  RELEASE, I'm only just experimenting with FreeBSD at the moment, but if I choose to use it further I'll be sure to install a STABLE RELEASE release instead.

And sorry about the images, since this is all occurring within VMs I don't think it's possible to copy text out of it to past here. In those cases I have used pastebin to upload logs/command output, however given that networking is not working in the VM thats not an option. I'll try to hand type out everything I can in this case.

And also thanks for letting me know about the /etc/rc.conf, here is its contents:

```
hostname="Laptop-VM-FreeBSD"
ifconfig_vtnet0="inet netmask "
defaultrouter=""
local_unbound_enable="YES"
sshd_enable="YES"
ntpdate_enable="YES"
dumpdev="YES"
zfs_enable="YES"
```


----------



## Jose (Apr 14, 2021)

Try `ifconfig_vtnet0="DHCP"`


----------



## SirDice (Apr 14, 2021)

Sol33t303 said:


> ```
> ifconfig_vtnet0="inet netmask "
> ```


That's your error. You likely want to use DHCP here so change it to:

```
ifconfig_vtnet0="DHCP"
```
Or, if you want to use a static address:

```
ifconfig_vtnet0="inet 192.168.x.x netmask 255.255.255.0"
defaultrouter="192.168.x.1"
```
Also don't forget to configure /etc/resolv.conf if you use static addresses.


----------



## BjarneB (Apr 14, 2021)

On FreeBSD 12.2 you are better off using chipset i440FX. Q35 is not really working until FreeBSD 13.  As you allready discovered vtnet is not working probably.  Been there - done that.


----------



## harajukakei (Apr 15, 2021)

I'm currently upgraded my 12.2 VM to 13. But still, cant get Q35 working for this. The VM boot, but it hangs up indefinitely at "promiscious mode enabled". Already try to change the NIC to e1000, but still same problem. VM work fine in i440fx with virtio-scsi and virtio networking. I'm using oVirt 4.4.5. Anybody having this problem ?


----------



## BjarneB (Apr 15, 2021)

Hm - default install FreeBSD 13 uefi, chipset q35 on kvm, I have no issues. 
This is from my kvm config:

```
<os>
    <type arch='x86_64' machine='pc-q35-4.2'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x86_64-4m-code.bin</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/bsd-uefi-ufs-q35_VARS.fd</nvram>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
```

The only problem I have, is that I can't figure out how to get the new nice graphics in uefi mode to work.


----------



## SirDice (Apr 15, 2021)

BjarneB said:


> I can't figure out how to get the new nice graphics in uefi mode to work.


Try adding this to /boot/loader.conf:

```
hw.vga.textmode="0"
```
Or set a graphics resolution:

```
efi_max_resolution="1024x768"
vbe_max_resolution="1024x768"
```
You'll need to set it to 1024x768 or higher for the graphics to show up.


----------



## BjarneB (Apr 15, 2021)

Thanks, yes I allready tried that.

I have this in loader.conf.local:

```
hw.vga.textmode="0"
vbe_max_resolution="720p"
efi_max_resolution="720p"
```

Booting with bios, it show the nice graphic logo, booting the exact same server with uefi, no matter which chipset I select, text chareacters only.
Well, at least now i have read through all of defaults/loader.conf.
Small thing, just annoying, maybe it is a kvm thing.


----------



## SirDice (Apr 15, 2021)

Maybe it's a copy/paste error but you have `w.vga.textmode="0"` instead of `hw.vga.textmode="0"`.


----------



## BjarneB (Apr 15, 2021)

ah - you are rigth, copy/paste error
fixed
thanks


----------



## Sol33t303 (Apr 16, 2021)

Jose said:


> Try `ifconfig_vtnet0="DHCP"`





SirDice said:


> That's your error. You likely want to use DHCP here so change it to:
> 
> ```
> ifconfig_vtnet0="DHCP"
> ...


Thank you both, sorry for the late reply, been too busy over the last few days to return to the VM. I set ifconfig_vtnet0 to DHCP and now it all appears to be working fine, thanks for the help, good to know it was a simple fix, I was thinking it might have been something more complex 

Still quite strange however that invoking a dhcp client manually did not work. I assume with that option set to DHCP FreeBSD just autostarts a dhcp client on the interface right? Don't see any reason for invoking it manually to fail in that case, or is there more at play when I set that option in rc.conf?


----------



## SirDice (Apr 16, 2021)

Sol33t303 said:


> I assume with that option set to DHCP FreeBSD just autostarts a dhcp client on the interface right?


Correct. Make sure to remove that empty `defaultrouter` if you use DHCP. The default gateway gets set by DHCP of course, having it set in rc.conf would only add confusion. 



Sol33t303 said:


> Don't see any reason for invoking it manually to fail in that case, or is there more at play when I set that option in rc.conf?


Maybe the interface was in some weird state due to the error. But, yeah, odd, it should have worked.


----------



## harajukakei (Apr 17, 2021)

BjarneB said:


> Hm - default install FreeBSD 13 uefi, chipset q35 on kvm, I have no issues.
> This is from my kvm config:
> 
> ```
> ...


I don't have this machine type on oVirt. only pc-q35-rhelxxxx . Already tried to change it manually but it doesnt work. Any idea about pc-q35-4.2 equivalent in oVirt ? Another finding, same issue. The installer wont detect any disk if i use virtio disk and virtio networking same as 12.2  Don't know whats wrong.


----------



## BjarneB (Apr 17, 2021)

I am sorry, I can't offer much help. My knowledge on libvirt/qemu is not that deep. Maybe the following offers some help:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236922
I am using OpenSuse leap 15.2 as kvm host, with these versions:


```
Name           : qemu
Version        : 4.2.1-lp152.9.9.2

libvrirt:
Name           : libvirt
Version        : 6.0.0-lp152.9.6.2
```

As, I mentioned, vtnet do not work on freebsd 12.2 on chipset q35, whereas it works fine with freebsd13 - in this setup.
Since you say this is for testing out FreeBSD on kvm, I would suggest to stick with chipset i440fx for now and then swich over when q35 is better supported.


----------

