]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: restore persistent definition after process stop master
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 31 Jul 2026 18:40:01 +0000 (20:40 +0200)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 10 Aug 2026 15:53:34 +0000 (17:53 +0200)
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 <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/bhyve/bhyve_process.c

index 81f00954c2e6c4174e9a1135867a1e27867a1e4e..65e3bdfd02fded44b475420ef7e234b811e79819 100644 (file)
@@ -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)