bhyve: Add console support for grub-bhyve bootloader

This enables booting interactive GRUB menus (e.g. install CDs) with
libvirt-bhyve.

Caveat: A terminal other than the '--console' option to 'virsh start'
(e.g. 'cu -l /dev/nmdm0B -s 115200') must be used to connect to
grub-bhyve because the bhyve loader path is synchronous and must occur
before the VM actually starts.

Changing the bhyveProcessStart logic around to accommodate '--console'
for interactive loader use seems like a significant project and probably
not worth it, if UEFI/BIOS support for bhyve is "coming soon."
This commit is contained in:
Conrad Meyer 2014-11-08 11:48:35 -05:00 committed by Michal Privoznik
parent 0cd4cd2904
commit 7c7c8b0b6c
4 changed files with 35 additions and 0 deletions

View File

@ -25,8 +25,10 @@
#include <net/if.h>
#include <net/if_tap.h>
#include "bhyve_capabilities.h"
#include "bhyve_command.h"
#include "bhyve_domain.h"
#include "bhyve_driver.h"
#include "datatypes.h"
#include "viralloc.h"
#include "virfile.h"
@ -447,6 +449,22 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
virCommandAddArgFormat(cmd, "%llu",
VIR_DIV_UP(def->mem.max_balloon, 1024));
if ((bhyveDriverGetGrubCaps(conn) & BHYVE_GRUB_CAP_CONSDEV) != 0 &&
def->nserials > 0) {
virDomainChrDefPtr chr;
chr = def->serials[0];
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_NMDM) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("only nmdm console types are supported"));
return NULL;
}
virCommandAddArg(cmd, "--cons-dev");
virCommandAddArg(cmd, chr->source.data.file.path);
}
/* VM name */
virCommandAddArg(cmd, def->name);

View File

@ -1169,6 +1169,9 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
if (!(bhyve_driver->caps = virBhyveCapsBuild()))
goto cleanup;
if (virBhyveProbeGrubCaps(&bhyve_driver->grubcaps) < 0)
goto cleanup;
if (!(bhyve_driver->xmlopt = virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
&virBhyveDriverPrivateDataCallbacks,
NULL)))
@ -1226,6 +1229,16 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
return -1;
}
unsigned
bhyveDriverGetGrubCaps(virConnectPtr conn)
{
bhyveConnPtr driver = conn->privateData;
if (driver != NULL)
return driver->grubcaps;
return 0;
}
static void
bhyveStateAutoStart(void)
{

View File

@ -25,4 +25,6 @@
int bhyveRegister(void);
unsigned bhyveDriverGetGrubCaps(virConnectPtr conn);
#endif /* __BHYVE_DRIVER_H__ */

View File

@ -45,6 +45,8 @@ struct _bhyveConn {
virObjectEventStatePtr domainEventState;
virCloseCallbacksPtr closeCallbacks;
unsigned grubcaps;
};
typedef struct _bhyveConn bhyveConn;