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

View File

@ -61,6 +61,21 @@ virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks = {
.free = bhyveDomainObjPrivateFree, .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 static int
bhyveDomainDefPostParse(virDomainDefPtr def, bhyveDomainDefPostParse(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,

View File

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