edecca
From 281b3fe785078497e4bb3156fe4da9af91f204c2 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <281b3fe785078497e4bb3156fe4da9af91f204c2@dist-git>
edecca
From: Jiri Denemark <jdenemar@redhat.com>
edecca
Date: Tue, 11 Sep 2018 15:13:08 +0200
edecca
Subject: [PATCH] qemu: Map running reason to resume event detail
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
Thanks to the previous commit the RESUME event handler knows what reason
edecca
should be used when changing the domain state to VIR_DOMAIN_RUNNING, but
edecca
the emitted VIR_DOMAIN_EVENT_RESUMED event still uses a generic
edecca
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED detail. Luckily, the event detail can
edecca
be easily deduced from the running reason, which saves us from having to
edecca
pass one more value to the handler.
edecca
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
Reviewed-by: John Ferlan <jferlan@redhat.com>
edecca
(cherry picked from commit 8ae9b49f5a4a02f57a1dfa20d4fe04c3d40a4665)
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1634758
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1634759
edecca
edecca
Conflicts:
edecca
	src/qemu/qemu_domain.c
edecca
	src/qemu/qemu_domain.h
edecca
            - nodenames code is not backported
edecca
edecca
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_domain.c  | 29 +++++++++++++++++++++++++++++
edecca
 src/qemu/qemu_domain.h  |  3 +++
edecca
 src/qemu/qemu_process.c | 11 +++++++----
edecca
 3 files changed, 39 insertions(+), 4 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
edecca
index 17be6e5537..d80f9b393e 100644
edecca
--- a/src/qemu/qemu_domain.c
edecca
+++ b/src/qemu/qemu_domain.c
edecca
@@ -13149,3 +13149,32 @@ qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv)
edecca
 
edecca
     return ret;
edecca
 }
edecca
+
edecca
+
edecca
+virDomainEventResumedDetailType
edecca
+qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason)
edecca
+{
edecca
+    switch (reason) {
edecca
+    case VIR_DOMAIN_RUNNING_RESTORED:
edecca
+    case VIR_DOMAIN_RUNNING_FROM_SNAPSHOT:
edecca
+        return VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT;
edecca
+
edecca
+    case VIR_DOMAIN_RUNNING_MIGRATED:
edecca
+    case VIR_DOMAIN_RUNNING_MIGRATION_CANCELED:
edecca
+        return VIR_DOMAIN_EVENT_RESUMED_MIGRATED;
edecca
+
edecca
+    case VIR_DOMAIN_RUNNING_POSTCOPY:
edecca
+        return VIR_DOMAIN_EVENT_RESUMED_POSTCOPY;
edecca
+
edecca
+    case VIR_DOMAIN_RUNNING_UNKNOWN:
edecca
+    case VIR_DOMAIN_RUNNING_SAVE_CANCELED:
edecca
+    case VIR_DOMAIN_RUNNING_BOOTED:
edecca
+    case VIR_DOMAIN_RUNNING_UNPAUSED:
edecca
+    case VIR_DOMAIN_RUNNING_WAKEUP:
edecca
+    case VIR_DOMAIN_RUNNING_CRASHED:
edecca
+    case VIR_DOMAIN_RUNNING_LAST:
edecca
+        break;
edecca
+    }
edecca
+
edecca
+    return VIR_DOMAIN_EVENT_RESUMED_UNPAUSED;
edecca
+}
edecca
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
edecca
index 6a96f27a5f..cc406e3ca0 100644
edecca
--- a/src/qemu/qemu_domain.h
edecca
+++ b/src/qemu/qemu_domain.h
edecca
@@ -1066,4 +1066,7 @@ qemuDomainDiskCachemodeFlags(int cachemode,
edecca
 
edecca
 char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
edecca
 
edecca
+virDomainEventResumedDetailType
edecca
+qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
edecca
+
edecca
 #endif /* __QEMU_DOMAIN_H__ */
edecca
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
edecca
index 7325bc4c90..37568165b7 100644
edecca
--- a/src/qemu/qemu_process.c
edecca
+++ b/src/qemu/qemu_process.c
edecca
@@ -694,6 +694,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
edecca
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
edecca
     qemuDomainObjPrivatePtr priv;
edecca
     virDomainRunningReason reason = VIR_DOMAIN_RUNNING_UNPAUSED;
edecca
+    virDomainEventResumedDetailType eventDetail;
edecca
 
edecca
     virObjectLock(vm);
edecca
 
edecca
@@ -709,14 +710,16 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
edecca
             goto unlock;
edecca
         }
edecca
 
edecca
+        eventDetail = qemuDomainRunningReasonToResumeEvent(reason);
edecca
         VIR_DEBUG("Transitioned guest %s out of paused into resumed state, "
edecca
-                  "reason '%s'",
edecca
-                  vm->def->name, virDomainRunningReasonTypeToString(reason));
edecca
+                  "reason '%s', event detail %d",
edecca
+                  vm->def->name, virDomainRunningReasonTypeToString(reason),
edecca
+                  eventDetail);
edecca
 
edecca
         virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
edecca
         event = virDomainEventLifecycleNewFromObj(vm,
edecca
-                                         VIR_DOMAIN_EVENT_RESUMED,
edecca
-                                         VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
edecca
+                                                  VIR_DOMAIN_EVENT_RESUMED,
edecca
+                                                  eventDetail);
edecca
 
edecca
         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
edecca
             VIR_WARN("Unable to save status on vm %s after state change",
edecca
-- 
edecca
2.19.1
edecca