From nobody Sun May 19 13:34:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1664451503; cv=none; d=zohomail.com; s=zohoarc; b=hiiIbG351BMbp2HFsFxRCZ3OpI4GNwYq+/w4Aso6wltahlIY66C+VhjWEcQI1QY3z8Z+rslt8G9MKLIeDR5yHSkAGP+gVK+rUeKTNbnMTPhqzWfqw11bnKOSvp/QUZrqp1FfW22rN+eWj02hj0wceE5SPCpmATocaYIAy3IQ56E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664451503; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FD5tqKoIuCKdt3EjeFiH0Ylx2a5NGEf/IislPBb6b9E=; b=drAKbLF5JZC6yh8AAlGe4S6y+k/5nng5trEDDLBK+omJC6/98VYwUryW3JN3qfmB9Gr/VQQND/FugcywaaTeNYmS52cBW2t8duaJe4Rn2CduvOH4HkMUp9XavfM1GtStvatSGx6PN9bZY1ogF2aP+gwJjsVbZMhZNsVPDE1BZAA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 166445150376316.61413104265978; Thu, 29 Sep 2022 04:38:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251-jUbo7yxiMIa3fM4ji4ZY-A-1; Thu, 29 Sep 2022 07:38:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E27AB293248D; Thu, 29 Sep 2022 11:38:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9E5D2033970; Thu, 29 Sep 2022 11:38:12 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA6661946A45; Thu, 29 Sep 2022 11:38:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C561619465B8 for ; Thu, 29 Sep 2022 11:38:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B2D81C15BA5; Thu, 29 Sep 2022 11:38:11 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B141C15BA4 for ; Thu, 29 Sep 2022 11:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664451501; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FD5tqKoIuCKdt3EjeFiH0Ylx2a5NGEf/IislPBb6b9E=; b=eDv0Bbg127TgOsQOv5aMA61SfuoMCTsAt10VsgnO6mmEPJyqZfG6yx7BIHVrT/me92Ryct POe8g0Jznt4ILN7sXryROtpoPlAE8mIX2/pSDigQOKcLphlCgep0P+cget8oBUIiFZv4iV IhuSdk7e/+eGJWyXGf9osNaRsh9QBBw= X-MC-Unique: jUbo7yxiMIa3fM4ji4ZY-A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuNamespaceMknodPaths: Don't fork needlessly Date: Thu, 29 Sep 2022 13:38:08 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664451505098100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The qemuNamespaceMknodPaths() function is responsible for creating files/directories in QEMU's mount namespace. When called, it is given list of paths that have to be created in the namespace. It processes this list and removes items that are not directly under /dev, but on a 'shared' filesystem (note that all other mount points are preserved). And it may so happen that after this pre-process no files/directories need to be created in the namespace. If that's the case, exit early and avoid fork()-ing only to find out the same. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 09e235e120..a2c31310d9 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1293,6 +1293,9 @@ qemuNamespaceMknodPaths(virDomainObj *vm, goto cleanup; } =20 + if (data.nitems =3D=3D 0) + return 0; + for (i =3D 0; i < data.nitems; i++) { qemuNamespaceMknodItem *item =3D &data.items[i]; if (item->target && --=20 2.35.1