From nobody Tue Nov 05 01:40:55 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xj9yw0ZzXz5cq6l; Tue, 05 Nov 2024 01:40:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xj9yv4yCpz3wj1; Tue, 5 Nov 2024 01:40:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730770855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xeqHLaRaBzGq88AdvNDAOe0QMqSWmoXAtxObNcN3qfo=; b=tzl4dwg26WTsubaq9//QBpedAEbUvkTM71FfZwmcHcJLwwNxlGjMY+msTFHysBFiUg0TBp sNtAHDtjuTAzd455kMK+2cXmaXhmlcxxLR3dWbLu22Ys44myaC1c03HSvzaaPN/0oQlqUO zRdwo7JA5NcxTPVeYIx1BSnjG1N4/a1W5A1cj/XaF7wkXlqJniBWgzo27V2tL3hkUQZdpW e6rUCvGCDR6QFv4ndDUvt17Pp4AIxmttvcxotUWI6t4UmtiD9e6QAZ2uera5sGTc0VwmDC i300eLYb3i+LqY4yDky1DcT8+leJSH/VUkg1OlwRako4Z/0rgJoIWDkrU+3Jeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730770855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xeqHLaRaBzGq88AdvNDAOe0QMqSWmoXAtxObNcN3qfo=; b=btV5AW6RJKdOfe75tzzKml3Yf7/Ro9+nRW8JDpEQrfah3VgOOMW3nmoPcUAvGrqeScc4P7 wIMmd4oxFWoXCHuyHb6o7CDwFnC5pl0vGIrkbmg28YNBWs9927R08LWs9nhJPiUpg+hqQJ bTaze0ORQyL+PfuLgO1hPwKrJY0o6R2+nBfb4I0TGOg+n/LnfuPD+mcpNP5NShf1lgrF2Z Su0UmUe2tzFqqEklPSIa5E7oY1DgLsfqcs+CTgR/zDSdlppNkxkLx9mzpcsBGoMK1PGK+X n8tMuw5jdsLg9jlnKouq7D7GGgpsVYTQdqd/fiLSiZ49ILuxXtmXOgWpMqerXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730770855; a=rsa-sha256; cv=none; b=ZauqiNfpxgHtpcbz6CM+XJBlAVLdf+wySOaV8cHSu/Q6DOTvQ12wpXe6uRgJawKNotgG27 7repW9JDUSh0m7YLh+AmpxTzCaEpy/nObW9fBiEIVRnEydpsPqHqpC2BkzgRDAHqbrAPbZ 577rCAsYQmqy847966ol85+saZhjnv/ju/cS2eV0Fq5h+fozIQVF/E6qsUlFVAudYd+Nil MwtVkvbPZJoRrzTbeD2XGx2v9+P2W8rQcFsl3vw0Va1pph7SA71076i6j1xzlZFV6wQZv1 6ZP5CqWFrXQMDE6pXeKedEs+vnZfEjm2ZmD8DUWK4ZeC4E4k+jaEC4ELDHn52Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xj9yv3zg7zxdZ; Tue, 5 Nov 2024 01:40:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A51etX7062851; Tue, 5 Nov 2024 01:40:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A51etNc062848; Tue, 5 Nov 2024 01:40:55 GMT (envelope-from git) Date: Tue, 5 Nov 2024 01:40:55 GMT Message-Id: <202411050140.4A51etNc062848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 5ef0cd25c4c9 - main - bhyve: Convert to using vm_openf() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ef0cd25c4c90e44b556e0420005e128b8fcc6e0 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5ef0cd25c4c90e44b556e0420005e128b8fcc6e0 commit 5ef0cd25c4c90e44b556e0420005e128b8fcc6e0 Author: Mark Johnston AuthorDate: 2024-11-05 01:37:16 +0000 Commit: Mark Johnston 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");