]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: hooks: improve process start error handling
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sun, 21 Sep 2025 18:16:42 +0000 (20:16 +0200)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 26 Sep 2025 15:50:04 +0000 (17:50 +0200)
When the virBhyveProcessStart() fails early, make sure to execute
the "stopped" and "release" hooks.

Spotted while running TCK hooks tests against the bhyve driver.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/bhyve/bhyve_process.c

index 4bfd511bae71052debb38ed9aab6b1c13d7fbe13..4fb7e642e143ccf67b098c839f156f45496efd3b 100644 (file)
@@ -413,18 +413,24 @@ virBhyveProcessStart(bhyveConn *driver,
 {
     /* Run an early hook to setup missing devices. */
     if (bhyveProcessStartHook(driver, vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
-        return -1;
+        goto cleanup;
 
     if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY)
         virCloseCallbacksDomainAdd(vm, conn, bhyveProcessAutoDestroy);
 
     if (bhyveProcessPrepareDomain(driver, vm, flags) < 0)
-        return -1;
+        goto cleanup;
 
     if (bhyveProcessPrepareHost(driver, vm->def, flags) < 0)
-        return -1;
+        goto cleanup;
 
     return virBhyveProcessStartImpl(driver, vm, reason);
+
+ cleanup:
+    bhyveProcessStopHook(driver, vm, VIR_HOOK_BHYVE_OP_STOPPED);
+    bhyveProcessStopHook(driver, vm, VIR_HOOK_BHYVE_OP_RELEASE);
+
+    return -1;
 }
 
 static void