Page MenuHomeFreeBSD

D58771.diff
No OneTemporary

D58771.diff

diff --git a/stand/userboot/userboot.h b/stand/userboot/userboot.h
--- a/stand/userboot/userboot.h
+++ b/stand/userboot/userboot.h
@@ -46,6 +46,13 @@
*/
#define USERBOOT_VERSION_5 5
+/*
+ * Version 6 added a callback for indicating that the guest
+ * is OK with the existing interpreter, so the host can close associated
+ * resources. The callback structure is still backward compatible.
+ */
+#define USERBOOT_VERSION_6 6
+
/*
* Exit codes from the loader
*/
@@ -225,4 +232,9 @@
* Version 5 addition.
*/
void (*swap_interpreter)(void *arg, const char *interp);
+
+ /*
+ * Version 6 addition.
+ */
+ void (*accept_interpreter)(void *arg);
};
diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c
--- a/stand/userboot/userboot/main.c
+++ b/stand/userboot/userboot/main.c
@@ -217,6 +217,8 @@
*/
if (version >= USERBOOT_VERSION_5)
check_interpreter();
+ if (version >= USERBOOT_VERSION_6)
+ CALLBACK(accept_interpreter);
if (setjmp(jb))
return;
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -102,6 +102,7 @@
static struct termios term, oldterm;
static int disk_fd[NDISKS];
static int ndisks;
+static int bootfd = -1;
static int consin_fd, consout_fd;
static int hostbase_fd = -1;
@@ -641,6 +642,16 @@
longjmp(jb, JMP_SWAPLOADER);
}
+static void
+cb_accept_interpreter(void *arg __unused)
+{
+ if (bootfd == -1)
+ return;
+
+ close(bootfd);
+ bootfd = -1;
+}
+
static struct loader_callbacks cb = {
.getc = cb_getc,
.putc = cb_putc,
@@ -678,6 +689,9 @@
/* Version 5 additions */
.swap_interpreter = cb_swap_interpreter,
+
+ /* Version 6 additions */
+ .accept_interpreter = cb_accept_interpreter,
};
static int
@@ -760,7 +774,7 @@
}
static void
-loader_open(int bootfd)
+loader_open(void)
{
int fd;
@@ -790,9 +804,8 @@
{
void (*func)(struct loader_callbacks *, void *, int, int);
uint64_t mem_size;
- int bootfd, opt, error, memflags, need_reinit;
+ int opt, error, memflags, need_reinit;
- bootfd = -1;
progname = basename(argv[0]);
memflags = 0;
@@ -922,7 +935,7 @@
if (error)
err(1, "vm_setup_memory");
- loader_open(bootfd);
+ loader_open();
func = dlsym(loader_hdl, "loader_main");
if (!func)
errx(1, "dlsym: %s", dlerror());
@@ -937,7 +950,7 @@
addenv("smbios.bios.vendor=BHYVE");
addenv("boot_serial=1");
- func(&cb, NULL, USERBOOT_VERSION_5, ndisks);
+ func(&cb, NULL, USERBOOT_VERSION_6, ndisks);
free(loader);
return (0);

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 7, 9:10 PM (54 m, 11 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40376472
Default Alt Text
D58771.diff (2 KB)

Event Timeline