Matthew Martin <phy1...@gmail.com> writes:

> When vmd/vmctl switched to handling memory in bytes, seems a few places
> for user VMs were missed. Additionally the first hunk removes the quota
> hit if the VM will not be created.
>

Thanks, I'll take a deeper look this week. I don't use the user quota
pieces, so I'll need to read through some of this to confirm. If you
don't hear from me by end of week (October) you're welcome to nudge me.

>
> diff --git config.c config.c
> index 374d7de6629..425c901f36a 100644
> --- config.c
> +++ config.c
> @@ -241,8 +241,10 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
> uint32_t peerid, uid_t uid)
>       /* increase the user reference counter and check user limits */
>       if (vm->vm_user != NULL && user_get(vm->vm_user->usr_id.uid) != NULL) {
>               user_inc(vcp, vm->vm_user, 1);
> -             if (user_checklimit(vm->vm_user, vcp) == -1)
> +             if (user_checklimit(vm->vm_user, vcp) == -1) {
> +                     user_inc(vcp, vm->vm_user, 0);
>                       return (EPERM);
> +             }
>       }
>
>       /*
> diff --git vmd.c vmd.c
> index 2f3ac1a76f2..a7687d6ce93 100644
> --- vmd.c
> +++ vmd.c
> @@ -1966,7 +1966,7 @@ user_inc(struct vm_create_params *vcp, struct vmd_user 
> *usr, int inc)
>       usr->usr_maxifs += vcp->vcp_nnics * inc;
>
>       if (log_getverbose() > 1) {
> -             (void)fmt_scaled(usr->usr_maxmem * 1024 * 1024, mem);
> +             (void)fmt_scaled(usr->usr_maxmem, mem);
>               log_debug("%s: %c uid %d ref %d cpu %llu mem %s ifs %llu",
>                   __func__, inc == 1 ? '+' : '-',
>                   usr->usr_id.uid, usr->usr_refcnt,
> diff --git vmd.h vmd.h
> index 9010ad6eb9f..8be7db3d059 100644
> --- vmd.h
> +++ vmd.h
> @@ -67,7 +67,7 @@
>
>  /* default user instance limits */
>  #define VM_DEFAULT_USER_MAXCPU       4
> -#define VM_DEFAULT_USER_MAXMEM       2048
> +#define VM_DEFAULT_USER_MAXMEM       2L * 1024 * 1024 * 1024 /* 2 GiB */
>  #define VM_DEFAULT_USER_MAXIFS       8
>
>  /* vmd -> vmctl error codes */

Reply via email to