提交 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, ...@@ -3182,7 +3182,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false))) if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup; goto cleanup;
if (!qemuMigrationIsAllowed(driver, vm, false, false)) if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup; goto cleanup;
if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0) if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
...@@ -3614,7 +3614,7 @@ doCoreDump(virQEMUDriverPtr driver, ...@@ -3614,7 +3614,7 @@ doCoreDump(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
if (!qemuMigrationIsAllowed(driver, vm, false, false)) if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup; goto cleanup;
ret = qemuMigrationToFile(driver, vm, fd, 0, path, ret = qemuMigrationToFile(driver, vm, fd, 0, path,
...@@ -13688,7 +13688,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, ...@@ -13688,7 +13688,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
bool resume = false; bool resume = false;
int ret = -1; int ret = -1;
if (!qemuMigrationIsAllowed(driver, vm, false, false)) if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup; goto cleanup;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
...@@ -14503,7 +14503,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, ...@@ -14503,7 +14503,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
/* do the memory snapshot if necessary */ /* do the memory snapshot if necessary */
if (memory) { if (memory) {
/* check if migration is possible */ /* check if migration is possible */
if (!qemuMigrationIsAllowed(driver, vm, false, false)) if (!qemuMigrationIsAllowed(driver, vm, false, 0))
goto cleanup; goto cleanup;
/* allow the migration job to be cancelled or the domain to be paused */ /* allow the migration job to be cancelled or the domain to be paused */
......
...@@ -2184,11 +2184,25 @@ qemuMigrationIsAllowedHostdev(const virDomainDef *def) ...@@ -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 bool
qemuMigrationIsAllowed(virQEMUDriverPtr driver, qemuMigrationIsAllowed(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
bool remote, bool remote,
bool abort_on_error) unsigned int flags)
{ {
int nsnapshots; int nsnapshots;
int pauseReason; int pauseReason;
...@@ -2214,7 +2228,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, ...@@ -2214,7 +2228,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
} }
/* cancel migration if disk I/O error is emitted while migrating */ /* 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 && virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&
pauseReason == VIR_DOMAIN_PAUSED_IOERROR) { pauseReason == VIR_DOMAIN_PAUSED_IOERROR) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
...@@ -2950,7 +2964,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, ...@@ -2950,7 +2964,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
unsigned int cookieFlags = QEMU_MIGRATION_COOKIE_LOCKSTATE; 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," VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
" cookieout=%p, cookieoutlen=%p," " cookieout=%p, cookieoutlen=%p,"
...@@ -2969,7 +2982,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, ...@@ -2969,7 +2982,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_BEGIN3); qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_BEGIN3);
if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error)) if (!qemuMigrationIsAllowed(driver, vm, true, flags))
goto cleanup; goto cleanup;
if (!(flags & VIR_MIGRATE_UNSAFE) && if (!(flags & VIR_MIGRATE_UNSAFE) &&
...@@ -5319,7 +5332,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver, ...@@ -5319,7 +5332,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
virErrorPtr orig_err = NULL; virErrorPtr orig_err = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup; goto cleanup;
...@@ -5330,7 +5342,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver, ...@@ -5330,7 +5342,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
goto endjob; goto endjob;
} }
if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error)) if (!qemuMigrationIsAllowed(driver, vm, true, flags))
goto endjob; goto endjob;
if (!(flags & VIR_MIGRATE_UNSAFE) && if (!(flags & VIR_MIGRATE_UNSAFE) &&
......
...@@ -174,7 +174,7 @@ int qemuMigrationConfirm(virConnectPtr conn, ...@@ -174,7 +174,7 @@ int qemuMigrationConfirm(virConnectPtr conn,
int cancelled); int cancelled);
bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm, bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
bool remote, bool abort_on_error); bool remote, unsigned int flags);
int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
int fd, off_t offset, const char *path, 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.
先完成此消息的编辑!
想要评论请 注册