提交 b6c44af0 编写于 作者: P Peter Krempa

qemu: migration: Use migration flags in qemuMigrationIsAllowed

Use the migration @flags for checking various migration aspects rather
than picking them out as booleans. Document the new semantics in the
function header.
上级 f558c66f
......@@ -3182,7 +3182,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (!qemuMigrationIsAllowed(driver, vm, false, false))
if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup;
if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
......@@ -3614,7 +3614,7 @@ doCoreDump(virQEMUDriverPtr driver,
goto cleanup;
}
if (!qemuMigrationIsAllowed(driver, vm, false, false))
if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup;
ret = qemuMigrationToFile(driver, vm, fd, 0, path,
......@@ -13688,7 +13688,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
bool resume = false;
int ret = -1;
if (!qemuMigrationIsAllowed(driver, vm, false, false))
if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
......@@ -14503,7 +14503,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
/* do the memory snapshot if necessary */
if (memory) {
/* check if migration is possible */
if (!qemuMigrationIsAllowed(driver, vm, false, false))
if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup;
/* allow the migration job to be cancelled or the domain to be paused */
......
......@@ -2184,11 +2184,25 @@ qemuMigrationIsAllowedHostdev(const virDomainDef *def)
}
/**
* qemuMigrationIsAllowed:
* @driver: qemu driver struct
* @vm: domain object
* @remote: migration is remote
* @flags: migration flags (see struct virDomainMigrateFlags)
*
* Validates that the configuration of @vm can be migrated in various
* situations. If @remote is true, the migration happens to remote host. @flags
* is used to check various special migration types according to the request.
*
* Returns true if migration is supported. Reports libvirt error and returns
* false otherwise.
*/
bool
qemuMigrationIsAllowed(virQEMUDriverPtr driver,
virDomainObjPtr vm,
bool remote,
bool abort_on_error)
unsigned int flags)
{
int nsnapshots;
int pauseReason;
......@@ -2214,7 +2228,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
}
/* cancel migration if disk I/O error is emitted while migrating */
if (abort_on_error &&
if (flags & VIR_MIGRATE_ABORT_ON_ERROR &&
virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&
pauseReason == VIR_DOMAIN_PAUSED_IOERROR) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -2950,7 +2964,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virCapsPtr caps = NULL;
unsigned int cookieFlags = QEMU_MIGRATION_COOKIE_LOCKSTATE;
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
" cookieout=%p, cookieoutlen=%p,"
......@@ -2969,7 +2982,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_BEGIN3);
if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error))
if (!qemuMigrationIsAllowed(driver, vm, true, flags))
goto cleanup;
if (!(flags & VIR_MIGRATE_UNSAFE) &&
......@@ -5319,7 +5332,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
int ret = -1;
virErrorPtr orig_err = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup;
......@@ -5330,7 +5342,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
goto endjob;
}
if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error))
if (!qemuMigrationIsAllowed(driver, vm, true, flags))
goto endjob;
if (!(flags & VIR_MIGRATE_UNSAFE) &&
......
......@@ -174,7 +174,7 @@ int qemuMigrationConfirm(virConnectPtr conn,
int cancelled);
bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
bool remote, bool abort_on_error);
bool remote, unsigned int flags);
int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
int fd, off_t offset, const char *path,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册