From nobody Sun Feb 8 22:07:46 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=1595411104; cv=none; d=zohomail.com; s=zohoarc; b=UtcLR6jyUrm/WLYH0lfKwXNrIplrecwzB29Kyi2oMVoH1wolk+DBAlm8kunAeRz3kfqEQvHjDWSTO/mAVsDh0xoIWzFV0H/fq48fV7nkU7aSKSUI1O+yozP+QWva8gtMfrDOdmPlb7BbhQsZzPoL+5SAGrj9mumc8Q5FJ/Y+0kQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595411104; 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=sa3lJ0C27SIbvAZ77/Z0aPYN2GciI9jiHakpndiEhlA=; b=YNDis0x3fluWzvZB3OuaQOkrdY8DvDSNctyV10V1sGeTGqsnM7l7S4XITU2XTr62juiz4v/Hqg18d5W6YFHlv6c4Tc+hdLfhOdo0PpSczlHp7XDjY8ADSAtAwITK2rcWw5OoPzueUToWfRiBT/t8qyYxO7zC8XdzSvFQH/TaxSk= 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 1595411104943965.5305184303421; Wed, 22 Jul 2020 02:45:04 -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-108-TzciLSD_N0u4DwIse7VTDA-1; Wed, 22 Jul 2020 05:44:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19A8618C63D1; Wed, 22 Jul 2020 09:44:01 +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 E2F69726AE; Wed, 22 Jul 2020 09:44:00 +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 B2886730F1; Wed, 22 Jul 2020 09:44:00 +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 06M9f2V8001009 for ; Wed, 22 Jul 2020 05:41:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 712941A8F7; Wed, 22 Jul 2020 09:41:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id E08AD2855B for ; Wed, 22 Jul 2020 09:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595411103; 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=sa3lJ0C27SIbvAZ77/Z0aPYN2GciI9jiHakpndiEhlA=; b=TT52+7ry24hFVEuQziBFYjrSkov/RQnQZ3psyGpmp3RMLvwXCX6lCssdw+M6GuOzmy+5M1 aNCXQId/Pxphsj8RplJ6icX09mtHJzNWTKGp+NFEfDf/gRjBiMuyWlyTh3H4nNKKkFJCyu 7ja6hNeouqTrojZywRN8X0+dcFS+sYo= X-MC-Unique: TzciLSD_N0u4DwIse7VTDA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 20/34] qemuDomainBuildNamespace: Populate chardevs from daemon's namespace Date: Wed, 22 Jul 2020 11:40:14 +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.79 on 10.5.11.15 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" As mentioned in one of previous commits, populating domain's namespace from pre-exec() hook is dangerous. This commit moves population of the namespace with domain chardevs into daemon's namespace. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_namespace.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namesp= ace.c index bafb08fac8..36d22b42f2 100644 --- a/src/qemu/qemu_domain_namespace.c +++ b/src/qemu/qemu_domain_namespace.c @@ -629,7 +629,7 @@ qemuDomainSetupChardev(virDomainDefPtr def G_GNUC_UNUSE= D, virDomainChrDefPtr dev, void *opaque) { - const struct qemuDomainCreateDeviceData *data =3D opaque; + char ***paths =3D opaque; const char *path =3D NULL; =20 if (!(path =3D virDomainChrSourceDefGetPath(dev->source))) @@ -640,20 +640,20 @@ qemuDomainSetupChardev(virDomainDefPtr def G_GNUC_UNU= SED, dev->source->data.nix.listen) return 0; =20 - return qemuDomainCreateDevice(path, data, true); + return virStringListAdd(paths, path); } =20 =20 static int qemuDomainSetupAllChardevs(virDomainObjPtr vm, - const struct qemuDomainCreateDeviceData *data) + char ***paths) { VIR_DEBUG("Setting up chardevs"); =20 if (virDomainChrDefForeach(vm->def, true, qemuDomainSetupChardev, - (void *)data) < 0) + paths) < 0) return -1; =20 VIR_DEBUG("Setup all chardevs"); @@ -877,6 +877,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg, if (qemuDomainSetupAllMemories(vm, &paths) < 0) return -1; =20 + if (qemuDomainSetupAllChardevs(vm, &paths) < 0) + return -1; + if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths) < 0) return -1; =20 @@ -928,9 +931,6 @@ qemuDomainUnshareNamespace(virQEMUDriverConfigPtr cfg, if (qemuDomainSetupDev(mgr, vm, devPath) < 0) goto cleanup; =20 - if (qemuDomainSetupAllChardevs(vm, &data) < 0) - goto cleanup; - if (qemuDomainSetupAllTPMs(vm, &data) < 0) goto cleanup; =20 @@ -1779,20 +1779,15 @@ int qemuDomainNamespaceSetupChardev(virDomainObjPtr vm, virDomainChrDefPtr chr) { - const char *path; + VIR_AUTOSTRINGLIST paths =3D NULL; =20 if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; =20 - if (!(path =3D virDomainChrSourceDefGetPath(chr->source))) - return 0; + if (qemuDomainSetupChardev(vm->def, chr, &paths) < 0) + return -1; =20 - /* Socket created by qemu. It doesn't exist upfront. */ - if (chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && - chr->source->data.nix.listen) - return 0; - - if (qemuDomainNamespaceMknodPath(vm, path) < 0) + if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths) < 0) return -1; =20 return 0; --=20 2.26.2