From nobody Thu Sep 19 01:36:38 2024 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 1720102403369255.9204330127028; Thu, 4 Jul 2024 07:13:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3F0F415E4; Thu, 4 Jul 2024 10:13:22 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3025F1602; Thu, 4 Jul 2024 10:11:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 94F2D1587; Thu, 4 Jul 2024 10:11:43 -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 D3F7615AB for ; Thu, 4 Jul 2024 10:11:34 -0400 (EDT) Received: from mx-prod-mc-04.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-641-VL0w-LW5N0iBYgeAVBi2Iw-1; Thu, 04 Jul 2024 10:11:33 -0400 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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92C1419560BF for ; Thu, 4 Jul 2024 14:11:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.21]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 98797195605F for ; Thu, 4 Jul 2024 14:11:31 +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.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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=1720102294; 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=9srAE8MsMiUBEZY98aDis2BNug75Xij9w8vRaEdvskQ=; b=jSHpQ03471yG08NLBLB36t8zkITkPlXyGQrOTFDDul8YXoPHmrb4lqMXPfOWr40xR3zAJd pdhcrPK0guw+xuDRmYcNYc3vEQFN0XAlWFP/CxVdmICFXD85QqYzKlLH2usauQIhnTIi3i J48+rmy9nwbtT8oWIgPkeUXtqAvgCAk= X-MC-Unique: VL0w-LW5N0iBYgeAVBi2Iw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCHv2 4/5] qemu: do not use deprecated options for new virtiofsd Date: Thu, 4 Jul 2024 15:54:29 +0200 Message-ID: <36373b03622017eb62bddab7f0317746530f4cdb.1720101270.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3NKM7REKVRR6QYBVMA7F5UORDG7QWKWS X-Message-ID-Hash: 3NKM7REKVRR6QYBVMA7F5UORDG7QWKWS X-MailFrom: jtomko@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: 1720102404802100001 Content-Type: text/plain; charset="utf-8" Use the to-be-introduced virtiofsd capability to mark whether new options are safe to use. Depends on: https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/231 https://issues.redhat.com/browse/RHEL-7108 Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_virtiofs.c | 83 +++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index aba6a19562..2271051b9a 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -139,36 +139,67 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); *fd =3D -1; =20 - virCommandAddArg(cmd, "-o"); - virBufferAddLit(&opts, "source=3D"); - virQEMUBuildBufferEscapeComma(&opts, fs->src->path); - if (fs->cache) - virBufferAsprintf(&opts, ",cache=3D%s", virDomainFSCacheModeTypeTo= String(fs->cache)); - if (fs->sandbox) - virBufferAsprintf(&opts, ",sandbox=3D%s", virDomainFSSandboxModeTy= peToString(fs->sandbox)); - - if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",xattr"); - else if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_xattr"); - - if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",flock"); - else if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_flock"); - - if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",posix_lock"); - else if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_posix_lock"); - - virCommandAddArgBuffer(cmd, &opts); + if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_SEPARATE_OP= TIONS)) { + /* Note that this option format is used by the Rust version of the= daemon + * since v1.0.0, which is way longer than the capability existed. + * The -o style of options can be removed once we bump the minimal + * QEMU version to 8.0.0, which dropped the C virtiofsd daemon */ + virCommandAddArg(cmd, "--shared-dir"); + virCommandAddArg(cmd, fs->src->path); + + if (fs->cache) { + virCommandAddArg(cmd, "--cache"); + virCommandAddArg(cmd, virDomainFSCacheModeTypeToString(fs->cac= he)); + } + if (fs->sandbox) { + virCommandAddArg(cmd, "--sandbox"); + virCommandAddArg(cmd, virDomainFSSandboxModeTypeToString(fs->s= andbox)); + } + + if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) + virCommandAddArg(cmd, "--xattr"); + + if (fs->posix_lock !=3D VIR_TRISTATE_SWITCH_ABSENT || + fs->flock !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("locking op= tions are not supported by this virtiofsd")); + return NULL; + } + } else { + virCommandAddArg(cmd, "-o"); + virBufferAddLit(&opts, "source=3D"); + virQEMUBuildBufferEscapeComma(&opts, fs->src->path); + if (fs->cache) + virBufferAsprintf(&opts, ",cache=3D%s", virDomainFSCacheModeTy= peToString(fs->cache)); + if (fs->sandbox) + virBufferAsprintf(&opts, ",sandbox=3D%s", virDomainFSSandboxMo= deTypeToString(fs->sandbox)); + + if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",xattr"); + else if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_xattr"); + + if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",flock"); + else if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_flock"); + + if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",posix_lock"); + else if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_posix_lock"); + + virCommandAddArgBuffer(cmd, &opts); + } =20 if (fs->thread_pool_size >=3D 0) virCommandAddArgFormat(cmd, "--thread-pool-size=3D%i", fs->thread_= pool_size); =20 - if (cfg->virtiofsdDebug) - virCommandAddArg(cmd, "-d"); + if (cfg->virtiofsdDebug) { + if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_SEPARAT= E_OPTIONS)) + virCommandAddArgList(cmd, "--log-level", "debug", NULL); + else + virCommandAddArg(cmd, "-d"); + } =20 for (i =3D 0; i < fs->idmap.nuidmap; i++) { virCommandAddArgFormat(cmd, "--uid-map=3D:%u:%u:%u:", --=20 2.45.2