render / rpms / libvirt

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