qemu: blockjob: Add string convertors for blockjob type and state enums

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-11-30 16:55:08 +01:00
parent 5ff46aaa7f
commit 8d82e6d98a
2 changed files with 23 additions and 0 deletions

View File

@ -43,6 +43,25 @@
VIR_LOG_INIT("qemu.qemu_blockjob"); 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; static virClassPtr qemuBlockJobDataClass;

View File

@ -42,6 +42,8 @@ typedef enum {
} qemuBlockjobState; } qemuBlockjobState;
verify((int)QEMU_BLOCKJOB_STATE_NEW == VIR_DOMAIN_BLOCK_JOB_LAST); 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 * 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 * to the same values. All internal blockjobs can be mapped after and don't
@ -60,6 +62,8 @@ typedef enum {
} qemuBlockJobType; } qemuBlockJobType;
verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST); verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST);
VIR_ENUM_DECL(qemuBlockjob);
typedef struct _qemuBlockJobData qemuBlockJobData; typedef struct _qemuBlockJobData qemuBlockJobData;
typedef qemuBlockJobData *qemuBlockJobDataPtr; typedef qemuBlockJobData *qemuBlockJobDataPtr;