mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
bhyve: refactor bhyveConnectDomainXMLToNative
Use g_auto and remove the ret variable, as well as the cleanup label. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
681df4776b
commit
a55ee2a3fd
@ -671,27 +671,26 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
struct _bhyveConn *privconn = conn->privateData;
|
struct _bhyveConn *privconn = conn->privateData;
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
virCommand *loadcmd = NULL;
|
g_autoptr(virCommand) loadcmd = NULL;
|
||||||
char *ret = NULL;
|
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
|
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) {
|
if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("Unsupported config type %s"), format);
|
_("Unsupported config type %s"), format);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(def = virDomainDefParseString(xmlData, privconn->xmlopt,
|
if (!(def = virDomainDefParseString(xmlData, privconn->xmlopt,
|
||||||
NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (bhyveDomainAssignAddresses(def, NULL) < 0)
|
if (bhyveDomainAssignAddresses(def, NULL) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (def->os.bootloader == NULL &&
|
if (def->os.bootloader == NULL &&
|
||||||
def->os.loader) {
|
def->os.loader) {
|
||||||
@ -699,35 +698,30 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
if (!virDomainDefHasOldStyleROUEFI(def)) {
|
if (!virDomainDefHasOldStyleROUEFI(def)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Only read-only pflash is supported."));
|
_("Only read-only pflash is supported."));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bhyveDriverGetBhyveCaps(privconn) & BHYVE_CAP_LPC_BOOTROM) == 0) {
|
if ((bhyveDriverGetBhyveCaps(privconn) & BHYVE_CAP_LPC_BOOTROM) == 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Installed bhyve binary does not support "
|
_("Installed bhyve binary does not support "
|
||||||
"bootrom"));
|
"bootrom"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def,
|
if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def,
|
||||||
"<device.map>", NULL)))
|
"<device.map>", NULL)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
virCommandToStringBuf(loadcmd, &buf, false, false);
|
virCommandToStringBuf(loadcmd, &buf, false, false);
|
||||||
virBufferAddChar(&buf, '\n');
|
virBufferAddChar(&buf, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
|
if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
virCommandToStringBuf(cmd, &buf, false, false);
|
virCommandToStringBuf(cmd, &buf, false, false);
|
||||||
|
|
||||||
ret = virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(loadcmd);
|
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user