1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-26 11:47:31 +00:00

bhyve: Convert to using vm_openf()

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D47032
This commit is contained in:
Mark Johnston 2024-11-05 01:37:16 +00:00
parent c2b34d0607
commit 5ef0cd25c4

View File

@ -521,41 +521,23 @@ do_open(const char *vmname)
{
struct vmctx *ctx;
int error;
bool reinit, romboot;
reinit = false;
bool romboot;
romboot = bootrom_boot();
error = vm_create(vmname);
if (error) {
if (errno == EEXIST) {
if (romboot) {
reinit = true;
} else {
/*
* The virtual machine has been setup by the
* userspace bootloader.
*/
}
} else {
perror("vm_create");
exit(4);
}
} else {
if (!romboot) {
/*
* If the virtual machine was just created then a
* bootrom must be configured to boot it.
*/
fprintf(stderr, "virtual machine cannot be booted\n");
exit(4);
}
}
ctx = vm_open(vmname);
/*
* If we don't have a boot ROM, the guest context must have been
* initialized by bhyveload(8) or equivalent.
*/
ctx = vm_openf(vmname, romboot ? VMMAPI_OPEN_REINIT : 0);
if (ctx == NULL) {
perror("vm_open");
exit(4);
if (errno != ENOENT)
err(4, "vm_openf");
if (!romboot)
errx(4, "no bootrom was configured");
ctx = vm_openf(vmname, VMMAPI_OPEN_CREATE);
if (ctx == NULL)
err(4, "vm_openf");
}
#ifndef WITHOUT_CAPSICUM
@ -563,13 +545,6 @@ do_open(const char *vmname)
err(EX_OSERR, "vm_limit_rights");
#endif
if (reinit) {
error = vm_reinit(ctx);
if (error) {
perror("vm_reinit");
exit(4);
}
}
error = vm_set_topology(ctx, cpu_sockets, cpu_cores, cpu_threads, 0);
if (error)
errx(EX_OSERR, "vm_set_topology");