提交 0d1c17aa 编写于 作者: P Peter Krempa

qemu: process: Convert multiple boolean args to a single flag

Validation of qemu process startup requires to know whether the process
is used for a fresh VM or whether it's reloaded from a
snapshot/migration. Pass this information in via a flag rather than
calculating it from a bunch of bools.
上级 43e21b1f
......@@ -3627,7 +3627,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
}
if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
true, false, VIR_QEMU_PROCESS_START_AUTODESTROY) < 0)
true, VIR_QEMU_PROCESS_START_AUTODESTROY) < 0)
goto stopjob;
stopProcess = true;
......
......@@ -4285,8 +4285,7 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm)
static int
qemuProcessStartValidateXML(virDomainObjPtr vm,
virQEMUCapsPtr qemuCaps,
bool migration,
bool snapshot)
unsigned int flags)
{
/* The bits we validate here are XML configs that we previously
* accepted. We reject them at VM startup time rather than parse
......@@ -4299,7 +4298,10 @@ qemuProcessStartValidateXML(virDomainObjPtr vm,
if (qemuValidateCpuCount(vm->def, qemuCaps) < 0)
return -1;
if (!migration && !snapshot &&
/* checks below should not be executed when starting a qemu process for a
* VM that was running before (migration, snapshots, save). It's more
* important to start such VM than keep the configuration clean */
if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
return -1;
......@@ -4329,8 +4331,6 @@ static int
qemuProcessStartValidate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virQEMUCapsPtr qemuCaps,
bool migration,
bool snapshot,
unsigned int flags)
{
size_t i;
......@@ -4358,7 +4358,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
}
if (qemuProcessStartValidateXML(vm, qemuCaps, migration, snapshot) < 0)
if (qemuProcessStartValidateXML(vm, qemuCaps, flags) < 0)
return -1;
VIR_DEBUG("Checking for any possible (non-fatal) issues");
......@@ -4408,7 +4408,6 @@ qemuProcessInit(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
bool migration,
bool snap,
unsigned int flags)
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
......@@ -4438,8 +4437,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
vm->def->os.machine)))
goto cleanup;
if (qemuProcessStartValidate(driver, vm, priv->qemuCaps,
migration, snap, flags) < 0)
if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, flags) < 0)
goto cleanup;
/* Do this upfront, so any part of the startup process can add
......@@ -5415,8 +5413,10 @@ qemuProcessStart(virConnectPtr conn,
VIR_QEMU_PROCESS_START_PAUSED |
VIR_QEMU_PROCESS_START_AUTODESTROY, cleanup);
if (qemuProcessInit(driver, vm, asyncJob, !!migrateFrom,
!!snapshot, flags) < 0)
if (!migrateFrom && !snapshot)
flags |= VIR_QEMU_PROCESS_START_NEW;
if (qemuProcessInit(driver, vm, asyncJob, !!migrateFrom, flags) < 0)
goto cleanup;
if (migrateFrom) {
......@@ -5493,9 +5493,9 @@ qemuProcessCreatePretendCmd(virConnectPtr conn,
VIR_QEMU_PROCESS_START_AUTODESTROY, cleanup);
flags |= VIR_QEMU_PROCESS_START_PRETEND;
flags |= VIR_QEMU_PROCESS_START_NEW;
if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_NONE, !!migrateURI,
false, flags) < 0)
if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_NONE, !!migrateURI, flags) < 0)
goto cleanup;
if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0)
......
......@@ -68,6 +68,7 @@ typedef enum {
VIR_QEMU_PROCESS_START_PAUSED = 1 << 1,
VIR_QEMU_PROCESS_START_AUTODESTROY = 1 << 2,
VIR_QEMU_PROCESS_START_PRETEND = 1 << 3,
VIR_QEMU_PROCESS_START_NEW = 1 << 4, /* internal, new VM is starting */
} qemuProcessStartFlags;
int qemuProcessStart(virConnectPtr conn,
......@@ -93,7 +94,6 @@ int qemuProcessInit(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
bool migration,
bool snap,
unsigned int flags);
int qemuProcessPrepareDomain(virConnectPtr conn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册