case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:
qemuDomainSetFakeReboot(vm, true);
- qemuProcessShutdownOrReboot(vm);
+ ignore_value(qemuProcessShutdownOrReboot(vm));
break;
case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:
}
-void
+/**
+ * qemuProcessShutdownOrReboot:
+ * @vm: domain object
+ *
+ * Perform the appropriate action when the guest OS shuts down. This can be
+ * either fake reboot (the VM is reset started again) or the VM is terminated.
+ *
+ * The function returns true if the VM was terminated.
+ */
+bool
qemuProcessShutdownOrReboot(virDomainObj *vm)
{
qemuDomainObjPrivate *priv = vm->privateData;
qemuDomainSetFakeReboot(vm, false);
virObjectUnref(vm);
}
+
+ return false;
} else {
ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
+ return true;
}
+
+ return false;
}
if (priv->agent)
qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SHUTDOWN);
- qemuProcessShutdownOrReboot(vm);
+ ignore_value(qemuProcessShutdownOrReboot(vm));
unlock:
virObjectUnlock(vm);
reason == VIR_DOMAIN_PAUSED_USER)) {
VIR_DEBUG("Finishing shutdown sequence for domain %s",
obj->def->name);
- qemuProcessShutdownOrReboot(obj);
- goto cleanup;
+ /* qemuProcessShutdownOrReboot returns 'true' if the VM was terminated.
+ * If the VM is kept (e.g. for fake reboot) we need to continue the
+ * reconnection */
+ if (qemuProcessShutdownOrReboot(obj))
+ goto cleanup;
}
/* if domain requests security driver we haven't loaded, report error, but
int qemuProcessFakeRebootViaRecreate(virDomainObj *vm, bool locked);
-void qemuProcessShutdownOrReboot(virDomainObj *vm);
+bool qemuProcessShutdownOrReboot(virDomainObj *vm)
+ G_GNUC_WARN_UNUSED_RESULT;
void qemuProcessAutoDestroy(virDomainObj *dom,
virConnectPtr conn);