qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Cc: qemu-devel@nongnu.org, Cleber Rosa <crosa@redhat.com>,
	"yc-core @ yandex-team . ru" <yc-core@yandex-team.ru>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3] tests/functional: add memlock tests
Date: Tue, 15 Apr 2025 11:36:45 +0100	[thread overview]
Message-ID: <Z_42vZhXelZyFJRo@redhat.com> (raw)
In-Reply-To: <7c63f352-4ef0-4e1e-b95e-8e3e586799dd@yandex-team.ru>

On Tue, Apr 15, 2025 at 03:27:29PM +0500, Alexandr Moshkov wrote:
> 
> On 4/15/25 14:20, Daniel P. Berrangé wrote:
> > On Tue, Apr 15, 2025 at 02:08:55PM +0500, Alexandr Moshkov wrote:
> > > Add new tests to check the correctness of the `-overcommit memlock`
> > > option (possible values: off, on, on-fault) by using
> > > `/proc/{qemu_pid}/smaps` file to check in Size, Rss and Locked fields of
> > > anonymous segments:
> > > 
> > > * if `memlock=off`, then Locked = 0 on every anonymous smaps;
> > > * if `memlock=on`, then Size, Rss and Locked values must be equal for
> > > every anon smaps where Rss is not 0;
> > > * if `memlock=on-fault`, then Rss and Locked must be equal on every anon
> > > smaps and anonymous segment with Rss < Size must exists.
> > How are you running this test ?  Unprivileged users don't get to
> > lock any non-trivial amount of memory by default, and QEMU functional
> > tests pretty much exclusively get run as an unprivileged user account.
> > 
> > This test immediately fails when run:
> > 
> >    qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
> > 	Exit code: 1
> > 	Command: ./build/qemu-system-x86_64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -overcommit mem-lock=on
> > 	Output: qemu-system-x86_64: mlockall: Cannot allocate memory
> >          qemu-system-x86_64: locking memory failed
> > 
> > and we don't expect users to run anything as root.
> > 
> Hello, thanks for reply! Looks like i have a larger amount of memory for
> locking in my system:
> 
> > ulimit -l
> 4063912
> 
> I think that's why this test was successfully running on my system.

In Fedora this limit is set to 8192, and GitLab CI has it set
the same.

> Honestly,Idon't know yet how to solve this problem properly. Ithink the only
> ways is to runas root (whichis a bad idea)ortoincrease limits on an
> unprivileged user account by using /etc/security/limits.conf.

Add a new decorator "skipLockedMemoryTest()" to:

  tests/functional/qemu_test/decorators.py

with the decorator accepting an amount of required locked memory in KB, and
checking it against the current user ulimits. That will make the tst do
the right thing and skip execution of insufficient locked memory is
available.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2025-04-15 10:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15  9:08 [PATCH v3] tests/functional: add memlock tests Alexandr Moshkov
2025-04-15  9:20 ` Daniel P. Berrangé
2025-04-15 10:27   ` Alexandr Moshkov
2025-04-15 10:36     ` Daniel P. Berrangé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z_42vZhXelZyFJRo@redhat.com \
    --to=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=dtalexundeer@yandex-team.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yc-core@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).