git: a4153a7b77e8 - stable/13 - bhyve: Allocate dynamic arrays to hold per-VCPU state.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 May 2022 18:56:08 UTC
The branch stable/13 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=a4153a7b77e8c65bb89b6623cf168833ba4ab7e3
commit a4153a7b77e8c65bb89b6623cf168833ba4ab7e3
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-03-09 23:39:08 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-11 18:51:41 +0000
bhyve: Allocate dynamic arrays to hold per-VCPU state.
This avoids hardcoding VM_MAXCPU in userspace.
Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34491
(cherry picked from commit 7261f82156fb35d4a5e928769041c5987f700cda)
---
usr.sbin/bhyve/bhyverun.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 8a1a82cefc7c..43032b9f78fa 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -196,7 +196,7 @@ static cpuset_t cpumask;
static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip);
-static struct vm_exit vmexit[VM_MAXCPU];
+static struct vm_exit *vmexit;
struct bhyvestats {
uint64_t vmexit_bogus;
@@ -212,10 +212,10 @@ struct bhyvestats {
struct mt_vmm_info {
pthread_t mt_thr;
struct vmctx *mt_ctx;
- int mt_vcpu;
-} mt_vmm_info[VM_MAXCPU];
+ int mt_vcpu;
+} *mt_vmm_info;
-static cpuset_t *vcpumap[VM_MAXCPU] = { NULL };
+static cpuset_t **vcpumap;
static void
usage(int code)
@@ -471,6 +471,7 @@ build_vcpumaps(void)
const char *value;
int vcpu;
+ vcpumap = calloc(guest_ncpus, sizeof(*vcpumap));
for (vcpu = 0; vcpu < guest_ncpus; vcpu++) {
snprintf(key, sizeof(key), "vcpu.%d.cpuset", vcpu);
value = get_config_value(key);
@@ -1550,6 +1551,10 @@ main(int argc, char *argv[])
vm_restore_time(ctx);
#endif
+ /* Allocate per-VCPU resources. */
+ vmexit = calloc(guest_ncpus, sizeof(*vmexit));
+ mt_vmm_info = calloc(guest_ncpus, sizeof(*mt_vmm_info));
+
/*
* Add CPU 0
*/