bhyve: add bhyveDomainDefNeedsISAController helper

Add a bhyveDomainDefNeedsISAController() helper function
which by domain configuration determines whether LPC controller is
required or not.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Roman Bogorodskiy 2019-02-17 11:27:28 +04:00
parent a042c94880
commit 12f4bf80a7
3 changed files with 18 additions and 4 deletions

View File

@ -460,7 +460,6 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
* vm0
*/
size_t i;
bool add_lpc = false;
int nusbcontrollers = 0;
unsigned int nvcpus = virDomainDefGetVcpus(def);
@ -553,7 +552,6 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM)) {
virCommandAddArg(cmd, "-l");
virCommandAddArgFormat(cmd, "bootrom,%s", def->os.loader->path);
add_lpc = true;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Installed bhyve binary does not support "
@ -617,7 +615,6 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->videos[0],
conn, cmd, dryRun) < 0)
goto error;
add_lpc = true;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Multiple graphics devices are not supported"));
@ -625,7 +622,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
}
}
if (add_lpc || def->nserials)
if (bhyveDomainDefNeedsISAController(def))
bhyveBuildLPCArgStr(def, cmd);
if (bhyveBuildConsoleArgStr(def, cmd) < 0)

View File

@ -61,6 +61,21 @@ virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks = {
.free = bhyveDomainObjPrivateFree,
};
bool
bhyveDomainDefNeedsISAController(virDomainDefPtr def)
{
if (def->os.bootloader == NULL && def->os.loader)
return true;
if (def->nserials)
return true;
if (def->ngraphics && def->nvideos)
return true;
return false;
}
static int
bhyveDomainDefPostParse(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,

View File

@ -41,4 +41,6 @@ extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks;
extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig;
extern virDomainXMLNamespace virBhyveDriverDomainXMLNamespace;
bool bhyveDomainDefNeedsISAController(virDomainDefPtr def);
#endif /* LIBVIRT_BHYVE_DOMAIN_H */