summaryrefslogtreecommitdiff
path: root/usr/src/lib/libvmm/libvmm.c
diff options
context:
space:
mode:
authorHans Rosenfeld <hans.rosenfeld@joyent.com>2019-01-15 16:29:40 +0100
committerHans Rosenfeld <hans.rosenfeld@joyent.com>2019-02-13 23:29:32 +0000
commit2d1a8a4a97fe44c06e3fedddbb32f89fc2755a3e (patch)
tree756d6c6c3ca55952fd45fe907eb1bc0631f6b59c /usr/src/lib/libvmm/libvmm.c
parent0dffce43ebed3eede3daefae50319a3731a68e6d (diff)
downloadillumos-joyent-2d1a8a4a97fe44c06e3fedddbb32f89fc2755a3e.tar.gz
OS-7508 mdb: assertion tripped in libvmm when bhyve VM halts while mdb is attached
OS-7519 mdb: bhyve target can attach before the first vCPU is configured
Diffstat (limited to 'usr/src/lib/libvmm/libvmm.c')
-rw-r--r--usr/src/lib/libvmm/libvmm.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/usr/src/lib/libvmm/libvmm.c b/usr/src/lib/libvmm/libvmm.c
index 373dfe2844..8c8e32c9f3 100644
--- a/usr/src/lib/libvmm/libvmm.c
+++ b/usr/src/lib/libvmm/libvmm.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright 2018 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -30,6 +30,7 @@
#include <errno.h>
#include <stdlib.h>
#include <strings.h>
+#include <unistd.h>
#include <assert.h>
#include <machine/vmm.h>
@@ -104,6 +105,18 @@ vmm_open_vm(const char *name)
vmm_update_ncpu(vmm);
+ /*
+ * If we open a VM that has just been created we may see a state
+ * where it has no CPUs configured yet. We'll just wait for 10ms
+ * and retry until we get a non-zero CPU count.
+ */
+ if (vmm->vmm_ncpu == 0) {
+ do {
+ (void) usleep(10000);
+ vmm_update_ncpu(vmm);
+ } while (vmm->vmm_ncpu == 0);
+ }
+
return (vmm);
}
@@ -304,10 +317,10 @@ vmm_memsize(vmm_t *vmm)
return (vmm->vmm_memsize);
}
-void
+int
vmm_cont(vmm_t *vmm)
{
- assert(vm_resume_cpu(vmm->vmm_ctx, -1) == 0);
+ return (vm_resume_cpu(vmm->vmm_ctx, -1));
}
int
@@ -336,12 +349,15 @@ vmm_step(vmm_t *vmm, int vcpu)
return (ret);
}
-void
+int
vmm_stop(vmm_t *vmm)
{
- assert(vm_suspend_cpu(vmm->vmm_ctx, -1) == 0);
+ int ret = vm_suspend_cpu(vmm->vmm_ctx, -1);
- vmm_update_ncpu(vmm);
+ if (ret == 0)
+ vmm_update_ncpu(vmm);
+
+ return (ret);
}
/*