Re: getting domain info list: Cannot allocate memory

From: Roger Pau Monné <roger.pau_at_citrix.com>
Date: Tue, 19 Dec 2023 10:27:02 UTC
On Tue, Dec 19, 2023 at 09:48:32AM +0800, Zhenlei Huang wrote:
> 
> 
> > On Dec 19, 2023, at 9:15 AM, ASOU Masato <takeasou.masato@gmail.com> wrote:
> > 
> > I was solved this problem by my self.
> > 
> > asou@intel-fbsd:~ $ sudo xl list
> > Password:
> > libxl: error: libxl_domain.c:335:libxl_list_domain: getting domain
> > info list: Cannot allocate memory
> > libxl_list_domain failed.
> > asou@intel-fbsd:~ $ su
> > Password:
> > root@intel-fbsd:/home/asou # xl list
> > Name                                        ID   Mem VCPUs State Time(s)
> > Domain-0                                     0  4095     4     r-----      14.8
> > root@intel-fbsd:/home/asou #
> > 
> > If I was used sudo command, I got `Cannot allocate memory'. However, I used
> > su command and execute xl list command, then I got correct result.
> 
> That is an interesting bug / feature ;)

This is the result of user limits, see:

$ sudo limits -l
Resource limits (current):
  memorylocked               64 kB

vs

# limits -l
Resource limits (current):
  memorylocked         infinity kB

Seems like user limits are inherited into root context when using
sudo.

You might want to edit /etc/login.conf and set memorylocked to a more
suitable value (unlimited?) for the user you plan to execute xl from.

You might also need to modify the vm.max_user_wired sysctl to set it
to -1 in order to allow unlimited wired memory for users.  Note this
is likely only safe for systems where the (non-root) user you plan to
run xl from is fully trusted, and doesn't run any other tasks.

Regards, Roger.