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

Re: [libvirt] [PATCH RFC 21/51] qemu: blockjob: Record job type when starting the job



On Wed, Dec 12, 2018 at 06:08:37PM +0100, Peter Krempa wrote:
We can properly track the job type when starting the job so that we
don't have to infer it later.

This patch also adds an enum of block job types specific to qemu
(qemuBlockjobType) which mirrors the public block job types
(virDomainBlockJobType) but allows for other types to be added later
which will not be public.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
src/qemu/qemu_blockjob.c  | 10 +++++-----
src/qemu/qemu_blockjob.h  | 20 ++++++++++++++++++--
src/qemu/qemu_driver.c    | 11 ++++++-----
src/qemu/qemu_migration.c |  2 +-
src/qemu/qemu_process.c   |  8 ++++++--
5 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index feaee4dee3..6f6d0aa691 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -25,6 +25,21 @@
# include "internal.h"
# include "qemu_conf.h"

+/**
+ * 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
+ * need to have stable values.
+ */
+typedef enum {
+    QEMU_BLOCKJOB_TYPE_NONE = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN,
+    QEMU_BLOCKJOB_TYPE_PULL = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL,
+    QEMU_BLOCKJOB_TYPE_COPY = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY,
+    QEMU_BLOCKJOB_TYPE_COMMIT = VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT,
+    QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT = VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT,
+    QEMU_BLOCKJOB_TYPE_INTERNAL,
+    QEMU_BLOCKJOB_TYPE_LAST
+} qemuBlockjobType;

qemuBlockjobType does not have a capital J like qemuBlockJobData and
lots of the functions.

+verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL == VIR_DOMAIN_BLOCK_JOB_TYPE_LAST);

typedef struct _qemuBlockJobData qemuBlockJobData;
typedef qemuBlockJobData *qemuBlockJobDataPtr;
@@ -7766,13 +7765,18 @@ qemuProcessRefreshLegacyBlockjob(void *payload,
    qemuMonitorBlockJobInfoPtr info = payload;
    virDomainDiskDefPtr disk;
    qemuBlockJobDataPtr job;
+    virDomainBlockJobType jobtype = info->type;

    if (!(disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, jobname, jobname))) {
        VIR_DEBUG("could not find disk for block job '%s'", jobname);
        return 0;
    }

-    if (!(job = qemuBlockJobDiskNew(disk)))
+    if (jobtype == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
+        disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
+        jobtype = disk->mirrorJob;
+
+    if (!(job = qemuBlockJobDiskNew(disk, jobtype)))

This fails to compile on Clang:
qemu/qemu_process.c:7780:43: error: implicit conversion from enumeration type
'virDomainBlockJobType' to different enumeration type 'qemuBlockjobType'
[-Werror,-Wenum-conversion]
   if (!(job = qemuBlockJobDiskNew(disk, jobtype)))
               ~~~~~~~~~~~~~~~~~~~       ^~~~~~~
1 error generated.

Reviewed-by: Ján Tomko <jtomko redhat com>

Jano

Attachment: signature.asc
Description: PGP signature


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