From nobody Tue Oct 25 15:17:04 2022 X-Original-To: dev-commits-src-main@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 4MxbC45Rl4z4g4dq; Tue, 25 Oct 2022 15:17:04 +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 4MxbC44wbtz3x7T; Tue, 25 Oct 2022 15:17:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711024; 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=MFyB40Q4DNbS9crPE/u5SnjAWA0pm21nMUeJofDlsxM=; b=kFOCqlde2bu4uoT2aaNa8JkXcbvvF3YIV31vlVsKWaJmZ8ZaVG5a8kLYy+ulRgIjiQGQ9l vULKoqg/UctQLqoO10Y3TXWJwfv9h1cFshn1Nn/6sRv6+uUKc1+O4YUsFDsTahRDxQJ8FO l3ezEJKvSvdxinviLc/ssOQTHYu0BMRG4J2zxN1zOUClwnJV67kTVhKo9qCYCMCYxO0/CS +CVrrQLDXfYSdTjBKSXKDm8fs8lTR8CDM68BBlEUPBkjRV5AfLqYZdOGdMQeB1OcxIvKaM j9fz8ds/LVx73gz1utNDzBA5f0nYTYu5hqKxxz6ZF5qwj0Fniqxf33NYENtdcQ== 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 4MxbC43zbMzj6d; Tue, 25 Oct 2022 15:17:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29PFH439023141; Tue, 25 Oct 2022 15:17:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29PFH41k023140; Tue, 25 Oct 2022 15:17:04 GMT (envelope-from git) Date: Tue, 25 Oct 2022 15:17:04 GMT Message-Id: <202210251517.29PFH41k023140@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: 3b6cb9b43657 - main - bhyve: Avoid shadowing global variables in bhyverun.c List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 3b6cb9b43657d8898c165c5cd26459e4646ba4f0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711024; 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=MFyB40Q4DNbS9crPE/u5SnjAWA0pm21nMUeJofDlsxM=; b=wZe4hiuT7wQLh7ZqNDROC3ijN1FAtHu9GgR3TAhQjlZYaw8c6CnfBwHbd8mBpN89XR3/0l VOyPDm8YMBr9VRSYhpR3sSvFCkKeJyy23irSdAOnfIFzpfJv6qX/nmKpZwSj4U2lSJmKTt xFUHWq13mE5fQ28TFJ917nOl7ZvBN6OBFFrYkSo1M+laPnGYMRn1ef3imOjMwcPkJtW3vF CbRvF9uXCjvtEXbpPZWgwITR5j/7RF1i7oobDTA9AeTJ7Wl42r8jz7lg8nJ7E5PuJc3T7p q8If7z20TsTxrKUCYb03UktFIrJoAYIKwM1jjkwKtUUeaKb1rCtbycLCytEfQw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666711024; a=rsa-sha256; cv=none; b=tI41SZv7nkVZBX5khJTY2MBzfegB6tr/gUaPhqX6Q4J23ZUuPhS4Ec4Yp99Sbs40E2uYz8 8X7/P08mHxGoosbnq9/gmtGGgJN184fqTJSlONm0WGSP+XuXLBzcyEvKukI7dzxMYXqvPz Ws+a68R0gmg7NdBqZ38kX46fmiuS+lyZhk2c39xnuirD0S5vui1bzGCVhyVl6rSpM/8uK+ kwY/KNjWIi8y2RlMHV1/seInzmVQfzxRvJObvXKNEh05i9QZPa+qDK8hDszia9pu29wUqT 7/bXPB3YI0QioZUyjZNzwMMzB69QdfOk0P7a0izkQX/+NjJzYQyj2TuAV72X3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3b6cb9b43657d8898c165c5cd26459e4646ba4f0 commit 3b6cb9b43657d8898c165c5cd26459e4646ba4f0 Author: Mark Johnston AuthorDate: 2022-09-09 00:40:02 +0000 Commit: Mark Johnston CommitDate: 2022-10-25 15:16:56 +0000 bhyve: Avoid shadowing global variables in bhyverun.c - Rename the global cores/sockets/threads to cpu_cores/sockets/threads. This way, num_vcpus_allowed() doesn't shadow them. - The global maxcpus is unused, remove it for the same reason. MFC after: 1 week --- usr.sbin/bhyve/bhyverun.c | 22 ++++++++++++---------- usr.sbin/bhyve/bhyverun.h | 2 +- usr.sbin/bhyve/smbiostbl.c | 10 +++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index a0261e755cfc..65e1223bd25f 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -185,7 +185,7 @@ static const char * const vmx_exit_reason_desc[] = { typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); int guest_ncpus; -uint16_t cores, maxcpus, sockets, threads; +uint16_t cpu_cores, cpu_sockets, cpu_threads; int raw_stdio = 0; @@ -348,25 +348,25 @@ calc_topolopgy(void) } value = get_config_value("cores"); if (value != NULL) - cores = parse_int_value("cores", value, 1, UINT16_MAX); + cpu_cores = parse_int_value("cores", value, 1, UINT16_MAX); else - cores = 1; + cpu_cores = 1; value = get_config_value("threads"); if (value != NULL) - threads = parse_int_value("threads", value, 1, UINT16_MAX); + cpu_threads = parse_int_value("threads", value, 1, UINT16_MAX); else - threads = 1; + cpu_threads = 1; value = get_config_value("sockets"); if (value != NULL) - sockets = parse_int_value("sockets", value, 1, UINT16_MAX); + cpu_sockets = parse_int_value("sockets", value, 1, UINT16_MAX); else - sockets = guest_ncpus; + cpu_sockets = guest_ncpus; /* * Compute sockets * cores * threads avoiding overflow. The * range check above insures these are 16 bit values. */ - ncpus = (uint64_t)sockets * cores * threads; + ncpus = (uint64_t)cpu_sockets * cpu_cores * cpu_threads; if (ncpus > UINT16_MAX) errx(4, "Computed number of vCPUs too high: %ju", (uintmax_t)ncpus); @@ -374,7 +374,8 @@ calc_topolopgy(void) if (explicit_cpus) { if (guest_ncpus != ncpus) errx(4, "Topology (%d sockets, %d cores, %d threads) " - "does not match %d vCPUs", sockets, cores, threads, + "does not match %d vCPUs", + cpu_sockets, cpu_cores, cpu_threads, guest_ncpus); } else guest_ncpus = ncpus; @@ -1153,7 +1154,8 @@ do_open(const char *vmname) exit(4); } } - error = vm_set_topology(ctx, sockets, cores, threads, maxcpus); + error = vm_set_topology(ctx, cpu_sockets, cpu_cores, cpu_threads, + 0 /* maxcpus, unimplemented */); if (error) errx(EX_OSERR, "vm_set_topology"); return (ctx); diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h index e68b68fe5483..1e1e5f9880f8 100644 --- a/usr.sbin/bhyve/bhyverun.h +++ b/usr.sbin/bhyve/bhyverun.h @@ -35,7 +35,7 @@ #define VMEXIT_ABORT (-1) extern int guest_ncpus; -extern uint16_t cores, sockets, threads; +extern uint16_t cpu_cores, cpu_sockets, cpu_threads; struct vmctx; struct vm_exit; diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index 22e6a6c73848..075371808ca9 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -718,7 +718,7 @@ smbios_type4_initializer(const struct smbios_structure *template_entry, { int i; - for (i = 0; i < sockets; i++) { + for (i = 0; i < cpu_sockets; i++) { struct smbios_table_type4 *type4; char *p; int nstrings, len; @@ -738,15 +738,15 @@ smbios_type4_initializer(const struct smbios_structure *template_entry, (*endaddr)++; type4->socket = nstrings + 1; /* Revise cores and threads after update to smbios 3.0 */ - if (cores > 254) + if (cpu_cores > 254) type4->cores = 0; else - type4->cores = cores; + type4->cores = cpu_cores; /* This threads is total threads in a socket */ - if ((cores * threads) > 254) + if (cpu_cores * cpu_threads > 254) type4->threads = 0; else - type4->threads = (cores * threads); + type4->threads = cpu_cores * cpu_threads; curaddr = *endaddr; }