From 10a588bda5b547ccb52cd825933a0acc9c4f94ba Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Fri, 31 Jul 2026 20:40:01 +0200 Subject: [PATCH] bhyve: restore persistent definition after process stop The virBhyveProcessStop() function which handles bhyve process shutdown does not remove the transient definition, meaning that it overrides the persistent definition. Update it to call virDomainObjRemoveTransientDef(). Also, move the body of the code to virBhyveProcessStopImpl() which accepts 'restoreDef' argument telling whether the transient definition should be removed. That is necessary as reboot is implemented as stop + start, and in this case the transient definition should not be removed. Closes: https://gitlab.com/libvirt/libvirt/-/work_items/900 Signed-off-by: Roman Bogorodskiy Reviewed-by: Martin Kletzander --- src/bhyve/bhyve_process.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 81f00954c2..65e3bdfd02 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -630,6 +630,7 @@ bhyveProcessRemoveDomainStatus(const char *statusDir, * @vm: domain object * @reason: shutoff reason * @forceCleanup: boolean controlling cleanup + * @restoreDef: whether to restore the persistent definition after cleanup * * Stops the domain and cleans up its resources. * It could be used whether as a direct call or as a cleanup routine. @@ -641,11 +642,12 @@ bhyveProcessRemoveDomainStatus(const char *statusDir, * * Returns 0 on success, -1 on error. */ -int -virBhyveProcessStop(struct _bhyveConn *driver, - virDomainObj *vm, - virDomainShutoffReason reason, - bool forceCleanup) +static int +virBhyveProcessStopImpl(struct _bhyveConn *driver, + virDomainObj *vm, + virDomainShutoffReason reason, + bool forceCleanup, + bool restoreDef) { int ret = 0; size_t i = 0; @@ -724,9 +726,21 @@ virBhyveProcessStop(struct _bhyveConn *driver, virPidFileDelete(BHYVE_STATE_DIR, vm->def->name); bhyveProcessRemoveDomainStatus(BHYVE_STATE_DIR, vm->def->name); + if (restoreDef) + virDomainObjRemoveTransientDef(vm); + return ret; } +int +virBhyveProcessStop(struct _bhyveConn *driver, + virDomainObj *vm, + virDomainShutoffReason reason, + bool forceCleanup) +{ + return virBhyveProcessStopImpl(driver, vm, reason, forceCleanup, true); +} + int virBhyveProcessShutdown(virDomainObj *vm) { @@ -754,7 +768,8 @@ int virBhyveProcessRestart(struct _bhyveConn *driver, virDomainObj *vm) { - if (virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, false) < 0) + if (virBhyveProcessStopImpl(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, + false, false) < 0) return -1; if (virBhyveProcessStartImpl(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0) -- 2.47.3