Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-09 Thread Andrea Bolognani
On Tue, 2021-03-09 at 12:43 +0100, Michal Privoznik wrote: > On 3/5/21 8:13 PM, Andrea Bolognani wrote: > > +if (!g_file_get_contents(procfile, , , NULL)) > > +return -1; > > I did not spot this yesterday, but now I'm working on a something else > and have to read a contents of a

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-09 Thread Michal Privoznik
On 3/5/21 8:13 PM, Andrea Bolognani wrote: Calling prlimit() requires elevated privileges, specifically CAP_SYS_RESOURCE, and getrlimit() only works for the current process which is too limiting for our needs; /proc/$pid/limits, on the other hand, can be read by any process, so implement parsing

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-08 Thread Daniel P . Berrangé
On Mon, Mar 08, 2021 at 04:21:16PM +0100, Andrea Bolognani wrote: > On Mon, 2021-03-08 at 10:50 +, Daniel P. Berrangé wrote: > > On Fri, Mar 05, 2021 at 08:13:59PM +0100, Andrea Bolognani wrote: > > > +if (!(label = virProcessLimitResourceToLabel(resource))) { > > > +

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-08 Thread Andrea Bolognani
On Mon, 2021-03-08 at 10:50 +, Daniel P. Berrangé wrote: > On Fri, Mar 05, 2021 at 08:13:59PM +0100, Andrea Bolognani wrote: > > +if (!(label = virProcessLimitResourceToLabel(resource))) { > > +virReportError(VIR_ERR_INTERNAL_ERROR, > > + _("Unknown resource

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-08 Thread Andrea Bolognani
On Mon, 2021-03-08 at 11:30 +0100, Michal Privoznik wrote: > On 3/5/21 8:13 PM, Andrea Bolognani wrote: > > +if (!STRPREFIX(line, label)) > > +continue; > > + > > +line += strlen(label); > > Or if (!(line = STRSKIP(line, label)) continue; Oh, I didn't know that

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-08 Thread Daniel P . Berrangé
On Fri, Mar 05, 2021 at 08:13:59PM +0100, Andrea Bolognani wrote: > Calling prlimit() requires elevated privileges, specifically > CAP_SYS_RESOURCE, and getrlimit() only works for the current > process which is too limiting for our needs; /proc/$pid/limits, > on the other hand, can be read by any

Re: [libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-08 Thread Michal Privoznik
On 3/5/21 8:13 PM, Andrea Bolognani wrote: Calling prlimit() requires elevated privileges, specifically CAP_SYS_RESOURCE, and getrlimit() only works for the current process which is too limiting for our needs; /proc/$pid/limits, on the other hand, can be read by any process, so implement parsing

[libvirt PATCH 12/17] util: Try to get limits from /proc

2021-03-05 Thread Andrea Bolognani
Calling prlimit() requires elevated privileges, specifically CAP_SYS_RESOURCE, and getrlimit() only works for the current process which is too limiting for our needs; /proc/$pid/limits, on the other hand, can be read by any process, so implement parsing that file as a fallback for when prlimit()