Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143679058
D48269.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48269.diff
View Options
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -467,6 +467,8 @@
error = vmm_init();
if (error == 0)
vmm_initialized = 1;
+ else
+ (void)vmmdev_cleanup();
} else {
error = ENXIO;
}
diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c
--- a/sys/arm64/vmm/vmm.c
+++ b/sys/arm64/vmm/vmm.c
@@ -361,21 +361,26 @@
switch (what) {
case MOD_LOAD:
- /* TODO: if (vmm_is_hw_supported()) { */
error = vmmdev_init();
if (error != 0)
break;
error = vmm_init();
if (error == 0)
vmm_initialized = true;
+ else
+ (void)vmmdev_cleanup();
break;
case MOD_UNLOAD:
- /* TODO: if (vmm_is_hw_supported()) { */
error = vmmdev_cleanup();
if (error == 0 && vmm_initialized) {
error = vmmops_modcleanup();
- if (error)
+ if (error) {
+ /*
+ * Something bad happened - prevent new
+ * VMs from being created
+ */
vmm_initialized = false;
+ }
}
break;
default:
diff --git a/sys/dev/vmm/vmm_dev.c b/sys/dev/vmm/vmm_dev.c
--- a/sys/dev/vmm/vmm_dev.c
+++ b/sys/dev/vmm/vmm_dev.c
@@ -979,6 +979,7 @@
return (error);
}
+static struct cdev *vmmctl_cdev;
static struct cdevsw vmmctlsw = {
.d_name = "vmmctl",
.d_version = D_VERSION,
@@ -989,31 +990,34 @@
int
vmmdev_init(void)
{
- struct cdev *cdev;
int error;
- error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &vmmctlsw, NULL,
+ sx_xlock(&vmmdev_mtx);
+ error = make_dev_p(MAKEDEV_CHECKNAME, &vmmctl_cdev, &vmmctlsw, NULL,
UID_ROOT, GID_WHEEL, 0600, "vmmctl");
- if (error)
- return (error);
-
- pr_allow_flag = prison_add_allow(NULL, "vmm", NULL,
- "Allow use of vmm in a jail.");
+ if (error == 0)
+ pr_allow_flag = prison_add_allow(NULL, "vmm", NULL,
+ "Allow use of vmm in a jail.");
+ sx_xunlock(&vmmdev_mtx);
- return (0);
+ return (error);
}
int
vmmdev_cleanup(void)
{
- int error;
-
- if (SLIST_EMPTY(&head))
- error = 0;
- else
- error = EBUSY;
+ sx_xlock(&vmmdev_mtx);
+ if (!SLIST_EMPTY(&head)) {
+ sx_xunlock(&vmmdev_mtx);
+ return (EBUSY);
+ }
+ if (vmmctl_cdev != NULL) {
+ destroy_dev(vmmctl_cdev);
+ vmmctl_cdev = NULL;
+ }
+ sx_xunlock(&vmmdev_mtx);
- return (error);
+ return (0);
}
static int
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -259,21 +259,26 @@
switch (what) {
case MOD_LOAD:
- /* TODO: check if has_hyp here? */
error = vmmdev_init();
if (error != 0)
break;
error = vmm_init();
if (error == 0)
vmm_initialized = true;
+ else
+ (void)vmmdev_cleanup();
break;
case MOD_UNLOAD:
- /* TODO: check if has_hyp here? */
error = vmmdev_cleanup();
if (error == 0 && vmm_initialized) {
error = vmmops_modcleanup();
- if (error)
+ if (error) {
+ /*
+ * Something bad happened - prevent new
+ * VMs from being created
+ */
vmm_initialized = false;
+ }
}
break;
default:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 1, 6:16 AM (10 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28293920
Default Alt Text
D48269.diff (2 KB)
Attached To
Mode
D48269: vmm: Fix error handling in vmm_handler()
Attached
Detach File
Event Timeline
Log In to Comment