git: 5ef0cd25c4c9 - main - bhyve: Convert to using vm_openf()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 05 Nov 2024 01:40:55 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=5ef0cd25c4c90e44b556e0420005e128b8fcc6e0
commit 5ef0cd25c4c90e44b556e0420005e128b8fcc6e0
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-11-05 01:37:16 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-11-05 01:40:41 +0000
bhyve: Convert to using vm_openf()
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D47032
---
usr.sbin/bhyve/bhyverun.c | 51 ++++++++++++-----------------------------------
1 file changed, 13 insertions(+), 38 deletions(-)
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 41655a188bf9..be9cd1611700 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -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");