[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH RFC 48/51] qemu: blockjob: Add helper to convert monitor job status to internal state



Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_blockjob.c | 41 ++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_blockjob.h |  3 +++
 2 files changed, 44 insertions(+)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index ee545fc8de..020e7b3994 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -480,3 +480,44 @@ qemuBlockJobGetByDisk(virDomainDiskDefPtr disk)

     return virObjectRef(job);
 }
+
+
+/**
+ * @monitorstatus: Status of the blockjob from qemu monitor (qemuMonitorJobStatus)
+ *
+ * Converts the block job status from the monitor to the one used by
+ * qemuBlockJobData. If the status is unknown or does not require any handling
+ * QEMU_BLOCKJOB_TYPE_LAST is returned.
+ */
+qemuBlockjobState
+qemuBlockjobConvertMonitorStatus(int monitorstatus)
+{
+    qemuBlockjobState ret = QEMU_BLOCKJOB_TYPE_LAST;
+
+    switch ((qemuMonitorJobStatus) monitorstatus) {
+    case QEMU_MONITOR_JOB_STATUS_READY:
+        ret = QEMU_BLOCKJOB_STATE_READY;
+        break;
+
+    case QEMU_MONITOR_JOB_STATUS_CONCLUDED:
+        ret = QEMU_BLOCKJOB_STATE_CONCLUDED;
+        break;
+
+    case QEMU_MONITOR_JOB_STATUS_UNKNOWN:
+    case QEMU_MONITOR_JOB_STATUS_CREATED:
+    case QEMU_MONITOR_JOB_STATUS_RUNNING:
+    case QEMU_MONITOR_JOB_STATUS_PAUSED:
+    case QEMU_MONITOR_JOB_STATUS_STANDBY:
+    case QEMU_MONITOR_JOB_STATUS_WAITING:
+    case QEMU_MONITOR_JOB_STATUS_PENDING:
+    case QEMU_MONITOR_JOB_STATUS_ABORTING:
+    case QEMU_MONITOR_JOB_STATUS_UNDEFINED:
+    case QEMU_MONITOR_JOB_STATUS_NULL:
+    case QEMU_MONITOR_JOB_STATUS_LAST:
+    default:
+        break;
+    }
+
+    return ret;
+
+}
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index c8a6d8cf4c..9a2d047d03 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -118,4 +118,7 @@ qemuBlockJobDataPtr
 qemuBlockJobGetByDisk(virDomainDiskDefPtr disk)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;

+qemuBlockjobState
+qemuBlockjobConvertMonitorStatus(int monitorstatus);
+
 #endif /* __QEMU_BLOCKJOB_H__ */
-- 
2.19.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]