render / rpms / libvirt

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