]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: don't reset domain autostart flag on destroy
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sun, 20 Jul 2025 13:55:07 +0000 (15:55 +0200)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 21 Jul 2025 16:25:53 +0000 (18:25 +0200)
Currently, virBhyveProcessStop() uses the virDomainDeleteConfig()
helper to clean up domain status. It passes BHYVE_STATE_DIR as
a configuration dir and NULL as autostart dir, so the helper does its
job, even though it has a different purpose. However, the issue is that
it also resets the autostart (and autostartOnce) property.

This results in a situation that when a persistent domain with autostart
enabled gets destroyed, its autostart state is reported as disabled,
which is not correct.

To fix that, implement the bhyveProcessRemoveDomainStatus() which
removes the status file without side effects on the virDomainObj object.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com
src/bhyve/bhyve_process.c

index 5e77a9c4d68763a36082e516f75733963b20883c..4bfd511bae71052debb38ed9aab6b1c13d7fbe13 100644 (file)
@@ -427,6 +427,18 @@ virBhyveProcessStart(bhyveConn *driver,
     return virBhyveProcessStartImpl(driver, vm, reason);
 }
 
+static void
+bhyveProcessRemoveDomainStatus(const char *statusDir,
+                               const char *name)
+{
+    g_autofree char *file = virDomainConfigFile(statusDir, name);
+
+    if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) {
+        VIR_WARN("Failed to remove domain XML for %s: %s",
+                 name, g_strerror(errno));
+    }
+}
+
 int
 virBhyveProcessStop(struct _bhyveConn *driver,
                     virDomainObj *vm,
@@ -483,7 +495,7 @@ virBhyveProcessStop(struct _bhyveConn *driver,
 
  cleanup:
     virPidFileDelete(BHYVE_STATE_DIR, vm->def->name);
-    virDomainDeleteConfig(BHYVE_STATE_DIR, NULL, vm);
+    bhyveProcessRemoveDomainStatus(BHYVE_STATE_DIR, vm->def->name);
 
     return ret;
 }