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

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

 



Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux