]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: command: handle arm64 bootloader
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 22 Dec 2025 18:07:35 +0000 (19:07 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Wed, 7 Jan 2026 20:00:44 +0000 (21:00 +0100)
Just like consoles, bootloader is handled differently on arm64.
It also does not used the LPC bus, and is configured with:

 -o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin

Additionally, fill firmware inforamtion only for amd64.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_command.c
src/bhyve/bhyve_firmware.c
tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.args [new file with mode: 0644]
tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c

index bf9db963a12dab28a26947f1d427918c1327faa5..a45a5d1c3322463328d79e777e5d977b813b4d1a 100644 (file)
@@ -1002,17 +1002,24 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver, virDomainDef *def,
 
     if (def->os.bootloader == NULL &&
         def->os.loader) {
-        if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM)) {
+        virArch arch = def->os.arch;
             g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-            virBufferAsprintf(&buf, "bootrom,%s", def->os.loader->path);
-            if (def->os.loader->nvram && def->os.loader->nvram->path)
-                virBufferAsprintf(&buf, ",%s", def->os.loader->nvram->path);
 
-            virCommandAddArgList(cmd, "-l", virBufferContentAndReset(&buf), NULL);
-        } else {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Installed bhyve binary does not support UEFI loader"));
-            return NULL;
+        if (ARCH_IS_X86(arch)) {
+            if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM)) {
+                virBufferAsprintf(&buf, "bootrom,%s", def->os.loader->path);
+                if (def->os.loader->nvram && def->os.loader->nvram->path)
+                    virBufferAsprintf(&buf, ",%s", def->os.loader->nvram->path);
+
+                virCommandAddArgList(cmd, "-l", virBufferContentAndReset(&buf), NULL);
+            } else {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("Installed bhyve binary does not support UEFI loader"));
+                return NULL;
+            }
+        } else if (ARCH_IS_ARM(arch)) {
+            virBufferAsprintf(&buf, "bootrom=%s", def->os.loader->path);
+            virCommandAddArgList(cmd, "-o", virBufferContentAndReset(&buf), NULL);
         }
     }
 
index 57ad0031b0336fd57401945908044b1db6bd11f6..54e3ce296a5e81fa916653245bd684d54d897786 100644 (file)
@@ -125,6 +125,9 @@ bhyveFirmwareFillDomain(bhyveConn *driver,
 
     virCheckFlags(0, -1);
 
+    if (!ARCH_IS_X86(def->os.arch))
+        return 0;
+
     if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE)
         goto out;
 
diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.args b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.args
new file mode 100644 (file)
index 0000000..a07e70d
--- /dev/null
@@ -0,0 +1,9 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-s 0:0,hostbridge \
+-o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
+-s 2:0,virtio-blk,/tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.ldargs b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.ldargs
new file mode 100644 (file)
index 0000000..421376d
--- /dev/null
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.xml b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-bootloader.xml
new file mode 100644 (file)
index 0000000..6e1123e
--- /dev/null
@@ -0,0 +1,24 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+    <loader readonly='yes'>/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin</loader>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='52:54:00:b9:94:02'/>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+  </devices>
+</domain>
index 78e263865831879ab689af364377af12d717ab05..47b2726b14e9fbf88f002c9b846c066fc0ce065b 100644 (file)
@@ -336,6 +336,7 @@ mymain(void)
 
     DO_TEST("base");
     DO_TEST("console");
+    DO_TEST("bootloader");
 
     virObjectUnref(driver.caps);
     virObjectUnref(driver.xmlopt);