diff options
Diffstat (limited to 'usr/src/cmd/bhyve/bhyverun.c')
| -rw-r--r-- | usr/src/cmd/bhyve/bhyverun.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/usr/src/cmd/bhyve/bhyverun.c b/usr/src/cmd/bhyve/bhyverun.c index 63dd6a129a..fb64e059fc 100644 --- a/usr/src/cmd/bhyve/bhyverun.c +++ b/usr/src/cmd/bhyve/bhyverun.c @@ -86,6 +86,10 @@ __FBSDID("$FreeBSD$"); #endif #include <vmmapi.h> +#ifndef __FreeBSD__ +#include <sys/stat.h> +#endif + #include "bhyverun.h" #include "acpi.h" #include "atkbdc.h" @@ -1334,6 +1338,28 @@ do_open(const char *vmname) return (ctx); } +#ifndef __FreeBSD__ + +#define FILE_PROVISIONING "/var/svc/provisioning" +#define FILE_PROVISION_SUCCESS "/var/svc/provision_success" + +static void +mark_provisioned(void) +{ + struct stat stbuf; + + if (lstat(FILE_PROVISIONING, &stbuf) != 0) + return; + + if (rename(FILE_PROVISIONING, FILE_PROVISION_SUCCESS) != 0) { + (void) fprintf(stderr, "Cannot rename %s to %s: %s\n", + FILE_PROVISIONING, FILE_PROVISION_SUCCESS, + strerror(errno)); + } +} + +#endif + static bool parse_config_option(const char *option) { @@ -1741,9 +1767,7 @@ main(int argc, char *argv[]) errx(EX_OSERR, "cap_enter() failed"); #endif -#ifndef __FreeBSD__ - illumos_priv_lock(); -#endif +/* XXX SmartOS: Upstream drops privs here, but we can't yet. See below... */ #ifdef __FreeBSD__ /* @@ -1761,7 +1785,17 @@ main(int argc, char *argv[]) for (uint_t i = 1; i < guest_ncpus; i++) { spinup_halted_ap(ctx, i); } + mark_provisioned(); + /* + * XXX SmartOS: The mark_provisioned() call above required file-access + * privileges that are dropped by the generic call. We must widen the + * full-privilege window a bit. A better solution might be to have + * a way to keep file-access a bit longer, and only have THAT privilege + * to drop here. + */ + illumos_priv_lock(); #endif + /* * Head off to the main event dispatch loop */ |
