diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index ea7b3fc448..39155a6a5a 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -124,6 +124,7 @@ typedef enum { VIR_DOMAIN_PAUSED_IOERROR = 5, /* paused due to a disk I/O error */ VIR_DOMAIN_PAUSED_WATCHDOG = 6, /* paused due to a watchdog event */ VIR_DOMAIN_PAUSED_FROM_SNAPSHOT = 7, /* paused after restoring from snapshot */ + VIR_DOMAIN_PAUSED_SHUTTING_DOWN = 8, /* paused during shutdown process */ } virDomainPausedReason; typedef enum { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 03ab447c91..7476447677 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -487,7 +487,7 @@ VIR_ENUM_IMPL(virDomainRunningReason, VIR_DOMAIN_RUNNING_LAST, VIR_ENUM_IMPL(virDomainBlockedReason, VIR_DOMAIN_BLOCKED_LAST, "unknown") -#define VIR_DOMAIN_PAUSED_LAST (VIR_DOMAIN_PAUSED_FROM_SNAPSHOT + 1) +#define VIR_DOMAIN_PAUSED_LAST (VIR_DOMAIN_PAUSED_SHUTTING_DOWN + 1) VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST, "unknown", "user", @@ -496,7 +496,8 @@ VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST, "dump", "ioerror", "watchdog", - "from snapshot") + "from snapshot", + "shutdown") #define VIR_DOMAIN_SHUTDOWN_LAST (VIR_DOMAIN_SHUTDOWN_USER + 1) VIR_ENUM_IMPL(virDomainShutdownReason, VIR_DOMAIN_SHUTDOWN_LAST, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e45965e893..8235ea1276 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -231,6 +231,8 @@ virDiskNameToBusDeviceIndex; virDiskNameToIndex; virDomainActualNetDefFree; virDomainAssignDef; +virDomainBlockedReasonTypeFromString; +virDomainBlockedReasonTypeToString; virDomainChrConsoleTargetTypeFromString; virDomainChrConsoleTargetTypeToString; virDomainChrDefForeach; @@ -360,6 +362,8 @@ virDomainNetIndexByMac; virDomainNetInsert; virDomainNetRemoveByMac; virDomainNetTypeToString; +virDomainNostateReasonTypeFromString; +virDomainNostateReasonTypeToString; virDomainNumatuneMemModeTypeFromString; virDomainNumatuneMemModeTypeToString; virDomainObjAssignDef; @@ -379,12 +383,20 @@ virDomainObjSetState; virDomainObjTaint; virDomainObjUnlock; virDomainObjUnref; +virDomainPausedReasonTypeFromString; +virDomainPausedReasonTypeToString; virDomainRedirdevBusTypeFromString; virDomainRedirdevBusTypeToString; virDomainRemoveInactive; +virDomainRunningReasonTypeFromString; +virDomainRunningReasonTypeToString; virDomainSaveConfig; virDomainSaveStatus; virDomainSaveXML; +virDomainShutdownReasonTypeFromString; +virDomainShutdownReasonTypeToString; +virDomainShutoffReasonTypeFromString; +virDomainShutoffReasonTypeToString; virDomainSmartcardDefForeach; virDomainSmartcardDefFree; virDomainSmartcardTypeFromString; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 909c3f7f57..3baaa19cae 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -473,14 +473,22 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED, { struct qemud_driver *driver = qemu_driver; virDomainEventPtr event = NULL; + virDomainPausedReason reason = VIR_DOMAIN_PAUSED_UNKNOWN; virDomainObjLock(vm); if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_DEBUG("Transitioned guest %s to paused state due to unknown event", - vm->def->name); - virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_UNKNOWN); + if (priv->gotShutdown) { + VIR_DEBUG("Got STOP event after SHUTDOWN, assuming we are stopping" + " for shutdown"); + reason = VIR_DOMAIN_PAUSED_SHUTTING_DOWN; + } + + VIR_DEBUG("Transitioned guest %s to paused state, reason=%s", + vm->def->name, virDomainPausedReasonTypeToString(reason)); + + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); diff --git a/tools/virsh.c b/tools/virsh.c index d5fcd2cdc6..d575425fd5 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -15151,6 +15151,8 @@ vshDomainStateReasonToString(int state, int reason) return N_("watchdog"); case VIR_DOMAIN_PAUSED_FROM_SNAPSHOT: return N_("from snapshot"); + case VIR_DOMAIN_PAUSED_SHUTTING_DOWN: + return N_("shutting down"); case VIR_DOMAIN_PAUSED_UNKNOWN: ; }