Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107431499
D33433.id101349.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D33433.id101349.diff
View Options
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -442,6 +442,11 @@
memory ending just before the 4GB physical address.
If a boot ROM is present, a firmware interface device is
also enabled for use by the boot ROM.
+.It Va bootvars Ta path Ta Ta
+Path to boot VARS.
+The contents of this file are copied beneath the boot ROM.
+Firmware can write to it to save variables.
+All variables will be persistent even on reboots of the guest.
.It Va com1 Ta node Ta Ta
Settings for the COM1 serial port device.
.It Va com2 Ta node Ta Ta
diff --git a/usr.sbin/bhyve/bootrom.h b/usr.sbin/bhyve/bootrom.h
--- a/usr.sbin/bhyve/bootrom.h
+++ b/usr.sbin/bhyve/bootrom.h
@@ -36,6 +36,8 @@
#include <stdint.h>
#include <limits.h>
+#include "config.h"
+
struct vmctx;
void init_bootrom(struct vmctx *ctx);
@@ -45,6 +47,6 @@
};
int bootrom_alloc(struct vmctx *ctx, size_t len, int prot, int flags,
char **region_out, uint64_t *gpa_out);
-int bootrom_loadrom(struct vmctx *ctx, const char *romfile);
+int bootrom_loadrom(struct vmctx *ctx, const nvlist_t *const nvl);
#endif
diff --git a/usr.sbin/bhyve/bootrom.c b/usr.sbin/bhyve/bootrom.c
--- a/usr.sbin/bhyve/bootrom.c
+++ b/usr.sbin/bhyve/bootrom.c
@@ -191,19 +191,29 @@
}
int
-bootrom_loadrom(struct vmctx *ctx, const char *romfile)
+bootrom_loadrom(struct vmctx *ctx, const nvlist_t *const nvl)
{
struct stat sbuf;
ssize_t rlen;
off_t rom_size, var_size, total_size;
- char *ptr, *varfile;
+ char *ptr;
int fd, varfd, i, rv;
rv = -1;
varfd = -1;
- varfile = strdup(romfile);
- romfile = strsep(&varfile, ",");
+ /*
+ * get_config_value_node may use a thread local buffer to return
+ * variables. So, when we query the second variable, the first variable
+ * might get overwritten. For that reason, the strings should be
+ * duplicated.
+ */
+ char *const romfile = strdup(
+ get_config_value_node(nvl, "bootrom"));
+
+ if (romfile == NULL) {
+ return (-1);
+ }
fd = open(romfile, O_RDONLY);
if (fd < 0) {
@@ -212,6 +222,15 @@
goto done;
}
+ if (fstat(fd, &sbuf) < 0) {
+ EPRINTLN("Could not fstat bootrom file \"%s\": %s", romfile,
+ strerror(errno));
+ goto done;
+ }
+
+ rom_size = sbuf.st_size;
+
+ const char *const varfile = get_config_value_node(nvl, "bootvars");
if (varfile != NULL) {
varfd = open(varfile, O_RDWR);
if (varfd < 0) {
@@ -219,24 +238,17 @@
"\"%s\": %s\n", varfile, strerror(errno));
goto done;
}
- }
-
- if (fstat(fd, &sbuf) < 0) {
- EPRINTLN("Could not fstat bootrom file \"%s\": %s",
- romfile, strerror(errno));
- goto done;
- }
- rom_size = sbuf.st_size;
- if (varfd < 0) {
- var_size = 0;
- } else {
if (fstat(varfd, &sbuf) < 0) {
- fprintf(stderr, "Could not fstat bootrom variable file \"%s\": %s\n",
- varfile, strerror(errno));
+ fprintf(stderr,
+ "Could not fstat bootrom variable file \"%s\": %s\n",
+ varfile, strerror(errno));
goto done;
}
+
var_size = sbuf.st_size;
+ } else {
+ var_size = 0;
}
if (var_size > BOOTROM_SIZE ||
@@ -293,5 +305,6 @@
done:
if (fd >= 0)
close(fd);
+ free(romfile);
return (rv);
}
diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c
--- a/usr.sbin/bhyve/pci_lpc.c
+++ b/usr.sbin/bhyve/pci_lpc.c
@@ -101,7 +101,10 @@
lpcdev = strsep(&str, ",");
if (lpcdev != NULL) {
if (strcasecmp(lpcdev, "bootrom") == 0) {
- set_config_value("lpc.bootrom", str);
+ const char *const romfile = strsep(&str, ",");
+ const char *const varfile = strsep(&str, ",");
+ set_config_value("lpc.bootrom", romfile);
+ set_config_value("lpc.bootvars", varfile);
error = 0;
goto done;
}
@@ -204,13 +207,13 @@
{
struct lpc_uart_softc *sc;
struct inout_port iop;
- const char *backend, *name, *romfile;
+ const char *backend, *name;
char *node_name;
int unit, error;
- romfile = get_config_value("lpc.bootrom");
- if (romfile != NULL) {
- error = bootrom_loadrom(ctx, romfile);
+ const nvlist_t *const nvl = find_config_node("lpc");
+ if (nvl != NULL) {
+ error = bootrom_loadrom(ctx, nvl);
if (error)
return (error);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 15, 1:56 AM (10 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15804102
Default Alt Text
D33433.id101349.diff (4 KB)
Attached To
Mode
D33433: bhyve: add varfile option to nvlist of lpc device
Attached
Detach File
Event Timeline
Log In to Comment