Use the new userboot 'getenv' callback to set a couple of environment variables

in the guest.

The variables are: smbios.bios.vendor=BHYVE and boot_serial=1

The FreeBSD guest uses the "smbios.bios.vendor" environment variable to
detect whether or not it is running as a guest inside a hypervisor.

The "boot_serial=1" is temporary and will be dropped when bhyve can do VGA
emulation.

Obtained from:	NetApp
This commit is contained in:
Neel Natu 2012-11-06 21:48:45 +00:00
parent f684b7bb7b
commit c3e9ce3312
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/bhyve/; revision=242676

View File

@ -471,6 +471,25 @@ cb_getmem(void *arg, uint64_t *ret_lowmem, uint64_t *ret_highmem)
*ret_highmem = highmem;
}
static const char *
cb_getenv(void *arg, int num)
{
int max;
static const char * var[] = {
"smbios.bios.vendor=BHYVE",
"boot_serial=1",
NULL
};
max = sizeof(var) / sizeof(var[0]);
if (num < max)
return (var[num]);
else
return (NULL);
}
static struct loader_callbacks_v1 cb = {
.getc = cb_getc,
.putc = cb_putc,
@ -497,6 +516,8 @@ static struct loader_callbacks_v1 cb = {
.delay = cb_delay,
.exit = cb_exit,
.getmem = cb_getmem,
.getenv = cb_getenv,
};
static void
@ -600,5 +621,5 @@ main(int argc, char** argv)
if (disk_image) {
disk_fd = open(disk_image, O_RDONLY);
}
func(&cb, NULL, USERBOOT_VERSION_1, disk_fd >= 0);
func(&cb, NULL, USERBOOT_VERSION_3, disk_fd >= 0);
}