提交 3656bb0a 编写于 作者: P Peter Krempa

qemu: domain: Introduce QEMU_ASYNC_JOB_BACKUP async job type

We will want to use the async job infrastructure along with all the APIs
and event for the backup job so add the backup job as a new async job
type.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 fed2cb48
......@@ -114,6 +114,7 @@ VIR_ENUM_IMPL(qemuDomainAsyncJob,
"dump",
"snapshot",
"start",
"backup",
);
VIR_ENUM_IMPL(qemuDomainNamespace,
......@@ -210,6 +211,7 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_BACKUP:
G_GNUC_FALLTHROUGH;
case QEMU_ASYNC_JOB_LAST:
break;
......@@ -235,6 +237,7 @@ qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_BACKUP:
G_GNUC_FALLTHROUGH;
case QEMU_ASYNC_JOB_LAST:
break;
......
......@@ -104,6 +104,7 @@ typedef enum {
QEMU_ASYNC_JOB_DUMP,
QEMU_ASYNC_JOB_SNAPSHOT,
QEMU_ASYNC_JOB_START,
QEMU_ASYNC_JOB_BACKUP,
QEMU_ASYNC_JOB_LAST
} qemuDomainAsyncJob;
......
......@@ -14041,6 +14041,10 @@ static int qemuDomainAbortJob(virDomainPtr dom)
ret = qemuDomainAbortJobMigration(vm);
break;
case QEMU_ASYNC_JOB_BACKUP:
/* TODO: to be implemented later */
break;
case QEMU_ASYNC_JOB_LAST:
default:
virReportEnumRangeError(qemuDomainAsyncJob, priv->job.asyncJob);
......
......@@ -1444,6 +1444,8 @@ qemuMigrationJobName(virDomainObjPtr vm)
return _("snapshot job");
case QEMU_ASYNC_JOB_START:
return _("start job");
case QEMU_ASYNC_JOB_BACKUP:
return _("backup job");
case QEMU_ASYNC_JOB_LAST:
default:
return _("job");
......
......@@ -89,6 +89,7 @@
#include "virresctrl.h"
#include "virvsock.h"
#include "viridentity.h"
#include "virthreadjob.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
......@@ -3575,6 +3576,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainState state;
int reason;
unsigned long long now;
state = virDomainObjGetState(vm, &reason);
......@@ -3624,6 +3626,29 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
/* Already handled in VIR_DOMAIN_PAUSED_STARTING_UP check. */
break;
case QEMU_ASYNC_JOB_BACKUP:
ignore_value(virTimeMillisNow(&now));
/* Restore the config of the async job which is not persisted */
priv->jobs_queued++;
priv->job.asyncJob = QEMU_ASYNC_JOB_BACKUP;
priv->job.asyncOwnerAPI = virThreadJobGet();
priv->job.asyncStarted = now;
qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK |
JOB_MASK(QEMU_JOB_SUSPEND) |
JOB_MASK(QEMU_JOB_MODIFY)));
/* We reset the job parameters for backup so that the job will look
* active. This is possible because we are able to recover the state
* of blockjobs and also the backup job allows all sub-job types */
priv->job.current = g_new0(qemuDomainJobInfo, 1);
priv->job.current->operation = VIR_DOMAIN_JOB_OPERATION_BACKUP;
priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP;
priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
priv->job.current->started = now;
break;
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_LAST:
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册