]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: drop virProcessKillPainfully() from destroy
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Wed, 4 May 2016 16:41:58 +0000 (19:41 +0300)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Thu, 5 May 2016 05:01:19 +0000 (08:01 +0300)
Current implementation of domainDestroy for bhyve calls
virProcessKillPainfully() for the bhyve process and then
executes "bhyvectl --destroy".

This is wrong for two reasons:

 * bhyvectl --destroy alone is sufficient because it terminates
   the process
 * virProcessKillPainfully() first sends SIGTERM and after few
   attempts sends SIGKILL. As SIGTERM triggers ACPI shutdown that
   we're not interested in, it creates an unwanted side effect in
   domainDestroy.

Also, destroy monitor only after "bhyvectl --destroy" command succeeded
to avoid a case when the command fails and domain remains running, but
not being monitored anymore.

src/bhyve/bhyve_process.c

index 14588a9261d45693d7ce0dfff341cc1b0cf9eb61..fe61a9aa307fd8a21d416ebaea2195c4d135f492 100644 (file)
@@ -278,26 +278,18 @@ virBhyveProcessStop(bhyveConnPtr driver,
         return -1;
     }
 
+    if (!(cmd = virBhyveProcessBuildDestroyCmd(driver, vm->def)))
+        return -1;
+
+    if (virCommandRun(cmd, NULL) < 0)
+        goto cleanup;
+
     if ((priv != NULL) && (priv->mon != NULL))
          bhyveMonitorClose(priv->mon);
 
-    /* First, try to kill 'bhyve' process */
-    if (virProcessKillPainfully(vm->pid, true) != 0)
-        VIR_WARN("Failed to gracefully stop bhyve VM '%s' (pid: %d)",
-                 vm->def->name,
-                 (int)vm->pid);
-
     /* Cleanup network interfaces */
     bhyveNetCleanup(vm);
 
-    /* No matter if shutdown was successful or not, we
-     * need to unload the VM */
-    if (!(cmd = virBhyveProcessBuildDestroyCmd(driver, vm->def)))
-        goto cleanup;
-
-    if (virCommandRun(cmd, NULL) < 0)
-        goto cleanup;
-
     ret = 0;
 
     virCloseCallbacksUnset(driver->closeCallbacks, vm,