Page MenuHomeFreeBSD

bhyve: Introduce monitor mode
AcceptedPublic

Authored by bnovkov on Thu, Nov 13, 11:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 19, 11:52 PM
Unknown Object (File)
Wed, Nov 19, 11:52 PM
Unknown Object (File)
Wed, Nov 19, 11:51 PM
Unknown Object (File)
Tue, Nov 18, 8:53 PM
Unknown Object (File)
Tue, Nov 18, 1:18 PM
Unknown Object (File)
Sun, Nov 16, 8:25 AM
Unknown Object (File)
Sun, Nov 16, 8:25 AM
Unknown Object (File)
Sun, Nov 16, 8:25 AM

Details

Reviewers
markj
andrew
Group Reviewers
bhyve
Summary

This change introduces "monitor mode", a mechanism for automatically
releasing virtual machine resources when bhyve dies, bringing us
closer towards making non-root bhyve viable.
Under this regime bhyve will create a transient virtual machine using
vmmctl's VMMCTL_CREATE_DESTROY_ON_CLOSE flag and automatically
reboot said virtual machine as long as it exits with "reboot" status.

This is done by splitting bhyve into two processes. The parent process
creates the virtual machine while the child process initializes and
runs the virtual machine. When the child exits the parent inspects
its exit status and either exits or forks again. vmmctl automatically
destroys the underlying virtual machine once the parent process dies.

Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68597
Build 65480: arc lint + arc unit

Event Timeline

usr.sbin/bhyve/bhyve.8
278

I think "VM terminate with exit status 0" is a bit unclear. The main point is that the bhyve process doesn't exit when the guest reboot, so maybe,

.It Fl M
Run the VM in
.Ql monitor
mode.
In this mode, a guest reboot does not cause the bhyve process to exit.
Instead, bhyve will restart the VM.
Once the bhyve process exits or is killed, the VM will be destroyed automatically.
279
usr.sbin/bhyve/bhyverun.c
896

I think you probably want a loop around the waitpid() call, in case EINTR is returned.

901

What if status indicates that the child was killed by a signal? You need to write:

if (WIFSIGNALED(status)) {
    <print a message saying the child was killed by signal WTERMSIG(status)>
    exit();
} else {
    status = WEXITSTATUS(status);
    if (status != BHYVE_EXIT_RESET)
        exit(status);
    ...
}
markj added inline comments.
usr.sbin/bhyve/bhyve.8
283

The last two sentences are saying the same thing.

usr.sbin/bhyve/bhyverun.c
917
This revision is now accepted and ready to land.Thu, Nov 20, 3:04 PM
This revision now requires review to proceed.Fri, Nov 21, 10:08 AM
markj added inline comments.
usr.sbin/bhyve/bhyverun.c
693

Group flags with error.

888

Let's define forkpid here instead? (Why not call it "child"?)

This revision is now accepted and ready to land.Fri, Nov 21, 3:10 PM