From nobody Mon Feb 9 00:07:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1595413688; cv=none; d=zohomail.com; s=zohoarc; b=INbuRzRPYxV10r0JXLKV2Il19FPrOL3VjzQWtHcpblFDCv2m3J+V+0XeTPRXi4CgGNiggYnFb6S1ZVkPs/ipNN5TF60p4C57YazkU1GcNZWl0HtS5k4mD0cfg5qdKwctGWbQNgkW455OsveAw+sWD4qwCE0nr/6pOBsSJSs8vuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595413688; 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=YvhTh6o+Na2b59xZyM/1f7MuWf9h4DA35C3WOQlMPyw=; b=mKMT6JsV5jtunJJ23Plhi+drv4iz6ilEWKn8Li8uvRz+9Htgexb7LKC3Y8RGePRLHDauOxMNq82O8/fUMYmIo/1CTOe34S6LkOe1lk6i4ZagcN0SnmlB5OmPKCEMzFJgml/aAuvCJujpgY5cDhs1s5BkZow8CFpeXpfF9RQ3y90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595413688026409.9521067294345; Wed, 22 Jul 2020 03:28:08 -0700 (PDT) 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-268-7tJVGzeRNY6LujHrFLHqQA-1; Wed, 22 Jul 2020 06:28:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E883102C7F2; Wed, 22 Jul 2020 10:27:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 664A6100EBB3; Wed, 22 Jul 2020 10:27:58 +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 3630F730D6; Wed, 22 Jul 2020 10:27:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06M9ethh000947 for ; Wed, 22 Jul 2020 05:40:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D6431A8F7; Wed, 22 Jul 2020 09:40:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCFDE1A90F for ; Wed, 22 Jul 2020 09:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595413686; 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=YvhTh6o+Na2b59xZyM/1f7MuWf9h4DA35C3WOQlMPyw=; b=PLXKJWUrM4IW+I6CozEcTB7dItFSgncI3QbOBq0hdzHaFc211fpDffUSKx5/sa/b4Nx04k uKTIdDtDHXDW7HLiSSfqnzd8youTDHPEEIie75nLjMDh1ewmFF2Lup6RfsDvYEOFAw1ays gxTWq2cykzgh+Hzd4XrHSFiSelVr6tY= X-MC-Unique: 7tJVGzeRNY6LujHrFLHqQA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 12/34] qemuDomainNamespaceMknodPaths: Create more files in one go Date: Wed, 22 Jul 2020 11:40:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.84 on 10.5.11.22 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" While the previous commit prepared the helper function run in a forked off helper (with corresponding struct), this commit modifies the caller, which now create all files requested in a single process and does not fork off for every single path. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_namespace.c | 89 ++++++++++++-------------------- 1 file changed, 32 insertions(+), 57 deletions(-) diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namesp= ace.c index 31acf2bde6..b9f8c32770 100644 --- a/src/qemu/qemu_domain_namespace.c +++ b/src/qemu/qemu_domain_namespace.c @@ -1385,12 +1385,12 @@ qemuDomainMknodItemInit(qemuDomainMknodItemPtr item, =20 =20 static int -qemuDomainAttachDeviceMknodOne(qemuDomainMknodDataPtr data, - virQEMUDriverConfigPtr cfg, - virDomainObjPtr vm, - const char *file, - char * const *devMountsPath, - size_t ndevMountsPath) +qemuDomainNamespacePrepareOne(qemuDomainMknodDataPtr data, + virQEMUDriverConfigPtr cfg, + virDomainObjPtr vm, + const char *file, + char * const *devMountsPath, + size_t ndevMountsPath) { long ttl =3D sysconf(_SC_SYMLOOP_MAX); const char *next =3D file; @@ -1433,23 +1433,36 @@ qemuDomainAttachDeviceMknodOne(qemuDomainMknodDataP= tr data, =20 =20 static int -qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver, - virDomainObjPtr vm, - const char *file, - char * const *devMountsPath, - size_t ndevMountsPath) +qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, + const char **paths, + size_t npaths) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D NULL; + char **devMountsPath =3D NULL; + size_t ndevMountsPath =3D 0; qemuDomainMknodData data =3D { 0 }; size_t i; int ret =3D -1; =20 + if (npaths =3D=3D 0) + return 0; + + cfg =3D virQEMUDriverGetConfig(driver); + if (qemuDomainGetPreservedMounts(cfg, vm, + &devMountsPath, NULL, + &ndevMountsPath) < 0) + return -1; + data.driver =3D driver; data.vm =3D vm; =20 - if (qemuDomainAttachDeviceMknodOne(&data, cfg, vm, file, - devMountsPath, ndevMountsPath) < 0) - return -1; + for (i =3D 0; i < npaths; i++) { + if (qemuDomainNamespacePrepareOne(&data, cfg, vm, paths[i], + devMountsPath, ndevMountsPath) <= 0) + goto cleanup; + } =20 for (i =3D 0; i < data.nitems; i++) { qemuDomainMknodItemPtr item =3D &data.items[i]; @@ -1481,6 +1494,7 @@ qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver, } } qemuDomainMknodDataClear(&data); + virStringListFreeCount(devMountsPath, ndevMountsPath); return ret; } =20 @@ -1489,11 +1503,9 @@ qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver, =20 =20 static int -qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver G_GNUC_UNUSED, - virDomainObjPtr vm G_GNUC_UNUSED, - const char *file G_GNUC_UNUSED, - char * const *devMountsPath G_GNUC_UNUSED, - size_t ndevMountsPath G_GNUC_UNUSED) +qemuDomainNamespaceMknodPaths(virDomainObjPtr vm G_GNUC_UNUSED, + const char **paths G_GNUC_UNUSED, + size_t npaths G_GNUC_UNUSED) { virReportSystemError(ENOSYS, "%s", _("Namespaces are not supported on this platform.= ")); @@ -1550,43 +1562,6 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver= G_GNUC_UNUSED, } =20 =20 -static int -qemuDomainNamespaceMknodPaths(virDomainObjPtr vm, - const char **paths, - size_t npaths) -{ - qemuDomainObjPrivatePtr priv =3D vm->privateData; - virQEMUDriverPtr driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - char **devMountsPath =3D NULL; - size_t ndevMountsPath =3D 0; - int ret =3D -1; - size_t i; - - if (!npaths) - return 0; - - cfg =3D virQEMUDriverGetConfig(driver); - if (qemuDomainGetPreservedMounts(cfg, vm, - &devMountsPath, NULL, - &ndevMountsPath) < 0) - goto cleanup; - - for (i =3D 0; i < npaths; i++) { - if (qemuDomainAttachDeviceMknod(driver, - vm, - paths[i], - devMountsPath, ndevMountsPath) < 0) - goto cleanup; - } - - ret =3D 0; - cleanup: - virStringListFreeCount(devMountsPath, ndevMountsPath); - return ret; -} - - static int qemuDomainNamespaceMknodPath(virDomainObjPtr vm, const char *path) --=20 2.26.2