From nobody Sun Feb 8 22:50:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551883301761601.4837560766182; Wed, 6 Mar 2019 06:41:41 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7A673092650; Wed, 6 Mar 2019 14:41:39 +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 BED8E600D7; Wed, 6 Mar 2019 14:41:39 +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 803AF3D389; Wed, 6 Mar 2019 14:41:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x26EfWbO006192 for ; Wed, 6 Mar 2019 09:41:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3DC886B485; Wed, 6 Mar 2019 14:41:32 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E45A6B489; Wed, 6 Mar 2019 14:41:31 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 6 Mar 2019 15:41:18 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 2/3] qemu: Introduce qemuCommandEnvSetup helper 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 06 Mar 2019 14:41:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is a wrapper over virCommandAddEnvPassCommon and virCommandAddEnvXDG. It is defined within the qemu module, since it is meant to enforce isolation of QEMU processes which is not much useful for other processes we spawn, like dnsmasq. Signed-off-by: Erik Skultety --- src/qemu/qemu_command.c | 25 +++++++++++++++++++++++-- src/qemu/qemu_command.h | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2c6d6188e2..85b90be429 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10620,6 +10620,28 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, } =20 =20 +/** + * qemuCommandEnvSetup: + * @cmd: command to modify + * @baseDir: absolute path to a dir which HOME and XDG vars will be based = on + * + * Defines the basic set of environment variables for a QEMU process, e.g. + * HOME, PATH, XDG_, etc. To isolate individual QEMU processes, HOME and X= DG_ + * variables are derived from @baseDir. Therefore, @baseDir must not be NU= LL. + */ +void +qemuCommandEnvSetup(virCommandPtr cmd, + const char *baseDir) +{ + if (!baseDir) + return; + + virCommandAddEnvPassCommon(cmd); + + virCommandAddEnvXDG(cmd, baseDir); +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10657,8 +10679,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, =20 cmd =3D virCommandNew(def->emulator); =20 - virCommandAddEnvPassCommon(cmd); - virCommandAddEnvXDG(cmd, priv->libDir); + qemuCommandEnvSetup(cmd, priv->libDir); =20 if (qemuBuildNameCommandLine(cmd, cfg, def, qemuCaps) < 0) goto error; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 077484094d..07a034504a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -227,4 +227,7 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); =20 +void +qemuCommandEnvSetup(virCommandPtr cmd, const char *baseDir); + #endif /* LIBVIRT_QEMU_COMMAND_H */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list