From nobody Sun Jan 4 09:21:07 2026 X-Original-To: dev-commits-src-branches@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 4dkX3l4bqDz6MlbX for ; Sun, 04 Jan 2026 09:21:07 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dkX3l1cHfz474B for ; Sun, 04 Jan 2026 09:21:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767518467; 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=ysbkxybkd6qzMVuX1XTUOcIHj0xUlicink8tGmaX+gI=; b=aYar4Ob4WE4sqUa+kV5u7tdJO/xe//9OWnb+54PzTN9WiDKGEELXNzZmWZMYKT/mFumxEM CJqvdK906MIMipxcbRg+YVCYfvfXqHr3pLRJiYqOClI7BDwCCchbB5DrLuTmq+v1oTo4xI rqWZavykwRycNaK65sDMLe6bOsf6PxUoDjacDVG31VNubQZ74bHUGrZ+uU0P4nysUvDA0m 1z8IRm4bxzV/2apob5GOxOQqj0cM85dD3obF+fcY5Pbecovsi/kbXfkwvA/FklVG4cj5Xp 0SPG+d/0YMmUThJyyY7S8EKwfQ4z2fALNXUWnq7EIN3iXFVUTYvziCCdEumCfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767518467; 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=ysbkxybkd6qzMVuX1XTUOcIHj0xUlicink8tGmaX+gI=; b=rXzZo3zCGt5UcUWcDiZfVg9yFOnk4SlQZsUgRhY9b8i59wicRyrR9zkGYNbgemiVnhKfh7 HFnCaGKRHR+eJbdr41FC9BfVoos16H0I2acUrE+muI4YHenLKMpDZweisjkULDAz3EBcm7 XCd1INwRhqOISxuVhB+WFUZSinY62k9JSlQytak4zNZ5+tL4Os1hNtebmo/TmoFY8+Zfm3 Fpf7uO4MjvbTPnQEdcehJ5iPWmzU6ODvrxS821A6DVv5+rHcK0onVKHpD6Pq0rOzEPZNBE g5MsuIdnSa4Yr/o37FQqvxDfIU4am5al9ixk3Co7HMcKDxS5N1rsjY+E47VHDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767518467; a=rsa-sha256; cv=none; b=eo0RWbNPt3J/N5l+vEiwvoId3tVORpRsBD/uT55t92D59IP2yzIuHop2TeCqI4W74yUdDo 66LoBxywTv9235t9o2OJpS7cspVwMuHSBlvH5AfLqn8e8+w0cFpB57bxpecoUaHoKJDp0o vSMOvRckEI6uKk7Myyr9u70hOmaQWRhhVtdMBrLd0C0VFfyPiA/i1a5CXRog8yrxKRkhtI ojeueCvvvUSaeAG20fYXN5CwjuS6qA4ruubrGYIG104yvhFgCAGRvT8jNLDOKmoULZDaAQ A6g2xSwq8wMArJ3uSSGg/lIX7GYgQu9GoqWN0eauDMRLF6cqJpPrUwYvXq9LIg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dkX3l0xktzCSV for ; Sun, 04 Jan 2026 09:21:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 90e9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 04 Jan 2026 09:21:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Roman Bogorodskiy Subject: git: a8fb6303b835 - stable/15 - bhyvectl: improve options error handling List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: novel X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a8fb6303b835e07e94226f3ae8591a4fe71c6274 Auto-Submitted: auto-generated Date: Sun, 04 Jan 2026 09:21:07 +0000 Message-Id: <695a3103.90e9.5a2162c9@gitrepo.freebsd.org> The branch stable/15 has been updated by novel: URL: https://cgit.FreeBSD.org/src/commit/?id=a8fb6303b835e07e94226f3ae8591a4fe71c6274 commit a8fb6303b835e07e94226f3ae8591a4fe71c6274 Author: Roman Bogorodskiy AuthorDate: 2025-12-05 18:45:03 +0000 Commit: Roman Bogorodskiy CommitDate: 2026-01-04 05:15:25 +0000 bhyvectl: improve options error handling Currently, it is possible to execute bhyvectl(8) with mutually exclusive options, such as "--destroy" and "--suspend", and it will print out obscure errors, e.g.: bhyvectl --suspend=/var/run/vms/my_vm --destroy --vm my_vm connect() failed: Connection refused Address that by failing early if mutually exclusive options were specified. Additionally, move the BHYVE_SNAPSHOT block before the errors are printed, so its errors are also displayed. Approved by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D54092 (cherry picked from commit 148111d3775eb159d71a36e3a8b4c5c1bf53392c) --- usr.sbin/bhyvectl/bhyvectl.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 41055678ac30..8c37b670ab2e 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -326,7 +326,7 @@ int main(int argc, char *argv[]) { char *vmname; - int error, ch, vcpuid; + int action_opts, error, ch, vcpuid; struct vm_run vmrun; struct vmctx *ctx; struct vcpu *vcpu; @@ -338,6 +338,7 @@ main(int argc, char *argv[]) opts = setup_options(); + action_opts = 0; vcpuid = 0; vmname = NULL; progname = basename(argv[0]); @@ -388,6 +389,16 @@ main(int argc, char *argv[]) if (vmname == NULL) usage(opts); + action_opts = create + destroy + force_reset + force_poweroff; +#ifdef BHYVE_SNAPSHOT + if (checkpoint_file) + action_opts++; +#endif + + if (action_opts > 1) { + fprintf(stderr, "mutually exclusive actions specified\n"); + exit(1); + } ctx = vm_openf(vmname, create ? VMMAPI_OPEN_CREATE : 0); if (ctx == NULL) { @@ -508,17 +519,17 @@ main(int argc, char *argv[]) if (!error && force_poweroff) error = vm_suspend(ctx, VM_SUSPEND_POWEROFF); +#ifdef BHYVE_SNAPSHOT + if (!error && checkpoint_file) + error = snapshot_request(vmname, checkpoint_file, vm_suspend_opt); +#endif + if (error) printf("errno = %d\n", errno); if (!error && destroy) vm_destroy(ctx); -#ifdef BHYVE_SNAPSHOT - if (!error && checkpoint_file) - error = snapshot_request(vmname, checkpoint_file, vm_suspend_opt); -#endif - free(opts); exit(error); }