From nobody Sun Feb 8 21:29:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1595411058; cv=none; d=zohomail.com; s=zohoarc; b=FVoXiyd780z4vK8hAWk4S7vo81OZH0eGW0Vblx3Ro/GyKpzldLayHX79IRr/ozYwm/uWCu95+BIfnS0uOsvGKPagOfxDVwaqdaVM+oaaxtQtZKGSZC1AAbWGFaZCG0V8MPCUHeTTSM2muueOLNOeTvvkNq8eNGnDLs5oy9Q5Oz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595411058; 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=x2Y35sOdEPCfFmUiWn8vi0DPtEAU6krW1ZmGfUHmgV0=; b=P9ywbKI4qaHIHYGXj01g04b30gWq3vMMZDP3RtRcdvWyR4EA4QRYZHtRuy3jOQoYC/ZtJJzVZ2/gt+Gjv99X8UFXDXFPB9o6dSHOU78eh0WjZ+YiUIOlQj49e4JUnyC1pQLKpPNbZA4jgfLb+xeimRna6ninSfLWOxHPlkk1APU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1595411058155919.0953618316448; Wed, 22 Jul 2020 02:44:18 -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-93-84f25NY3OqKUQZN0nrisHw-1; Wed, 22 Jul 2020 05:44:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 026F5100CCC2; Wed, 22 Jul 2020 09:44:09 +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 D449A2B6DB; Wed, 22 Jul 2020 09:44:08 +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 A61EB730FB; Wed, 22 Jul 2020 09:44:08 +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 06M9f5ZC001048 for ; Wed, 22 Jul 2020 05:41:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id EB78B2B5BF; Wed, 22 Jul 2020 09:41:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6ABD22B6DB for ; Wed, 22 Jul 2020 09:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595411057; 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=x2Y35sOdEPCfFmUiWn8vi0DPtEAU6krW1ZmGfUHmgV0=; b=bp0n1gyiYT0nGfvE3fUFEbGtKDoGgkUo+1/Ybo7n57J9Oe0CTJ8/FMbTaZCWRYhibSUWTh 0q1s1/dNmjfJ/Nzu+hfen0eipa2hDu6wxTYdwi8j2U/LVhzmMKXEW8DY88hYasbQf3Eq9R PO/3A/TwX/JMzVRv1T7rw4Fce+GW12g= X-MC-Unique: 84f25NY3OqKUQZN0nrisHw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v1 24/34] qemuDomainBuildNamespace: Populate RNGs from daemon's namespace Date: Wed, 22 Jul 2020 11:40:18 +0200 Message-Id: <7dd494c43a2d96839fc4b03c15fa1ce90665bf04.1595410402.git.mprivozn@redhat.com> 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.23 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 RNGs into daemon's namespace. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_namespace.c | 40 +++++++++----------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namesp= ace.c index f709fbb616..2ab10cb9f0 100644 --- a/src/qemu/qemu_domain_namespace.c +++ b/src/qemu/qemu_domain_namespace.c @@ -762,11 +762,11 @@ qemuDomainSetupAllInputs(virDomainObjPtr vm, =20 static int qemuDomainSetupRNG(virDomainRNGDefPtr rng, - const struct qemuDomainCreateDeviceData *data) + char ***paths) { switch ((virDomainRNGBackend) rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: - if (qemuDomainCreateDevice(rng->source.file, data, false) < 0) + if (virStringListAdd(paths, rng->source.file) < 0) return -1; break; =20 @@ -783,14 +783,14 @@ qemuDomainSetupRNG(virDomainRNGDefPtr rng, =20 static int qemuDomainSetupAllRNGs(virDomainObjPtr vm, - const struct qemuDomainCreateDeviceData *data) + char ***paths) { size_t i; =20 VIR_DEBUG("Setting up RNGs"); for (i =3D 0; i < vm->def->nrngs; i++) { if (qemuDomainSetupRNG(vm->def->rngs[i], - data) < 0) + paths) < 0) return -1; } =20 @@ -888,6 +888,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg, if (qemuDomainSetupAllInputs(vm, &paths) < 0) return -1; =20 + if (qemuDomainSetupAllRNGs(vm, &paths) < 0) + return -1; + if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths) < 0) return -1; =20 @@ -939,9 +942,6 @@ qemuDomainUnshareNamespace(virQEMUDriverConfigPtr cfg, if (qemuDomainSetupDev(mgr, vm, devPath) < 0) goto cleanup; =20 - if (qemuDomainSetupAllRNGs(vm, &data) < 0) - goto cleanup; - if (qemuDomainSetupLoader(vm, &data) < 0) goto cleanup; =20 @@ -1581,16 +1581,6 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver= G_GNUC_UNUSED, } =20 =20 -static int -qemuDomainNamespaceMknodPath(virDomainObjPtr vm, - const char *path) -{ - const char *paths[] =3D { path, NULL }; - - return qemuDomainNamespaceMknodPaths(vm, paths); -} - - static int qemuDomainNamespaceUnlinkPaths(virDomainObjPtr vm, const char **paths, @@ -1818,23 +1808,15 @@ int qemuDomainNamespaceSetupRNG(virDomainObjPtr vm, virDomainRNGDefPtr rng) { - const char *path =3D NULL; + VIR_AUTOSTRINGLIST paths =3D NULL; =20 if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; =20 - switch ((virDomainRNGBackend) rng->backend) { - case VIR_DOMAIN_RNG_BACKEND_RANDOM: - path =3D rng->source.file; - break; + if (qemuDomainSetupRNG(rng, &paths) < 0) + return -1; =20 - case VIR_DOMAIN_RNG_BACKEND_EGD: - case VIR_DOMAIN_RNG_BACKEND_BUILTIN: - case VIR_DOMAIN_RNG_BACKEND_LAST: - break; - } - - if (path && qemuDomainNamespaceMknodPath(vm, path) < 0) + if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths) < 0) return -1; =20 return 0; --=20 2.26.2