[libvirt] [PATCH RFC 35/51] qemu: blockjob: Add string convertors for blockjob type and state enums

Peter Krempa pkrempa at redhat.com
Wed Dec 12 17:08:51 UTC 2018


Later on we'll format these values into the status XML so the from/to
string functions will come handy. The implementation also notes that
these will be used in the status XML to avoid somebody changing the
values.

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

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 97b9d7e5a6..24a0efe36f 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -42,6 +42,13 @@

 VIR_LOG_INIT("qemu.qemu_blockjob");

+/* Note that qemuBlockjobState and qemuBlockjobType values are formatted into
+ * the status XML */
+VIR_ENUM_IMPL(qemuBlockjobState, QEMU_BLOCKJOB_STATE_LAST,
+              "completed", "failed", "cancelled", "ready", "new", "running");
+
+VIR_ENUM_IMPL(qemuBlockjob, QEMU_BLOCKJOB_TYPE_LAST,
+              "", "pull", "copy", "commit", "active-commit", "");

 static virClassPtr qemuBlockJobDataClass;

diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index 6f58d323d0..d1e94dc066 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -41,6 +41,8 @@ typedef enum {
 } qemuBlockjobState;
 verify((int)QEMU_BLOCKJOB_STATE_NEW == VIR_DOMAIN_BLOCK_JOB_LAST);

+VIR_ENUM_DECL(qemuBlockjobState)
+
 /**
  * This enum has to map all known block job types from enum virDomainBlockJobType
  * to the same values. All internal blockjobs can be mapped after and don't
@@ -57,6 +59,8 @@ typedef enum {
 } qemuBlockjobType;
 verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST);

+VIR_ENUM_DECL(qemuBlockjob)
+
 typedef struct _qemuBlockJobData qemuBlockJobData;
 typedef qemuBlockJobData *qemuBlockJobDataPtr;

-- 
2.19.2




More information about the libvir-list mailing list