bhyve Unable to initialize backend 'nmdm0A' for LPC device COM1

Another round,another interesting question :)

I've installed netBSD emulated with Bhyve on FreeBSD. I'm trying to configure a serial console inside the bhyve parameters and also inside the boot.cfg config file of netBSD because I need to read the early boot messages printed by NetBSD. I am not sure how bhyve keeps logs. Xorg logs are fine but at the point that the OS have already booted and it can save to files. Before the system comes up, while it is booting, the system prints logs to the console. At that point it has no filesystem access. If the kernel crashes (and this is what I suspect,that the NetBSD kernel crashes on that point) while booting I typically get the debugger prompt on the console, or it reboots again. Unfortunately when the graphics driver kicks in, the screen blanks. So if the kernel crashes then, I don't see what happened. If I will be able to tell the kernel to boot from the serial console, then all the output will be directed there (and the debugger prompt). What I would like to do is to get the kernel use the serial console for input and output while booting so that I can see what happens when the screen blanks. Below you can see how I have configured bhyve to boot NetBSD from its phisycal installation :


Code:
bhyve -S -c 8 -m 8G -w -H \

-s 0,hostbridge \

-s 1,virtio-blk,/dev/ada1 \

-s 6,virtio-net,tap0 \

-s 29,fbuf,tcp=`[`0.0.0.0:5900`](https://0.0.0.0:5900)`,w=800,h=600 \

-s 30,xhci,tablet \

-s 31,lpc \

-l com1,nmdm0A \

-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \

vm0



as u can see,on the bhyve side I've added the parameter : "-l com1,nmdm0A" and on NetBSD side,I've added the same parameter on the file boot.cfg :



consdev com1 ;


when I run the VM with the command below :


Code:
root@marietto:/home/marietto/Desktop/Files/bhyve # kldstat


Id Refs Address                Size Name
1  108 0xffffffff80200000  1f11f28 kernel
---->  2    1 0xffffffff82112000     4110 nmdm.ko


bhyve -S -c 8 -m 8G -w -H \
-s 0,hostbridge \
-s 1,virtio-blk,/dev/ada1 \
-s 6,virtio-net,tap0 \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600 \
-s 30,xhci,tablet \
-s 31,lpc \
----->        -l com1,nmdmA \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
vm0

I get the following error mesage :

Unable to initialize backend 'nmdm0A' for LPC device COM1
device emulation initialization error: No such file or directory
 
You are showing a line break at your -s 31 device.
This is the exact place where you are having problems.
Why is slot 31 on two lines anyway in your config?
I dislike line breaks and jam it all on one line.
Code:
bhyve -S -c 12 -m 32G -A -H -P -u -s 0:0,hostbridge -s 3:0,ahci-hd,/vm/freebsd-vm3.img -s 5:0,passthru,133/0/2 -s 10:0,passthru,12/0/0 -s 11:0,passthru,15/0/0 -s 15:0,passthru,129/0/0 -s 16:0,passthru,129/0/1 -s 31:0,lpc -l com1,/dev/nmdm3A -l bootrom,/vm/BHYVE_UEFI.fd freebsd-vm3 &
 
I see from Reddit that you do in fact have the wrong syntax for slot 31. This is corrected:
Code:
bhyve -S -c 8 -m 8G -w -H \
-s 0,hostbridge \
-s 1,virtio-blk,/dev/ada1 \
-s 6,virtio-net,tap0 \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600 \
-s 30,xhci,tablet \
-s 31,lpc -l com1,/dev/nmdm1A \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
vm0

Then use cu to connect from host:
cu -l /dev/nmdm1B
 
-s 31,lpc \ -----> -l com1,nmdmA \
So besides the line break problem you did not add a device node number for the nmdm device.
The system is trying to use nmdm0A and you are passing thru nmdmA. That is wrong.

I like to start my nmdm devices at nmdm1. You can use nmdm0.
 
ok. thanks to everyone. I'm not sure if it worked. on the terminal I see only a bunch of messages,not so much. Almost every boot message is displayed inside the bhyve window. Please give a look at the screenshot that I have attached. This is the bhyve command that I have used :

Code:
bhyve -S -c 8 -m 8G -w -H \
    -s 0,hostbridge \
    -s 1,virtio-blk,/dev/ada1 \
    -s 6,virtio-net,tap0 \
    -s 29,fbuf,tcp=0.0.0.0:5900,w=1440,h=900,wait \
    -s 30,xhci,tablet \
    -s 31,lpc -l com1,/dev/nmdm1A \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    vm0

Then I used cu to connect from host:

Code:
cu -l /dev/nmdm1B

Under /dev I see the nmdm* entries :


Code:
@marietto:/home/marietto # cd /dev

@marietto:/dev # ls nmd*

nmdm1A    nmdm1B
 

Attachments

  • Screenshot_20210925_231430.png
    Screenshot_20210925_231430.png
    668.3 KB · Views: 116
Back
Top