|
|
3e5111 |
From 4db224dec8f4aeaadf95da115a57ed73244939a0 Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <4db224dec8f4aeaadf95da115a57ed73244939a0@dist-git>
|
|
|
3e5111 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Date: Wed, 26 Apr 2017 12:00:09 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: Report VIR_DOMAIN_JOB_OPERATION
|
|
|
3e5111 |
|
|
|
3e5111 |
Not all async jobs are visible via virDomainGetJobStats (either they are
|
|
|
3e5111 |
too fast or getting the stats is not allowed during the job), but
|
|
|
3e5111 |
forcing all of them to advertise the operation is easier than hunting
|
|
|
3e5111 |
the jobs for which fetching statistics is allowed. And we won't need to
|
|
|
3e5111 |
think about this when we add support for getting stats for more jobs.
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1441563
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 2a978269fc9dc31c354a7c9132cb62d52e7613ef)
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_domain.c | 16 +++++++++++++---
|
|
|
3e5111 |
src/qemu/qemu_domain.h | 4 +++-
|
|
|
3e5111 |
src/qemu/qemu_driver.c | 32 ++++++++++++++++++++++----------
|
|
|
3e5111 |
src/qemu/qemu_migration.c | 19 ++++++++++++-------
|
|
|
3e5111 |
src/qemu/qemu_process.c | 6 ++++--
|
|
|
3e5111 |
src/qemu/qemu_process.h | 3 ++-
|
|
|
3e5111 |
6 files changed, 56 insertions(+), 24 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
index c43ff3d63..9c09ced0c 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
@@ -405,6 +405,11 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
|
|
3e5111 |
int maxpar = 0;
|
|
|
3e5111 |
int npar = 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ if (virTypedParamsAddInt(&par, &npar, &maxpar,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION,
|
|
|
3e5111 |
+ jobInfo->operation) < 0)
|
|
|
3e5111 |
+ goto error;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (virTypedParamsAddULLong(&par, &npar, &maxpar,
|
|
|
3e5111 |
VIR_DOMAIN_JOB_TIME_ELAPSED,
|
|
|
3e5111 |
jobInfo->timeElapsed) < 0)
|
|
|
3e5111 |
@@ -3674,13 +3679,18 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
|
|
|
3e5111 |
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr obj,
|
|
|
3e5111 |
- qemuDomainAsyncJob asyncJob)
|
|
|
3e5111 |
+ qemuDomainAsyncJob asyncJob,
|
|
|
3e5111 |
+ virDomainJobOperation operation)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ qemuDomainObjPrivatePtr priv;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
|
|
|
3e5111 |
asyncJob) < 0)
|
|
|
3e5111 |
return -1;
|
|
|
3e5111 |
- else
|
|
|
3e5111 |
- return 0;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ priv = obj->privateData;
|
|
|
3e5111 |
+ priv->job.current->operation = operation;
|
|
|
3e5111 |
+ return 0;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
int
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
index 0e32bb9ea..f50330487 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.h
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
@@ -103,6 +103,7 @@ typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
|
|
|
3e5111 |
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
|
|
|
3e5111 |
struct _qemuDomainJobInfo {
|
|
|
3e5111 |
virDomainJobType type;
|
|
|
3e5111 |
+ virDomainJobOperation operation;
|
|
|
3e5111 |
unsigned long long started; /* When the async job started */
|
|
|
3e5111 |
unsigned long long stopped; /* When the domain's CPUs were stopped */
|
|
|
3e5111 |
unsigned long long sent; /* When the source sent status info to the
|
|
|
3e5111 |
@@ -433,7 +434,8 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
ATTRIBUTE_RETURN_CHECK;
|
|
|
3e5111 |
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr obj,
|
|
|
3e5111 |
- qemuDomainAsyncJob asyncJob)
|
|
|
3e5111 |
+ qemuDomainAsyncJob asyncJob,
|
|
|
3e5111 |
+ virDomainJobOperation operation)
|
|
|
3e5111 |
ATTRIBUTE_RETURN_CHECK;
|
|
|
3e5111 |
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr obj,
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
index 2fcf4612e..8699fb2fe 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_driver.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_driver.c
|
|
|
3e5111 |
@@ -268,7 +268,8 @@ qemuAutostartDomain(virDomainObjPtr vm,
|
|
|
3e5111 |
virResetLastError();
|
|
|
3e5111 |
if (vm->autostart &&
|
|
|
3e5111 |
!virDomainObjIsActive(vm)) {
|
|
|
3e5111 |
- if (qemuProcessBeginJob(data->driver, vm) < 0) {
|
|
|
3e5111 |
+ if (qemuProcessBeginJob(data->driver, vm,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_START) < 0) {
|
|
|
3e5111 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
3e5111 |
_("Failed to start job on VM '%s': %s"),
|
|
|
3e5111 |
vm->def->name, virGetLastErrorMessage());
|
|
|
3e5111 |
@@ -1764,7 +1765,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
|
|
3e5111 |
virObjectRef(vm);
|
|
|
3e5111 |
def = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuProcessBeginJob(driver, vm) < 0) {
|
|
|
3e5111 |
+ if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START) < 0) {
|
|
|
3e5111 |
qemuDomainRemoveInactive(driver, vm);
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
@@ -3152,7 +3153,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
|
|
3e5111 |
if (!qemuMigrationIsAllowed(driver, vm, false, 0))
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
|
|
|
3e5111 |
+ if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_SAVE) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!virDomainObjIsActive(vm)) {
|
|
|
3e5111 |
@@ -3690,7 +3692,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (qemuDomainObjBeginAsyncJob(driver, vm,
|
|
|
3e5111 |
- QEMU_ASYNC_JOB_DUMP) < 0)
|
|
|
3e5111 |
+ QEMU_ASYNC_JOB_DUMP,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_DUMP) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!virDomainObjIsActive(vm)) {
|
|
|
3e5111 |
@@ -3920,7 +3923,8 @@ processWatchdogEvent(virQEMUDriverPtr driver,
|
|
|
3e5111 |
switch (action) {
|
|
|
3e5111 |
case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
|
|
|
3e5111 |
if (qemuDomainObjBeginAsyncJob(driver, vm,
|
|
|
3e5111 |
- QEMU_ASYNC_JOB_DUMP) < 0) {
|
|
|
3e5111 |
+ QEMU_ASYNC_JOB_DUMP,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_DUMP) < 0) {
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -4007,7 +4011,8 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
bool removeInactive = false;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_DUMP) < 0)
|
|
|
3e5111 |
+ if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_DUMP,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_DUMP) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!virDomainObjIsActive(vm)) {
|
|
|
3e5111 |
@@ -6492,7 +6497,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|
|
3e5111 |
priv->hookRun = true;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuProcessBeginJob(driver, vm) < 0)
|
|
|
3e5111 |
+ if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
|
|
|
3e5111 |
@@ -6912,6 +6917,7 @@ qemuDomainObjStart(virConnectPtr conn,
|
|
|
3e5111 |
bool bypass_cache = (flags & VIR_DOMAIN_START_BYPASS_CACHE) != 0;
|
|
|
3e5111 |
bool force_boot = (flags & VIR_DOMAIN_START_FORCE_BOOT) != 0;
|
|
|
3e5111 |
unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
|
|
|
3e5111 |
+ qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
|
|
|
3e5111 |
start_flags |= start_paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
|
|
|
3e5111 |
start_flags |= autodestroy ? VIR_QEMU_PROCESS_START_AUTODESTROY : 0;
|
|
|
3e5111 |
@@ -6935,6 +6941,9 @@ qemuDomainObjStart(virConnectPtr conn,
|
|
|
3e5111 |
}
|
|
|
3e5111 |
vm->hasManagedSave = false;
|
|
|
3e5111 |
} else {
|
|
|
3e5111 |
+ virDomainJobOperation op = priv->job.current->operation;
|
|
|
3e5111 |
+ priv->job.current->operation = VIR_DOMAIN_JOB_OPERATION_RESTORE;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
ret = qemuDomainObjRestore(conn, driver, vm, managed_save,
|
|
|
3e5111 |
start_paused, bypass_cache, asyncJob);
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -6951,6 +6960,7 @@ qemuDomainObjStart(virConnectPtr conn,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
} else {
|
|
|
3e5111 |
VIR_WARN("Ignoring incomplete managed state %s", managed_save);
|
|
|
3e5111 |
+ priv->job.current->operation = op;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
}
|
|
|
3e5111 |
}
|
|
|
3e5111 |
@@ -7000,7 +7010,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|
|
3e5111 |
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuProcessBeginJob(driver, vm) < 0)
|
|
|
3e5111 |
+ if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (virDomainObjIsActive(vm)) {
|
|
|
3e5111 |
@@ -14567,7 +14577,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
3e5111 |
* a regular job, so we need to set the job mask to disallow query as
|
|
|
3e5111 |
* 'savevm' blocks the monitor. External snapshot will then modify the
|
|
|
3e5111 |
* job mask appropriately. */
|
|
|
3e5111 |
- if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT) < 0)
|
|
|
3e5111 |
+ if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
|
|
|
3e5111 |
@@ -15157,7 +15168,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuProcessBeginJob(driver, vm) < 0)
|
|
|
3e5111 |
+ if (qemuProcessBeginJob(driver, vm,
|
|
|
3e5111 |
+ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|
|
|
3e5111 |
index 8cbad894c..cadbf9b97 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_migration.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_migration.c
|
|
|
3e5111 |
@@ -5598,18 +5598,23 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
|
|
|
3e5111 |
qemuDomainAsyncJob job)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
-
|
|
|
3e5111 |
- if (qemuDomainObjBeginAsyncJob(driver, vm, job) < 0)
|
|
|
3e5111 |
- return -1;
|
|
|
3e5111 |
+ virDomainJobOperation op;
|
|
|
3e5111 |
+ unsigned long long mask;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
|
|
|
3e5111 |
- qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
|
|
|
3e5111 |
+ op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN;
|
|
|
3e5111 |
+ mask = QEMU_JOB_NONE;
|
|
|
3e5111 |
} else {
|
|
|
3e5111 |
- qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK |
|
|
|
3e5111 |
- JOB_MASK(QEMU_JOB_SUSPEND) |
|
|
|
3e5111 |
- JOB_MASK(QEMU_JOB_MIGRATION_OP)));
|
|
|
3e5111 |
+ op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT;
|
|
|
3e5111 |
+ mask = QEMU_JOB_DEFAULT_MASK |
|
|
|
3e5111 |
+ JOB_MASK(QEMU_JOB_SUSPEND) |
|
|
|
3e5111 |
+ JOB_MASK(QEMU_JOB_MIGRATION_OP);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
+ if (qemuDomainObjBeginAsyncJob(driver, vm, job, op) < 0)
|
|
|
3e5111 |
+ return -1;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ qemuDomainObjSetAsyncJobMask(vm, mask);
|
|
|
3e5111 |
priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
|
|
|
3e5111 |
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
3e5111 |
index 2eee70203..afd9dfb71 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_process.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_process.c
|
|
|
3e5111 |
@@ -4143,11 +4143,13 @@ qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
|
|
|
3e5111 |
*/
|
|
|
3e5111 |
int
|
|
|
3e5111 |
qemuProcessBeginJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
- virDomainObjPtr vm)
|
|
|
3e5111 |
+ virDomainObjPtr vm,
|
|
|
3e5111 |
+ virDomainJobOperation operation)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_START) < 0)
|
|
|
3e5111 |
+ if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_START,
|
|
|
3e5111 |
+ operation) < 0)
|
|
|
3e5111 |
return -1;
|
|
|
3e5111 |
|
|
|
3e5111 |
qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
|
|
|
3e5111 |
index 21f3b0cca..830d8cef8 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_process.h
|
|
|
3e5111 |
+++ b/src/qemu/qemu_process.h
|
|
|
3e5111 |
@@ -59,7 +59,8 @@ qemuProcessIncomingDefPtr qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
|
|
|
3e5111 |
void qemuProcessIncomingDefFree(qemuProcessIncomingDefPtr inc);
|
|
|
3e5111 |
|
|
|
3e5111 |
int qemuProcessBeginJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
- virDomainObjPtr vm);
|
|
|
3e5111 |
+ virDomainObjPtr vm,
|
|
|
3e5111 |
+ virDomainJobOperation operation);
|
|
|
3e5111 |
void qemuProcessEndJob(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm);
|
|
|
3e5111 |
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.12.2
|
|
|
3e5111 |
|