git: 1a6e0c38d023 - stable/15 - bhyve: fix boot device ordering

From: Roman Bogorodskiy <novel_at_FreeBSD.org>
Date: Mon, 28 Sep 2026 16:01:19 UTC
The branch stable/15 has been updated by novel:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a6e0c38d023f975d6015570b9fc34f09175dc03

commit 1a6e0c38d023f975d6015570b9fc34f09175dc03
Author:     Roman Bogorodskiy <novel@FreeBSD.org>
AuthorDate: 2026-09-20 14:41:55 +0000
Commit:     Roman Bogorodskiy <novel@FreeBSD.org>
CommitDate: 2026-09-28 15:59:17 +0000

    bhyve: fix boot device ordering
    
    EDK2's QemuBootOrderLib inspects the bootorder file provided
    via fw_cfg and requires it to be NUL-terminated. Otherwise,
    it rejects the supplied bootorder and falls back to its
    default boot order.
    
    Currently, bhyve registers bootorder with qemu_fwcfg_add_file()
    using bootorder_len returned by open_memstream(), which excludes
    the trailing NUL byte.
    
    Fix that by passing bootorder_len + 1 to qemu_fwcfg_add_file() so
    the fw_cfg payload is properly NUL-terminated.
    
    PR:             279720
    Reviewed by:    markj
    Found with:     codex (gpt-5.6-sol)
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D59859
    
    (cherry picked from commit b27a221ef79d6d77d6173897f12118e1126453d8)
---
 usr.sbin/bhyve/pci_emul.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index 538e4f284bec..228f797f8a86 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -1512,7 +1512,7 @@ init_bootorder(void)
 	}
 	fclose(fp);
 
-	return (qemu_fwcfg_add_file("bootorder", bootorder_len, bootorder));
+	return (qemu_fwcfg_add_file("bootorder", bootorder_len + 1, bootorder));
 }
 
 #define	BUSIO_ROUNDUP		32