Commit 33e9e9bd authored by Kevin Wolf's avatar Kevin Wolf
Browse files

job: Create Job, JobDriver and job_create()



This is the first step towards creating an infrastructure for generic
background jobs that aren't tied to a block device. For now, Job only
stores its ID and JobDriver, the rest stays in BlockJob.

The following patches will move over more parts of BlockJob to Job if
they are meaningful outside the context of a block job.

BlockJob.driver is now redundant, but this patch leaves it around to
avoid unnecessary churn. The next patches will get rid of almost all of
its uses anyway so that it can be removed later with much less churn.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
parent a81e0a82
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1369,6 +1369,8 @@ L: qemu-block@nongnu.org
S: Supported
F: blockjob.c
F: include/block/blockjob.h
F: job.c
F: include/block/job.h
F: block/backup.c
F: block/commit.c
F: block/stream.c
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ chardev-obj-y = chardev/
# block-obj-y is code used by both qemu system emulation and qemu-img

block-obj-y += nbd/
block-obj-y += block.o blockjob.o
block-obj-y += block.o blockjob.o job.o
block-obj-y += block/ scsi/
block-obj-y += qemu-io-cmds.o
block-obj-$(CONFIG_REPLICATION) += replication.o
+3 −1
Original line number Diff line number Diff line
@@ -523,7 +523,9 @@ static void coroutine_fn backup_run(void *opaque)
}

static const BlockJobDriver backup_job_driver = {
    .job_driver = {
        .instance_size          = sizeof(BackupBlockJob),
    },
    .job_type               = BLOCK_JOB_TYPE_BACKUP,
    .start                  = backup_run,
    .commit                 = backup_commit,
+3 −1
Original line number Diff line number Diff line
@@ -215,7 +215,9 @@ out:
}

static const BlockJobDriver commit_job_driver = {
    .job_driver = {
        .instance_size = sizeof(CommitBlockJob),
    },
    .job_type      = BLOCK_JOB_TYPE_COMMIT,
    .start         = commit_run,
};
+7 −3
Original line number Diff line number Diff line
@@ -913,7 +913,7 @@ static void mirror_complete(BlockJob *job, Error **errp)

    if (!s->synced) {
        error_setg(errp, "The active block job '%s' cannot be completed",
                   job->id);
                   job->job.id);
        return;
    }

@@ -986,7 +986,9 @@ static void mirror_drain(BlockJob *job)
}

static const BlockJobDriver mirror_job_driver = {
    .job_driver = {
        .instance_size          = sizeof(MirrorBlockJob),
    },
    .job_type               = BLOCK_JOB_TYPE_MIRROR,
    .start                  = mirror_run,
    .complete               = mirror_complete,
@@ -996,7 +998,9 @@ static const BlockJobDriver mirror_job_driver = {
};

static const BlockJobDriver commit_active_job_driver = {
    .job_driver = {
        .instance_size          = sizeof(MirrorBlockJob),
    },
    .job_type               = BLOCK_JOB_TYPE_COMMIT,
    .start                  = mirror_run,
    .complete               = mirror_complete,
Loading