From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 4887C5A026A for ; Mon, 9 Jan 2023 05:11:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673237476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9kOktsQpXO+UsWpiHdQA2KAmfKD+louWmtF6giA4UIQ=; b=YRTFEQSHXl0WTM9tKnd/NYqXcRqZvAW62MKjJYK8kgS3xr1Hb68gWGlS/yc1NhJJV6lDW4 IKkPPuk9PGqOluuDmZ0izN15Sr1ztr74m02niFhNRv6KxdyEiyUNEj9GsuP539e1ibtgh7 +M7DenLCEf+l8UefDDFQEa5UVwgdY0E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-leQmCuSCMRWjUNBsEVnVJA-1; Sun, 08 Jan 2023 23:11:15 -0500 X-MC-Unique: leQmCuSCMRWjUNBsEVnVJA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE3AB889059 for ; Mon, 9 Jan 2023 04:11:14 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AB4C1121314; Mon, 9 Jan 2023 04:11:14 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] qemu: add passtStateDir to qemu driver config Date: Sun, 8 Jan 2023 23:11:10 -0500 Message-Id: <20230109041112.368790-8-laine@redhat.com> In-Reply-To: <20230109041112.368790-1-laine@redhat.com> References: <20230109041112.368790-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: XUAZSOBOJE4NKRFTLJGF2SFPY2BBOMKT X-Message-ID-Hash: XUAZSOBOJE4NKRFTLJGF2SFPY2BBOMKT X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: -- It seems a bit wasteful to allocate another string for this, since it is 100% always ${stateDir}/passt, but everyone else is doing this (e.g. slirpStateDir), so I'm just following along with the cult. Signed-off-by: Laine Stump --- src/qemu/qemu_conf.c | 2 ++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..bb6a55738b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -225,6 +225,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged, cfg->configDir = g_strdup_printf("%s/qemu", cfg->configBaseDir); cfg->autostartDir = g_strdup_printf("%s/qemu/autostart", cfg->configBaseDir); cfg->slirpStateDir = g_strdup_printf("%s/slirp", cfg->stateDir); + cfg->passtStateDir = g_strdup_printf("%s/passt", cfg->stateDir); cfg->dbusStateDir = g_strdup_printf("%s/dbus", cfg->stateDir); /* Set the default directory to find TLS X.509 certificates. @@ -310,6 +311,7 @@ static void virQEMUDriverConfigDispose(void *obj) g_free(cfg->stateDir); g_free(cfg->swtpmStateDir); g_free(cfg->slirpStateDir); + g_free(cfg->passtStateDir); g_free(cfg->dbusStateDir); g_free(cfg->libDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..159fd61d2b 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -95,6 +95,7 @@ struct _virQEMUDriverConfig { char *stateDir; char *swtpmStateDir; char *slirpStateDir; + char *passtStateDir; char *dbusStateDir; /* These two directories are ones QEMU processes use (so must match * the QEMU user/group */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..3d8bea6462 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -663,6 +663,11 @@ qemuStateInitialize(bool privileged, cfg->slirpStateDir); goto error; } + if (g_mkdir_with_parents(cfg->passtStateDir, 0777) < 0) { + virReportSystemError(errno, _("Failed to create passt state dir %s"), + cfg->passtStateDir); + goto error; + } if (virDirCreate(cfg->dbusStateDir, 0770, cfg->user, cfg->group, VIR_DIR_CREATE_ALLOW_EXIST) < 0) { @@ -811,6 +816,13 @@ qemuStateInitialize(bool privileged, (int)cfg->group); goto error; } + if (chown(cfg->passtStateDir, cfg->user, cfg->group) < 0) { + virReportSystemError(errno, + _("unable to set ownership of '%s' to %d:%d"), + cfg->passtStateDir, (int)cfg->user, + (int)cfg->group); + goto error; + } run_uid = cfg->user; run_gid = cfg->group; -- 2.38.1