if (virDomainObjCheckActive(vm) < 0)
goto endjob;
- if (virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED) < 0)
+ if (virCHProcessStop(driver, vm,
+ VIR_DOMAIN_SHUTOFF_DESTROYED,
+ VIR_CH_PROCESS_STOP_FORCE) < 0) {
goto endjob;
+ }
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
goto end;
}
- if (virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED) < 0) {
+ if (virCHProcessStop(driver, vm,
+ VIR_DOMAIN_SHUTOFF_SAVED, VIR_CH_PROCESS_STOP_FORCE) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to shutoff after domain save"));
goto end;
cleanup:
if (ret)
- virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
+ virCHProcessStop(driver, vm,
+ VIR_DOMAIN_SHUTOFF_FAILED,
+ VIR_CH_PROCESS_STOP_FORCE);
return ret;
}
int
virCHProcessStop(virCHDriver *driver,
virDomainObj *vm,
- virDomainShutoffReason reason)
+ virDomainShutoffReason reason,
+ unsigned int flags)
{
g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
int ret;
virErrorPtr orig_err = NULL;
size_t i;
- VIR_DEBUG("Stopping VM name=%s pid=%d reason=%d",
- vm->def->name, (int)vm->pid, (int)reason);
+ VIR_DEBUG("Stopping VM name=%s pid=%d reason=%d flags=0x%x",
+ vm->def->name, (int)vm->pid, (int)reason, flags);
virErrorPreserveLast(&orig_err);
if (priv->monitor) {
- virProcessKillPainfully(vm->pid, true);
+ bool force = false;
+
+ if (flags & VIR_CH_PROCESS_STOP_FORCE)
+ force = true;
+
+ virProcessKillPainfully(vm->pid, force);
g_clear_pointer(&priv->monitor, virCHMonitorClose);
}
if (tapfds)
chCloseFDs(tapfds, ntapfds);
if (ret)
- virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
+ virCHProcessStop(driver, vm,
+ VIR_DOMAIN_SHUTOFF_FAILED,
+ VIR_CH_PROCESS_STOP_FORCE);
return ret;
}
int virCHProcessStart(virCHDriver *driver,
virDomainObj *vm,
virDomainRunningReason reason);
+
+typedef enum {
+ VIR_CH_PROCESS_STOP_FORCE = 1 << 0,
+} virCHProcessStopFlags;
+
int virCHProcessStop(virCHDriver *driver,
virDomainObj *vm,
- virDomainShutoffReason reason);
+ virDomainShutoffReason reason,
+ unsigned int flags);
int virCHProcessStartRestore(virCHDriver *driver,
virDomainObj *vm,