[libvirt PATCH] qemu: Do not try to set memlock on inactive domain

Jiri Denemark posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/31d321fe4c06bbf872ee3d0f4e34e2034c4912b9.1659527560.git.jdenemar@redhat.com
src/qemu/qemu_domain.c | 4 ++++
1 file changed, 4 insertions(+)
[libvirt PATCH] qemu: Do not try to set memlock on inactive domain
Posted by Jiri Denemark 1 year, 9 months ago
When we call qemuDomainSetMaxMemLock to reset memory locking limit back
to its original value the domain can already be stopped (for example
after the domain shuts down during migration) in which case it does not
make sense to set any limit. Doing so can even be harmful as we may end
up setting the limit for the daemon itself as the PID is 0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_domain.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 12c58a25b9..ad6c614d89 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9461,6 +9461,10 @@ qemuDomainSetMaxMemLock(virDomainObj *vm,
 {
     unsigned long long current = 0;
 
+    /* nothing to do if the domain is not running */
+    if (vm->pid <= 0)
+        return 0;
+
     if (virProcessGetMaxMemLock(vm->pid, &current) < 0)
         return -1;
 
-- 
2.35.1
Re: [libvirt PATCH] qemu: Do not try to set memlock on inactive domain
Posted by Pavel Hrdina 1 year, 9 months ago
On Wed, Aug 03, 2022 at 01:52:41PM +0200, Jiri Denemark wrote:
> When we call qemuDomainSetMaxMemLock to reset memory locking limit back
> to its original value the domain can already be stopped (for example
> after the domain shuts down during migration) in which case it does not
> make sense to set any limit. Doing so can even be harmful as we may end
> up setting the limit for the daemon itself as the PID is 0.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>