mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemuProcessCreatePretendCmd: Split up preparation and command building
Host preparation steps which are deliberately skipped when pretend-creating a commandline are normally executed after VM object preparation. In the test code we are faking some of the host preparation steps, but we were doing that prior to the call to qemuProcessPrepareDomain embedded in qemuProcessCreatePretendCmd. By splitting up qemuProcessCreatePretendCmd into two functions we can ensure that the ordering of the prepare steps stays consistent. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d8960bff71
commit
9ff3ad9058
@ -6451,9 +6451,12 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
||||
vm->def->nets[i] = newNet;
|
||||
}
|
||||
|
||||
if (!(cmd = qemuProcessCreatePretendCmd(driver, vm, NULL,
|
||||
qemuCheckFips(), true, false,
|
||||
VIR_QEMU_PROCESS_START_COLD)))
|
||||
if (qemuProcessCreatePretendCmdPrepare(driver, vm, NULL, true,
|
||||
VIR_QEMU_PROCESS_START_COLD) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(cmd = qemuProcessCreatePretendCmdBuild(driver, vm, NULL,
|
||||
qemuCheckFips(), true, false)))
|
||||
goto cleanup;
|
||||
|
||||
ret = virCommandToString(cmd, false);
|
||||
|
@ -7290,35 +7290,45 @@ qemuProcessStart(virConnectPtr conn,
|
||||
}
|
||||
|
||||
|
||||
virCommandPtr
|
||||
qemuProcessCreatePretendCmd(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool enableFips,
|
||||
bool standalone,
|
||||
bool jsonPropsValidation,
|
||||
unsigned int flags)
|
||||
int
|
||||
qemuProcessCreatePretendCmdPrepare(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool standalone,
|
||||
unsigned int flags)
|
||||
{
|
||||
unsigned int buildflags = 0;
|
||||
|
||||
virCheckFlags(VIR_QEMU_PROCESS_START_COLD |
|
||||
VIR_QEMU_PROCESS_START_PAUSED |
|
||||
VIR_QEMU_PROCESS_START_AUTODESTROY, NULL);
|
||||
VIR_QEMU_PROCESS_START_AUTODESTROY, -1);
|
||||
|
||||
flags |= VIR_QEMU_PROCESS_START_PRETEND;
|
||||
flags |= VIR_QEMU_PROCESS_START_NEW;
|
||||
if (standalone)
|
||||
flags |= VIR_QEMU_PROCESS_START_STANDALONE;
|
||||
|
||||
if (jsonPropsValidation)
|
||||
buildflags = QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON;
|
||||
|
||||
if (qemuProcessInit(driver, vm, NULL, QEMU_ASYNC_JOB_NONE,
|
||||
!!migrateURI, flags) < 0)
|
||||
return NULL;
|
||||
return -1;
|
||||
|
||||
if (qemuProcessPrepareDomain(driver, vm, flags) < 0)
|
||||
return NULL;
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virCommandPtr
|
||||
qemuProcessCreatePretendCmdBuild(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool enableFips,
|
||||
bool standalone,
|
||||
bool jsonPropsValidation)
|
||||
{
|
||||
unsigned int buildflags = 0;
|
||||
|
||||
if (jsonPropsValidation)
|
||||
buildflags = QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON;
|
||||
|
||||
VIR_DEBUG("Building emulator command line");
|
||||
return qemuBuildCommandLine(driver,
|
||||
|
@ -96,13 +96,18 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
virNetDevVPortProfileOp vmop,
|
||||
unsigned int flags);
|
||||
|
||||
virCommandPtr qemuProcessCreatePretendCmd(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool enableFips,
|
||||
bool standalone,
|
||||
bool jsonPropsValidation,
|
||||
unsigned int flags);
|
||||
int qemuProcessCreatePretendCmdPrepare(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool standalone,
|
||||
unsigned int flags);
|
||||
|
||||
virCommandPtr qemuProcessCreatePretendCmdBuild(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
const char *migrateURI,
|
||||
bool enableFips,
|
||||
bool standalone,
|
||||
bool jsonPropsValidation);
|
||||
|
||||
int qemuProcessInit(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
|
@ -401,6 +401,10 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (qemuProcessCreatePretendCmdPrepare(drv, vm, migrateURI, false,
|
||||
VIR_QEMU_PROCESS_START_COLD) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < vm->def->nhostdevs; i++) {
|
||||
virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
|
||||
|
||||
@ -466,10 +470,9 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
|
||||
}
|
||||
}
|
||||
|
||||
return qemuProcessCreatePretendCmd(drv, vm, migrateURI,
|
||||
(flags & FLAG_FIPS), false,
|
||||
jsonPropsValidation,
|
||||
VIR_QEMU_PROCESS_START_COLD);
|
||||
return qemuProcessCreatePretendCmdBuild(drv, vm, migrateURI,
|
||||
(flags & FLAG_FIPS), false,
|
||||
jsonPropsValidation);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user