On 09/15/2011 07:29 AM, Jiri Denemark wrote:
Qemu sends STOP event as part of the shutdown process. Detect such
STOP
event and consider shutdown to be reason of emitting such event. That's
the best we can do until qemu provides us the reason directly in STOP
event. This allows us to report shutdown reason for paused state so that
apps can detect domains that failed to finish the shutdown process
(e.g., because qemu is buggy and doesn't exit on SIGTERM or it is
blocked in flushing disk buffers).
---
include/libvirt/libvirt.h.in | 1 +
src/conf/domain_conf.c | 5 +++--
src/libvirt_private.syms | 12 ++++++++++++
src/qemu/qemu_process.c | 14 +++++++++++---
tools/virsh.c | 2 ++
5 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index ea7b3fc..39155a6 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 ea6b581..ad2a730 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)
We have several other instances of *_LAST defined in libvirt.h.in as
part of the enum, instead of a #define here; but this is a minimal
change and doesn't make the situation any worse.
+++ b/src/libvirt_private.syms
@@ -231,6 +231,8 @@ virDiskNameToBusDeviceIndex;
virDiskNameToIndex;
virDomainActualNetDefFree;
virDomainAssignDef;
+virDomainBlockedReasonTypeFromString;
+virDomainBlockedReasonTypeToString;
Looks like we forgot to export these earlier; this could almost be a
separate patch, but I'm okay keeping it in one.
ACK.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org