From nobody Mon Feb 9 21:37:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614971764; cv=none; d=zohomail.com; s=zohoarc; b=Q+nDszs8S4WpXuoSi1t9VB2SWZrFLH0RLpQf86IFgPEZAEyZzocSGGIBK74Ak/s+BmbTHua8Jc7PnY73OXwa02jwVOLCtzJw+h6AlE12uY4Y1QJmaJ+er7E+gcEdYU+vWgKfSKv9hRy7rWPzlms5yE+WHkTHIpecJ1mQjy7UCTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614971764; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lgvLC+FZ+JLZJUL8WMwnctL4DZo5zCO6njS83cUXTpo=; b=kUpo43Ak5ce/xOAqXKP65HAJT9SlZqmd6OZIW9qRfoKnReyWu+kiextVvg09IH0+4Of5g1rx0cUfc5FZOzZ5hChA7NlZCxuZWPtYCIDtsLUzzfc9HqPgGY6Xn0nAXXjf8vPi5oN3983kHktgNFIGL0KJt5WRIVSD2GoJPNlGUww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614971764410535.7428092484174; Fri, 5 Mar 2021 11:16:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-QGDHJ_CxMqi_W9PZyh9r_Q-1; Fri, 05 Mar 2021 14:15:33 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 732938015A0; Fri, 5 Mar 2021 19:15:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5034A12C53; Fri, 5 Mar 2021 19:15:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 158581803B33; Fri, 5 Mar 2021 19:15:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 125JEELn001716 for ; Fri, 5 Mar 2021 14:14:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id D5E515D6DC; Fri, 5 Mar 2021 19:14:14 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38D565D6B1 for ; Fri, 5 Mar 2021 19:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614971763; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lgvLC+FZ+JLZJUL8WMwnctL4DZo5zCO6njS83cUXTpo=; b=PhCUTqaW1ak+O6aVy1Q92713YSAwWgiX4xwQwKxEUVik4wnUM4/mgBGYPdlEVDTmtOlpzb NowhqIUoOfYQgO9biy1nlQSGCTVNwQ3u3ugCqocRnSiOA7Cg9iyEm1cVSMfO1WMzluQL9h 08KtAgM7eufuFJEtGIDGpzcNkb4bR7s= X-MC-Unique: QGDHJ_CxMqi_W9PZyh9r_Q-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 03/17] util: Always pass a pid to virProcessSetMax*() Date: Fri, 5 Mar 2021 20:13:50 +0100 Message-Id: <20210305191404.529903-4-abologna@redhat.com> In-Reply-To: <20210305191404.529903-1-abologna@redhat.com> References: <20210305191404.529903-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Currently, the functions accept either an explicit pid or zero, in which case the current process should be modified: the latter might sound like a convenient little feature, but in reality obtaining the pid of the current process is a single additional function call away, so it hardly makes a difference. Removing the few cases in which we're passing zero will allow us to simplify and improve the functions later. Signed-off-by: Andrea Bolognani --- src/util/vircommand.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 1a4b77ea24..3eef0767bb 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -780,11 +780,13 @@ virExec(virCommandPtr cmd) } } =20 + pid =3D getpid(); + if (cmd->pidfile) { int pidfilefd =3D -1; char c; =20 - pidfilefd =3D virPidFileAcquirePath(cmd->pidfile, false, getpid()); + pidfilefd =3D virPidFileAcquirePath(cmd->pidfile, false, pid); if (pidfilefd < 0) goto fork_error; if (virSetInherit(pidfilefd, true) < 0) { @@ -804,14 +806,14 @@ virExec(virCommandPtr cmd) /* pidfilefd is intentionally leaked. */ } =20 - if (virProcessSetMaxMemLock(0, cmd->maxMemLock) < 0) + if (virProcessSetMaxMemLock(pid, cmd->maxMemLock) < 0) goto fork_error; - if (virProcessSetMaxProcesses(0, cmd->maxProcesses) < 0) + if (virProcessSetMaxProcesses(pid, cmd->maxProcesses) < 0) goto fork_error; - if (virProcessSetMaxFiles(0, cmd->maxFiles) < 0) + if (virProcessSetMaxFiles(pid, cmd->maxFiles) < 0) goto fork_error; if (cmd->setMaxCore && - virProcessSetMaxCoreSize(0, cmd->maxCore) < 0) + virProcessSetMaxCoreSize(pid, cmd->maxCore) < 0) goto fork_error; =20 if (cmd->hook) { --=20 2.26.2