From nobody Mon Jan 22 17:30:04 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 4TJcg11KByz57rDL; Mon, 22 Jan 2024 17:30:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TJcg06Sfyz4fRd; Mon, 22 Jan 2024 17:30:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705944604; 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=el+TpVZQK9toXcdwvD0Ueel3dNptOHJRHefBcXudwFk=; b=IE0vha4iJpr4HvXH3iBo9fNNGlAe2Bixm/cP/sznPgA57o1XUsaF5nlkK8f6oDMxBuzpzE 7py5j2jRpJs9qAYkkhAR5cxkFjkHiFKSZdzatrRDUpYKeFUhIIGp2hf8f1dkYnUj/pZLeg nAAflQPMrM2ehOoZjOV7x04mA/n1+mtHmuePf7XyaNen7g3iOwZVMCHxjjWQ31IIzHk+KD bCTvckemiLvGIBLQFcD0gVj3DnnFPekY3s03Kms6i384JRqCq7AH6WUBbaPKC3u7cl43rv Wo9cHU9LZfDerMGVS9wjoEdEnh6JdRRHAVeHJwJxFEZHIJrSPYhaqBjg80++pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705944604; 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=el+TpVZQK9toXcdwvD0Ueel3dNptOHJRHefBcXudwFk=; b=cHoQHZ4jdbKyUc4JdtYrFoHOOrRYAreORNF5V5hBABc9LNRo5RnT+sczWVJklAi1YATpDm TktNGthnnEBaKl6+TBFP3KKGDchatkuDk7GQ15gTUB1ozZtwgQnDVASVyzU1EasBA9yUOC 8rBr12VLcsECA9SCeru9vceCX1M2gSOyVy1706F7UgwqOXuy7SvFuWFu7ebDFG3TaYlxUj 6Ew1/Il88XoyXgKtre/jpZslBGjnNfe53+QHulvbra6+KyfhlGOUIHQYGYzgfo5eSjUYco /Spyr8xpgosiddrmBtxF2ERxxRSrADbzcuhPI7HE/D+vd8tXfGdn56/9cHd2UA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705944604; a=rsa-sha256; cv=none; b=DZSrge41osQkk5qiSCgz9XoWPs0i2SSEn1oywvAX9ME+qDnLWWly09/7b0C+QsEuyVl5en KwlceZrFYXZpyyoJfjqx/6vML7r4Iq7UmiDyyXtQ80kNjsa0+j2nCD8WLR36z3Z4TXiv2Y ewlqBcHMJUAhmTvcquIgKwReGQ7lC4uSP8Bhf5StdlrvaSjdzH1dX2ZrEuBYU11ux2BM+o q3+ZUG6o4NTA0ISfMKaobiKDHTcHisdD1rui0GJxpUI8/sU2tUMTIHXpSxeF+GfmoPc3rm 7Os6pcTq6xQvZCzgx7ygNAXaKo8bHGO1BeZYETbzWzf7QY2N8tM4mmRRA8+c4Q== 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 4TJcg04wvCz19PS; Mon, 22 Jan 2024 17:30:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40MHU4K0008985; Mon, 22 Jan 2024 17:30:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40MHU4xg008980; Mon, 22 Jan 2024 17:30:04 GMT (envelope-from git) Date: Mon, 22 Jan 2024 17:30:04 GMT Message-Id: <202401221730.40MHU4xg008980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 7b74346b7d34 - stable/14 - bhyveload: make error printing consistent 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7b74346b7d3463a7f5c8d8464830e18b48ca3c2c Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7b74346b7d3463a7f5c8d8464830e18b48ca3c2c commit 7b74346b7d3463a7f5c8d8464830e18b48ca3c2c Author: Kyle Evans AuthorDate: 2024-01-08 17:49:40 +0000 Commit: Kyle Evans CommitDate: 2024-01-22 17:19:09 +0000 bhyveload: make error printing consistent Previously we used a mix of perror(3) + exit(3) and err(3); standardize on the latter instead. This does remove one free() in an error path, because we're decidedly leaking a lot more than just the loader name there (loader handle, vcpu, vmctx...) anyways. Reviewed by: markj (cherry picked from commit a4a838a31ac24e19c8ee68d45cf5234615d0b958) --- usr.sbin/bhyveload/bhyveload.c | 49 ++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c index 4f16f58bfc9f..4d89393424f4 100644 --- a/usr.sbin/bhyveload/bhyveload.c +++ b/usr.sbin/bhyveload/bhyveload.c @@ -861,18 +861,14 @@ main(int argc, char** argv) need_reinit = 0; error = vm_create(vmname); if (error) { - if (errno != EEXIST) { - perror("vm_create"); - exit(1); - } + if (errno != EEXIST) + err(1, "vm_create"); need_reinit = 1; } ctx = vm_open(vmname); - if (ctx == NULL) { - perror("vm_open"); - exit(1); - } + if (ctx == NULL) + err(1, "vm_open"); /* * If we weren't given an explicit loader to use, we need to support the @@ -882,10 +878,8 @@ main(int argc, char** argv) cap_rights_t rights; bootfd = open("/boot", O_DIRECTORY | O_PATH); - if (bootfd == -1) { - perror("open"); - exit(1); - } + if (bootfd == -1) + err(1, "open"); /* * bootfd will be used to do a lookup of our loader and do an @@ -893,19 +887,15 @@ main(int argc, char** argv) * to the more usual lookup rights. */ if (caph_rights_limit(bootfd, cap_rights_init(&rights, - CAP_FSTATAT, CAP_LOOKUP, CAP_MMAP_RX, CAP_READ)) < 0) { - perror("caph_rights_limit"); - exit(1); - } + CAP_FSTATAT, CAP_LOOKUP, CAP_MMAP_RX, CAP_READ)) < 0) + err(1, "caph_rights_limit"); } vcpu = vm_vcpu_open(ctx, BSP); caph_cache_catpages(); - if (caph_enter() < 0) { - perror("caph_enter"); - exit(1); - } + if (caph_enter() < 0) + err(1, "caph_enter"); /* * setjmp in the case the guest wants to swap out interpreter, @@ -921,26 +911,19 @@ main(int argc, char** argv) if (need_reinit) { error = vm_reinit(ctx); - if (error) { - perror("vm_reinit"); - exit(1); - } + if (error) + err(1, "vm_reinit"); } vm_set_memflags(ctx, memflags); error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL); - if (error) { - perror("vm_setup_memory"); - exit(1); - } + if (error) + err(1, "vm_setup_memory"); loader_open(bootfd); func = dlsym(loader_hdl, "loader_main"); - if (!func) { - printf("%s\n", dlerror()); - free(loader); - return (1); - } + if (!func) + errx(1, "dlsym: %s", dlerror()); tcgetattr(consout_fd, &term); oldterm = term;