Page MenuHomeFreeBSD

bhyveload: add non-interactive mode
AcceptedPublic

Authored by novel on Thu, Aug 27, 6:06 PM.
Tags
None
Referenced Files
F168476565: D59226.id185231.diff
Fri, Aug 28, 2:23 PM
F168469336: D59226.diff
Fri, Aug 28, 1:36 PM
Unknown Object (File)
Thu, Aug 27, 6:42 PM
Unknown Object (File)
Thu, Aug 27, 6:37 PM

Details

Reviewers
ziaee
Group Reviewers
bhyve
manpages
Summary

Currently, when bhyveload(8) fails to boot the guest,
it drops into the loader prompt waiting for user input.

This behaviour is inconvenient when using bhyveload(8) from
scripts.

Address by adding the '-n' option to enable non-interactive mode.
When enabled, bhyveload(8) will exit with code 1 if the
loader requests user input.

PR: 286289

Test Plan

Invalid image, default (interactive mode):

# bhyveload -m 2024 -d ./fake.img test                                                                                                                                                                                                                                                                                 
Consoles: userboot                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                       
FreeBSD/amd64 User boot lua, Revision 3.0                                                                                                                                                                                                                                                                              
(Thu Aug 27 10:40:55 UTC 2026 root@freebsd14)                                                                                                                                                                                                                                                                          
ERROR: cannot open /boot/lua/loader.lua: no such file or directory.                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                       
Type '?' for a list of commands, 'help' for more detailed help.                                                                                                                                                                                                                                                        
OK quit                                                                                                                                                                                                                                                                                                                
#

Invalid image, non-interactive mode:

# bhyveload -m 2024 -n -d ./fake.img test                                                                                                                                                                                                                                                                              
Consoles: userboot                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                       
FreeBSD/amd64 User boot lua, Revision 3.0                                                                                                                                                                                                                                                                              
(Thu Aug 27 10:40:55 UTC 2026 root@freebsd14)                                                                                                                                                                                                                                                                          
ERROR: cannot open /boot/lua/loader.lua: no such file or directory.                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                       
Type '?' for a list of commands, 'help' for more detailed help.                                                                                                                                                                                                                                                        
OK bhyveload: user input requested in non-interactive mode                                                                                                                                                                                                                                                             
                                                          #                                                                                                                                                                                                                                                            
#                                                                                                                                                                                                                                                                                                                      
# echo $?                                                                                                                                                                                                                                                                                                              
1                                                                                                                                                                                                                                                                                                                      
#

Valid image, non-interactive mode:

# bhyveload -m 2024 -n -d ./FreeBSD-14.3-RELEASE-amd64-ufs.raw  test
Consoles: userboot  

FreeBSD/amd64 User boot lua, Revision 3.0
(Thu Aug 27 10:40:55 UTC 2026 root@freebsd14)
Loading /boot/defaults/loader.conf
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
/
\
|  ______               ____   _____ _____  
  |  ____|             |  _ \ / ____|  __ \ 
  | |___ _ __ ___  ___ | |_) | (___ | |  | |
  |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
  | |   | | |  __/  __/| |_) |____) | |__| |
  | |   | | |    |    ||     |      |      |
  |_|   |_|  \___|\___||____/|_____/|_____/      ```                        `
                                                s` `.....---.......--.```   -/
 +---------- Welcome to FreeBSD -----------+    +o   .--`         /y:`      +.
 |                                         |     yo`:.            :o      `+-
 |  1. Boot Multi user [Enter]             |      y/               -/`   -o/
 |  2. Boot Single user                    |     .-                  ::/sy+:.
 |  3. Escape to loader prompt             |     /                     `--  /
 |  4. Reboot                              |    `:                          :`
 |  5. Cons: Serial                        |    `:                          :`
 |                                         |     /                          /
 |  Options:                               |     .-                        -.
 |  6. Kernel: default/kernel (1 of 1)     |      --                      -.
 |  7. Boot Options                        |       `:`                  `:`
 |                                         |         .--             `--.
 |                                         |            .---.....----.
 |                                         |
 +-----------------------------------------+
   Autoboot in 0 seconds. [Space] to pause  
Loading kernel...
/boot/kernel/kernel text=0x180078 text=0xd97948 text=0x43a46b data=0x180+0xe80 data=0x187590+0x478a70 0x8+0x18e940+0x8+0x1b2b03
Loading configured modules...
/etc/hostid size=0x25
/boot/entropy size=0x1000
# echo $?
0
#

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76281
Build 73164: arc lint + arc unit

Event Timeline

novel requested review of this revision.Thu, Aug 27, 6:06 PM

Does running bhyveload ... </dev/null not provide the desired behaviour?

ziaee added inline comments.
usr.sbin/bhyveload/bhyveload.8
133–134

Please move this after line 122 for alphabetical sorting.

Does running bhyveload ... </dev/null not provide the desired behaviour?

# bhyveload -m 2024 -d ./fake.img test </dev/null drops me into the loader prompt, but I cannot type anything in.
In the PR I have also tested -c /dev/null which does not help too.

Fix option order in the manpage.

manpage LGTM, no comment on implementation or if we should do this.

This revision is now accepted and ready to land.Fri, Aug 28, 7:14 PM