qemu: Use g_autoptr in qemuDomainDefPostParse

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2019-09-26 17:47:53 +02:00
parent 02e5cb0d1a
commit ac89b0549e

View File

@ -4613,54 +4613,50 @@ qemuDomainDefPostParse(virDomainDefPtr def,
void *parseOpaque) void *parseOpaque)
{ {
virQEMUDriverPtr driver = opaque; virQEMUDriverPtr driver = opaque;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
/* Note that qemuCaps may be NULL when this function is called. This /* Note that qemuCaps may be NULL when this function is called. This
* function shall not fail in that case. It will be re-run on VM startup * function shall not fail in that case. It will be re-run on VM startup
* with the capabilities populated. */ * with the capabilities populated. */
virQEMUCapsPtr qemuCaps = parseOpaque; virQEMUCapsPtr qemuCaps = parseOpaque;
int ret = -1;
if (def->os.bootloader || def->os.bootloaderArgs) { if (def->os.bootloader || def->os.bootloaderArgs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("bootloader is not supported by QEMU")); _("bootloader is not supported by QEMU"));
goto cleanup; return -1;
} }
if (!def->os.machine) { if (!def->os.machine) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing machine type")); _("missing machine type"));
goto cleanup; return -1;
} }
qemuDomainNVRAMPathGenerate(cfg, def); qemuDomainNVRAMPathGenerate(cfg, def);
if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0)
goto cleanup; return -1;
if (qemuCanonicalizeMachine(def, qemuCaps) < 0) if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
goto cleanup; return -1;
qemuDomainDefEnableDefaultFeatures(def, qemuCaps); qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0) if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0)
goto cleanup; return -1;
if (qemuSecurityVerify(driver->securityManager, def) < 0) if (qemuSecurityVerify(driver->securityManager, def) < 0)
goto cleanup; return -1;
if (qemuDomainDefVcpusPostParse(def) < 0) if (qemuDomainDefVcpusPostParse(def) < 0)
goto cleanup; return -1;
if (qemuDomainDefCPUPostParse(def) < 0) if (qemuDomainDefCPUPostParse(def) < 0)
goto cleanup; return -1;
if (qemuDomainDefTsegPostParse(def, qemuCaps) < 0) if (qemuDomainDefTsegPostParse(def, qemuCaps) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
virObjectUnref(cfg);
return ret;
} }