From c3e9ce3312e8bd27c01e00889f1a07bc630e26fc Mon Sep 17 00:00:00 2001 From: Neel Natu Date: Tue, 6 Nov 2012 21:48:45 +0000 Subject: [PATCH] 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 --- usr.sbin/bhyveload/bhyveload.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c index b8be5e3beff..3b7fad4850d 100644 --- a/usr.sbin/bhyveload/bhyveload.c +++ b/usr.sbin/bhyveload/bhyveload.c @@ -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); }