Signed-off-by: Ryan Moeller <ryan(a)iXsystems.com>
---
src/bhyve/bhyve_command.c | 40 +++++++++++++++++++--------------------
src/bhyve/bhyve_command.h | 4 ++--
src/bhyve/bhyve_driver.c | 21 +++++++++-----------
src/bhyve/bhyve_driver.h | 4 ++--
src/bhyve/bhyve_process.c | 8 +++-----
tests/bhyvexml2argvtest.c | 4 ++--
6 files changed, 37 insertions(+), 44 deletions(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 2df7b60115..a1078d1460 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -44,7 +44,7 @@
VIR_LOG_INIT("bhyve.bhyve_command");
static int
-bhyveBuildNetArgStr(virConnectPtr conn,
+bhyveBuildNetArgStr(bhyveConnPtr driver,
const virDomainDef *def,
virDomainNetDefPtr net,
virCommandPtr cmd,
@@ -60,7 +60,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) {
nic_model = g_strdup("virtio-net");
} else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) {
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) {
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_NET_E1000) != 0) {
nic_model = g_strdup("e1000");
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -167,7 +167,7 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd)
static int
bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
virDomainControllerDefPtr controller,
- virConnectPtr conn,
+ bhyveConnPtr driver,
virCommandPtr cmd)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -208,13 +208,13 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
switch (disk->device) {
case VIR_DOMAIN_DISK_DEVICE_DISK:
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT))
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_AHCI32SLOT))
virBufferAsprintf(&device, ",hd:%s", disk_source);
else
virBufferAsprintf(&device, "-hd,%s", disk_source);
break;
case VIR_DOMAIN_DISK_DEVICE_CDROM:
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT))
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_AHCI32SLOT))
virBufferAsprintf(&device, ",cd:%s", disk_source);
else
virBufferAsprintf(&device, "-cd,%s", disk_source);
@@ -323,7 +323,7 @@ static int
bhyveBuildGraphicsArgStr(const virDomainDef *def,
virDomainGraphicsDefPtr graphics,
virDomainVideoDefPtr video,
- virConnectPtr conn,
+ bhyveConnPtr driver,
virCommandPtr cmd,
bool dryRun)
{
@@ -332,9 +332,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
bool escapeAddr;
unsigned short port;
- bhyveConnPtr driver = conn->privateData;
-
- if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) ||
+ if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM) ||
def->os.bootloader ||
!def->os.loader) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -343,7 +341,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
return -1;
}
- if (!(bhyveDriverGetCaps(conn) & BHYVE_CAP_FBUF)) {
+ if (!(bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_FBUF)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Bhyve version does not support framebuffer"));
return -1;
@@ -434,7 +432,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
}
virCommandPtr
-virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
+virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver,
virDomainDefPtr def, bool dryRun)
{
/*
@@ -467,7 +465,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
goto error;
}
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_CPUTOPOLOGY) != 0) {
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_CPUTOPOLOGY) != 0) {
virCommandAddArgFormat(cmd,
"cpus=%d,sockets=%d,cores=%d,threads=%d",
nvcpus,
def->cpu->sockets,
@@ -506,7 +504,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
/* used by default in bhyve */
break;
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_RTC_UTC) != 0) {
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_RTC_UTC) != 0) {
virCommandAddArg(cmd, "-u");
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -540,7 +538,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
if (def->os.bootloader == NULL &&
def->os.loader) {
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM)) {
+ if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM)) {
virCommandAddArg(cmd, "-l");
virCommandAddArgFormat(cmd, "bootrom,%s",
def->os.loader->path);
} else {
@@ -563,7 +561,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
}
break;
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
- if (bhyveBuildAHCIControllerArgStr(def, controller, conn, cmd) < 0)
+ if (bhyveBuildAHCIControllerArgStr(def, controller, driver, cmd) < 0)
goto error;
break;
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
@@ -580,7 +578,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
}
for (i = 0; i < def->nnets; i++) {
virDomainNetDefPtr net = def->nets[i];
- if (bhyveBuildNetArgStr(conn, def, net, cmd, dryRun) < 0)
+ if (bhyveBuildNetArgStr(driver, def, net, cmd, dryRun) < 0)
goto error;
}
for (i = 0; i < def->ndisks; i++) {
@@ -604,7 +602,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
if (def->ngraphics && def->nvideos) {
if (def->ngraphics == 1 && def->nvideos == 1) {
if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->videos[0],
- conn, cmd, dryRun) < 0)
+ driver, cmd, dryRun) < 0)
goto error;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -747,7 +745,7 @@ virBhyveFormatGrubDevice(virBufferPtr devicemap, virDomainDiskDefPtr
def)
static virCommandPtr
virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
- virConnectPtr conn,
+ bhyveConnPtr driver,
const char *devmap_file,
char **devicesmap_out)
{
@@ -830,7 +828,7 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
virCommandAddArgFormat(cmd, "%llu",
VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024));
- if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
+ if ((bhyveDriverGetGrubCaps(driver) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
def->nserials > 0) {
virDomainChrDefPtr chr;
@@ -939,7 +937,7 @@ virBhyveGetBootDisk(virDomainDefPtr def)
}
virCommandPtr
-virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def,
+virBhyveProcessBuildLoadCmd(bhyveConnPtr driver, virDomainDefPtr def,
const char *devmap_file, char **devicesmap_out)
{
virDomainDiskDefPtr disk = NULL;
@@ -952,7 +950,7 @@ virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def,
return virBhyveProcessBuildBhyveloadCmd(def, disk);
} else if (strstr(def->os.bootloader, "grub-bhyve") != NULL) {
- return virBhyveProcessBuildGrubbhyveCmd(def, conn, devmap_file,
+ return virBhyveProcessBuildGrubbhyveCmd(def, driver, devmap_file,
devicesmap_out);
} else {
return virBhyveProcessBuildCustomLoaderCmd(def);
diff --git a/src/bhyve/bhyve_command.h b/src/bhyve/bhyve_command.h
index 8c39f4eb2f..5a934c4883 100644
--- a/src/bhyve/bhyve_command.h
+++ b/src/bhyve/bhyve_command.h
@@ -29,7 +29,7 @@
#define BHYVE_CONFIG_FORMAT_ARGV "bhyve-argv"
-virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
+virCommandPtr virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver,
virDomainDefPtr def,
bool dryRun);
@@ -38,5 +38,5 @@ virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver,
virDomainDefPtr def);
virCommandPtr
-virBhyveProcessBuildLoadCmd(virConnectPtr conn, virDomainDefPtr def,
+virBhyveProcessBuildLoadCmd(bhyveConnPtr driver, virDomainDefPtr def,
const char *devmap_file, char **devicesmap_out);
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 713301399e..365a3777a0 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -710,22 +710,22 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
goto cleanup;
}
- if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) == 0) {
+ if ((bhyveDriverGetBhyveCaps(privconn) & BHYVE_CAP_LPC_BOOTROM) == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Installed bhyve binary does not support "
"bootrom"));
goto cleanup;
}
} else {
- if (!(loadcmd = virBhyveProcessBuildLoadCmd(conn, def,
"<device.map>",
- NULL)))
+ if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def,
+ "<device.map>",
NULL)))
goto cleanup;
virBufferAdd(&buf, virCommandToString(loadcmd, false), -1);
virBufferAddChar(&buf, '\n');
}
- if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, def, true)))
+ if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
goto cleanup;
virBufferAdd(&buf, virCommandToString(cmd, false), -1);
@@ -1282,20 +1282,16 @@ bhyveStateInitialize(bool privileged,
}
unsigned
-bhyveDriverGetCaps(virConnectPtr conn)
+bhyveDriverGetBhyveCaps(bhyveConnPtr driver)
{
- bhyveConnPtr driver = conn->privateData;
-
if (driver != NULL)
return driver->bhyvecaps;
return 0;
}
unsigned
-bhyveDriverGetGrubCaps(virConnectPtr conn)
+bhyveDriverGetGrubCaps(bhyveConnPtr driver)
{
- bhyveConnPtr driver = conn->privateData;
-
if (driver != NULL)
return driver->grubcaps;
return 0;
@@ -1543,7 +1539,7 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn,
char *xml = NULL;
virDomainDefPtr def = NULL;
bhyveConnPtr privconn = conn->privateData;
- unsigned caps = bhyveDriverGetCaps(conn);
+ unsigned bhyveCaps = bhyveDriverGetBhyveCaps(privconn);
virCheckFlags(0, NULL);
@@ -1556,7 +1552,8 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn,
goto cleanup;
}
- def = bhyveParseCommandLineString(nativeConfig, caps, privconn->xmlopt);
+ def = bhyveParseCommandLineString(nativeConfig, bhyveCaps,
+ privconn->xmlopt);
if (def == NULL)
goto cleanup;
diff --git a/src/bhyve/bhyve_driver.h b/src/bhyve/bhyve_driver.h
index 98e75039a3..75a63e0233 100644
--- a/src/bhyve/bhyve_driver.h
+++ b/src/bhyve/bhyve_driver.h
@@ -25,8 +25,8 @@
int bhyveRegister(void);
-unsigned bhyveDriverGetCaps(virConnectPtr conn);
+unsigned bhyveDriverGetBhyveCaps(bhyveConnPtr driver);
-unsigned bhyveDriverGetGrubCaps(virConnectPtr conn);
+unsigned bhyveDriverGetGrubCaps(bhyveConnPtr driver);
virCapsPtr bhyveDriverGetCapabilities(bhyveConnPtr driver);
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 14f718403d..2ea8db3b55 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -140,9 +140,7 @@ virBhyveProcessStart(virConnectPtr conn,
goto cleanup;
/* Call bhyve to start the VM */
- if (!(cmd = virBhyveProcessBuildBhyveCmd(conn,
- vm->def,
- false)))
+ if (!(cmd = virBhyveProcessBuildBhyveCmd(driver, vm->def, false)))
goto cleanup;
virCommandSetOutputFD(cmd, &logfd);
@@ -158,8 +156,8 @@ virBhyveProcessStart(virConnectPtr conn,
virBhyveFormatDevMapFile(vm->def->name, &devmap_file);
- if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_file,
- &devicemap)))
+ if (!(load_cmd = virBhyveProcessBuildLoadCmd(driver, vm->def,
+ devmap_file, &devicemap)))
goto cleanup;
virCommandSetOutputFD(load_cmd, &logfd);
virCommandSetErrorFD(load_cmd, &logfd);
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 3c9c61f024..9e7eb218b8 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -51,11 +51,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
conn->privateData = &driver;
- cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false);
+ cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false);
if (vmdef->os.loader)
ldcmd = virCommandNew("dummy");
else
- ldcmd = virBhyveProcessBuildLoadCmd(conn, vmdef, "<device.map>",
+ ldcmd = virBhyveProcessBuildLoadCmd(&driver, vmdef,
"<device.map>",
&actualdm);
if ((cmd == NULL) || (ldcmd == NULL)) {
--
2.24.1