From nobody Wed Apr 24 01:11:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585221530; cv=none; d=zohomail.com; s=zohoarc; b=b7Vlm9FFRxbA3kFCOZVM568hYzjSPPtqznNjNZyY68GxeEqWvuaz+fUyabPNC/3sFL9Y/TtvUGX1u1hbzPC1Q9XwRBUczHPPpR1E1/+1yX0gd81pPTBC01/XbzoxGqXyxZ6maQh1YCIiIjtx0dhTE5pbqOi76viKyEeqEIpfKJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585221530; 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=qGI+kY18kmSa/+FMylvW/7sYkoY0AK1HDws9IS+KsSc=; b=OesEXlgFAFSgoo4W0NGw9rdzJTQqT3SyOxXEDyz6otLDBISM+0bQtpeZp2ASSjbe1FO+PvXkC9KKoRe5osG9ZW9XpgBRpVkO46fOwSbmodF7yhSo6whikguztjbNKbWiLkL3D5Q1+MEIAj+pyblKJs8ydta+fMJaHa0Kj+TnRtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585221530141866.6229571396087; Thu, 26 Mar 2020 04:18:50 -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-13-tH7a_t_HPWaiu_vAI0sXEQ-1; Thu, 26 Mar 2020 07:18:46 -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 0ACD3802B69; Thu, 26 Mar 2020 11:18: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 87D0E10002A9; Thu, 26 Mar 2020 11:18:38 +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 DEA7286FF7; Thu, 26 Mar 2020 11:18:37 +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 02QBIAjP018163 for ; Thu, 26 Mar 2020 07:18:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2250A60FFB; Thu, 26 Mar 2020 11:18:10 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9044A60FCC for ; Thu, 26 Mar 2020 11:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585221529; 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=qGI+kY18kmSa/+FMylvW/7sYkoY0AK1HDws9IS+KsSc=; b=iA99Fm/ZRe47uCIE2PeEUqaHo7HmnSj48i4U3vhJRmbWdV09dCJsGmACBIWOlFaY+TcjKg uXNac0hyynmb6SPuYmJxhDbRZt621MnORqjMM9uo2OPBY7zKJl8vYqCRn/rpL73eKFPW08 mOtJkpTBgkBsBIJvBHGGvEIybDX1p1E= X-MC-Unique: tH7a_t_HPWaiu_vAI0sXEQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuSecurityChownCallback: Remove 'cleanup' section Date: Thu, 26 Mar 2020 12:18:02 +0100 Message-Id: <9d1e3dd3adc9887cc06fbdb9ae15d1efd09845c3.1585221445.git.pkrempa@redhat.com> 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 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" Treat the shortcut for chowning local files as a stand-alone section by returning success from it and refactor the rest so that the cleanup section is inline. Signed-off-by: Peter Krempa Reviewed-by: Pavel Mores --- src/qemu/qemu_driver.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 570dc059e9..b1f7be50b4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -268,24 +268,20 @@ qemuSecurityChownCallback(const virStorageSource *src, } if (chown(src->path, uid, gid) < 0) - goto cleanup; - } else { - if (!(cpy =3D virStorageSourceCopy(src, false))) - goto cleanup; - - /* src file init reports errors, return -2 on failure */ - if (virStorageFileInit(cpy) < 0) { - ret =3D -2; - goto cleanup; - } + return -1; - if (virStorageFileChown(cpy, uid, gid) < 0) - goto cleanup; + return 0; } - ret =3D 0; + if (!(cpy =3D virStorageSourceCopy(src, false))) + return -1; + + /* src file init reports errors, return -2 on failure */ + if (virStorageFileInit(cpy) < 0) + return -2; + + ret =3D virStorageFileChown(cpy, uid, gid); - cleanup: save_errno =3D errno; virStorageFileDeinit(cpy); errno =3D save_errno; --=20 2.24.1 From nobody Wed Apr 24 01:11:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585221506; cv=none; d=zohomail.com; s=zohoarc; b=gY45ar7/ojGzPUuyKgYPlwEpl8lVAA4xx4XQZUfv+rpMYjS/8qt8+4ZJXaBaTEv6w8OCIR3QpiIPiRUmEfCsS6Lx8sRQJ+sj11n6AZwtYYiMRgKLQuJRxsYrfkRr8vJDHv/4zLC439eBYOPaGqcQbXquMJbirEpsXbn9Z8walTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585221506; 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=ygtuBL3sPj/e7xrvEbfFm9xrDybe7o+vaAhsTTrnayk=; b=mhbvWOW4ZVPlj7W8Kpdfpt470yR90O/B8hLLZuWuFwPZbBFmtqWLf5lSL990+h9rNlQDecw3BBU8aW4oTLAlZH6CUoHgHHEDljjWbkZe5uvq69NoC7zU36yYZm2lGYxlyjEXyyoNmgyx3qTXguPsCl0H5AotvkXz0kTTgSiYveM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585221506557616.7428824565507; Thu, 26 Mar 2020 04:18:26 -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-355-O0zIyG_hNaiCefZW4isNnA-1; Thu, 26 Mar 2020 07:18:23 -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 6917F192203A; Thu, 26 Mar 2020 11:18:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E5AE196AE; Thu, 26 Mar 2020 11:18:16 +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 C412018089CF; Thu, 26 Mar 2020 11:18:14 +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 02QBIDaS018176 for ; Thu, 26 Mar 2020 07:18:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE53E60FFB; Thu, 26 Mar 2020 11:18:13 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 734DE60FCC for ; Thu, 26 Mar 2020 11:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585221505; 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=ygtuBL3sPj/e7xrvEbfFm9xrDybe7o+vaAhsTTrnayk=; b=ZL1S1qeP0ZJ81n77Q+WneF4TH5Xwij0QAs4nXo5ySNJeP8gbFoVQM3VNAOl0udvlNN3PAw EHdDhwm7nxxjQFA1CueeSXLok5e77npfeU2Nq04YINToDoKa1phmzTRvIGRgGQxnUWvPSU rFUZCL6DuEKSsThLMWJ72ZTw3U/isAI= X-MC-Unique: O0zIyG_hNaiCefZW4isNnA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuSecurityChownCallback: Don't initialize storage file subsystem for local file Date: Thu, 26 Mar 2020 12:18:03 +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 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 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" virStorageFileSupportsSecurityDriver ends up initializing the storage file backend which after the recent changes to the daemon architecture may end up dlopening of the backend modules. Since this is required only for remote storage we can optimize the call by moving the check whether the backend is supported to the branch which deals with remote storage. This will prevent the pointless dlopen for local files. This is amplified by the fact that we now do most storage driver operations in forks so the storage backends may not even be initialized in the main daemon. On the other hand, not having gluster linked in the main daemon is a big win, so we should keep only the forks having to link with it. Signed-off-by: Peter Krempa Reviewed-by: Pavel Mores --- src/qemu/qemu_driver.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b1f7be50b4..3cbd900f7e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -249,10 +249,6 @@ qemuSecurityChownCallback(const virStorageSource *src, int rv; g_autoptr(virStorageSource) cpy =3D NULL; - rv =3D virStorageFileSupportsSecurityDriver(src); - if (rv <=3D 0) - return rv; - if (virStorageSourceIsLocalStorage(src)) { /* use direct chown for local files so that the file doesn't * need to be initialized */ @@ -273,6 +269,9 @@ qemuSecurityChownCallback(const virStorageSource *src, return 0; } + if ((rv =3D virStorageFileSupportsSecurityDriver(src)) <=3D 0) + return rv; + if (!(cpy =3D virStorageSourceCopy(src, false))) return -1; --=20 2.24.1