qemu_driver: cleanup qemuConnectDomainXMLToNative

Use qemuProcessCreatePretendCmd instead duplicating required steps from
qemuProcessStart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2016-03-17 13:20:58 +01:00
parent 758cca88b2
commit 12de369aa6
1 changed files with 2 additions and 40 deletions

View File

@ -6948,17 +6948,12 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
unsigned int flags)
{
virQEMUDriverPtr driver = conn->privateData;
virDomainChrSourceDef monConfig = {0};
virQEMUCapsPtr qemuCaps = NULL;
virDomainObjPtr vm = NULL;
bool monitor_json = false;
virCommandPtr cmd = NULL;
char *ret = NULL;
size_t i;
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
char *domainLibDir = NULL;
char *domainChannelTargetDir = NULL;
virCheckFlags(0, NULL);
@ -6984,17 +6979,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))
goto cleanup;
if (qemuProcessStartValidate(driver, vm, qemuCaps, false, false,
VIR_QEMU_PROCESS_START_COLD |
VIR_QEMU_PROCESS_START_PRETEND) < 0)
goto cleanup;
/* Generate per-domain paths because we don't have the domain object */
if (qemuDomainSetPrivatePaths(&domainLibDir, &domainChannelTargetDir,
cfg->libDir, cfg->channelTargetDir,
vm->def->name, -1) < 0)
goto cleanup;
/* Since we're just exporting args, we can't do bridge/network/direct
* setups, since libvirt will normally create TAP/macvtap devices
* directly. We convert those configs into generic 'ethernet'
@ -7083,17 +7067,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->mac = mac;
}
monitor_json = virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON);
if (qemuProcessPrepareMonitorChr(&monConfig, vm->def->name) < 0)
goto cleanup;
if (qemuAssignDeviceAliases(vm->def, qemuCaps) < 0)
goto cleanup;
if (qemuDomainAssignAddresses(vm->def, qemuCaps, NULL) < 0)
goto cleanup;
/* do fake auto-alloc of graphics ports, if such config is used */
for (i = 0; i < vm->def->ngraphics; ++i) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
@ -7106,28 +7079,17 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
}
}
if (!(cmd = qemuBuildCommandLine(conn, driver, NULL, vm->def,
&monConfig, monitor_json, qemuCaps,
NULL, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
&buildCommandLineCallbacks,
true,
qemuCheckFips(),
NULL, NULL, NULL,
domainLibDir,
domainChannelTargetDir)))
if (!(cmd = qemuProcessCreatePretendCmd(conn, driver, vm, NULL, false, true,
VIR_QEMU_PROCESS_START_COLD)))
goto cleanup;
ret = virCommandToString(cmd);
cleanup:
virObjectUnref(qemuCaps);
virCommandFree(cmd);
virObjectUnref(vm);
virObjectUnref(caps);
virObjectUnref(cfg);
VIR_FREE(domainLibDir);
VIR_FREE(domainChannelTargetDir);
return ret;
}