From: Roman Bogorodskiy Date: Tue, 28 Oct 2025 17:04:12 +0000 (+0100) Subject: bhyve: process: improve domain startup error handling X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Flibvirt.git bhyve: process: improve domain startup error handling After executing the bhyve binary, it might happen that it fails very early due to configuration issues (missing/inaccessible files, incorrect custom args), bugs, etc. In this case it'll look like the domain has started normally, but quickly turned off. Improve that by waiting for the domain's vmm entity to appear in /dev/vmm. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 4fb7e642e1..7de614a1a3 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -51,6 +51,7 @@ #include "virnetdev.h" #include "virnetdevbridge.h" #include "virnetdevtap.h" +#include "virtime.h" #define VIR_FROM_THIS VIR_FROM_BHYVE @@ -143,7 +144,10 @@ virBhyveProcessStartImpl(struct _bhyveConn *driver, g_autoptr(virCommand) cmd = NULL; g_autoptr(virCommand) load_cmd = NULL; bhyveDomainObjPrivate *priv = vm->privateData; + g_autofree char *domain_vmm_path = NULL; + virTimeBackOffVar timebackoff; int ret = -1, rc; + bool vmm_appeared = false; logfile = g_strdup_printf("%s/%s.log", BHYVE_LOG_DIR, vm->def->name); if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, @@ -228,6 +232,24 @@ virBhyveProcessStartImpl(struct _bhyveConn *driver, goto cleanup; } + domain_vmm_path = g_strdup_printf("/dev/vmm/%s", vm->def->name); + + if (virTimeBackOffStart(&timebackoff, 1, 5000) < 0) + goto cleanup; + while (virTimeBackOffWait(&timebackoff)) { + if (virFileExists(domain_vmm_path)) { + vmm_appeared = true; + break; + } + } + + if (!vmm_appeared) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Domain %1$s didn't show up in /dev/vmm"), + vm->def->name); + goto cleanup; + } + vm->def->id = vm->pid; virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); priv->mon = bhyveMonitorOpen(vm, driver);