From nobody Thu Jun 19 22:31:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729063416526985.3690254530301; Wed, 16 Oct 2024 00:23:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 826BF1590; Wed, 16 Oct 2024 03:23:35 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 734E0143E; Wed, 16 Oct 2024 03:23:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A5E41397; Wed, 16 Oct 2024 03:23:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 05CD61287 for ; Wed, 16 Oct 2024 03:23:13 -0400 (EDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-zAMMVjmFM0Gaq1GHnnF7HA-1; Wed, 16 Oct 2024 03:23:12 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4312b53256cso23122335e9.2 for ; Wed, 16 Oct 2024 00:23:12 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f6b3224sm40581715e9.32.2024.10.16.00.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 00:23:10 -0700 (PDT) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id B088D3287522 for ; Wed, 16 Oct 2024 09:23:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729063393; h=from:from: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; bh=BJWec0a7gxHk9KNlO742R4XfiYf6Mwy01M7YwaAmv9M=; b=CrnY4XTNRcgrAXtVxjR1Nct/zadBbY4i33G/9/VgM9UW9FpmZrJcbmgKaUnZodCSYf1o3l GCqBNdWytGCRTSQKYtqQspSKOBKaiKJeJG9WCGPZ1knUgfshLGE7PlVTbbnwG9IS88VbGC ERurEUAnYPcTbS74nNqjad80i1Ba5Dc= X-MC-Unique: zAMMVjmFM0Gaq1GHnnF7HA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729063391; x=1729668191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BJWec0a7gxHk9KNlO742R4XfiYf6Mwy01M7YwaAmv9M=; b=WJ6+Alf/a41tGZ82QFOlNe1ASwmEp6fPKsi4uaVDLYVb/0Ix/3IyOF1WTfm+BtIzmY OvmV7KGrTU82P9UFBzi3VWYkgTOAoEsrmCEIIOxYfsxxOydS9bwhL++FlhvhVHLfFVOw BnElPp2LM5Soz/ELxc01oZdGkmkNwfsCJ2HiDhFjTa3pngEWnvv1hgsC+s2W9/2pde+C Wx9FrAnQA1BMJ6n3B5mvm0DwxuXFm39beGdOd6h3PYpHJZ4iRqN80QVX83f7AJOM2pEt TOpkCs0Am7/UHONHVlJW1nE1wmaoHmQ9zc1b3HMf+mFqzeSq6J9ZugRIo5NM0fd/yoss sthQ== X-Gm-Message-State: AOJu0Yw+RL3yByeDfCdoB/4O6stUoGrePVsokjYUCYiNsY2mxTnmLwVw 0DFP/6eN+v5oxJ35oxTVLQCeOmpD8aIQHpVw4CT1j2CwW86qhJ8gS2wvsVtNRP9uio+9kF86Bri xQXGo5vUGPPW1J7xNMXFKcQe4zjfPElhuJFz/LFAIdqa2Eq5eJ4oSRY7KCgj/NwCav/NQvoGyGD fmHWT7jAwxEzAh8lYCajBfeOTpe/lNmH8R2Glt218= X-Received: by 2002:a05:600c:5248:b0:42c:bae0:f05b with SMTP id 5b1f17b1804b1-4311deae1a9mr158242495e9.1.1729063391006; Wed, 16 Oct 2024 00:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTjN/AlO/ainVmQroM/lgn5aj/Kod1m/NHhZ7OPNm6I+Flx8WqWO635sqv1O4y/H7yLg3k8A== X-Received: by 2002:a05:600c:5248:b0:42c:bae0:f05b with SMTP id 5b1f17b1804b1-4311deae1a9mr158242195e9.1.1729063390540; Wed, 16 Oct 2024 00:23:10 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 1/3] qemu_namespace: Rename variable Date: Wed, 16 Oct 2024 09:23:05 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 2YJTXLZO7467NN22IW37LBNK5IPCB5LN X-Message-ID-Hash: 2YJTXLZO7467NN22IW37LBNK5IPCB5LN X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729063418244116600 Content-Type: text/plain; charset="utf-8"; x-default="true" The boolean actually tells whether the file existed when the function was called and using it in more places later on makes them confusing (e.g. do something with a file if it does not exist). To better reflect the above and prepare for next patch rename this variable. Signed-off-by: Martin Kletzander Reviewed-by: Peter Krempa --- src/qemu/qemu_namespace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index bbe3d5a1f78a..71e29b4ba4f6 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1002,10 +1002,10 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) bool isDev =3D S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode); bool isReg =3D S_ISREG(data->sb.st_mode) || S_ISFIFO(data->sb.st_mode)= || S_ISSOCK(data->sb.st_mode); bool isDir =3D S_ISDIR(data->sb.st_mode); - bool exists =3D false; + bool existed =3D false; =20 if (virFileExists(data->file)) - exists =3D true; + existed =3D true; =20 if (virFileMakeParentPath(data->file) < 0) { virReportSystemError(errno, @@ -1131,7 +1131,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) virFileMoveMount(data->target, data->file) < 0) goto cleanup; =20 - ret =3D exists; + ret =3D existed; cleanup: if (ret < 0 && delDevice) { if (isDir) --=20 2.47.0 From nobody Thu Jun 19 22:31:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729063450936139.53226265200385; Wed, 16 Oct 2024 00:24:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EC900186F; Wed, 16 Oct 2024 03:24:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DC7EB14EC; Wed, 16 Oct 2024 03:23:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D40AA1287; Wed, 16 Oct 2024 03:23:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 38EAF13AA for ; Wed, 16 Oct 2024 03:23:14 -0400 (EDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-zA02DWf3P7qp3ovT0nxorA-1; Wed, 16 Oct 2024 03:23:12 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d609ef9f7so1705680f8f.3 for ; Wed, 16 Oct 2024 00:23:12 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f55dec4sm40402595e9.8.2024.10.16.00.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 00:23:10 -0700 (PDT) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id BC8B03287523 for ; Wed, 16 Oct 2024 09:23:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729063393; h=from:from: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; bh=6L8gjGW0xBSBDkDYfX/7PQLkqk1H5AEii0GQHFhpnlY=; b=Y5cifuPXw6Ca06HwxQnIt1HXGqUYrcWbmA1jxyXV0VEorON1WWumpH2S0Q/7lY268rTkle QL8DqUfcDBiC04HsimaMtIiny42VUCSrn2FQrK0jcFfABbA9WVd3UmesBQZ+Irnp189ILn zvar/qSgwkZrlZO0qrsILQsTiOjdZtw= X-MC-Unique: zA02DWf3P7qp3ovT0nxorA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729063391; x=1729668191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6L8gjGW0xBSBDkDYfX/7PQLkqk1H5AEii0GQHFhpnlY=; b=HbqcRlXvFDadomM7cyhFKhy0mSK/d3oNMag3f+aG2WKG7sii2R9ClyIeJZUK5JlNi8 TBxaT9ZZ92AUnfE2DOEl7LoD/ehgokDacIsMQyxIWZrgMyzV6XG85B4WOMk4kUg00LWq brwJhjhY5xTFBwWzk/diEsiauS4Cz6A+Jf0V+mJqoqYp9r76hbPNFTFc269P3AcNj057 UB8150kN5QvvSRZJ9IoC+u/X7oA8MLe4M9v+JyZk+85AJJmFfa5I+/skmIMSUZ4G7k40 yDmx3LO8PLgyWUW8SlevSgaAvYGSWNQLQ1GUMwnFsYNvdF21NH/j5fMCJWZlCE9Kktpm Daeg== X-Gm-Message-State: AOJu0YzL4vexF1QwLM0XGXzQZkMyBN1qxOuSLo4+oEbILugvif+YfUP/ eKdw4kAUZ7CxAAmrOKEZblEy6YlQ66VdhkjJLdvkM6KQ4O9/hG1H5N35ZUPXyDT5r8aQEKuKzu9 Gqh6xnKZM5e4gu421Npcp6fdoIUUqaqHZAA2CzNj/xemZplKtLI3tCbo1I1F7pfZMFtcNeLm4Mo 9A0+t4Ovh9Bk82Qw2vYF69vVm0kS3sdJt8/PGP6dg= X-Received: by 2002:a05:6000:10c6:b0:37d:47b3:7b86 with SMTP id ffacd0b85a97d-37d5529a82dmr11220039f8f.44.1729063391512; Wed, 16 Oct 2024 00:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzIHswUZzjESg3fTpu8BM+71NwsSlBZ6hD9xGJlU5yTjZNsHEtbW517cZpJGZ6G/pPYZfQEA== X-Received: by 2002:a05:6000:10c6:b0:37d:47b3:7b86 with SMTP id ffacd0b85a97d-37d5529a82dmr11220029f8f.44.1729063390941; Wed, 16 Oct 2024 00:23:10 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 2/3] qemu_namespace: Properly report new files Date: Wed, 16 Oct 2024 09:23:06 +0200 Message-ID: <8d45ac2f1f97dd9be98491cb9258d2135ed0fb74.1729062819.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: R6T5A5UX7PDCPHII642FKDW47XMQR3Y5 X-Message-ID-Hash: R6T5A5UX7PDCPHII642FKDW47XMQR3Y5 X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729063451954116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Function qemuNamespaceMknodOne() is supposed to return 0 if the file did not exist before this function. If, however, the file existed, but was removed and recreated by this function the @existed flag should be reset to its original state (false) because the function then behaves the same way as if the file did not exist as it needed to be recreated. So reset the @existed flag to properly reflect what happened. Signed-off-by: Martin Kletzander Reviewed-by: Peter Krempa --- src/qemu/qemu_namespace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 71e29b4ba4f6..33a773917373 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1022,6 +1022,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) data->file, data->target); } else { VIR_DEBUG("Creating symlink %s -> %s", data->file, data->targe= t); + existed =3D false; =20 /* First, unlink the symlink target. Symlinks change and * therefore we have no guarantees that pre-existing @@ -1053,6 +1054,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) } else { VIR_DEBUG("Creating dev %s (%d,%d)", data->file, major(data->sb.st_rdev), minor(data->sb.= st_rdev)); + existed =3D false; unlink(data->file); if (mknod(data->file, data->sb.st_mode, data->sb.st_rdev) < 0)= { virReportSystemError(errno, --=20 2.47.0 From nobody Thu Jun 19 22:31:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729063470189874.9597249203644; Wed, 16 Oct 2024 00:24:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 326A01724; Wed, 16 Oct 2024 03:24:29 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BBF4F18A0; Wed, 16 Oct 2024 03:23:22 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E3F2C1283; Wed, 16 Oct 2024 03:23:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 566211421 for ; Wed, 16 Oct 2024 03:23:14 -0400 (EDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-fVXcYl5fNIG6xINSo0yeWQ-1; Wed, 16 Oct 2024 03:23:12 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-431285dd196so24956895e9.0 for ; Wed, 16 Oct 2024 00:23:12 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f5698a3sm40849505e9.13.2024.10.16.00.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 00:23:10 -0700 (PDT) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id C8D8B3287524 for ; Wed, 16 Oct 2024 09:23:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729063394; h=from:from: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; bh=whEMV/8/BodYp9LCmlrLJTnus2NvGcsN9VZ5VfI+ZVQ=; b=hLiOWovCWvF7+7at4z6IXJO19Ff0q7dEkgoIibP/VoVjBeUx8pU7ty3ZQlRMD7qtoFisT3 mMAQfD+8EVT21iFFFqFLRCnIC8mUhTrfCWMo8IReSFH79RJDJ4bpuWUJsz8mbXriugK/RS xtf6cpDlV85tUk3NgLMiLtMi5+VCKT0= X-MC-Unique: fVXcYl5fNIG6xINSo0yeWQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729063391; x=1729668191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=whEMV/8/BodYp9LCmlrLJTnus2NvGcsN9VZ5VfI+ZVQ=; b=KmEau1H1VN1j98jZM5PxuhDaAFj4q1i7CwcCfONJxuKGRGJ5QRvEzejr0q1zGX8d7g Kna2EonmvmC9XnND5IPe9dvaCH4XuZQeIlnoQA26pxNnPnP7pxTNhMUjTVvfQUrbtOzF w3p0DX+fsb5QviDIRky+UbONEJhnVrzZ5x2C39z0pIeDZWqCaQ4W2rd475vNaQXRe0I5 wAG7KKvWvZRYiVaidrpMlDirrtJHYVUX48D2qK/TZ8LNe/7DoHIu4Vgom8CBVPmGYqFX 275mSOZhcc4dtLxjnL3KfS9rcJ1cBIsOSmjfrEvCTklFfZOVk0s1//dUdFxXAgTcQXyA xR9A== X-Gm-Message-State: AOJu0YwrZHD1WPUCaxBx8aFv3wkuJjHTgx9ewPDUmJSwh1tLqKi/mibA o4CFU7jkrLGxY0i36NaAU1lDbVQWQFM6txb59IoYo3ReY/gJRLcG3pJwzrEn8XMgz2vCahDwyCL 33vUG4Tb+tQBxwE5EDvxirN6K4cm0+HimBvnXg4fSkdh9XdRuycjdx3SNRAG77BDlcEPsdaTlyk bHTOskwwsosGAG8ZbY3QJtlouJhpU4W4cNIu4+Oks= X-Received: by 2002:a05:600c:1f8c:b0:42c:b220:4778 with SMTP id 5b1f17b1804b1-4311df5c639mr156288915e9.33.1729063391588; Wed, 16 Oct 2024 00:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdzyc1dvYYkeApnWpth10+wJWqlodSoXxL28V9JZ7zXL8lSeDKCCtwEdgUgAaPJNwHqPnIVw== X-Received: by 2002:a05:600c:1f8c:b0:42c:b220:4778 with SMTP id 5b1f17b1804b1-4311df5c639mr156288635e9.33.1729063391120; Wed, 16 Oct 2024 00:23:11 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 3/3] qemu_namespace: Only replicate labels on created files Date: Wed, 16 Oct 2024 09:23:07 +0200 Message-ID: <07d50b961bbf0b78844db737b8ee85436b87e9f7.1729062819.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3XVWNLZUI77YZWIITFZTX25YE5JQJNTL X-Message-ID-Hash: 3XVWNLZUI77YZWIITFZTX25YE5JQJNTL X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729063472110116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Function qemuNamespaceMknodOne() is trying to replicate a file from the parent namespace as perfectly as possible, with the same permissions, labels, ACLs, etc. If that file already existed it means that the qemu process is probably using it already and the current setting is probably more correct than the ones from the parent namespace. In order to reflect that only replicate the file metadata when it was (re-)created in this function. Resolves: https://issues.redhat.com/browse/RHEL-62174 Signed-off-by: Martin Kletzander Reviewed-by: Peter Krempa --- src/qemu/qemu_namespace.c | 56 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 33a773917373..6594657bfa3e 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1090,43 +1090,45 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) goto cleanup; } =20 - if (lchown(data->file, data->sb.st_uid, data->sb.st_gid) < 0) { - virReportSystemError(errno, - _("Failed to chown device %1$s"), - data->file); - goto cleanup; - } + if (!existed) { + if (lchown(data->file, data->sb.st_uid, data->sb.st_gid) < 0) { + virReportSystemError(errno, + _("Failed to chown device %1$s"), + data->file); + goto cleanup; + } =20 - /* Symlinks don't have mode */ - if (!isLink && - chmod(data->file, data->sb.st_mode) < 0) { - virReportSystemError(errno, - _("Failed to set permissions for device %1$s"= ), - data->file); - goto cleanup; - } + /* Symlinks don't have mode */ + if (!isLink && + chmod(data->file, data->sb.st_mode) < 0) { + virReportSystemError(errno, + _("Failed to set permissions for device %= 1$s"), + data->file); + goto cleanup; + } =20 - if (data->acl && - virFileSetACLs(data->file, data->acl) < 0 && - errno !=3D ENOTSUP) { - virReportSystemError(errno, - _("Unable to set ACLs on %1$s"), data->file); - goto cleanup; - } + if (data->acl && + virFileSetACLs(data->file, data->acl) < 0 && + errno !=3D ENOTSUP) { + virReportSystemError(errno, + _("Unable to set ACLs on %1$s"), data->fi= le); + goto cleanup; + } =20 # ifdef WITH_SELINUX - if (data->tcon && - lsetfilecon_raw(data->file, (const char *)data->tcon) < 0) { - VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR - if (errno !=3D EOPNOTSUPP && errno !=3D ENOTSUP) { - VIR_WARNINGS_RESET + if (data->tcon && + lsetfilecon_raw(data->file, (const char *)data->tcon) < 0) { + VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR + if (errno !=3D EOPNOTSUPP && errno !=3D ENOTSUP) { + VIR_WARNINGS_RESET virReportSystemError(errno, _("Unable to set SELinux label on %1$s"), data->file); goto cleanup; + } } - } # endif + } =20 /* Finish mount process started earlier. */ if ((isReg || isDir) && --=20 2.47.0