From nobody Tue Sep 9 19:12:42 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 1735910586413650.9905330610198; Fri, 3 Jan 2025 05:23:06 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 60B2999A; Fri, 3 Jan 2025 08:23:05 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7774E982; Fri, 3 Jan 2025 08:22:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 608B7955; Fri, 3 Jan 2025 08:22:32 -0500 (EST) 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 A8CA096B for ; Fri, 3 Jan 2025 08:22:31 -0500 (EST) Received: from mx-prod-mc-01.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-20-qhKPoRT6OuWV09i2EQ1MOg-1; Fri, 03 Jan 2025 08:22:30 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 251981956058 for ; Fri, 3 Jan 2025 13:22:29 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.2.183]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D2E8195605F for ; Fri, 3 Jan 2025 13:22:28 +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.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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=1735910551; 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; bh=Gx6XmW3JV39atfmGP5STvjy7L0x6YkmXbhHTvkWk578=; b=be6paxuU/l67UFAxYmowIKKO/Jm44zA72lC3OdnAVlszOMVadoHzEWTeL5siVE5RMWHFum RdMYhvKVTlAKq/AAjco09mexD45utkpk7TkWElz/OkT/8zCBDE6LLnMZ0WDcVHcOlsBirZ 8nqc47dYinOt+R0WkGOttTFZ1rWlr+8= X-MC-Unique: qhKPoRT6OuWV09i2EQ1MOg-1 X-Mimecast-MFC-AGG-ID: qhKPoRT6OuWV09i2EQ1MOg From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] virtiofs: allow read only mode Date: Fri, 3 Jan 2025 14:22:23 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8YmX5Hz_5AbHY4dmvO63njOPibRnxq67VCCFvXypK1I_1735910549 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GACWEU6BIL4YWGZBUIWXEZWKPHL465WP X-Message-ID-Hash: GACWEU6BIL4YWGZBUIWXEZWKPHL465WP X-MailFrom: ajulis@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: 1735910587928116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Resolves: https://issues.redhat.com/browse/RHEL-72192 Signed-off-by: Adam Julis Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 2 +- src/qemu/qemu_validate.c | 11 ----- src/qemu/qemu_virtiofs.c | 3 ++ .../vhost-user-fs-readonly.x86_64-latest.args | 34 ++++++++++++++ .../vhost-user-fs-readonly.x86_64-latest.err | 1 - .../vhost-user-fs-readonly.x86_64-latest.xml | 45 +++++++++++++++++++ .../vhost-user-fs-readonly.xml | 1 + tests/qemuxmlconftest.c | 2 +- 8 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-lat= est.args delete mode 100644 tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-lat= est.err create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-lat= est.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 8d787ef59a..e8e8336708 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3824,7 +3824,7 @@ A directory on the host that can be accessed directly= from the guest. :since:`Since 10.0.0` ``readonly`` Enables exporting filesystem as a readonly mount for guest, by default - read-write access is given (currently only works for QEMU/KVM driver; n= ot + read-write access is given (works for QEMU/KVM driver and :since:`Since= 11.0.0` with virtiofs). ``space_hard_limit`` Maximum space available to this guest's filesystem. :since:`Since 0.9.1= 3` diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index aaa056379e..086c66b602 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4540,11 +4540,6 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs, =20 case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS: if (!fs->sock) { - if (fs->readonly) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtiofs does not yet support read-only = mode")); - return -1; - } if (fs->accessmode !=3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtiofs only supports passthrough acces= smode")); @@ -4557,12 +4552,6 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs, } } =20 - if (fs->readonly) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtiofs does not support read-only access")= ); - return -1; - } - if (fs->model !=3D VIR_DOMAIN_FS_MODEL_DEFAULT) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtiofs does not support model")); diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index 87226be288..dd3e0dd9fe 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -228,6 +228,9 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, fs->idmap.gidmap[i].count); } =20 + if (fs->readonly) + virCommandAddArg(cmd, "--readonly"); + return g_steal_pointer(&cmd); } =20 diff --git a/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.arg= s b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.args new file mode 100644 index 0000000000..d3c71544f8 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-guest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dguest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,acpi=3Doff \ +-accel kvm \ +-cpu qemu64 \ +-m size=3D14680064k \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-guest/ram-node0","share":true,"size":15032385536= }' \ +-numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ +-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-chardev socket,id=3Dchr-vu-fs0,path=3D/var/lib/libvirt/qemu/domain--1-gue= st/fs0-fs.sock \ +-device '{"driver":"vhost-user-fs-pci","id":"fs0","chardev":"chr-vu-fs0","= queue-size":1024,"tag":"mount_tag","bus":"pci.0","addr":"0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.err= b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.err deleted file mode 100644 index fff45fac4b..0000000000 --- a/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.err +++ /dev/null @@ -1 +0,0 @@ -unsupported configuration: virtiofs does not yet support read-only mode diff --git a/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.xml= b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.xml new file mode 100644 index 0000000000..c9c1e5c3d2 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-readonly.x86_64-latest.xml @@ -0,0 +1,45 @@ + + guest + 126f2720-6f8e-45ab-a886-ec9277079a67 + 14680064 + 14680064 + + + + + 2 + + hvm + + + + qemu64 + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + +
+ + + +