From nobody Tue Nov 01 13:52:36 2022 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 4N1s0N34wDz4gMPX; Tue, 1 Nov 2022 13:52:36 +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 4N1s0N2KRHz3gGC; Tue, 1 Nov 2022 13:52:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667310756; 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=4c/Kvw1NsO0L3hiJ0TXi0EFI5+5GWQncvoVqHGtIfew=; b=jZU4QyxnunnT0SjuBoKb0FdKaisO3JwPHxFYxzVC44I24Cm3u6jiMLwu8d7vz5w5dscP+Q E9noIqTWoZoeE65hxmrRRrMhILlzmEFtMOMYt++qBNJLb3SCUqia5RVq3hsB44UaN8h/jA SA0pCGQP48teFEBrcD6sM8JWEGLt9aeY+FOzWx6VLOP/meKfegi3Z0yrR6W1f/Uzxa7INt MAYwhH0es0Xns8Jw+BO1CLU37r9PXLbJ+y/s9bdsrzEUDrxOj85rmaTsfx6vuRcR9PEbH9 fAK5au/k/pxWcKjl/kVP6dsj5GBScO96RhQb9D5ZE54Lr1g3687VG2ZtuYq00g== 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 4N1s0N1PfjzJJ8; Tue, 1 Nov 2022 13:52:36 +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 2A1DqaVu059140; Tue, 1 Nov 2022 13:52:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A1DqalR059139; Tue, 1 Nov 2022 13:52:36 GMT (envelope-from git) Date: Tue, 1 Nov 2022 13:52:36 GMT Message-Id: <202211011352.2A1DqalR059139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 419c10c8460b - stable/13 - bhyve: Avoid shadowing global variables in bhyverun.c 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 419c10c8460b84a4e1b4121add8b4e4c0a953d95 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667310756; 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=4c/Kvw1NsO0L3hiJ0TXi0EFI5+5GWQncvoVqHGtIfew=; b=WlsFyq7JcZxtaSLQFIwsbRp3+E1MVRGCl31Gt6lj3siqlx2u99NEQelhTTIyJmd7ZmNkL9 +RUrxyQFmuoU0XE+aopgRQROny3V86Su2af3Ck9Rj7PkrA2AX6W6YwFGF/LbnKNVKZbLQq QzUZitKnGUGOs2sXP1/ZiQD2/vPSIfcijUaPun+9Wqap/YbdvpbIBd+xMM4giFupVOVWpg 78awzBpZFc4KzBuNF8/IWCvF/v2Jn8WtEP9yKOeC9I8w4RF7VvFOGaC9Fh5Km9Je8mzlM7 hghDklCX8KG3WZps9Kozkx5bjzBMaiudV0BAo+hxCKbGBvigvJv6qD6ylJgDtw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667310756; a=rsa-sha256; cv=none; b=EET/eh+R6nSxhFlyq7YKSQA82NpLBL2nQv9K3Pntz2sK4NfYSa+SGkaSDEvWZYOvVib7Tx MTfaPyB39Ur2lDplMRX4ENKqi37aLaGe+eq54FVpuLlLhZtvN+jFwNUc3HMCvBEMOhYwIO 9ToqRodCVIkmig+NsdVPjFYTP0DadfiYdk3ZJEuVysp0z4UGWOlKQLB+NwJUDB3x5b8yR6 BVFkUOEzXNN6q0EPRTprrghAuv2IBXFKsExF62fzHcdvN/4ZHCLtKfXoUvRKjF5CwyKdoM 6EJiZJTXv2FBpYbHeCdK05fwgQRGfU218jkaATRvW9+anD3K50petMDvn9YyjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=419c10c8460b84a4e1b4121add8b4e4c0a953d95 commit 419c10c8460b84a4e1b4121add8b4e4c0a953d95 Author: Mark Johnston AuthorDate: 2022-09-09 00:40:02 +0000 Commit: Mark Johnston CommitDate: 2022-11-01 13:46:05 +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. (cherry picked from commit 3b6cb9b43657d8898c165c5cd26459e4646ba4f0) --- 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 b6bc94490d75..fec4ca29de80 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -185,7 +185,7 @@ typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); extern int vmexit_task_switch(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; @@ -347,25 +347,25 @@ calc_topology(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); @@ -373,7 +373,8 @@ calc_topology(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; @@ -1118,7 +1119,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 9b0c9fb533e2..d10604011d31 100644 --- a/usr.sbin/bhyve/bhyverun.h +++ b/usr.sbin/bhyve/bhyverun.h @@ -36,7 +36,7 @@ struct vmctx; extern int guest_ncpus; -extern uint16_t cores, sockets, threads; +extern uint16_t cpu_cores, cpu_sockets, cpu_threads; void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); #ifdef BHYVE_SNAPSHOT diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index c1b7652d90bf..9488d733b90e 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -716,7 +716,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; @@ -736,15 +736,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; }