From nobody Wed Dec 17 06:13:13 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 1738858059753523.8864667109779; Thu, 6 Feb 2025 08:07:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id EAA201717; Thu, 6 Feb 2025 11:07:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 69CA81979; Thu, 6 Feb 2025 11:06:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id EA0BD1727; Thu, 6 Feb 2025 11:06:00 -0500 (EST) 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 279781727 for ; Thu, 6 Feb 2025 11:05:55 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-Hk7SNashP1KA4WCvFuQE6Q-1; Thu, 06 Feb 2025 11:05:53 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C366319560BB for ; Thu, 6 Feb 2025 16:05:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.3]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F04701800875 for ; Thu, 6 Feb 2025 16:05:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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=1738857954; 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=K/AiY3Z2VsVopV4M62pdwZ9mHTvKjyZ5AXF8PlYOHII=; b=BYo12YvsNe+RyNcT6GpLkiuyeuzakkxEnbRx+i/aRR3KdeeXNvKzmO3kGKQR/Wc957y5Qa ARm6OvXcd/MEcVpTIGcLRgE+bufVdOeCsG0M6hAM/ThDG5GFYtSVF17rtaX64FYIl06xLn fmHcSR62Z7SPCsPV45rvKDkH6LfWPl8= X-MC-Unique: Hk7SNashP1KA4WCvFuQE6Q-1 X-Mimecast-MFC-AGG-ID: Hk7SNashP1KA4WCvFuQE6Q From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 3/3] qemu: domain: Initialize FD passthrough for a virStorageSource before using it Date: Thu, 6 Feb 2025 17:05:46 +0100 Message-ID: <931dcc6bc55744e746657f6a78c246a133cee318.1738857899.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kWzEpQIL5Z7V81KvcFSFiP9hagsywxOENRY29kSZX0M_1738857952 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 37637IW7XSHOW5IE5GSQTNB46K6QBXNA X-Message-ID-Hash: 37637IW7XSHOW5IE5GSQTNB46K6QBXNA X-MailFrom: pkrempa@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: 1738858062398019000 Content-Type: text/plain; charset="utf-8" The call to 'qemuBlockStorageSourceNeedsFormatLayer()' bases the decision also on the state of the passed FD, so we must initialize the passthrough data via 'qemuDomainPrepareStorageSourceFDs()' before the aforementioned call. In the test change it's visible that we didn't add the necessary 'raw' driver which allows the 'protocol' blockdev to be opened in 'rw' mode so that qemu picks the proper file descriptior while keeping the device read-only. Resolves: https://issues.redhat.com/browse/RHEL-37519 Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 6 +++--- .../qemuxmlconfdata/disk-source-fd.x86_64-latest.args | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 56f86140cd..cf05dca55a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9661,6 +9661,9 @@ qemuDomainPrepareStorageSourceBlockdevNodename(virDom= ainDiskDef *disk, /* qemuBlockStorageSourceSetStorageNodename steals 'nodestorage' */ qemuBlockStorageSourceSetStorageNodename(src, nodestorage); + if (qemuDomainPrepareStorageSourceFDs(src, priv) < 0) + return -1; + if (qemuBlockStorageSourceNeedsFormatLayer(src, priv->qemuCaps)) { char *nodeformat =3D g_strdup_printf("%s-format", nodenameprefix); @@ -9701,9 +9704,6 @@ qemuDomainPrepareStorageSourceBlockdevNodename(virDom= ainDiskDef *disk, if (qemuDomainPrepareStorageSourceNFS(src) < 0) return -1; - if (qemuDomainPrepareStorageSourceFDs(src, priv) < 0) - return -1; - return 0; } diff --git a/tests/qemuxmlconfdata/disk-source-fd.x86_64-latest.args b/test= s/qemuxmlconfdata/disk-source-fd.x86_64-latest.args index d77b3ca505..27d852cf32 100644 --- a/tests/qemuxmlconfdata/disk-source-fd.x86_64-latest.args +++ b/tests/qemuxmlconfdata/disk-source-fd.x86_64-latest.args @@ -33,11 +33,12 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUG= uest1/.config \ -blockdev '{"node-name":"libvirt-6-format","read-only":false,"driver":"qco= w2","file":"libvirt-6-storage"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-6-format","id":"virtio-disk4","bootindex":1}' \ -add-fd set=3D4,fd=3D209,opaque=3Dlibvirt-5-storage0 \ --blockdev '{"driver":"file","filename":"/dev/fdset/4","node-name":"libvirt= -5-storage","read-only":true}' \ +-blockdev '{"driver":"file","filename":"/dev/fdset/4","node-name":"libvirt= -5-storage","read-only":false,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-5-format","read-only":true,"driver":"raw"= ,"file":"libvirt-5-storage"}' \ -add-fd set=3D3,fd=3D247,opaque=3Dlibvirt-4-storage0 \ -add-fd set=3D3,fd=3D248,opaque=3Dlibvirt-4-storage1 \ -blockdev '{"driver":"file","filename":"/dev/fdset/3","node-name":"libvirt= -4-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-4-format","read-only":true,"driver":"qcow= 2","file":"libvirt-4-storage","backing":"libvirt-5-storage"}' \ +-blockdev '{"node-name":"libvirt-4-format","read-only":true,"driver":"qcow= 2","file":"libvirt-4-storage","backing":"libvirt-5-format"}' \ -add-fd set=3D2,fd=3D204,opaque=3Dlibvirt-3-storage0 \ -blockdev '{"driver":"file","filename":"/dev/fdset/2","node-name":"libvirt= -3-storage","read-only":false,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"qco= w2","file":"libvirt-3-storage","backing":"libvirt-4-format"}' \ @@ -46,8 +47,9 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -blockdev '{"driver":"file","filename":"/dev/fdset/1","node-name":"libvirt= -2-storage","read-only":true}' \ -device '{"driver":"ide-cd","bus":"ide.0","unit":0,"drive":"libvirt-2-stor= age","id":"ide0-0-0"}' \ -add-fd set=3D0,fd=3D208,opaque=3Dlibvirt-1-storage0 \ --blockdev '{"driver":"file","filename":"/dev/fdset/0","node-name":"libvirt= -1-storage","read-only":true}' \ --device '{"driver":"ide-cd","bus":"ide.0","unit":1,"drive":"libvirt-1-stor= age","id":"ide0-0-1"}' \ +-blockdev '{"driver":"file","filename":"/dev/fdset/0","node-name":"libvirt= -1-storage","read-only":false,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":true,"driver":"raw"= ,"file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-cd","bus":"ide.0","unit":1,"drive":"libvirt-1-form= at","id":"ide0-0-1"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ --=20 2.48.1