From c35c2fe78eb05f9becf848393912e0d7ded70da2 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Wed, 4 May 2016 19:41:58 +0300 Subject: [PATCH] bhyve: drop virProcessKillPainfully() from destroy 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 | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 14588a9261..fe61a9aa30 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -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, -- 2.47.2