On Fri, Feb 25, 2022 at 01:46:00PM -0500, Ted Unangst wrote:
> On 2022-02-25, Robert Nagy wrote:
> > Maybe we need a default vmd class? What do you guys think?
>
> Regardless of what the limit is, this seems like a daemon where people
> will bump into the limit. Perhaps a reminder is in order too?
>
ok mlarkin on this one. thanks
>
> Index: vm.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/vm.c,v
> retrieving revision 1.67
> diff -u -p -r1.67 vm.c
> --- vm.c 30 Dec 2021 08:12:23 -0000 1.67
> +++ vm.c 25 Feb 2022 18:42:39 -0000
> @@ -26,6 +26,7 @@
> #include <sys/socket.h>
> #include <sys/time.h>
> #include <sys/mman.h>
> +#include <sys/resource.h>
>
> #include <dev/ic/i8253reg.h>
> #include <dev/isa/isareg.h>
> @@ -292,8 +293,12 @@ start_vm(struct vmd_vm *vm, int fd)
> ret = alloc_guest_mem(vcp);
>
> if (ret) {
> + struct rlimit lim;
> + const char *msg = "could not allocate guest memory - exiting";
> + if (getrlimit(RLIMIT_DATA, &lim) == 0)
> + msg = "could not allocate guest memory (data limit is
> %llu) - exiting";
> errno = ret;
> - fatal("could not allocate guest memory - exiting");
> + fatal(msg, lim.rlim_cur);
> }
>
> ret = vmm_create_vm(vcp);
>