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: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 3 +++
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_migration.c | 2 ++
src/qemu/qemu_process.c | 25 +++++++++++++++++++++++++
4 files changed, 31 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c1b0f81c81..4c8ffd60b0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index a552af6180..4cd7eec4ce 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -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;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index dabdda2715..d0e2b65d01 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1415,6 +1415,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");
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 75ee3893c6..cca280992f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -89,6 +89,7 @@
#include "virresctrl.h"
#include "virvsock.h"
#include "viridentity.h"
+#include "virthreadjob.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -3583,6 +3584,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainState state;
int reason;
+ unsigned long long now;
state = virDomainObjGetState(vm, &reason);
@@ -3632,6 +3634,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;
--
2.23.0