From nobody Mon Feb 2 07:30:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1769620446; cv=none; d=zohomail.com; s=zohoarc; b=h7xeqcHSo5A9e0AwvM9c9pbxVHN8ALz0oLbw4ebg+1OstBQCcnxrv3yX4pOScseLKe8IPpOCaKAjKRwSZxbBxgtpLdgHPNY6Am+IL9gkcZZgItjjXGdlMnhFwVhYqH61bEFhrqlfydmqkvsHDqw4cm/IJ7tbAo7M9hM8/fRE1hA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769620446; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=AoyNMPrhM0F68pf7EQ1XLVySw5XX8vhMVBrbLgkM5vs=; b=YV4sxDUhbsaHZ09opJ5uneFI6stqnyZ8X+ngJQ+aYDb7XBFxXvQqZGMN8vwuXu/a+zg2DCVl7x+PDZmf0YtVCvc+NYn6WbOvjlA7eoeGw/id0JOyzP/UbTtsdnSoDuxQjYobSQyidfAzD50aQmODboWMbgIhIi29qUkWHomSOSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 176962044647568.51705699675995; Wed, 28 Jan 2026 09:14:06 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 2885541AC5; Wed, 28 Jan 2026 12:14:06 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 55DAB41C8E; Wed, 28 Jan 2026 12:12:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id D8EEE418A8; Wed, 28 Jan 2026 12:12:08 -0500 (EST) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4DC164189D for ; Wed, 28 Jan 2026 12:12:08 -0500 (EST) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b79f8f7ea43so10819166b.2 for ; Wed, 28 Jan 2026 09:12:08 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-c218-03ff-feb5-6cc4.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:c218:3ff:feb5:6cc4]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8dbf1baa42sm150216266b.46.2026.01.28.09.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 09:12:04 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769620326; x=1770225126; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AoyNMPrhM0F68pf7EQ1XLVySw5XX8vhMVBrbLgkM5vs=; b=DtOC0O9iEiRc1z65g9i46bqa9PSBUAPUFDYqr3mhRTnfVUsOK5RHANA42M6Foc2QQl +trXrRQPWQrtj6SZZ/ZLX7nCnutTQZA9bDrfgN514mrIDno3vQMus84ZUsu0Jg4DibtD pHSWD1YdmfeSonKeS/nV5E3S2UDtCLGLUWv0OU0uY0IrgJdG6th59ZTsa6kivgZgaQvK mOgZBaLUL0Mf5QKVcKbC+WK6Zy360p6JiyNueCC6iTHnPGNMMXEaRtAPXew5iQQvZqfL 43RtJean9vdT9lNo0f/O49yQos+GJ35/v8Ejkeyoz0WnSg1NlHTOrieyLTf2qX2WpJfB qJyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769620326; x=1770225126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AoyNMPrhM0F68pf7EQ1XLVySw5XX8vhMVBrbLgkM5vs=; b=eKBq8ewSX/PQQhS1irctCIkmUgvC26O27JDUdkvOfGb3gcRbxMYsRNNWz7y1m8AJh2 ovWHs0RYwnOPkzUep+0emq1/tRoDBrap1kWjA+c06X6DR+lNkMNtTMObFKdgDWZhcjc5 QXXO+Rnd3MsJdM587a0wKhGH2O16r50pzz2KqffOX67HwdYG38yLQER+xhoIiIScEPfD OZOh1h/Axpoy9lZnZ6I6XZLQpIf+WmIIUcdCE+MN4r3u5w4+7P8zAcOZzR5sJjzpf5u7 MnalGk9W/DKBECwTU5PAU9Z1TMAiti3qU6xTGxnkGrVZmyONWjNryioxkxWlEyraHbuY B59A== X-Gm-Message-State: AOJu0Ywl9jSWzaGiZ4L2w26MhZDIYJjHfyKuUv3qPYfzd2LBWYlZkC4M qqlCP7Lu/e97iPmAZUICn20/CtwZ5chlGsEHoLlwfefPEYqokcvY/Y3AeaScg3Xn X-Gm-Gg: AZuq6aJSHSr7b2dpglS+moKm9PJxPi+0BCgaN94xPfYcZ8hUe3WcrKrwIRkwG7fcZzs dUZ9d0fCS5a5NOBWhBVPeNzR6oueGsgSmjiQIl95ZBhfH3PXeScCSDSjw/XMboY2xi2SJ43YiP8 FRhjCcNeTc9ZHnFyhPqftFN4CKuU/UzMh0GlS/HBv8S1L1gVmJNCA1vX/WZ7CjIyZxE+7bS8TUo Pqjk3acBdD3V9LgPITvsownVEJ/JdfPGOY7y/QSN9zfSNGE2mlfPmoiRsbrwnlZ62NaSJqGCy8K eniDfU7/ThYnZSFWpsJX4EPaTLeeIryIncCpq/3kbhsdfvXaeY/uKzBPBxNjs2q6HEdEiciDTxS oNMWaAnFHPyXV+tvIEX1vj9SrnTFfF6k6jgLpAvhE3xyX1+V0a82Ntpm1pzxD8aPjkDlaBIYMKE WcC77DfrfNrOlZwqyMgR9OFEfrzf/rcPIOVcDLOtlK45+/7yxGjpYEXBVtoSlL9Z5bnabcFaVbc PIo1xelkzcil/2+oRKW0AwR X-Received: by 2002:a17:907:1c95:b0:b87:6f58:a845 with SMTP id a640c23a62f3a-b8dab330a3amr447035966b.36.1769620325840; Wed, 28 Jan 2026 09:12:05 -0800 (PST) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH v2 1/2] bhyve: improve loader handling on arm64 Date: Wed, 28 Jan 2026 18:11:41 +0100 Message-ID: <20260128171142.31492-2-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128171142.31492-1-bogorodskiy@gmail.com> References: <20260128171142.31492-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UZSXZAYE3IXS4WQLT6BN2BPFLQM6Z5U3 X-Message-ID-Hash: UZSXZAYE3IXS4WQLT6BN2BPFLQM6Z5U3 X-MailFrom: bogorodskiy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1769620447969158500 Content-Type: text/plain; charset="utf-8" Bhyve on arm64 does not have the bhyveload(8) tool. That means that it cannot be used as a default if the loader is not configured for the domain. To prevent users from getting unusable configurations, handle loader configuration on arm64 like that: - if loader is specified in the domain XML, just use it - if not specified, try to check whether the default uboot loader is available on the system. In case it is, set is as the loader, otherwise fail with the error. Additionally, the loader could be configured in bhyve.conf. By default, it uses the loader installed by the sysutils/u-boot-bhyve-arm64 port or a corresponding package. Signed-off-by: Roman Bogorodskiy --- src/bhyve/bhyve.conf | 5 ++++ src/bhyve/bhyve_conf.c | 8 +++++++ src/bhyve/bhyve_domain.c | 23 +++++++++++++++++++ src/bhyve/bhyve_utils.h | 2 ++ .../aarch64/bhyvexml2argv-base.args | 1 + .../aarch64/bhyvexml2argv-base.ldargs | 8 +------ .../aarch64/bhyvexml2argv-console.args | 1 + .../aarch64/bhyvexml2argv-console.ldargs | 8 +------ tests/bhyvexml2argvmock.c | 20 +++++++++++++++- tests/bhyvexml2argvtest.c | 2 ++ .../aarch64/bhyvexml2xmlout-base.xml | 1 + .../aarch64/bhyvexml2xmlout-console.xml | 1 + tests/bhyvexml2xmltest.c | 4 ++++ 13 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve.conf b/src/bhyve/bhyve.conf index dc8d3d8fd8..a845937d87 100644 --- a/src/bhyve/bhyve.conf +++ b/src/bhyve/bhyve.conf @@ -6,6 +6,11 @@ # to the directory that sysutils/bhyve-firmware installs files into. #firmware_dir =3D "/usr/local/share/uefi-firmware" =20 +# Path to the U-Boot loader for the arm64 guests. +# By default it's pointing to the loader installed +# by the sysutils/u-boot-bhyve-arm64 port +#uboot_path =3D "/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin" + # Set timeout for the bhyveload(8) command. This might be necessary # because in case of errors bhyveload(8) drops to an interactive # loader and hangs indefinitely. These timeout values are passed diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c index 182e00ee1d..f9a657f402 100644 --- a/src/bhyve/bhyve_conf.c +++ b/src/bhyve/bhyve_conf.c @@ -61,6 +61,8 @@ virBhyveDriverConfigNew(void) cfg->libDir =3D g_strdup_printf("%s/lib/libvirt/bhyve", LOCALSTATEDIR); cfg->nvramDir =3D g_strdup_printf("%s/nvram", cfg->libDir); =20 + cfg->ubootPath =3D g_strdup(DATADIR "/u-boot/u-boot-bhyve-arm64/u-boot= .bin"); + cfg->bhyveloadTimeout =3D 300; cfg->bhyveloadTimeoutKill =3D 15; =20 @@ -85,6 +87,10 @@ virBhyveLoadDriverConfig(struct _virBhyveDriverConfig *c= fg, &cfg->firmwareDir) < 0) return -1; =20 + if (virConfGetValueString(conf, "uboot_path", + &cfg->ubootPath) < 0) + return -1; + if (virConfGetValueInt(conf, "bhyveload_timeout", &cfg->bhyveloadTimeout) < 0) return -1; @@ -111,6 +117,8 @@ virBhyveDriverConfigDispose(void *obj) g_free(cfg->firmwareDir); g_free(cfg->libDir); g_free(cfg->nvramDir); + + g_free(cfg->ubootPath); } =20 void diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index df0a008ecd..8fc9733756 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -27,6 +27,7 @@ #include "bhyve_domain.h" #include "bhyve_capabilities.h" #include "viralloc.h" +#include "virfile.h" #include "virlog.h" #include "virutil.h" =20 @@ -112,6 +113,28 @@ bhyveDomainDefPostParse(virDomainDef *def, !(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_RTC_UTC)) def->clock.offset =3D VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME; =20 + /* bhyve/arm64 does not provide the bhyveload(8) tool, + * so if the loader is not specified and we cannot fall back to the + * default one, then this results in an unusable configuration. */ + if (ARCH_IS_ARM(def->os.arch)) { + if (def->os.loader =3D=3D NULL) { + g_autoptr(virBhyveDriverConfig) cfg =3D virBhyveDriverGetConfi= g(driver); + char *uboot_path =3D cfg->ubootPath; + + if (virFileExists(uboot_path)) { + def->os.loader =3D virDomainLoaderDefNew(); + def->os.loader->path =3D g_strdup(uboot_path); + def->os.loader->readonly =3D true; + def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_PFLASH; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("loader is not specified and the default = loader (%1$s) not found"), + uboot_path); + return -1; + } + } + } + return 0; } =20 diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h index 8ed1fa5509..19369047fe 100644 --- a/src/bhyve/bhyve_utils.h +++ b/src/bhyve/bhyve_utils.h @@ -42,6 +42,8 @@ struct _virBhyveDriverConfig { char *libDir; char *nvramDir; =20 + char *ubootPath; + int bhyveloadTimeout; int bhyveloadTimeoutKill; }; diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.args b/test= s/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.args index aef3ebd017..37292aa3fe 100644 --- a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.args +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.args @@ -2,6 +2,7 @@ bhyve \ -c 1 \ -m 214 \ -s 0:0,hostbridge \ +-o bootrom=3Dfakeubootpath/u-boot.bin \ -s 3:0,virtio-net,faketapdev,mac=3D52:54:00:b9:94:02 \ -s 2:0,virtio-blk,/tmp/freebsd.img \ bhyve diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.ldargs b/te= sts/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.ldargs index 264ae48441..421376db9e 100644 --- a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.ldargs +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-base.ldargs @@ -1,7 +1 @@ -timeout \ ---foreground \ ---verbose \ --k 20s 300s bhyveload \ --m 214 \ --d /tmp/freebsd.img \ -bhyve +dummy diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args b/t= ests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args index 4a031afb71..afd5f5d7b2 100644 --- a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.args @@ -2,6 +2,7 @@ bhyve \ -c 1 \ -m 214 \ -s 0:0,hostbridge \ +-o bootrom=3Dfakeubootpath/u-boot.bin \ -s 3:0,virtio-net,faketapdev,mac=3D52:54:00:b9:94:02 \ -s 2:0,virtio-blk,/tmp/freebsd.img \ -o console=3D/dev/nmdm0A \ diff --git a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs b= /tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs index 264ae48441..421376db9e 100644 --- a/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs +++ b/tests/bhyvexml2argvdata/aarch64/bhyvexml2argv-console.ldargs @@ -1,7 +1 @@ -timeout \ ---foreground \ ---verbose \ --k 20s 300s bhyveload \ --m 214 \ --d /tmp/freebsd.img \ -bhyve +dummy diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c index fe76564d51..191d6bdaf5 100644 --- a/tests/bhyvexml2argvmock.c +++ b/tests/bhyvexml2argvmock.c @@ -2,7 +2,9 @@ =20 #include =20 +#include "configmake.h" #include "viralloc.h" +#include "virfile.h" #include "virstring.h" #include "virnetdev.h" #include "virnetdevtap.h" @@ -12,11 +14,16 @@ #define VIR_FROM_THIS VIR_FROM_BHYVE =20 static DIR * (*real_opendir)(const char *name); +static bool (*real_virFileExists)(const char *path); =20 static void init_syms(void) { - VIR_MOCK_REAL_INIT(opendir); + if (!real_opendir) + VIR_MOCK_REAL_INIT(opendir); + + if (!real_virFileExists) + VIR_MOCK_REAL_INIT(virFileExists); } =20 #define FAKEFIRMWAREDIR abs_srcdir "/bhyvefirmwaredata/three_firmwares" @@ -89,3 +96,14 @@ int bind(int sockfd G_GNUC_UNUSED, { return 0; } + +bool +virFileExists(const char *path) +{ + init_syms(); + + if (STREQ(path, "fakeubootpath/u-boot.bin")) + return true; + + return real_virFileExists(path); +} diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index c7c18c3690..42c14b6ab3 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -151,6 +151,7 @@ mymain(void) g_autofree char *fakefirmwaredir =3D g_strdup("fakefirmwaredir"); g_autofree char *fakenvramdir =3D g_strdup("fakenvramdir"); g_autofree char *fakefirmwareemptydir =3D g_strdup("fakefirmwareemptyd= ir"); + g_autofree char *fakeubootpath =3D g_strdup("fakeubootpath/u-boot.bin"= ); =20 if ((driver.caps =3D virBhyveCapsBuild()) =3D=3D NULL) return EXIT_FAILURE; @@ -166,6 +167,7 @@ mymain(void) =20 driver.config->firmwareDir =3D fakefirmwaredir; driver.config->nvramDir =3D fakenvramdir; + driver.config->ubootPath =3D fakeubootpath; driver.config->bhyveloadTimeout =3D 0; driver.config->bhyveloadTimeoutKill =3D 0; =20 diff --git a/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-base.xml b/t= ests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-base.xml index ee72370047..d6c9caa225 100644 --- a/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-base.xml +++ b/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-base.xml @@ -6,6 +6,7 @@ 1 hvm + /usr/local/share/u-boot/u-boo= t-bhyve-arm64/u-boot.bin diff --git a/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-console.xml = b/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-console.xml index d43ce8fd6f..d694ecfb8d 100644 --- a/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-console.xml +++ b/tests/bhyvexml2xmloutdata/aarch64/bhyvexml2xmlout-console.xml @@ -6,6 +6,7 @@ 1 hvm + /usr/local/share/u-boot/u-boo= t-bhyve-arm64/u-boot.bin diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 5df1f2b6ba..50bf82bd52 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -5,6 +5,7 @@ #ifdef WITH_BHYVE =20 # include "bhyve/bhyve_capabilities.h" +# include "bhyve/bhyve_conf.h" # include "bhyve/bhyve_domain.h" # include "bhyve/bhyve_utils.h" =20 @@ -63,6 +64,9 @@ mymain(void) if ((driver.xmlopt =3D virBhyveDriverCreateXMLConf(&driver)) =3D=3D NU= LL) return EXIT_FAILURE; =20 + if (!(driver.config =3D virBhyveDriverConfigNew())) + return EXIT_FAILURE; + # define DO_TEST_FULL(name, flags) \ do { \ const struct testInfo info =3D {name, (flags)}; \ --=20 2.52.0