Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/vmm/vmm_dev.c
| Show First 20 Lines • Show All 1,027 Lines • ▼ Show 20 Lines | vmmdev_create(const char *name, uint32_t flags, struct ucred *cred) | ||||
| SLIST_INSERT_HEAD(&head, sc, link); | SLIST_INSERT_HEAD(&head, sc, link); | ||||
| sc->flags = flags; | sc->flags = flags; | ||||
| if ((flags & VMMCTL_CREATE_DESTROY_ON_CLOSE) != 0) | if ((flags & VMMCTL_CREATE_DESTROY_ON_CLOSE) != 0) | ||||
| LIST_INSERT_HEAD(&priv->softcs, sc, priv_link); | LIST_INSERT_HEAD(&priv->softcs, sc, priv_link); | ||||
| make_dev_args_init(&mda); | make_dev_args_init(&mda); | ||||
| mda.mda_devsw = &vmmdevsw; | mda.mda_devsw = &vmmdevsw; | ||||
| mda.mda_cr = sc->ucred; | mda.mda_cr = sc->ucred; | ||||
| mda.mda_uid = UID_ROOT; | mda.mda_uid = cred->cr_uid; | ||||
| mda.mda_gid = GID_WHEEL; | mda.mda_gid = GID_VMM; | ||||
| mda.mda_mode = 0600; | mda.mda_mode = 0600; | ||||
| mda.mda_si_drv1 = sc; | mda.mda_si_drv1 = sc; | ||||
| mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; | mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; | ||||
| error = make_dev_s(&mda, &cdev, "vmm/%s", name); | error = make_dev_s(&mda, &cdev, "vmm/%s", name); | ||||
| if (error != 0) { | if (error != 0) { | ||||
| sx_xunlock(&vmmdev_mtx); | sx_xunlock(&vmmdev_mtx); | ||||
| vmmdev_destroy(sc); | vmmdev_destroy(sc); | ||||
| return (error); | return (error); | ||||
| ▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
| static int | static int | ||||
| vmmdev_init(void) | vmmdev_init(void) | ||||
| { | { | ||||
| int error; | int error; | ||||
| sx_xlock(&vmmdev_mtx); | sx_xlock(&vmmdev_mtx); | ||||
| error = make_dev_p(MAKEDEV_CHECKNAME, &vmmctl_cdev, &vmmctlsw, NULL, | error = make_dev_p(MAKEDEV_CHECKNAME, &vmmctl_cdev, &vmmctlsw, NULL, | ||||
| UID_ROOT, GID_WHEEL, 0600, "vmmctl"); | UID_ROOT, GID_VMM, 0660, "vmmctl"); | ||||
| if (error == 0) { | if (error == 0) { | ||||
| pr_allow_vmm_flag = prison_add_allow(NULL, "vmm", NULL, | pr_allow_vmm_flag = prison_add_allow(NULL, "vmm", NULL, | ||||
| "Allow use of vmm in a jail"); | "Allow use of vmm in a jail"); | ||||
| pr_allow_vmm_ppt_flag = prison_add_allow(NULL, "vmm_ppt", NULL, | pr_allow_vmm_ppt_flag = prison_add_allow(NULL, "vmm_ppt", NULL, | ||||
| "Allow use of vmm with ppt devices in a jail"); | "Allow use of vmm with ppt devices in a jail"); | ||||
| } | } | ||||
| sx_xunlock(&vmmdev_mtx); | sx_xunlock(&vmmdev_mtx); | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | devmem_create_cdev(struct vmmdev_softc *sc, int segid, char *devname) | ||||
| dsc->segid = segid; | dsc->segid = segid; | ||||
| dsc->name = devname; | dsc->name = devname; | ||||
| dsc->sc = sc; | dsc->sc = sc; | ||||
| SLIST_INSERT_HEAD(&sc->devmem, dsc, link); | SLIST_INSERT_HEAD(&sc->devmem, dsc, link); | ||||
| make_dev_args_init(&mda); | make_dev_args_init(&mda); | ||||
| mda.mda_devsw = &devmemsw; | mda.mda_devsw = &devmemsw; | ||||
| mda.mda_cr = sc->ucred; | mda.mda_cr = sc->ucred; | ||||
| mda.mda_uid = UID_ROOT; | mda.mda_uid = sc->ucred->cr_uid; | ||||
| mda.mda_gid = GID_WHEEL; | mda.mda_gid = GID_VMM; | ||||
| mda.mda_mode = 0600; | mda.mda_mode = 0600; | ||||
| mda.mda_si_drv1 = dsc; | mda.mda_si_drv1 = dsc; | ||||
| mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; | mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; | ||||
| error = make_dev_s(&mda, &dsc->cdev, "vmm.io/%s.%s", vm_name(sc->vm), | error = make_dev_s(&mda, &dsc->cdev, "vmm.io/%s.%s", vm_name(sc->vm), | ||||
| devname); | devname); | ||||
| if (error != 0) { | if (error != 0) { | ||||
| SLIST_REMOVE(&sc->devmem, dsc, devmem_softc, link); | SLIST_REMOVE(&sc->devmem, dsc, devmem_softc, link); | ||||
| free(dsc->name, M_VMMDEV); | free(dsc->name, M_VMMDEV); | ||||
| Show All 17 Lines | |||||