MCPcopy Create free account
hub / github.com/F-Stack/f-stack / alloc_memseg

Function alloc_memseg

freebsd/amd64/vmm/vmm_dev.c:280–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static int
281alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg, size_t len)
282{
283 char *name;
284 int error;
285 bool sysmem;
286
287 error = 0;
288 name = NULL;
289 sysmem = true;
290
291 /*
292 * The allocation is lengthened by 1 to hold a terminating NUL. It'll
293 * by stripped off when devfs processes the full string.
294 */
295 if (VM_MEMSEG_NAME(mseg)) {
296 sysmem = false;
297 name = malloc(len, M_VMMDEV, M_WAITOK);
298 error = copystr(mseg->name, name, len, NULL);
299 if (error)
300 goto done;
301 }
302
303 error = vm_alloc_memseg(sc->vm, mseg->segid, mseg->len, sysmem);
304 if (error)
305 goto done;
306
307 if (VM_MEMSEG_NAME(mseg)) {
308 error = devmem_create_cdev(vm_name(sc->vm), mseg->segid, name);
309 if (error)
310 vm_free_memseg(sc->vm, mseg->segid);
311 else
312 name = NULL; /* freed when 'cdev' is destroyed */
313 }
314done:
315 free(name, M_VMMDEV);
316 return (error);
317}
318
319static int
320vm_get_register_set(struct vm *vm, int vcpu, unsigned int count, int *regnum,

Callers 1

vmmdev_ioctlFunction · 0.85

Calls 7

mallocFunction · 0.85
copystrFunction · 0.85
vm_alloc_memsegFunction · 0.85
devmem_create_cdevFunction · 0.85
vm_nameFunction · 0.85
vm_free_memsegFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected