From nobody Sun Feb 8 15:25:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1672936390; cv=none; d=zohomail.com; s=zohoarc; b=P1pOK4ubJcHeGzOJdOcj9RJiNhhg565rUqV6TtEc79RDJpzjj+PDLzv8fAkBPTLZs4Q98arTbqxpZyhI9o75u51FZMp3y2fnAEdoU0d+WA3yMqsYDVNnypcTm9uT4U4qGUvniQndFNlWZUSPQAol4JDs/EfTwcrpU0dDHJpg4Oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936390; 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=r+53Hj50HjxKQcpXZqhSoqQBxeIdDWqvI3EljrhO9D4=; b=hYsi0AwLNhsT54AaWJ4djfp2pd+UUgswTGvdgfjFsg5b75XPkvs+TI9/z+SUd1nwW96TIucq78k2U1EtdqRlzong4KlxxEDCS7qLOwMx8RyGi70Hu/+IzHyfwO9Hi/u1TRra7wMP25JSPYPrDpBTst7Ql+vuenXf42LhUbqeTB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936390588320.6658286174812; Thu, 5 Jan 2023 08:33:10 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-101-nFSe0bE4NcKCZGoc9OiUbw-1; Thu, 05 Jan 2023 11:31:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D0AD3C10ED6; Thu, 5 Jan 2023 16:31:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47B8A14171B6; Thu, 5 Jan 2023 16:31:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D34A1947040; Thu, 5 Jan 2023 16:31:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A144F1947051 for ; Thu, 5 Jan 2023 16:31:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 960742166B31; Thu, 5 Jan 2023 16:31:01 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB5D62166B30 for ; Thu, 5 Jan 2023 16:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936389; 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=r+53Hj50HjxKQcpXZqhSoqQBxeIdDWqvI3EljrhO9D4=; b=IaC2RqV80ndyxph43YjAeItjb7Jh3q7+6q7qtd0zgfaQE/ixtYyP4nKeJRp3JnTGUMJ81u SAevljNw6uuhvL1fV+IMJ5NsClh277WOOpkwDTSeBi7GZ0KvXsl7YwAu8Rl7ez9g3DWgi4 /iCMpbOTyr07FQxdTA6j/LOrq/uu8y4= X-MC-Unique: nFSe0bE4NcKCZGoc9OiUbw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/36] qemu: block: Add support for passing FDs of disk images Date: Thu, 5 Jan 2023 17:30:18 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936391394100009 Content-Type: text/plain; charset="utf-8" Prepare the internal data for passing FDs instead of having qemu open the file internally. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_block.c | 31 ++++++++++++++++++++++++++++--- src/qemu/qemu_command.c | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a6f601b29..a672ad6f54 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -673,22 +673,47 @@ qemuBlockStorageSourceGetSshProps(virStorageSource *s= rc) static virJSONValue * qemuBlockStorageSourceGetFileProps(virStorageSource *src, - bool onlytarget) + bool onlytarget, + virTristateBool *autoReadOnly, + virTristateBool *readOnly) { + const char *path =3D src->path; const char *iomode =3D NULL; const char *prManagerAlias =3D NULL; virJSONValue *ret =3D NULL; if (!onlytarget) { + qemuDomainStorageSourcePrivate *srcpriv =3D QEMU_DOMAIN_STORAGE_SO= URCE_PRIVATE(src); + if (src->pr) prManagerAlias =3D src->pr->mgralias; if (src->iomode !=3D VIR_DOMAIN_DISK_IO_DEFAULT) iomode =3D virDomainDiskIoTypeToString(src->iomode); + + if (srcpriv && srcpriv->fdpass) { + path =3D qemuFDPassGetPath(srcpriv->fdpass); + + /* when passing a FD to qemu via the /dev/fdset mechanism qemu + * fetches the appropriate FD from the fdset by checking that = it has + * the correct accessmode. Now with 'auto-read-only' in effect= qemu + * wants to use a read-only FD first. If the user didn't pass = multiple + * FDs the feature will not work regardless, so we'll disable = it. */ + if (src->fdtuple->nfds =3D=3D 1) { + *autoReadOnly =3D VIR_TRISTATE_BOOL_ABSENT; + + /* now we setup the normal readonly flag. If user requeste= d write + * access honour it */ + if (src->fdtuple->writable) + *readOnly =3D VIR_TRISTATE_BOOL_NO; + else + *readOnly =3D virTristateBoolFromBool(src->readonly); + } + } } ignore_value(virJSONValueObjectAdd(&ret, - "s:filename", src->path, + "s:filename", path, "S:aio", iomode, "S:pr-manager", prManagerAlias, NULL) < 0); @@ -818,7 +843,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource = *src, driver =3D "file"; } - if (!(fileprops =3D qemuBlockStorageSourceGetFileProps(src, onlyta= rget))) + if (!(fileprops =3D qemuBlockStorageSourceGetFileProps(src, onlyta= rget, &aro, &ro))) return NULL; break; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 06e29ff8ae..ed159bc8b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2146,6 +2146,25 @@ qemuBuildBlockStorageSourceAttachDataCommandline(vir= Command *cmd, } +static int +qemuBuildDiskSourceCommandLineFDs(virCommand *cmd, + virDomainDiskDef *disk) +{ + virStorageSource *n; + + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + qemuDomainStorageSourcePrivate *srcpriv =3D QEMU_DOMAIN_STORAGE_SO= URCE_PRIVATE(n); + + if (!srcpriv || !srcpriv->fdpass) + continue; + + qemuFDPassTransferCommand(srcpriv->fdpass, cmd); + } + + return 0; +} + + static int qemuBuildDiskSourceCommandLine(virCommand *cmd, virDomainDiskDef *disk, @@ -2163,6 +2182,9 @@ qemuBuildDiskSourceCommandLine(virCommand *cmd, if (virStorageSourceIsEmpty(disk->src)) return 0; + if (qemuBuildDiskSourceCommandLineFDs(cmd, disk) < 0) + return -1; + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src))) return -1; --=20 2.38.1